From c5d0ddb01bfc4290a6755d898d15a41547b66ace Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 20 Dec 2019 22:15:35 +0100 Subject: [PATCH] Structure-Change: push a set of suitable ViewHook-Interfaces into the DisplayFrame ...actual Operations not yet implemented (but trivial to implement in the end) --- src/stage/timeline/display-manager.hpp | 1 + src/stage/timeline/timeline-controller.cpp | 5 +- src/stage/timeline/timeline-layout.hpp | 2 - src/stage/timeline/track-body.cpp | 28 ++++++ src/stage/timeline/track-body.hpp | 14 ++- src/stage/timeline/track-head-widget.cpp | 27 ++++++ src/stage/timeline/track-head-widget.hpp | 10 ++ src/stage/timeline/track-presenter.cpp | 12 +-- src/stage/timeline/track-presenter.hpp | 105 ++++++++++++++++----- wiki/thinkPad.ichthyo.mm | 76 ++++++++++++--- 10 files changed, 227 insertions(+), 53 deletions(-) diff --git a/src/stage/timeline/display-manager.hpp b/src/stage/timeline/display-manager.hpp index 3ae4f4ae0..44f012495 100644 --- a/src/stage/timeline/display-manager.hpp +++ b/src/stage/timeline/display-manager.hpp @@ -69,6 +69,7 @@ namespace timeline { using util::max; + using model::ViewHooked; class TrackHeadWidget; class TrackBody; diff --git a/src/stage/timeline/timeline-controller.cpp b/src/stage/timeline/timeline-controller.cpp index 06cb04ed9..502af0043 100644 --- a/src/stage/timeline/timeline-controller.cpp +++ b/src/stage/timeline/timeline-controller.cpp @@ -89,10 +89,7 @@ namespace timeline { : Controller{identity, nexus} , name_{identity.getSym()} // fallback initialise name from human-readable ID symbol , markers_{} - , fork_{new TrackPresenter{trackID, nexus, [&](TrackHeadWidget& head,TrackBody& body) - { - layoutManager.installRootTrack (head, body); - }}} + , fork_{new TrackPresenter{trackID, nexus, layoutManager}} /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this , DEBUG_canvas_{layoutManager.exposeCanvasForDebug()} /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this diff --git a/src/stage/timeline/timeline-layout.hpp b/src/stage/timeline/timeline-layout.hpp index 8205c4fda..aeeb4beba 100644 --- a/src/stage/timeline/timeline-layout.hpp +++ b/src/stage/timeline/timeline-layout.hpp @@ -101,8 +101,6 @@ namespace timeline { class TrackHeadWidget; class TrackBody; - using model::ViewHooked; - /** * Top-level anchor point for the timeline display (widgets). diff --git a/src/stage/timeline/track-body.cpp b/src/stage/timeline/track-body.cpp index 2ee02191d..088207596 100644 --- a/src/stage/timeline/track-body.cpp +++ b/src/stage/timeline/track-body.cpp @@ -107,6 +107,34 @@ namespace timeline { } + /* ==== Interface: ViewHook ===== */ + + void + TrackBody::hook (TrackBody& subBody, int xPos, int yPos) + { + UNIMPLEMENTED ("attach sub-TrackBody"); + } + + void + TrackBody::move (TrackBody& subBody, int xPos, int yPos) + { + NOTREACHED ("woot?? can we even move a sub-TrackBody????"); + } + + void + TrackBody::remove (TrackBody& subBody) + { + UNIMPLEMENTED ("detach sub-TrackBody"); + } + + void + TrackBody::rehook (ViewHooked& subBody) noexcept + { + UNIMPLEMENTED ("re-attach sub-TrackBody"); + } + + + /* ==== Code for vertical track display layout ==== */ /** * recursively calculate the height in pixels to display this track, diff --git a/src/stage/timeline/track-body.hpp b/src/stage/timeline/track-body.hpp index 938dbb92d..b9e6abd8a 100644 --- a/src/stage/timeline/track-body.hpp +++ b/src/stage/timeline/track-body.hpp @@ -92,6 +92,7 @@ namespace timeline { * @todo WIP-WIP as of 6/2019 */ class TrackBody + : public model::ViewHook { uint contentHeight_; uint contentOffset_; @@ -117,13 +118,21 @@ namespace timeline { uint calcRulerHeight(); uint calcHeight(); + uint getContentOffsetY() { return startLine_; } + DisplayManager::SignalStructureChange signalStructureChange_; - private:/* ===== Internals ===== */ + /* ==== Interface: ViewHook ===== */ + void hook (TrackBody&, int xPos=0, int yPos=0) override; + void move (TrackBody&, int xPos, int yPos) override; + void remove (TrackBody&) override; + void rehook (ViewHooked&) noexcept override; + + /* ===== Internals ===== */ /** - * Allow the TrackPresenter to manage the rulers + * @internal Allow the TrackPresenter to manage the rulers * The collection of rulers is part of the systematic UI model * and thus formally a direct child of the TrackPresenter; however they * are only relevant for the immediate display and interaction mechanics, @@ -138,7 +147,6 @@ namespace timeline { return rulers_; } - friend class TrackPresenter; /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this uString TODO_trackName_; /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this diff --git a/src/stage/timeline/track-head-widget.cpp b/src/stage/timeline/track-head-widget.cpp index 8ac231b03..a096adb5b 100644 --- a/src/stage/timeline/track-head-widget.cpp +++ b/src/stage/timeline/track-head-widget.cpp @@ -112,5 +112,32 @@ namespace timeline { } + /* ==== Interface: ViewHook ===== */ + + void + TrackHeadWidget::hook (TrackHeadWidget& subHead, int xPos, int yPos) + { + UNIMPLEMENTED ("attach sub-TrackHead"); + } + + void + TrackHeadWidget::move (TrackHeadWidget& subHead, int xPos, int yPos) + { + NOTREACHED ("woot?? can we even move a sub-TrackHead????"); + } + + void + TrackHeadWidget::remove (TrackHeadWidget& subHead) + { + UNIMPLEMENTED ("detach sub-TrackHead"); + } + + void + TrackHeadWidget::rehook (ViewHooked& hookedSubHead) noexcept + { + UNIMPLEMENTED ("re-attach sub-TrackHead"); + } + + }}// namespace stage::timeline diff --git a/src/stage/timeline/track-head-widget.hpp b/src/stage/timeline/track-head-widget.hpp index 67519b6f1..d38704b17 100644 --- a/src/stage/timeline/track-head-widget.hpp +++ b/src/stage/timeline/track-head-widget.hpp @@ -48,6 +48,7 @@ #include "stage/gtk-base.hpp" #include "stage/ctrl/bus-term.hpp" +#include "stage/model/view-hook.hpp" //#include "lib/util.hpp" @@ -60,6 +61,7 @@ namespace stage { namespace timeline { using ID = ctrl::BusTerm::ID; + using model::ViewHooked; /** * Header pane control area corresponding to a Track with nested child Tracks. @@ -70,12 +72,20 @@ namespace timeline { */ class TrackHeadWidget : public Gtk::Grid + , public model::ViewHook { Gtk::Label nameTODO_; Gtk::Label treeTODO_; uint childCnt_; + /* ==== Interface: ViewHook ===== */ + + void hook (TrackHeadWidget&, int xPos=0, int yPos=0) override; + void move (TrackHeadWidget&, int xPos, int yPos) override; + void remove (TrackHeadWidget&) override; + void rehook (ViewHooked&) noexcept override; + public: TrackHeadWidget(); ~TrackHeadWidget(); diff --git a/src/stage/timeline/track-presenter.cpp b/src/stage/timeline/track-presenter.cpp index 039c2cf58..0b6848282 100644 --- a/src/stage/timeline/track-presenter.cpp +++ b/src/stage/timeline/track-presenter.cpp @@ -85,7 +85,8 @@ namespace timeline { void TrackPresenter::injectDebugTrackLabels(BodyCanvasWidget& bodyCanvas) { - bodyCanvas.DEBUG_injectTrackLabel (display_.body.TODO_trackName_, display_.body.startLine_ + display_.body.contentOffset_); + ///////////////////////////TODO TOD-oh +// bodyCanvas.DEBUG_injectTrackLabel (display_.body_.TODO_trackName_, display_.body_.startLine_ + display_.body_.contentOffset_); for (auto& subTrack : subFork_) subTrack->injectDebugTrackLabels (bodyCanvas); } @@ -109,7 +110,7 @@ namespace timeline { buffer.create ( TreeMutator::build() - .attach (collection(display_.body.bindRulers()) + .attach (collection(display_.bindRulers()) .isApplicableIf ([&](GenNode const& spec) -> bool { // »Selector« : require object-like sub scope with type-field "Ruler" return TYPE_Ruler == spec.data.recordType(); @@ -177,12 +178,7 @@ namespace timeline { }) .constructFrom ([&](GenNode const& spec) -> PFork { - return make_unique (spec.idi - ,this->uiBus_ - ,[&](TrackHeadWidget& head,TrackBody& body) - { - display_.injectSubTrack (head, body); - }); + return make_unique (spec.idi, uiBus_, this->display_); }) .buildChildMutator ([&](PFork& target, GenNode::ID const& subID, TreeMutator::Handle buff) -> bool { diff --git a/src/stage/timeline/track-presenter.hpp b/src/stage/timeline/track-presenter.hpp index 3c591d5b5..7d377b8ab 100644 --- a/src/stage/timeline/track-presenter.hpp +++ b/src/stage/timeline/track-presenter.hpp @@ -74,43 +74,103 @@ namespace timeline { /** - * Reference frame to organise the display related to a specific Track in the Timeline-GUI. + * ViewHook decorator to apply a (dynamic) offset + * when attaching or moving Widgets on the shared canvas. + */ + class CanvasOffsetHook + : public model::ViewHook + { + model::ViewHook& refHook_; + + + /* ==== Interface: ViewHook ===== */ + + void + hook (Gtk::Widget& widget, int xPos=0, int yPos=0) override + { + refHook_.hook (widget, hookAdjX (xPos), hookAdjY (yPos)); + } + + void + move (Gtk::Widget& widget, int xPos, int yPos) override + { + refHook_.move (widget, hookAdjX (xPos), hookAdjY (yPos)); + } + + void + remove (Gtk::Widget& widget) override + { + refHook_.remove (widget); + } + + void + rehook (ViewHooked& hookedWidget) noexcept override + { + refHook_.rehook (hookedWidget); + } + + protected: /* === extended Interface for relative view hook === */ + virtual int hookAdjX (int xPos) =0; + virtual int hookAdjY (int yPos) =0; + + public: + CanvasOffsetHook(model::ViewHook& refHook) + : refHook_{refHook} + { } + }; + + + /** + * Reference frame to organise the presentation related to a specific Track in the Timeline-GUI. * With the help of such a common frame of reference, we solve the problem that each individual * track display needs to hook into two distinct UI presentation structures: the track head controls * and the presentation of track contents on the BodyCanvasWidget. */ - struct DisplayFrame + class DisplayFrame : util::NonCopyable + , public DisplayViewHooks + , public CanvasOffsetHook { - TrackHeadWidget head; - TrackBody body; + TrackHeadWidget head_; + TrackBody body_; - template - DisplayFrame (FUN anchorDisplay) - : head{} - , body{} - { - anchorDisplay (head, body); - } + /* ==== Interface: DisplayViewHooks===== */ - ~DisplayFrame() - { - // Note: ~TrackBody triggers DisplayManager::signalStructureChange_() - TODO ("cause the managed presentation elements to detach from their parents"); - } ///////////////////////////////////TICKET #1198 -- clarify to what extent esp. the header widgets need to be actively removed from the display structure. Is it sufficient just to kill the TrackHeadWidget + model::ViewHook& getHeadHook() override { return head_; }; + model::ViewHook& getBodyHook() override { return body_; }; + model::ViewHook& getClipHook() override { return *this; }; + + /* === extended Interface for relative view hook === */ + + int hookAdjX (int xPos) override { return xPos; }; + int hookAdjY (int yPos) override { return yPos + body_.getContentOffsetY(); }; + + + public: + DisplayFrame (DisplayViewHooks& displayAnchor) + : CanvasOffsetHook{displayAnchor.getClipHook()} + , head_{} + , body_{} + { } void setTrackName (cuString& name) { - head.setTrackName (name); - body.setTrackName (name); ///////////////////////////////////TICKET #1017 -- TODO 11/18 : not clear yet if TrackBody needs to know its name + head_.setTrackName (name); + body_.setTrackName (name); ///////////////////////////////////TICKET #1017 -- TODO 11/18 : not clear yet if TrackBody needs to know its name } void injectSubTrack (TrackHeadWidget& subHead, TrackBody& subBody) { - head.injectSubFork (subHead); - body.attachSubTrack (&subBody); + head_.injectSubFork (subHead); + body_.attachSubTrack (&subBody); + } + + vector>& + bindRulers() + { + return body_.bindRulers(); } }; @@ -136,10 +196,9 @@ namespace timeline { * @param nexus a way to connect this Controller to the UI-Bus. * @param anchorDisplay a one-way closure to attach into the display fabric */ - template - TrackPresenter (ID id, ctrl::BusTerm& nexus, FUN anchorDisplay) + TrackPresenter (ID id, ctrl::BusTerm& nexus, DisplayViewHooks& displayAnchor) : Controller{id, nexus} - , display_{anchorDisplay} + , display_{displayAnchor} , subFork_{} , markers_{} , clips_{} diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 7dd370d28..43d4e2640 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -21435,7 +21435,7 @@ - + @@ -21464,11 +21464,34 @@ + + + + + + +

+ Streng genommen würden wir in der Tat einen generischen Quer-Zugriffsmechanismus brauchen. +

+

+ Allerdings ist dieser entweder nicht implementierbar, oder, wenn implementierbar, dann auch redundant. +

+

+ Und zudem kristallisiert sich bereits heraus, daß wir es nicht mit einem "Universum" generischer Typen zu tun bekommen, sondern mit einer kleinen Auswahl, für die wir halt dann die Quer-Verbindungen direkt auscoden und gut is... +

+ + +
+
- - + + + - + + + + @@ -21817,10 +21840,28 @@ - + - - + + + + + + + + + + + +

+ also einen speziellen Offset für Clips und einen anderen speziellen Offset für Effekt-Marker? +

+

+ Oder, anders, wie bekommen wir diese Dinger jeweils in den richtigen unter-Bereich des Track-Layouts?? +

+ + +
@@ -21879,8 +21920,8 @@ - - + + @@ -21895,7 +21936,8 @@ - + + @@ -21919,7 +21961,7 @@ - + @@ -21963,7 +22005,14 @@ - + + + + + + + + @@ -22045,7 +22094,8 @@ - + +