From 4d2766963bad9395b842761a26344ffdca194fd5 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 29 Aug 2019 16:19:29 +0200 Subject: [PATCH] Timeline: size allocation is not yet correct... need to investigate and probably need to store per track offset values already while building the track profile. The primary reason for the observed discrepancy seems to be the rather flexible combination of slope borders. --- src/stage/timeline/body-canvas-widget.cpp | 45 ++-- src/stage/timeline/track-body.cpp | 22 +- src/stage/timeline/track-body.hpp | 26 ++- wiki/thinkPad.ichthyo.mm | 243 ++++++++++++++++++---- 4 files changed, 264 insertions(+), 72 deletions(-) diff --git a/src/stage/timeline/body-canvas-widget.cpp b/src/stage/timeline/body-canvas-widget.cpp index 7f11758f7..a709bef7a 100644 --- a/src/stage/timeline/body-canvas-widget.cpp +++ b/src/stage/timeline/body-canvas-widget.cpp @@ -91,6 +91,7 @@ namespace timeline { default:return CLASS_slope_verydeep; } } + const uint SLOPE_CAP_DEPTH = 5; /** @@ -104,17 +105,30 @@ namespace timeline { StyleC styleRuler{trackRulerStyle.getAdvice()}; StyleC styleBody {trackBodyStyle.getAdvice()}; - int decorationRuler = styleRuler->get_margin().get_top() - + styleRuler->get_margin().get_bottom() - + styleRuler->get_border().get_top() - + styleRuler->get_border().get_bottom() - + styleRuler->get_padding().get_top() - + styleRuler->get_padding().get_bottom() - ; - int decorationBody = styleBody->get_padding().get_top() - + styleBody->get_padding().get_bottom() - ; - TrackBody::setupDecoration(decorationBody, decorationRuler); + TrackBody::decoration.ruler = styleRuler->get_margin().get_top() + + styleRuler->get_margin().get_bottom() + + styleRuler->get_border().get_top() + + styleRuler->get_border().get_bottom() + + styleRuler->get_padding().get_top() + + styleRuler->get_padding().get_bottom() + ; + TrackBody::decoration.content = styleBody->get_padding().get_top() + + styleBody->get_padding().get_bottom() + ; + TrackBody::decoration.topMar = styleBody->get_margin().get_top(); + TrackBody::decoration.botMar = styleBody->get_margin().get_bottom(); + + for (uint depth=SLOPE_CAP_DEPTH; depth>0; --depth) + { +// styleBody->context_save(); // <<<---does not work. Asked on SO: https://stackoverflow.com/q/57342478 + styleBody->add_class (slopeClassName(depth)); + + TrackBody::decoration.borders[depth] = styleBody->get_border().get_bottom(); + TrackBody::decoration.borders[0] = styleBody->get_border().get_top(); // Note: we use a common size for all opening borders + + styleBody->remove_class (slopeClassName(depth)); +// styleBody->context_restore(); // <<<---does not work... + } } @@ -572,9 +586,13 @@ namespace timeline { { renderGrounding_(cox); /////////////////////////////////////////////TICKET #1039 : placeholder drawing + // + guint w, h; + this->get_size(w, h); // mark the currently configured canvas size cox->set_source_rgb(0.8, 0.0, 0.0); cox->set_line_width (5.0); - cox->rectangle(0,0, 80, 40); + cox->move_to(0, 0); + cox->line_to(w, h); cox->stroke(); /////////////////////////////////////////////TICKET #1039 : placeholder drawing } @@ -589,7 +607,8 @@ namespace timeline { { renderOverlay_(cox); /////////////////////////////////////////////TICKET #1039 : placeholder drawing - auto alloc = get_allocation(); + // + auto alloc = get_allocation(); // mark the current space allocation by GTK int w = alloc.get_width(); int h = alloc.get_height(); int rad = MIN (w,h) / 2; diff --git a/src/stage/timeline/track-body.cpp b/src/stage/timeline/track-body.cpp index e4e6e177b..a269648b4 100644 --- a/src/stage/timeline/track-body.cpp +++ b/src/stage/timeline/track-body.cpp @@ -79,8 +79,7 @@ namespace timeline { /** storage for common style/padding settings */ - uint TrackBody::contentDecoration = 0; - uint TrackBody::rulerDecoration = 0; + Decoration TrackBody::decoration{}; void @@ -102,21 +101,6 @@ namespace timeline { } - /** - * Setup additional vertical padding for the decorations added through CSS. - * Our drawing code retrieves the margin, padding and border size settings from the - * appropriate CSS rules and adds the necessary additional space to the drawing coordinates; - * however, since one purpose of TrackBody is to calculate overall space requirements, we also - * need to account for this additional space. This call allows to pass in those values, which - * will be stored in static (class) variables. - */ - void - TrackBody::setupDecoration (uint content, uint ruler) - { - contentDecoration = content; - rulerDecoration = ruler; - } - /** * recursively calculate the height in pixels to display this track, @@ -125,7 +109,7 @@ namespace timeline { uint TrackBody::calcHeight() { - uint heightSum = calcRulerHeight() + contentHeight_ + contentDecoration; + uint heightSum = calcRulerHeight() + contentHeight_ + decoration.content; for (TrackBody* subTrack : subTracks_) heightSum += subTrack->calcHeight(); return heightSum; @@ -144,7 +128,7 @@ namespace timeline { { overviewHeight += ruler->calcHeight() + ruler->getGapHeight() - + rulerDecoration; + + decoration.ruler; } return overviewHeight; } diff --git a/src/stage/timeline/track-body.hpp b/src/stage/timeline/track-body.hpp index 59c8e2549..23cfc3134 100644 --- a/src/stage/timeline/track-body.hpp +++ b/src/stage/timeline/track-body.hpp @@ -48,6 +48,7 @@ #include #include +#include @@ -58,6 +59,26 @@ namespace timeline { class TrackProfile; + /** + * Configure additional vertical padding for the decorations added through CSS. + * Our drawing code retrieves the margin, padding and border size settings from the + * appropriate CSS rules and adds the necessary additional space to the drawing coordinates; + * however, since one purpose of TrackBody is to calculate overall space requirements, we also + * need to account for this additional space. These common amounts are stored into a static + * field and (re)configured when [establishing the track spacing](\ref TrackBody::establishTrackSpace). + */ + struct Decoration + { + uint content = 0; + uint ruler = 0; + uint topMar = 0; + uint botMar = 0; + + using Borders = std::array; + Borders borders{0,0,0,0,0}; + }; + + /** * Helper to organise and draw the space allocated for a fork of sub-tracks. * TrackBody units work together with the TimelineCanvas, which arranges all @@ -73,8 +94,6 @@ namespace timeline { class TrackBody { uint contentHeight_; - static uint contentDecoration; - static uint rulerDecoration; using PRuler = std::unique_ptr; using Rulers = std::vector; @@ -85,11 +104,12 @@ namespace timeline { Rulers rulers_; public: + static Decoration decoration; + TrackBody(); ~TrackBody(); void setTrackName (cuString&); - static void setupDecoration (uint content, uint ruler); void establishTrackSpace (TrackProfile&); void attachSubTrack (TrackBody*); uint calcRulerHeight(); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 42f4eb6e8..a74840427 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -16629,7 +16629,7 @@ - + @@ -16951,7 +16951,7 @@

- + @@ -20088,8 +20088,8 @@ - - + + @@ -20103,6 +20103,12 @@ + + + + + +
@@ -21529,8 +21535,7 @@   }

- - +
@@ -21549,8 +21554,7 @@ Macht trotzdem nix

- - +
@@ -21574,8 +21578,7 @@ Problem ist aber, daß diese Zuweisung später, nach einem set_size auf dem Canvas nicht revidiert wird.

- - + @@ -21934,6 +21937,33 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -21953,8 +21983,9 @@ - + + @@ -22079,8 +22110,7 @@ manchmal ist die alte Lösung besser

- - + @@ -22098,8 +22128,7 @@ Und letztere neigt stets zur "Verschlimmbesserung"

- -
+
@@ -22130,8 +22159,7 @@ Wohl aber lassen sich lokale Nachbarschafts-Beziehungen (höhe / tiefer) durch Schattierung hervorheben

- - +
@@ -22146,8 +22174,7 @@ Die Inhalts-Flächen selber sind zu groß und zu strukturiert, um sie per Schattierung zu verdeutlichen

- -
+
@@ -22773,8 +22800,7 @@ Damit werden effektiv die "schließenden Klammern" in eine einzige zusammengefaßt

- - +
@@ -22840,8 +22866,9 @@ - + + @@ -22927,8 +22954,7 @@ ist ineffizient, aber der Code ist so klarer

- - +
@@ -23212,8 +23238,7 @@ und zwar für bestimmte Elemente (Konvention)

- - + @@ -23231,8 +23256,7 @@ weil über alles andere darübergezeichnet wird

- - +
@@ -23820,8 +23844,9 @@ - + + @@ -23836,8 +23861,7 @@ Daher verzichte ich global (für die Slopes) darauf, wende sie aber lokal  an

- -
+
@@ -23883,8 +23907,7 @@ ...wo parktischerweise der Style-Advice in einer lokalen statischen Variablen liegt

- - +
@@ -23898,8 +23921,8 @@ - - + + @@ -23911,6 +23934,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ ....für den Kreis +

+

+ Und nicht die sichtbare Größe +

+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +

+ d.h. wir müssen... +

+
    +
  • + die Clips bündig in einen Track legen können +
  • +
  • + feststellen, ob ein Mausklick in einen bestimmten Track fällt +
  • +
+ + +
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ weil dann der Platz für den "pinned" Ruler redundant im Body-Canvas vorhanden ist! +

+ + +
+
+
+
+
+ + + + + + + + + + +

+ die gekoppelten Scrollbars funktionieren dann "von selber" +

+ +
+
+ + + + +
@@ -32756,7 +32925,7 @@
- + @@ -34294,7 +34463,7 @@ - +