From 223113ee446d8fae1e49774d1d7b5371be618f7a Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 11 Jun 2019 02:40:08 +0200 Subject: [PATCH] Timeline: switch TrackProfile to hold a sequence of VerbPack entries turns out to be mostly a drop-in replacement. --- src/stage/timeline/body-canvas-widget.cpp | 2 +- src/stage/timeline/track-body.cpp | 2 +- src/stage/timeline/track-profile.hpp | 48 ++++++++++++++--------- wiki/thinkPad.ichthyo.mm | 41 +++++++++++++------ 4 files changed, 61 insertions(+), 32 deletions(-) diff --git a/src/stage/timeline/body-canvas-widget.cpp b/src/stage/timeline/body-canvas-widget.cpp index ee919ed21..e8ea05601 100644 --- a/src/stage/timeline/body-canvas-widget.cpp +++ b/src/stage/timeline/body-canvas-widget.cpp @@ -119,7 +119,7 @@ namespace timeline { /** paint opening slope to enter nested sub tracks * @note we only ever open one level deep a time */ void - open (uint n) override + open() override { UNIMPLEMENTED ("paint downward slope"); } diff --git a/src/stage/timeline/track-body.cpp b/src/stage/timeline/track-body.cpp index 6aa60d6e6..fdd9cbcb9 100644 --- a/src/stage/timeline/track-body.cpp +++ b/src/stage/timeline/track-body.cpp @@ -94,7 +94,7 @@ namespace timeline { uint overviewHeight = 0; for (auto& ruler : rulers_) { - overviewHeight += ruler->calcHeight(); + overviewHeight += ruler->calcHeight() + ruler->getGapHeight(); } uint heightSum = overviewHeight + contentHeight_; diff --git a/src/stage/timeline/track-profile.hpp b/src/stage/timeline/track-profile.hpp index 1a8c9a0d2..ea00efb23 100644 --- a/src/stage/timeline/track-profile.hpp +++ b/src/stage/timeline/track-profile.hpp @@ -39,12 +39,13 @@ #define STAGE_TIMELINE_TRACK_PROFILE_H #include "stage/gtk-base.hpp" -#include "lib/verb-token.hpp" +#include "lib/verb-visitor.hpp" #include "lib/symbol.hpp" #include "lib/util.hpp" //#include +#include #include @@ -54,19 +55,22 @@ namespace timeline { using lib::Literal; using util::isnil; + using std::forward; class ProfileInterpreter { public: virtual ~ProfileInterpreter() { } ///< this is an interface - virtual void ruler(uint h) =0; ///< represent a overview/ruler track with the given height + virtual void ruler(uint h) =0; ///< represent an overview/ruler track with the given height virtual void gap(uint h) =0; ///< represent a gap to structure the display virtual void content(uint h) =0; ///< represent a content area with the given vertical extension - virtual void open(uint n) =0; ///< indicate entering a nested structure, typically as 3D inset (`n` is always 1) + virtual void open() =0; ///< indicate entering a nested structure, typically as 3D inset virtual void close(uint n) =0; ///< indicate the end of `n` nested structures, typically by ascending back `n` levels virtual void prelude(uint f) =0; ///< start rack presentation at top of the timeline, with `f` pinned (always visible) elements virtual void coda(uint pad) =0; ///< the closing part of the timeline at the bottom of the track display, with `pad` additional padding + + static const size_t MAX_ARG_SIZE = sizeof(size_t); }; /** @@ -80,9 +84,8 @@ namespace timeline { */ struct TrackProfile { - using SlopeVerb = lib::VerbToken; - using SlopeElm = std::pair; - using Elements = std::vector; + using SlopeVerb = lib::VerbPack; + using Elements = std::vector; Elements elements; @@ -97,22 +100,25 @@ namespace timeline { void performWith (ProfileInterpreter& interpreter) { - for (auto& slopeElm : elements) - slopeElm.first.applyTo (interpreter, uint(slopeElm.second)); + for (auto& slopeVerb : elements) + slopeVerb.applyTo (interpreter); } private:/* ===== Internals: handling tokens ===== */ + + template void - append (SlopeVerb::Handler handler, Literal token, uint param) + append (FUN&& handler, Literal token, ARGS&&... params) { - elements.emplace_back (SlopeVerb{handler, token}, param); + elements.emplace_back (forward(handler), token, forward(params)...); } -#define TOKEN_BUILDER(_TOK_) \ - void \ - append_ ## _TOK_ (uint param)\ - { \ - this->append (&ProfileInterpreter::_TOK_, STRINGIFY(_TOK_), param);\ +#define TOKEN_BUILDER(_TOK_) \ + template \ + void \ + append_ ## _TOK_ (ARGS&&... params)\ + { \ + this->append (&ProfileInterpreter::_TOK_, STRINGIFY(_TOK_), forward(params)...); \ } public: @@ -127,7 +133,7 @@ namespace timeline { void addSlopeDown() { - this->append_open (1); + this->append_open(); } void @@ -143,15 +149,19 @@ namespace timeline { bool lastEntryIs (Literal expectedToken) { - return util::isnil (elements) - or elements.back().first.getID() == expectedToken; + return not isnil(elements) + and elements.back()->getID() == expectedToken; } void incrementLastCloseSlope() { REQUIRE (lastEntryIs ("close")); - ++ elements.back().second; + using EmbeddedPayload = lib::VerbHolder; + EmbeddedPayload& embedded = static_cast(elements.back().getPayload()); + uint& slopeDepth = std::get<0> (embedded.args_); + + ++ slopeDepth; } }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 6f2b73d63..9033a0c88 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -20307,18 +20307,22 @@ - - + + - - + + + + + - - + + + - + @@ -20337,8 +20341,24 @@ - - + + + + + + +

+ das ist nur technisch und etwas häslich, +

+

+ aber durchaus sauber (unter der Annahme, daß wir uns unsere Token +

+

+ stets selbst erzeugen und daher auf das korrekte Literal Verlaß ist) +

+ + +
@@ -20351,8 +20371,7 @@ Verhältnis zum Inteface Renderer klären

- - +