From 3f04bb86983b04f84add0ec1205ab68bcdd1be61 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 13 Jun 2019 17:48:30 +0200 Subject: [PATCH] Timeline: sort out how to link the ProfileInterpreter into the draw function --- src/stage/timeline/body-canvas-widget.cpp | 27 ++++-- src/stage/timeline/body-canvas-widget.hpp | 24 ++--- src/stage/timeline/timeline-layout.cpp | 4 +- wiki/thinkPad.ichthyo.mm | 109 ++++++++++++++++++++++ 4 files changed, 138 insertions(+), 26 deletions(-) diff --git a/src/stage/timeline/body-canvas-widget.cpp b/src/stage/timeline/body-canvas-widget.cpp index e8ea05601..04b99348f 100644 --- a/src/stage/timeline/body-canvas-widget.cpp +++ b/src/stage/timeline/body-canvas-widget.cpp @@ -93,7 +93,7 @@ namespace timeline { UNIMPLEMENTED ("draw bottom"); } - /** draw grounding of a overview/ruler track + /** draw grounding of an overview/ruler track * with the given height */ void ruler (uint h) override @@ -141,12 +141,23 @@ namespace timeline { virtual ~TrackGroundingRenderer() { } }; + + template + auto + makeRenderer (TrackProfile& profile, bool isHeadPart) + { + return [&profile, isHeadPart](CairoC cox) + { + PINT concreteRenderScheme{cox, PixSpan{}}; ///////////////////////////////////TICKET #1019 : do we actually need to know the covered virtual area (PixSpan)? + profile.performWith (concreteRenderScheme); + }; + } } - TimelineCanvas::TimelineCanvas (_RenderFactory groundingFac, _RenderFactory overlayFac) + TimelineCanvas::TimelineCanvas (_Renderer groundingFac, _Renderer overlayFac) : Gtk::Layout{} , getGroundingRenderer_{groundingFac} , getOverlayRenderer_{overlayFac} @@ -159,12 +170,12 @@ namespace timeline { BodyCanvasWidget::BodyCanvasWidget (DisplayManager& displayManager) : Gtk::Box{Gtk::ORIENTATION_VERTICAL} - , contentArea_{} - , rulerCanvas_{std::function(), std::function()} ///////////TODO dummy placeholder factories.... need to build the real thing - , mainCanvas_{std::function(), std::function()} , layout_{displayManager} , profile_{} , rootBody_{nullptr} + , contentArea_{} + , rulerCanvas_{makeRenderer(profile_, true), makeRenderer(profile_, true)} + , mainCanvas_{makeRenderer(profile_, false), makeRenderer(profile_, false)} { this->set_border_width (0); this->property_expand() = true; // dynamically grab any available additional space @@ -214,9 +225,8 @@ namespace timeline { { if (not profile_) rootBody_->establishTrackSpace (profile_); - -// TrackGroundingRenderer renderer{cox, layout_.getPixSpan()}; //////////TODO TOD-oh } + return profile_; //////////////////////////////////////////////////////////////////////////////////////TICKET #1039 : who actually invokes this function? what if not(rootBody_)? } @@ -287,7 +297,7 @@ namespace timeline { void TimelineCanvas::drawGrounding (CairoC const& cox) { -// profile_.performWith (renderer); + getGroundingRenderer_(cox); /////////////////////////////////////////////TICKET #1039 : placeholder drawing cox->set_source_rgb(0.8, 0.0, 0.0); cox->set_line_width (5.0); @@ -304,6 +314,7 @@ namespace timeline { void TimelineCanvas::drawOverlays (CairoC const& cox) { + getOverlayRenderer_(cox); /////////////////////////////////////////////TICKET #1039 : placeholder drawing auto alloc = get_allocation(); int w = alloc.get_width(); diff --git a/src/stage/timeline/body-canvas-widget.hpp b/src/stage/timeline/body-canvas-widget.hpp index 6c457c82a..37a4eec41 100644 --- a/src/stage/timeline/body-canvas-widget.hpp +++ b/src/stage/timeline/body-canvas-widget.hpp @@ -77,25 +77,17 @@ namespace timeline { class TrackBody; class TimelineCanvas; - class Renderer - { - public: - virtual ~Renderer() { } ///< this is an interface - - virtual void drawTo (TimelineCanvas&) =0; - }; - class TimelineCanvas : public Gtk::Layout { - using _RenderFactory = std::function; + using _Renderer = std::function; - _RenderFactory getGroundingRenderer_; - _RenderFactory getOverlayRenderer_; + _Renderer getGroundingRenderer_; + _Renderer getOverlayRenderer_; public: - TimelineCanvas (_RenderFactory groundingFac, _RenderFactory overlayFac); + TimelineCanvas (_Renderer groundingFac, _Renderer overlayFac); private: virtual bool on_draw (CairoC) override; @@ -114,14 +106,14 @@ namespace timeline { class BodyCanvasWidget : public Gtk::Box { - Gtk::ScrolledWindow contentArea_; - TimelineCanvas rulerCanvas_; - TimelineCanvas mainCanvas_; - DisplayManager& layout_; TrackProfile profile_; TrackBody* rootBody_; + Gtk::ScrolledWindow contentArea_; + TimelineCanvas rulerCanvas_; + TimelineCanvas mainCanvas_; + public: BodyCanvasWidget (DisplayManager&); ~BodyCanvasWidget(); diff --git a/src/stage/timeline/timeline-layout.cpp b/src/stage/timeline/timeline-layout.cpp index c83aec8c9..58313b288 100644 --- a/src/stage/timeline/timeline-layout.cpp +++ b/src/stage/timeline/timeline-layout.cpp @@ -92,8 +92,8 @@ namespace timeline { PixSpan TimelineLayout::getPixSpan() { - ////////////////////////////////////////////////////////TICKET 1019 : need a "ZoomWindow" here to manage the visible area - ////////////////////////////////////////////////////////TICKET 1039 : "somehow" wire with the TimelineController to find out the covered span + ////////////////////////////////////////////////////////TICKET #1019 : need a "ZoomWindow" here to manage the visible area + ////////////////////////////////////////////////////////TICKET #1039 : "somehow" wire with the TimelineController to find out the covered span return PixSpan {0, 2048}; ////////////////Lalala Lalü } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 9033a0c88..51e553e84 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -20374,12 +20374,121 @@ + + + + + + + +

+ vorher war nämlich das Profil im Canvas selber. +

+

+ Jetzt ist das Profil in das BodyCanvasWidget hochgewandert, +

+

+ und soll von beiden sub-Canvas gleichermaßen jeweils passend interpretiert werden +

+ + +
+
+ + +
+ + + + + + + +

+ ...daher die Factory +

+ + +
+
+ + + + + + +
    +
  1. + getXxxRenderer(CairoC) -> packt Profil ein +
  2. +
  3. + Renderer.drawTo(canvas) +
  4. +
+ + +
+ + + + + + + + + + + + + + + + + + +

+ Renderer ist bereits der Funktor +

+ + +
+ + + + + + + + + + + + +
    +
  1. + der Renderer. Abstrahiert welcher Interpreter wie genau zum Einsatz kommen soll (Hintergrund/Overla sowie Ruler/Content) +
  2. +
  3. + der konkrete Interpreter +
  4. +
  5. + die einzelnen Verben im Profil +
  6. +
+ + +
+
+ + + +