From 09714cfe28739ceff0b5693447be41166c1cc8d6 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 6 Jan 2023 03:09:28 +0100 Subject: [PATCH] Timeline: draft solution to interconnect ZoomWindow and scrollbar After quite some tinkering, instead of extending the DisplayManager interface, I now prefer to treat this connection rather as an intricate implementation detail: The TimelineLayout implementatino now provides two translation functions, which are directly wired as slots from the Signals emitted by moving the hand of the scrollbar; the idea is that these functions mutate the ZoomWindow, which then triggers a DisplayEvaltuation, which in turn causes the drawing code to pick up and translate back the new metric and position. Results look promising, insofar the DisplayEvaluation is now triggered repeatedly, and the actual window width in pixel is propagated; however, the response of the layout code is seemingly random at times, the allocated height grows monontonously and the code Segfaults when moving the scrollbar... --- src/stage/model/zoom-window.hpp | 13 ++- src/stage/timeline/body-canvas-widget.cpp | 4 +- src/stage/timeline/body-canvas-widget.hpp | 9 +- src/stage/timeline/timeline-layout.cpp | 56 ++++++++-- src/stage/timeline/timeline-layout.hpp | 3 +- wiki/thinkPad.ichthyo.mm | 127 +++++++++++++++++++++- 6 files changed, 193 insertions(+), 19 deletions(-) diff --git a/src/stage/model/zoom-window.hpp b/src/stage/model/zoom-window.hpp index 2721e15ff..bed6ec1e4 100644 --- a/src/stage/model/zoom-window.hpp +++ b/src/stage/model/zoom-window.hpp @@ -276,7 +276,11 @@ namespace model { /* === Mutators === */ /** - * define the extension of the window in pixels. + * Define the extension of the window in pixels. + * The existing logical scale factor is retained, meaning that + * the logical duration of the actually visible window is adjusted + * alongside to match the new given pixel size, if necessary, also + * the canvas is expanded to fit. * @note all other manipulations will always retain this value */ void @@ -362,6 +366,13 @@ namespace model { fireChangeNotification(); } + void + setVisibleStart (TimeValue start) + { + mutateWindow (TimeSpan{start, Duration(afterWin_-startWin_)}); + fireChangeNotification(); + } + /** * explicitly set the visible window, * possibly expanding the canvas to fit. diff --git a/src/stage/timeline/body-canvas-widget.cpp b/src/stage/timeline/body-canvas-widget.cpp index df3a7c964..f067ca301 100644 --- a/src/stage/timeline/body-canvas-widget.cpp +++ b/src/stage/timeline/body-canvas-widget.cpp @@ -518,7 +518,7 @@ namespace timeline { * Find out the extension in pixels currently allocated for the content display. * @return number of pixels reasonably representing the actual visible with in the window */ - int + uint BodyCanvasWidget::getEffectiveHorizontalSize() const { int widthForDebug = contentArea_.get_allocated_width(); @@ -529,7 +529,7 @@ namespace timeline { auto hadj = contentArea_.get_hadjustment(); cout<<"|?| win::width="<get_upper()<property_value().signal_changed().connect( + sigc::bind(sigc::mem_fun(*this, &TimelineLayout::syncZoomWindow) + ,bodyCanvas_.get_focus_hadjustment())); + // make the ZoomWindow react on changes to the window geometry + bodyCanvas_.signal_size_allocate().connect( + sigc::mem_fun(*this, &TimelineLayout::sizeZoomWindow)); } @@ -143,18 +150,53 @@ namespace timeline { void TimelineLayout::establishLayout (DisplayEvaluation&) { - int contentWidthPx = bodyCanvas_.getEffectiveHorizontalSize(); - if (contentWidthPx != zoomWindow_.pxWidth()) -{////////////////////////////////////////////////////////////////TODO - cout<<"|!| zoom-calibrateExtension("<offset="<set_value(pxOffset); } void TimelineLayout::completeLayout (DisplayEvaluation&) { - /* noting to do for the collect-phase */ + /* nothing to do for the collect-phase */ + } + + /** + * Signal receiver (slot) to react on scrollbar changes. + * Changes the logical window position in the ZoomWindow to reflect + * the given #scrollPos, which is interpreted relative to the implicitly + * known size of the timeline canvas in pixels. + * @remark changes to ZoomWindow parameters cause notification of the listener, + * thereby triggering a new DisplayEvaluation; this in turn will invoke + * TimelineLayout::establishLayout() eventually, accommodating changes. + */ + void + TimelineLayout::syncZoomWindow (PAdjustment hadj) + { + double pos = hadj->get_value(); + TimeValue windowStart = applyScreenDelta(zoomWindow_.overallSpan().start(), pos); +cout<<"|!| zoom-scroll pos="< - + @@ -43389,8 +43389,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ Ja!!!
Hat lange gedauert, bis ich da drauf gekommen bin; aber das ist so eindeutig die richtige und angemessene Lösung, daß ich jetzt ausgesprochen erleichtert bin. +

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

+ alle Steuersignale aus dem GUI kommen in Pixel-Einheiten, entweder absolut oder relativ; das ZoomWindow selber aber arbeitet in Zeit-Einheiten (und das ist auch seine Aufgabe). +

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

+ in Grenzbereichen greift das ZoomWindow ein und begrenzt Ausschläge; selbst wenn der angeschlossene Code direkt die Pixel-Werte verwendet, muß trotzdem auf solche Eingriffe geprüft werden +

+ +
+
+
+ + + + + + + + + - + @@ -43398,6 +43502,21 @@ + + + + + + + + + + + + + + + @@ -43405,6 +43524,10 @@ + + + +