Timeline: switch TrackProfile to hold a sequence of VerbPack entries

turns out to be mostly a drop-in replacement.
This commit is contained in:
Fischlurch 2019-06-11 02:40:08 +02:00
parent 1a8917e60a
commit 223113ee44
4 changed files with 61 additions and 32 deletions

View file

@ -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");
}

View file

@ -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_;

View file

@ -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 <memory>
#include <utility>
#include <vector>
@ -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<ProfileInterpreter, void(uint)>;
using SlopeElm = std::pair<SlopeVerb, uint>;
using Elements = std::vector<SlopeElm>;
using SlopeVerb = lib::VerbPack<ProfileInterpreter, void, ProfileInterpreter::MAX_ARG_SIZE>;
using Elements = std::vector<SlopeVerb>;
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<typename FUN, typename...ARGS>
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<FUN>(handler), token, forward<ARGS>(params)...);
}
#define TOKEN_BUILDER(_TOK_) \
void \
append_ ## _TOK_ (uint param)\
{ \
this->append (&ProfileInterpreter::_TOK_, STRINGIFY(_TOK_), param);\
#define TOKEN_BUILDER(_TOK_) \
template<typename...ARGS> \
void \
append_ ## _TOK_ (ARGS&&... params)\
{ \
this->append (&ProfileInterpreter::_TOK_, STRINGIFY(_TOK_), forward<ARGS>(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<ProfileInterpreter, void(uint)>;
EmbeddedPayload& embedded = static_cast<EmbeddedPayload&>(elements.back().getPayload());
uint& slopeDepth = std::get<0> (embedded.args_);
++ slopeDepth;
}
};

View file

@ -20307,18 +20307,22 @@
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1557590586650" ID="ID_1348312855" MODIFIED="1557590595855" TEXT="den (neu gebauten) VerbPack integrieren">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1557590586650" ID="ID_1348312855" MODIFIED="1560213524736" TEXT="den (neu gebauten) VerbPack integrieren">
<icon BUILTIN="pencil"/>
<node CREATED="1560175373902" ID="ID_1956293405" MODIFIED="1560175561475" TEXT="bestehendes TrackProfile sinngem&#xe4;&#xdf; umbauen">
<icon BUILTIN="yes"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1560175492578" ID="ID_1159091213" MODIFIED="1560175557813" TEXT="Verb + explizite Storage -&gt; VerbPack">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1560175492578" ID="ID_1159091213" MODIFIED="1560213489122" TEXT="Verb + explizite Storage -&gt; VerbPack">
<icon BUILTIN="button_ok"/>
<node COLOR="#435e98" CREATED="1560213502726" ID="ID_1476369075" MODIFIED="1560213516539" TEXT="l&#xe4;&#xdf;t sich 1:1 umschreiben"/>
<node COLOR="#338800" CREATED="1560213581507" ID="ID_691911700" MODIFIED="1560213594489" TEXT="habe die Argumente sofort komplett flexibel gemacht">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1560175383722" ID="ID_107500239" MODIFIED="1560175568187" TEXT="Problem: addSlopeUp()">
<icon BUILTIN="flag-yellow"/>
</node>
<node COLOR="#338800" CREATED="1560175383722" ID="ID_107500239" MODIFIED="1560213484696" TEXT="Problem: addSlopeUp()">
<icon BUILTIN="button_ok"/>
<node CREATED="1560175410857" ID="ID_1553338375" MODIFIED="1560175429772" TEXT="bisher konnten wir einfach das Argument manipulieren"/>
<node CREATED="1560175430998" ID="ID_125919592" MODIFIED="1560175477371" TEXT="...aber jetzt gibt es nicht mehr &quot;das&quot; Argument">
<node CREATED="1560175430998" ID="ID_125919592" MODIFIED="1560213396570" TEXT="...aber jetzt gibt es nicht mehr &quot;das&quot; Argument">
<richcontent TYPE="NOTE"><html>
<head>
@ -20337,8 +20341,24 @@
</html>
</richcontent>
</node>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1560175478468" ID="ID_105401193" MODIFIED="1560175566685" TEXT="Hilfe... was tun?">
<icon BUILTIN="flag-pink"/>
<node CREATED="1560213397573" ID="ID_1416770885" MODIFIED="1560213473607" TEXT="und dann mu&#xdf; man eben explizit casten und auspacken!">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
das ist nur technisch und etwas h&#228;slich,
</p>
<p>
aber durchaus sauber (unter der Annahme, da&#223; wir uns unsere Token
</p>
<p>
stets selbst erzeugen und daher auf das korrekte Literal Verla&#223; ist)
</p>
</body>
</html>
</richcontent>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1560175529230" ID="ID_914166338" MODIFIED="1560175635885">
@ -20351,8 +20371,7 @@
Verh&#228;ltnis zum Inteface <b>Renderer</b>&#160;kl&#228;ren
</p>
</body>
</html>
</richcontent>
</html></richcontent>
<arrowlink COLOR="#508bd1" DESTINATION="ID_1592949721" ENDARROW="Default" ENDINCLINATION="59;-58;" ID="Arrow_ID_1618633786" STARTARROW="None" STARTINCLINATION="-91;0;"/>
<icon BUILTIN="flag-yellow"/>
</node>