Structure-Change: introduce a common accessor interface

...to solve the problem with interwoven nested ctor invocation.
This interface also promises to help with nested invcations,
without being overly generic.
This commit is contained in:
Fischlurch 2019-12-20 20:06:26 +01:00
parent c5bffa21f4
commit 33a19c404b
5 changed files with 98 additions and 8 deletions

View file

@ -537,6 +537,32 @@ namespace timeline {
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this
/* ==== Interface: ViewHook ===== */
void
BodyCanvasWidget::hook (Gtk::Widget& head, int xPos, int yPos)
{
UNIMPLEMENTED ("find the relevant canvas and attach the widget at given pos");
}
void
BodyCanvasWidget::remove (Gtk::Widget& head)
{
UNIMPLEMENTED ("find the relevant canvas and search and attach the widget");
}
void
BodyCanvasWidget::rehook (model::ViewHooked<Gtk::Widget>&) noexcept
{
UNIMPLEMENTED ("find the relevant canvas and attach the widget anew");
}
void
BodyCanvasWidget::move (Gtk::Widget& head, int xPos, int yPos)
{
UNIMPLEMENTED ("find the relevant canvas and reposition the widget");
}

View file

@ -59,6 +59,7 @@
#include "stage/gtk-base.hpp"
#include "stage/timeline/track-profile.hpp"
#include "stage/model/view-hook.hpp"
//#include "lib/util.hpp"
@ -105,6 +106,7 @@ namespace timeline {
*/
class BodyCanvasWidget
: public Gtk::Box
, public model::ViewHook<Gtk::Widget>
{
DisplayManager& layout_;
TrackProfile profile_;
@ -136,6 +138,13 @@ namespace timeline {
void DEBUG_injectTrackLabel(cuString const& trackName, int startLine);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this
protected: /* ==== Interface: ViewHook ===== */
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;
void rehook (model::ViewHooked<Gtk::Widget>&) noexcept override;
private:/* ===== Internals ===== */
void slotStructureChange() noexcept;

View file

@ -57,14 +57,11 @@
#include "lib/error.hpp"
#include "lib/nocopy.hpp"
#include "stage/model/view-hook.hpp"
#include "lib/util.hpp"
#include <sigc++/signal.h>
//#include <memory>
//#include <vector>
namespace stage {
@ -72,10 +69,35 @@ namespace timeline {
using util::max;
// class TrackHeadWidget;
class TrackHeadWidget;
class TrackBody;
/** @todo quick-n-dirty hack. Should consider the Range TR (C++20) */
/**
* Interface: a compound of anchoring facilities.
* With the help of view-hooking, some detail presentation component
* or widget can attach itself into the overarching view context or canvas
* of the Timeline, while remaining agnostic about actual structure or implementation
* of this »display umbrella«. The local presentation component itself is then model::ViewHooked,
* thereby managing its attachment to the global context automatically. As it turns out, within
* the timeline display, we typically need a specific combination of such model::ViewHook, and
* we need them recursively: the actual timeline::DisplayFrame, while attaching below such
* DisplayViewHooks, is in turn itself again such a sub-anchor, allowing to attach
* child display frames recursively, which is required to display sub-tracks.
*/
class DisplayViewHooks
{
public:
virtual ~DisplayViewHooks() { } ///< this is an interface
virtual model::ViewHook<TrackHeadWidget>& getHeadHook() =0;
virtual model::ViewHook<TrackBody>& getBodyHook() =0;
virtual model::ViewHook<Gtk::Widget>& getClipHook() =0;
};
/** @todo quick-n-dirty hack. Should consider the Range TS (C++20) */
struct PixSpan
{
int b = 0;
@ -100,11 +122,12 @@ namespace timeline {
};
/**
* Interface used by the widgets to translate themselves into screen layout.
* @todo WIP-WIP as of 11/2018
* Interface used by the widgets to attach and translate themselves into screen layout.
* @todo WIP-WIP as of 12/2019
*/
class DisplayManager
: util::NonCopyable
, public DisplayViewHooks
{
// TimelineLayout();

View file

@ -140,6 +140,12 @@ namespace timeline {
PixSpan getPixSpan() override;
void triggerDisplayEvaluation() override;
protected: /* ==== Interface: DisplayViewHooks===== */
model::ViewHook<TrackHeadWidget>& getHeadHook() override { return *this; };
model::ViewHook<TrackBody>& getBodyHook() override { return *this; };
model::ViewHook<Gtk::Widget>& getClipHook() override { return bodyCanvas_; };
protected: /* ==== Interface: ViewHook ===== */
void hook (TrackHeadWidget&, int xPos=0, int yPos=0) override;

View file

@ -21895,6 +21895,28 @@
<icon BUILTIN="smily_bad"/>
</node>
<node CREATED="1576760324713" ID="ID_1267786696" MODIFIED="1576760340354" TEXT="einziger Ausweg... Display-Manager wird zum Super-Hook"/>
<node COLOR="#338800" CREATED="1576806720057" ID="ID_805988831" MODIFIED="1576855579888" TEXT="noch besser: das in ein Sammel-Interface packen">
<icon BUILTIN="idea"/>
<node CREATED="1576806744893" ID="ID_526365809" MODIFIED="1576855570801" TEXT="vielleicht sogar ein Accessor-Interface">
<icon BUILTIN="idea"/>
</node>
<node CREATED="1576806754123" ID="ID_931227814" MODIFIED="1576806765651" TEXT="das was wir brauchen -- nicht generisch">
<icon BUILTIN="yes"/>
</node>
<node CREATED="1576806780944" ID="ID_424677663" MODIFIED="1576806787371" TEXT="wo definieren?">
<node CREATED="1576806800277" ID="ID_1586259922" MODIFIED="1576806811655" TEXT="Track-Presenter (zumindest) mu&#xdf; das sehen"/>
<node CREATED="1576806815591" ID="ID_1412328590" MODIFIED="1576806824733" TEXT="ViewHook sollte reine Implementierung bleiben"/>
<node COLOR="#435e98" CREATED="1576806845175" ID="ID_302576498" MODIFIED="1576855554242" TEXT="DisplayManager">
<icon BUILTIN="yes"/>
<node CREATED="1576806881586" ID="ID_1243796008" MODIFIED="1576806891357" TEXT="ja da geh&#xf6;rt&apos;s eigentlich hin"/>
<node CREATED="1576806892609" ID="ID_981763412" MODIFIED="1576806908361" TEXT="versuch, m&#xf6;glichst mit forward-decl zu arbeiten"/>
</node>
</node>
</node>
<node COLOR="#435e98" CREATED="1576855633920" ID="ID_1642579599" MODIFIED="1576855726346" TEXT="damit ist auch die Basis zum relativen Positionieren gegeben">
<arrowlink COLOR="#6780d3" DESTINATION="ID_1121301646" ENDARROW="Default" ENDINCLINATION="551;-498;" ID="Arrow_ID_229033893" STARTARROW="None" STARTINCLINATION="-477;21;"/>
<icon BUILTIN="idea"/>
</node>
</node>
</node>
<node CREATED="1576710544415" ID="ID_88564726" MODIFIED="1576710556729" TEXT="zwei F&#xe4;lle zu unterscheiden">
@ -22023,6 +22045,10 @@
<node CREATED="1576705779910" ID="ID_968522268" MODIFIED="1576705792920" TEXT="damit ViewHook&lt;Clip&gt;"/>
<node CREATED="1576705802515" ID="ID_674496871" MODIFIED="1576705809765" TEXT="und ViewHook&lt;Marker&gt;"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1576855620250" ID="ID_1121301646" MODIFIED="1576855705548" TEXT="relatives Positionieren erm&#xf6;glichen">
<linktarget COLOR="#6780d3" DESTINATION="ID_1121301646" ENDARROW="Default" ENDINCLINATION="551;-498;" ID="Arrow_ID_229033893" SOURCE="ID_1642579599" STARTARROW="None" STARTINCLINATION="-477;21;"/>
<icon BUILTIN="flag-yellow"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1576705946751" ID="ID_478555928" MODIFIED="1576705956429" TEXT="re-Konstrkutions-Mechanismus realisieren">
<icon BUILTIN="flag-yellow"/>