From 526f1d09e7179a41e1d24d01219b17e57403052e Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 13 May 2021 18:29:37 +0200 Subject: [PATCH] Clip-Drag: integrate indirectly with the TimelineLayout for metric translation The ClipPresenter can access the CanvasHook wired into its actual ClipDelegate (widget). And this in turn exposes the DisplayMetric, with the ability to transform presentation coordinates (pixels) into a model representation (Time) The actual translation is still hardwired placeholder code, since it is planned to build an generic component "ZoomWindow" to provide all the typical zomming and view window translations found in every timeline editor --- src/lib/time/control.hpp | 15 ++++---- src/stage/model/canvas-hook.hpp | 7 ++++ src/stage/timeline/clip-presenter.hpp | 7 +++- src/stage/timeline/timeline-layout.cpp | 9 ++++- src/stage/timeline/timeline-layout.hpp | 8 +++-- wiki/thinkPad.ichthyo.mm | 49 ++++++++++++++++++++------ 6 files changed, 75 insertions(+), 20 deletions(-) diff --git a/src/lib/time/control.hpp b/src/lib/time/control.hpp index 24740e38c..379162cdc 100644 --- a/src/lib/time/control.hpp +++ b/src/lib/time/control.hpp @@ -40,7 +40,9 @@ ** of time-like entities -- be it the running time display in a GUI widget, a ruler marker ** which can be dragged, a modifiable selection or the animated playhead cursor. ** - ** \par usage scenarios + ** + ** # Usage scenarios + ** ** The time::Control element provides mediating functionality, but doesn't assume or provide ** anything special regarding the usage pattern or the lifecycle, beyond the ability to ** attach listeners, attach to a (different) target and to detach from all connections. @@ -59,10 +61,10 @@ ** may expose a time::Control, thus allowing to attach target and listeners, while the ** actual changes will originate somewhere within the opaque service implementation. ** - ** Another usage pattern would be to expose a time::Control \c const&, allowing only to + ** Another usage pattern would be to expose a `time::Control const&`, allowing only to ** impose changes, but not to change the target or listener attachments. To the contrary, - ** when exposing only a time::Mutation \c const& through an interface allows only to - ** attach new target elements, but not to change listeners or feed any value changes. + ** exposing only a time::Mutation \c const& through some interface allows only to attach + ** new target elements, but not to change listeners or feed any value changes. ** ** Using time::Control as an implementation building block and just exposing the ** change (function) operators or the listener attachment through an forwarding sub @@ -71,7 +73,7 @@ ** @note time::Control is default constructible and freely copyable. ** ** - ** \par changing quantised (grid aligned) time entities + ** ## Changing quantised (grid aligned) time entities ** ** The time::Control element includes the functionality to handle grid aligned time values, ** both as target and as change/notification value. This ability is compiled in conditionally, @@ -80,7 +82,8 @@ ** the LIB_TIME_TIMEQUANT_H header guard needs to be defined, which happens automatically ** if lib/time/mutation.hpp is included prior to lib/time/control.hpp. ** - ** \par implementation notes + ** + ** # implementation notes ** - the validity of a given combination of change and target is checked immediately, ** when connecting to the target. Depending on the situation, the actual changes later ** are subject to specific treatment (e.g. frame quantisation) diff --git a/src/stage/model/canvas-hook.hpp b/src/stage/model/canvas-hook.hpp index 7b5d6d5ff..57d6c9350 100644 --- a/src/stage/model/canvas-hook.hpp +++ b/src/stage/model/canvas-hook.hpp @@ -88,6 +88,13 @@ namespace model { /** extension point for time axis zoom management. */ virtual int translateTimeToPixels (TimeValue) const =0; + + /** translate an offset in pixel coordinates into a temporal position + * @param anchor the start point on the time axis where to apply the delta + * @param deltaPx a delta given as canvas pixel displacement + * @return resulting TimeValue when applying the offset within current metric + */ + virtual TimeValue applyScreenDelta(Time anchor, double deltaPx) const =0; }; diff --git a/src/stage/timeline/clip-presenter.hpp b/src/stage/timeline/clip-presenter.hpp index d939bb952..4772a56bf 100644 --- a/src/stage/timeline/clip-presenter.hpp +++ b/src/stage/timeline/clip-presenter.hpp @@ -226,14 +226,18 @@ namespace timeline { : public interact::GestureObserver { ClipPresenter& subject_; + model::DisplayMetric const& metric_; void updateOffset (double deltaX, double deltaY) override { - std::cerr << _Fmt{"Gesture(%s) --> Δ := (%3.1f,%3.1f)"} + TimeValue newStartTime = metric_.applyScreenDelta(subject_.widget_->getStartTime(), deltaX); + std::cerr << _Fmt{"Gesture(%s) → Δ ≔ (%3.1f,%3.1f) ⟹ %s ↷ %s"} % getCmdID() % deltaX % deltaY + % subject_.widget_->getStartTime() + % newStartTime << std::endl; } @@ -249,6 +253,7 @@ namespace timeline { DragRelocateObserver(Symbol cmdID, ClipPresenter& clipPresenter) : interact::GestureObserver{cmdID} , subject_{clipPresenter} + , metric_{clipPresenter.widget_->getCanvas().getMetric()} { } }; diff --git a/src/stage/timeline/timeline-layout.cpp b/src/stage/timeline/timeline-layout.cpp index 7d54a2243..d6856190c 100644 --- a/src/stage/timeline/timeline-layout.cpp +++ b/src/stage/timeline/timeline-layout.cpp @@ -129,9 +129,16 @@ namespace timeline { int TimelineLayout::translateTimeToPixels (TimeValue startTimePoint) const { - return _raw(startTimePoint) * TODO_px_per_second / Time::SCALE; //////////TICKET #1213 : delegate zoom handling to the display manager (field #layout_) !! + return _raw(startTimePoint) * TODO_px_per_second / Time::SCALE; //////////TICKET #1213 : use a mix-in component, which in turn relies on the "ZoomWindow" !! } + TimeValue + TimelineLayout::applyScreenDelta(Time anchor, double deltaPx) const + { //////////TICKET #1213 : use a mix-in component, which in turn relies on the "ZoomWindow" !! + return anchor + TimeValue{gavl_time_t(Time::SCALE * deltaPx / TODO_px_per_second)}; + } + + /** * Perform a complete recursive pass over all elements relevant for layout, diff --git a/src/stage/timeline/timeline-layout.hpp b/src/stage/timeline/timeline-layout.hpp index 4bdfeb4d9..2de40bfdd 100644 --- a/src/stage/timeline/timeline-layout.hpp +++ b/src/stage/timeline/timeline-layout.hpp @@ -89,6 +89,7 @@ #include "stage/timeline/body-canvas-widget.hpp" #include "stage/model/canvas-hook.hpp" #include "stage/model/view-hook.hpp" +#include "lib/time/timevalue.hpp" //#include "lib/util.hpp" @@ -100,6 +101,8 @@ namespace stage { namespace timeline { + using lib::time::Time; + class LayoutElement; class TrackHeadWidget; class TrackBody; @@ -140,8 +143,9 @@ namespace timeline { 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; + virtual lib::time::TimeSpan coveredTime() const override; + virtual int translateTimeToPixels (TimeValue) const override; + virtual TimeValue applyScreenDelta(Time, double) const override; /////////////////////////////////////////////////////////////////////////////////////////////TICKET 1218 : better extract into a sub component when providing a non-dummy implementation diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 21aa77a9c..10d600900 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -32884,7 +32884,23 @@ - + + + + + + + + +

+ verwendet hart gedrahtete Konstante TODO_px_per_second +

+ +
+
+ + +
@@ -33072,7 +33088,7 @@
  • - der clipHook() delegiert an seinen jweiligen refHook_ + der clipHook() delegiert an seinen jeweiligen refHook_
  • dieser wird bei der Konstruktion tatsächlich jweils auf den Anchor-Hook des Parent-Hook gesetzt @@ -33168,15 +33184,15 @@ - - + + - - + + @@ -33215,6 +33231,9 @@ + + + @@ -33298,8 +33317,8 @@ - - + + @@ -33607,8 +33626,18 @@ - - + + + + + + +

    + funktioniert... Zeit-Werte werden an der Konsole ausgegeben +

    + +
    +