Timeline: switch TrackProfile to hold a sequence of VerbPack entries
turns out to be mostly a drop-in replacement.
This commit is contained in:
parent
1a8917e60a
commit
223113ee44
4 changed files with 61 additions and 32 deletions
|
|
@ -119,7 +119,7 @@ namespace timeline {
|
||||||
/** paint opening slope to enter nested sub tracks
|
/** paint opening slope to enter nested sub tracks
|
||||||
* @note we only ever open one level deep a time */
|
* @note we only ever open one level deep a time */
|
||||||
void
|
void
|
||||||
open (uint n) override
|
open() override
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED ("paint downward slope");
|
UNIMPLEMENTED ("paint downward slope");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace timeline {
|
||||||
uint overviewHeight = 0;
|
uint overviewHeight = 0;
|
||||||
for (auto& ruler : rulers_)
|
for (auto& ruler : rulers_)
|
||||||
{
|
{
|
||||||
overviewHeight += ruler->calcHeight();
|
overviewHeight += ruler->calcHeight()
|
||||||
+ ruler->getGapHeight();
|
+ ruler->getGapHeight();
|
||||||
}
|
}
|
||||||
uint heightSum = overviewHeight + contentHeight_;
|
uint heightSum = overviewHeight + contentHeight_;
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,13 @@
|
||||||
#define STAGE_TIMELINE_TRACK_PROFILE_H
|
#define STAGE_TIMELINE_TRACK_PROFILE_H
|
||||||
|
|
||||||
#include "stage/gtk-base.hpp"
|
#include "stage/gtk-base.hpp"
|
||||||
#include "lib/verb-token.hpp"
|
#include "lib/verb-visitor.hpp"
|
||||||
|
|
||||||
#include "lib/symbol.hpp"
|
#include "lib/symbol.hpp"
|
||||||
#include "lib/util.hpp"
|
#include "lib/util.hpp"
|
||||||
|
|
||||||
//#include <memory>
|
//#include <memory>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -54,19 +55,22 @@ namespace timeline {
|
||||||
|
|
||||||
using lib::Literal;
|
using lib::Literal;
|
||||||
using util::isnil;
|
using util::isnil;
|
||||||
|
using std::forward;
|
||||||
|
|
||||||
class ProfileInterpreter
|
class ProfileInterpreter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ProfileInterpreter() { } ///< this is an interface
|
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 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 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 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 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
|
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
|
struct TrackProfile
|
||||||
{
|
{
|
||||||
using SlopeVerb = lib::VerbToken<ProfileInterpreter, void(uint)>;
|
using SlopeVerb = lib::VerbPack<ProfileInterpreter, void, ProfileInterpreter::MAX_ARG_SIZE>;
|
||||||
using SlopeElm = std::pair<SlopeVerb, uint>;
|
using Elements = std::vector<SlopeVerb>;
|
||||||
using Elements = std::vector<SlopeElm>;
|
|
||||||
|
|
||||||
Elements elements;
|
Elements elements;
|
||||||
|
|
||||||
|
|
@ -97,22 +100,25 @@ namespace timeline {
|
||||||
void
|
void
|
||||||
performWith (ProfileInterpreter& interpreter)
|
performWith (ProfileInterpreter& interpreter)
|
||||||
{
|
{
|
||||||
for (auto& slopeElm : elements)
|
for (auto& slopeVerb : elements)
|
||||||
slopeElm.first.applyTo (interpreter, uint(slopeElm.second));
|
slopeVerb.applyTo (interpreter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:/* ===== Internals: handling tokens ===== */
|
private:/* ===== Internals: handling tokens ===== */
|
||||||
|
|
||||||
|
template<typename FUN, typename...ARGS>
|
||||||
void
|
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_) \
|
#define TOKEN_BUILDER(_TOK_) \
|
||||||
void \
|
template<typename...ARGS> \
|
||||||
append_ ## _TOK_ (uint param)\
|
void \
|
||||||
{ \
|
append_ ## _TOK_ (ARGS&&... params)\
|
||||||
this->append (&ProfileInterpreter::_TOK_, STRINGIFY(_TOK_), param);\
|
{ \
|
||||||
|
this->append (&ProfileInterpreter::_TOK_, STRINGIFY(_TOK_), forward<ARGS>(params)...); \
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -127,7 +133,7 @@ namespace timeline {
|
||||||
void
|
void
|
||||||
addSlopeDown()
|
addSlopeDown()
|
||||||
{
|
{
|
||||||
this->append_open (1);
|
this->append_open();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -143,15 +149,19 @@ namespace timeline {
|
||||||
bool
|
bool
|
||||||
lastEntryIs (Literal expectedToken)
|
lastEntryIs (Literal expectedToken)
|
||||||
{
|
{
|
||||||
return util::isnil (elements)
|
return not isnil(elements)
|
||||||
or elements.back().first.getID() == expectedToken;
|
and elements.back()->getID() == expectedToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
incrementLastCloseSlope()
|
incrementLastCloseSlope()
|
||||||
{
|
{
|
||||||
REQUIRE (lastEntryIs ("close"));
|
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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20307,18 +20307,22 @@
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1557590586650" ID="ID_1348312855" MODIFIED="1557590595855" TEXT="den (neu gebauten) VerbPack integrieren">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1557590586650" ID="ID_1348312855" MODIFIED="1560213524736" TEXT="den (neu gebauten) VerbPack integrieren">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="pencil"/>
|
||||||
<node CREATED="1560175373902" ID="ID_1956293405" MODIFIED="1560175561475" TEXT="bestehendes TrackProfile sinngemäß umbauen">
|
<node CREATED="1560175373902" ID="ID_1956293405" MODIFIED="1560175561475" TEXT="bestehendes TrackProfile sinngemäß umbauen">
|
||||||
<icon BUILTIN="yes"/>
|
<icon BUILTIN="yes"/>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1560175492578" ID="ID_1159091213" MODIFIED="1560175557813" TEXT="Verb + explizite Storage -> VerbPack">
|
<node COLOR="#338800" CREATED="1560175492578" ID="ID_1159091213" MODIFIED="1560213489122" TEXT="Verb + explizite Storage -> VerbPack">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="button_ok"/>
|
||||||
|
<node COLOR="#435e98" CREATED="1560213502726" ID="ID_1476369075" MODIFIED="1560213516539" TEXT="läß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>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1560175383722" ID="ID_107500239" MODIFIED="1560175568187" TEXT="Problem: addSlopeUp()">
|
</node>
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<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="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 "das" Argument">
|
<node CREATED="1560175430998" ID="ID_125919592" MODIFIED="1560213396570" TEXT="...aber jetzt gibt es nicht mehr "das" Argument">
|
||||||
<richcontent TYPE="NOTE"><html>
|
<richcontent TYPE="NOTE"><html>
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
|
|
@ -20337,8 +20341,24 @@
|
||||||
</html>
|
</html>
|
||||||
</richcontent>
|
</richcontent>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1560175478468" ID="ID_105401193" MODIFIED="1560175566685" TEXT="Hilfe... was tun?">
|
<node CREATED="1560213397573" ID="ID_1416770885" MODIFIED="1560213473607" TEXT="und dann muß man eben explizit casten und auspacken!">
|
||||||
<icon BUILTIN="flag-pink"/>
|
<richcontent TYPE="NOTE"><html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>
|
||||||
|
das ist nur technisch und etwas häslich,
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
aber durchaus sauber (unter der Annahme, daß wir uns unsere Token
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
stets selbst erzeugen und daher auf das korrekte Literal Verlaß ist)
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
</richcontent>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1560175529230" ID="ID_914166338" MODIFIED="1560175635885">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1560175529230" ID="ID_914166338" MODIFIED="1560175635885">
|
||||||
|
|
@ -20351,8 +20371,7 @@
|
||||||
Verhältnis zum Inteface <b>Renderer</b> klären
|
Verhältnis zum Inteface <b>Renderer</b> klären
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html></richcontent>
|
||||||
</richcontent>
|
|
||||||
<arrowlink COLOR="#508bd1" DESTINATION="ID_1592949721" ENDARROW="Default" ENDINCLINATION="59;-58;" ID="Arrow_ID_1618633786" STARTARROW="None" STARTINCLINATION="-91;0;"/>
|
<arrowlink COLOR="#508bd1" DESTINATION="ID_1592949721" ENDARROW="Default" ENDINCLINATION="59;-58;" ID="Arrow_ID_1618633786" STARTARROW="None" STARTINCLINATION="-91;0;"/>
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
</node>
|
</node>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue