From 737505979b0470ac6f176b879f3e3ed24fd27b29 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 23 Aug 2019 03:56:38 +0200 Subject: [PATCH] Timeline: also observe additional space for decorations added via CSS --- src/stage/timeline/body-canvas-widget.cpp | 26 ++++++++++++++++++ src/stage/timeline/track-body.cpp | 26 ++++++++++++++++-- src/stage/timeline/track-body.hpp | 3 +++ wiki/thinkPad.ichthyo.mm | 32 ++++++++++++++++++++--- 4 files changed, 81 insertions(+), 6 deletions(-) diff --git a/src/stage/timeline/body-canvas-widget.cpp b/src/stage/timeline/body-canvas-widget.cpp index e8ceebaa5..7f11758f7 100644 --- a/src/stage/timeline/body-canvas-widget.cpp +++ b/src/stage/timeline/body-canvas-widget.cpp @@ -93,6 +93,31 @@ namespace timeline { } + /** + * Adjust the vertical space to accommodate for additional decorations + * as required by the CSS style rules. Our custom drawing code observes + * the same adjustments when drawing background and frame borders. + */ + void + setupAdditionalTrackPadding_fromCSS() + { + 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); + } + + /** * @internal drawing routines to paint the nested system * of insets and rulers in the track content display @@ -431,6 +456,7 @@ namespace timeline { { if (rootBody_ and isnil (profile_)) { + setupAdditionalTrackPadding_fromCSS(); layout_.triggerDisplayEvaluation(); rootBody_->establishTrackSpace (profile_); adjustCanvasHeight(layout_.getPixSpan().delta(), diff --git a/src/stage/timeline/track-body.cpp b/src/stage/timeline/track-body.cpp index 5c6e60f61..e4e6e177b 100644 --- a/src/stage/timeline/track-body.cpp +++ b/src/stage/timeline/track-body.cpp @@ -78,6 +78,11 @@ namespace timeline { } + /** storage for common style/padding settings */ + uint TrackBody::contentDecoration = 0; + uint TrackBody::rulerDecoration = 0; + + void TrackBody::setTrackName (cuString& trackName) { @@ -97,6 +102,22 @@ 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, * including all nested sub-tracks @@ -104,7 +125,7 @@ namespace timeline { uint TrackBody::calcHeight() { - uint heightSum = calcRulerHeight() + contentHeight_; + uint heightSum = calcRulerHeight() + contentHeight_ + contentDecoration; for (TrackBody* subTrack : subTracks_) heightSum += subTrack->calcHeight(); return heightSum; @@ -122,7 +143,8 @@ namespace timeline { for (auto& ruler : rulers_) { overviewHeight += ruler->calcHeight() - + ruler->getGapHeight(); + + ruler->getGapHeight() + + rulerDecoration; } return overviewHeight; } diff --git a/src/stage/timeline/track-body.hpp b/src/stage/timeline/track-body.hpp index 325bc39f7..59c8e2549 100644 --- a/src/stage/timeline/track-body.hpp +++ b/src/stage/timeline/track-body.hpp @@ -73,6 +73,8 @@ namespace timeline { class TrackBody { uint contentHeight_; + static uint contentDecoration; + static uint rulerDecoration; using PRuler = std::unique_ptr; using Rulers = std::vector; @@ -87,6 +89,7 @@ namespace timeline { ~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 31c22a940..c32f0c862 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -23817,8 +23817,8 @@ - - + + @@ -23847,6 +23847,9 @@ + + + @@ -23866,14 +23869,35 @@ - - + + + + + + + + + +

+ ...wo parktischerweise der Style-Advice in einer lokalen statischen Variablen liegt +

+ + +
+ +
+
+ +
+ + +