From ea3ea811bf7adc6ec84859f7f33276bbf59fdd2b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 6 Apr 2020 23:10:53 +0200 Subject: [PATCH] Clip: sort out access to the canvas abstraction --- src/stage/model/canvas-hook.hpp | 2 +- src/stage/model/view-hook.hpp | 5 +++-- src/stage/timeline/clip-widget.cpp | 31 ++++++++++++------------------ src/stage/timeline/clip-widget.hpp | 2 +- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/stage/model/canvas-hook.hpp b/src/stage/model/canvas-hook.hpp index e13edb31e..6a210d0d1 100644 --- a/src/stage/model/canvas-hook.hpp +++ b/src/stage/model/canvas-hook.hpp @@ -157,7 +157,7 @@ namespace model { protected: Canvas& - getCanvas() + getCanvas() const { REQUIRE (INSTANCEOF(ViewHook, &Hooked::getView() )); return static_cast (Hooked::getView()); diff --git a/src/stage/model/view-hook.hpp b/src/stage/model/view-hook.hpp index 378f16dc8..1344e4350 100644 --- a/src/stage/model/view-hook.hpp +++ b/src/stage/model/view-hook.hpp @@ -86,7 +86,7 @@ namespace model { public: virtual ~ViewHook() { } ///< this is an interface - virtual void hook (WID& widget) =0; + virtual void hook (WID& widget) =0; virtual void remove (WID& widget) =0; virtual void rehook (WID& widget) noexcept =0; @@ -128,7 +128,8 @@ namespace model { View* view_; protected: - View& getView() { return *view_; } + View& + getView() const { return *view_; } public: template diff --git a/src/stage/timeline/clip-widget.cpp b/src/stage/timeline/clip-widget.cpp index dc64fa622..d24bb5a58 100644 --- a/src/stage/timeline/clip-widget.cpp +++ b/src/stage/timeline/clip-widget.cpp @@ -128,14 +128,7 @@ namespace timeline { { return unConst(this)->display_; } - - WidgetHook::Pos - establishHookPoint (WidgetHook* newView) const override - { - if (not newView) - newView = &display_; - return newView->hookedAt (getStartTime(), defaultOffsetY); - } + public: ClipData(WidgetHook& displayAnchor) @@ -147,7 +140,7 @@ namespace timeline { ClipData(ClipDelegate& existing) : ClipDelegate{} , display_{existing.getCanvas()} - { + { TODO("copy further clip presentation properties"); } }; @@ -188,16 +181,8 @@ namespace timeline { WidgetHook& getCanvas() const override { - UNIMPLEMENTED("sort the base access out"); //return static_cast (unConst(*this)).getCanvas(); + return HookedWidget::getCanvas(); } - - WidgetHook::Pos - establishHookPoint (WidgetHook* newView) const override - { - if (not newView) - newView = &getCanvas(); - return newView->hookedAt (getStartTime(), defaultOffsetY); - } ///////////////////////////////////////////////////////////////TICKET #1038 : TODO mostly duplicated implementation public: @@ -210,7 +195,7 @@ namespace timeline { ClipWidget(ClipDelegate& existing, WidgetHook* newView) : HookedWidget{existing.establishHookPoint(newView), existing.getClipName()} , ClipDelegate{} - { + { TODO("copy further clip presentation properties"); } }; @@ -266,5 +251,13 @@ namespace timeline { } + WidgetHook::Pos + ClipDelegate::establishHookPoint (WidgetHook* newView) + { + if (not newView) + newView = & getCanvas(); + return newView->hookedAt (getStartTime(), defaultOffsetY); + } + }}// namespace stage::timeline diff --git a/src/stage/timeline/clip-widget.hpp b/src/stage/timeline/clip-widget.hpp index ceb24163f..00c4058a5 100644 --- a/src/stage/timeline/clip-widget.hpp +++ b/src/stage/timeline/clip-widget.hpp @@ -164,7 +164,7 @@ namespace timeline { * @param newView (optional) new canvas; use existing if not given * @return record defining the canvas and the coordinates thereon */ - virtual WidgetHook::Pos establishHookPoint (WidgetHook* newView) const =0; + WidgetHook::Pos establishHookPoint (WidgetHook* newView); /** request to change the clip delegate's appearance style, if possible.