diff --git a/src/stage/model/canvas-hook.hpp b/src/stage/model/canvas-hook.hpp index 4d3978f36..7b5d6d5ff 100644 --- a/src/stage/model/canvas-hook.hpp +++ b/src/stage/model/canvas-hook.hpp @@ -64,6 +64,7 @@ namespace model { using lib::time::Time; using lib::time::TimeValue; + using lib::time::TimeSpan; @@ -82,8 +83,11 @@ namespace model { public: virtual ~DisplayMetric() { } ///< this is an interface + /** the overall time Duration covered by this timeline canvas */ + virtual TimeSpan coveredTime() const =0; + /** extension point for time axis zoom management. */ - virtual int translateTimeToPixels (TimeValue) const =0; + virtual int translateTimeToPixels (TimeValue) const =0; }; @@ -101,7 +105,6 @@ namespace model { */ template class CanvasHook - : public DisplayMetric { public: virtual ~CanvasHook() { } ///< this is an interface @@ -110,6 +113,9 @@ namespace model { virtual void move (WID& widget, int xPos, int yPos) =0; virtual void remove (WID& widget) =0; + /** access the component to handle layout metric */ + virtual DisplayMetric& getMetric() const =0; + /** Anchor point to build chains of related View Hooks */ virtual CanvasHook& getAnchorHook() noexcept @@ -137,7 +143,7 @@ namespace model { Pos hookedAt (Time start, int downshift=0) { - return hookedAt (translateTimeToPixels (start), downshift); + return hookedAt (getMetric().translateTimeToPixels (start), downshift); } }; diff --git a/src/stage/timeline/body-canvas-widget.cpp b/src/stage/timeline/body-canvas-widget.cpp index eb9fe80a6..fd2872d27 100644 --- a/src/stage/timeline/body-canvas-widget.cpp +++ b/src/stage/timeline/body-canvas-widget.cpp @@ -84,10 +84,6 @@ namespace timeline { using CairoC = PCairoContext const&; using StyleC = PStyleContext const&; - namespace { /////////////////////////////////////////////////////TICKET #1213 : use proper zoom handling instead of dummy constants!! - const int TODO_px_per_second = 25; - } /////////////////////////////////////////////////////TICKET #1213 : (END) get rid of these dummy constants!! - namespace { // details of track background painting const int INITIAL_TIMERULER_HEIGHT_px = 30; @@ -576,10 +572,10 @@ namespace timeline { getCanvas(yPos).move (widget, xPos, yPos); } - int - BodyCanvasWidget::translateTimeToPixels (TimeValue startTimePoint) const + model::DisplayMetric& + BodyCanvasWidget::getMetric() const { - return _raw(startTimePoint) * TODO_px_per_second / Time::SCALE; //////////TICKET #1213 : delegate zoom handling to the display manager (field #layout_) !! + return layout_; } /** respond to the DisplayEvaluation pass. diff --git a/src/stage/timeline/body-canvas-widget.hpp b/src/stage/timeline/body-canvas-widget.hpp index 3030bdc0a..2c6996ad8 100644 --- a/src/stage/timeline/body-canvas-widget.hpp +++ b/src/stage/timeline/body-canvas-widget.hpp @@ -176,8 +176,8 @@ namespace timeline { void hook (Gtk::Widget&, int xPos=0, int yPos=0) override; void move (Gtk::Widget&, int xPos, int yPos) override; void remove (Gtk::Widget&) override; - - int translateTimeToPixels (TimeValue) const override; + + model::DisplayMetric& getMetric() const override; protected: /* ==== Interface: LayoutElement ===== */ diff --git a/src/stage/timeline/clip-widget.cpp b/src/stage/timeline/clip-widget.cpp index aacbfd295..bfade0673 100644 --- a/src/stage/timeline/clip-widget.cpp +++ b/src/stage/timeline/clip-widget.cpp @@ -327,7 +327,7 @@ namespace timeline { void establishHorizontalExtension() { - int hSize = getCanvas().translateTimeToPixels (getLen()); + int hSize = getCanvas().getMetric().translateTimeToPixels (getLen()); set_size_request (hSize, -1); // queue_resize(); } @@ -349,7 +349,7 @@ namespace timeline { void get_preferred_width_vfunc(int& minimum_width, int& natural_width) const override { - minimum_width = natural_width = getCanvas().translateTimeToPixels (getLen()); + minimum_width = natural_width = getCanvas().getMetric().translateTimeToPixels (getLen()); } diff --git a/src/stage/timeline/display-manager.hpp b/src/stage/timeline/display-manager.hpp index 7cb17a132..13909c9ef 100644 --- a/src/stage/timeline/display-manager.hpp +++ b/src/stage/timeline/display-manager.hpp @@ -146,11 +146,11 @@ namespace timeline { virtual int hookAdjX (int xPos) =0; virtual int hookAdjY (int yPos) =0; - /** delegating default implementation for timeline zoom */ - int - translateTimeToPixels (TimeValue startTimePoint) const override + /** delegating layout metric to the root canvas */ + model::DisplayMetric& + getMetric() const override { - return refHook_.translateTimeToPixels (startTimePoint); + return refHook_.getMetric(); } public: @@ -215,15 +215,13 @@ namespace timeline { class DisplayManager : util::NonCopyable , public DisplayViewHooks + , public model::DisplayMetric { public: virtual ~DisplayManager(); ///< this is an interface - /** the overall horizontal pixel span to cover by this timeline */ - virtual PixSpan getPixSpan() =0; - /** cause a re-allocation of the complete layout */ virtual void triggerDisplayEvaluation() =0; @@ -235,6 +233,16 @@ namespace timeline { * arrangement of the timeline layout. */ SignalStructureChange signalStructureChange_; + + + /** the overall horizontal pixel span to cover by this timeline */ + PixSpan + getPixSpan() + { + return {translateTimeToPixels (coveredTime().start()) + ,translateTimeToPixels (coveredTime().end()) + }; + } private:/* ===== Internals ===== */ diff --git a/src/stage/timeline/timeline-layout.cpp b/src/stage/timeline/timeline-layout.cpp index c3b9ca6ec..7d54a2243 100644 --- a/src/stage/timeline/timeline-layout.cpp +++ b/src/stage/timeline/timeline-layout.cpp @@ -40,6 +40,7 @@ #include "common/advice.hpp" //#include "lib/util.hpp" +#include "lib/time/timevalue.hpp" //#include //#include @@ -53,11 +54,19 @@ //using sigc::ptr_fun; //using std::cout; //using std::endl; +using lib::time::Time; +using lib::time::FSecs; +//using lib::time::Duration; +using lib::time::TimeSpan; namespace stage { namespace timeline { + namespace { /////////////////////////////////////////////////////TICKET #1213 : use proper zoom handling instead of dummy constants!! + const int TODO_px_per_second = 25; + } /////////////////////////////////////////////////////TICKET #1213 : (END) get rid of these dummy constants!! + @@ -108,14 +117,19 @@ namespace timeline { - /* ==== Interface: LayoutManager===== */ + /* ==== Interface: DisplayManager===== */ - PixSpan - TimelineLayout::getPixSpan() + TimeSpan + TimelineLayout::coveredTime() const + { /////////////////////////////////////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 TimeSpan {Time::ZERO, FSecs{23}}; ////////////////Lalala Lalü + } + + int + TimelineLayout::translateTimeToPixels (TimeValue startTimePoint) const { - ////////////////////////////////////////////////////////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, 248}; ////////////////Lalala Lalü + return _raw(startTimePoint) * TODO_px_per_second / Time::SCALE; //////////TICKET #1213 : delegate zoom handling to the display manager (field #layout_) !! } diff --git a/src/stage/timeline/timeline-layout.hpp b/src/stage/timeline/timeline-layout.hpp index b8387be18..4bdfeb4d9 100644 --- a/src/stage/timeline/timeline-layout.hpp +++ b/src/stage/timeline/timeline-layout.hpp @@ -137,9 +137,14 @@ namespace timeline { protected: /* ==== Interface: LayoutManager===== */ - PixSpan getPixSpan() override; void triggerDisplayEvaluation() override; + /////////////////////////////////////////////////////////////////////////////////////////////TICKET 1218 : better extract into a sub component when providing a non-dummy implementation + virtual lib::time::TimeSpan coveredTime() const override; + virtual int translateTimeToPixels (TimeValue) const override; + /////////////////////////////////////////////////////////////////////////////////////////////TICKET 1218 : better extract into a sub component when providing a non-dummy implementation + + protected: /* ==== Interface: DisplayViewHooks===== */ model::ViewHook& getHeadHook() override { return *this; }; diff --git a/tests/stage/model/canvas-hook-test.cpp b/tests/stage/model/canvas-hook-test.cpp index 66b93ca7a..c223427a9 100644 --- a/tests/stage/model/canvas-hook-test.cpp +++ b/tests/stage/model/canvas-hook-test.cpp @@ -151,11 +151,10 @@ namespace test { } protected: - int - translateTimeToPixels (TimeValue) const override + DisplayMetric& + getMetric() const override { NOTREACHED ("Time to pixel translation not covered in this unit test"); - return -1; } }; } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 19e4a798b..dd141e861 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -33099,7 +33099,7 @@ - + @@ -33123,8 +33123,8 @@ - - + + @@ -33164,14 +33164,14 @@ das Platzieren auf den Canvas ist keine high-Performance-Operation;
vielmehr ist es sogar vernachlässigbar im Vergleich zum Aufwand der Zeichen-Operationen; und letztere werden eben genau aus Performance-Gründen gebatcht und gebündelt....

- - +
- + + @@ -33192,14 +33192,13 @@ im Gegensatz zum CanvasHook ist das hier durchaus relevant

- - +
- - + +
@@ -33214,7 +33213,8 @@ - + + @@ -33232,11 +33232,15 @@ - - + + + + - - + + + +