From b38481fa89620e3eeda94e2968aebb8349e6d4f9 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 20 Jan 2023 23:55:44 +0100 Subject: [PATCH] Timeline: solve basic layout issue by properly calculating the height As it turns out, we need to take the actual allocation of the cells within the grid explicitly into account: combined cells will report their extension for each of the underlying cells, thus leading to excessively overestimated measurements. So we now calculate the overall height based on the actual structure - first row holds the label - left column below used as expander - right column holds individual content Remaining problems: - height of ruler canvas at top not taken into account (11px in this example) - start of sub-track headers not synchronised with start of sub-tracks in the body area --- src/stage/timeline/track-head-widget.cpp | 139 ++++++++------------ src/stage/timeline/track-head-widget.hpp | 33 +++-- src/stage/timeline/track-presenter.hpp | 16 +-- wiki/thinkPad.ichthyo.mm | 153 +++++++++++++++++++++-- 4 files changed, 228 insertions(+), 113 deletions(-) diff --git a/src/stage/timeline/track-head-widget.cpp b/src/stage/timeline/track-head-widget.cpp index 2e25a6b20..6de758140 100644 --- a/src/stage/timeline/track-head-widget.cpp +++ b/src/stage/timeline/track-head-widget.cpp @@ -68,6 +68,7 @@ namespace timeline { : Gtk::Grid{} , nameTODO_{"?"} , treeTODO_{"↳"} + , padding_{} , headCtrl_{} , childCnt_{0} { @@ -78,9 +79,10 @@ namespace timeline { headCtrl_.set_valign(Gtk::Align::ALIGN_CENTER); headCtrl_.set_halign(Gtk::Align::ALIGN_FILL); this->attach (nameTODO_, 0,0, 2,1); - this->attach (treeTODO_, 0,1, 1,1); - attachDirectContent(); - this->property_expand() = false; // do not expand to fill + this->attach (treeTODO_, 0,1, 1,2); + this->attach (headCtrl_, 1,1, 1,1); // corresponds to direct content + this->attach (padding_, 1,2, 1,1);// used to sync with sub-track display + this->property_expand() = false; // do not expand to fill this->show_all(); } @@ -113,68 +115,52 @@ namespace timeline { return max (0, max (actual, natural)); } - /** - * @remark the cell(1,1) is guaranteed to exist; - * if childCnt_ == 0, it holds the direct content control area - */ uint - TrackHeadWidget::calcContentHeight() const + TrackHeadWidget::getOverallHeight() const { - uint heightSum = 0; - for (uint line=1; line <= max(1u, childCnt_); ++line) - { - int h = getHeightAt (1,line); - heightSum += max (0,h); - } - return heightSum; - } - - uint - TrackHeadWidget::calcOverallHeight() const - { - uint heightSum = 0; - for (uint line=0; line <= max(1u, childCnt_); ++line) - { + uint heightSum{0}; + for (uint line=1; line <= 2u + childCnt_; ++line) + {/////////////////////////////////////////////TODO int h1 = getHeightAt (0,line); int h2 = getHeightAt (1,line); - - heightSum += max (0, max (h1,h2)); - } - return heightSum; +////////////////////////////////////////////////////TODO +cout<<"|o| cH(line="<get_child_at(left,top); + REQUIRE (cell); +cell->get_size_request (reqW, reqH); + cell->set_size_request (-1, height); +uint hnach = getOverallHeight(); +cell->get_size_request (reqW, reqHn); +cout<<"|+| Head:inc ("< localHeight) - increaseContentHeight (contentHeight-localHeight); - } - - /** apply the Δ to the »content area« (4th quadrant) */ - void - TrackHeadWidget::increaseContentHeight(uint delta) - { - increaseHeightAt (1,1, delta); - } - - /** increase the general vertical spread by the given Δ */ - void - TrackHeadWidget::increaseExpansionHeight(uint delta) - { - increaseHeightAt (0,1, delta); + enforceContentHeight (contentHeight); } void - TrackHeadWidget::increaseHeightAt(int left, int top, uint delta) + TrackHeadWidget::accommodateOverallHeight(uint overallHeight) { -uint hvor = calcOverallHeight(); - auto* cell = this->get_child_at(left,top); - REQUIRE (cell); - uint h = getHeightAt (left,top); - cell->set_size_request (-1, h+delta); -uint hnach = calcOverallHeight(); -cout<<"|+| Head:inc ("< localHeight) + enforceExpansionHeight (overallHeight - getLabelHeight()); } @@ -184,23 +170,26 @@ cout<<"|+| Head:inc ("<determineRequiredVerticalExtension(); })); -auto headH = head_.calcContentHeight();/////////////////////////////////////////////////////////////////////TODO +auto headH = head_.getContentHeight();/////////////////////////////////////////////////////////////////////TODO auto bodyH = maxVSize; maxVSize = max (maxVSize, headH); this->body_.accommodateContentHeight (maxVSize); this->head_.accommodateContentHeight (maxVSize); -auto headN = head_.calcContentHeight(); +auto headN = head_.getContentHeight(); auto bodyN = body_.DEBUGconH(); cout<<"|*| establishExtension(clipH="< + + + + + + +

+ wozu haben wir das Gtk::Grid +

+ +
+ +
+ + + - - + + + + + + + + + @@ -27779,11 +27802,9 @@ - - - + @@ -29181,8 +29202,8 @@ - - + + @@ -29192,14 +29213,127 @@ - + + + + + + + + + + + + + + + + + + + + + + + +

+ |o| cH(line=0) += (14,14) +

+

+ |o| cH(line=1) += (68,12) +

+

+ |o| cH(line=2) += (68,82) +

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

+ ...und das würde auch erklären, warum trotzdem die Zelle mit der Glühbirne (=die direkten Controls) überhaupt nicht aufgespreitzt wird +

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

+ ⟹ es muß das strukturell korrekte Maximum explizit berechnet werden; würden wir nur die rechte Spalte summieren, bliebe eine bereits bestehende Spreizung in der linken Spalte unberücksichtigt +

+ +
+ +
+ + + + + + +

+ ⟹ aber auch das umgekehrte Szenario muß berücksichtigt werden: falls die Gesamthöhe von der Summe in der rechten Spalte dominiert wird, genügt es nicht, blindlings nur eine eigentlich kleinere linke Strukturspalte mit dem Δ zu beaufschlagen +

+ +
+ +
+
+ + + + +
+ + + + + + + + + - + @@ -31617,6 +31751,7 @@ +