From 0a2f3ba395242d770c345d2614d23d2111a1f692 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 4 Oct 2022 00:51:05 +0200 Subject: [PATCH] ElementBox: further testing and investigation - Test the new layout code with debugger + dump messages - Experiment: live changes to the name-ID content (send msg. "manip" -> Text changed and Layout properly revalidated) --- src/stage/timeline/timeline-controller.cpp | 4 + src/stage/timeline/track-presenter.hpp | 13 +- src/stage/widget/element-box-widget.cpp | 16 +- src/stage/widget/element-box-widget.hpp | 2 + wiki/thinkPad.ichthyo.mm | 209 ++++++++++++++++----- 5 files changed, 189 insertions(+), 55 deletions(-) diff --git a/src/stage/timeline/timeline-controller.cpp b/src/stage/timeline/timeline-controller.cpp index 9ef76888a..d0d0e373e 100644 --- a/src/stage/timeline/timeline-controller.cpp +++ b/src/stage/timeline/timeline-controller.cpp @@ -110,6 +110,10 @@ namespace timeline { { this->fork_->attachElementBox(); } + if (mark.idi.getSym() == "manip" && this->fork_) + { + this->fork_->manipulateBox(); + } else // forward to default handler model::Controller::doMark (mark); } diff --git a/src/stage/timeline/track-presenter.hpp b/src/stage/timeline/track-presenter.hpp index 26769ac12..d04c6df25 100644 --- a/src/stage/timeline/track-presenter.hpp +++ b/src/stage/timeline/track-presenter.hpp @@ -96,6 +96,7 @@ #include "lib/util-coll.hpp" /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this #include "lib/format-cout.hpp" +#include "lib/test/test-helper.hpp" /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this #include "lib/nocopy.hpp" @@ -217,9 +218,11 @@ namespace timeline { /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this void injectDebugTrackLabels(); void attachElementBox(); + void manipulateBox(); /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this uString TODO_trackName_; + widget::ElementBoxWidget* theBox_{nullptr}; /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this protected: /* ==== Interface: LayoutElement ===== */ @@ -263,7 +266,7 @@ namespace timeline { { uint x = rand() % 200; uint y = 0; - widget::ElementBoxWidget* box = Gtk::manage ( + theBox_ = Gtk::manage ( new model::CanvasHooked{display_.hookedAt(x,y) , widget::Kind::MARK , widget::Type::LABEL @@ -276,6 +279,14 @@ namespace timeline { }) }); } + inline void + TrackPresenter::manipulateBox() + { + if (not theBox_) return; + string rands = lib::test::randStr(rand() % 40); + cout << _Fmt{"maniRandS(%d):%s"} % rands.length() % rands <setName (rands); + } /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this /** * @note we distinguish between the contents of our four nested child collections diff --git a/src/stage/widget/element-box-widget.cpp b/src/stage/widget/element-box-widget.cpp index 23fedae1b..7e5719391 100644 --- a/src/stage/widget/element-box-widget.cpp +++ b/src/stage/widget/element-box-widget.cpp @@ -199,6 +199,7 @@ namespace widget { IDLabel::setCaption(cuString& idCaption) { name_.set_text(idCaption); + show_all(); // cache required full display size (for size constrained layout) queryNaturalSize (*this, labelFullSize_); } @@ -225,6 +226,12 @@ namespace widget { } + void + ElementBoxWidget::setName (cuString& nameID) + { + label_.setCaption (nameID); + } + /** * Layout trend for ElementBoxWidget is nailed down (`final`) to "height-for-width". * The reason is, some of the use cases entail placing the element box onto a canvas @@ -382,12 +389,13 @@ namespace widget { * @param w additional width available * @param h vertical headroom available * @param reCheck function to update and verify success - * @return if additional content could successfully be expanded + * @return if hidden content could successfully be expanded */ template inline bool maybeShow(Gtk::Button& icon, int w, int h, FUN& reCheck) { + if (icon.is_visible()) return true; // nothing can be done here bool success{false}; if (w >= ICON_SIZ.width * HYSTERESIS and h >= ICON_SIZ.height) { @@ -452,9 +460,9 @@ namespace widget { {//reduce to comply int goal = currW - widthC; ASSERT (goal > 0); - if (goal -= reduce(name_, goal) <= 0) return; - if (goal -= reduce(menu_) <= 0) return; - if (goal -= reduce(icon_) <= 0) return; + if ((goal -= reduce(name_, goal)) <= 0) return; + if ((goal -= reduce(menu_) ) <= 0) return; + if ((goal -= reduce(icon_) ) <= 0) return; currW = queryNaturalWidth(*this); goal = currW - widthC; ENSURE (goal <= 0, "IDLabel layout management floundered. " diff --git a/src/stage/widget/element-box-widget.hpp b/src/stage/widget/element-box-widget.hpp index 157aa5bb4..cdcdebd72 100644 --- a/src/stage/widget/element-box-widget.hpp +++ b/src/stage/widget/element-box-widget.hpp @@ -168,6 +168,8 @@ namespace widget { // default copy acceptable + void setName(cuString&); + private:/* ===== Internals ===== */ Gtk::SizeRequestMode get_request_mode_vfunc() const final; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 162f9d4c5..3a74c54e8 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -18073,12 +18073,13 @@ - - - + + + + - - + + @@ -18360,8 +18361,9 @@

+
- + @@ -18375,7 +18377,7 @@ - + @@ -18409,8 +18411,8 @@ - - + + @@ -18605,18 +18607,18 @@ - - + + - + - + @@ -18629,6 +18631,9 @@ + + + @@ -18749,9 +18754,9 @@ - - - + + + @@ -19001,13 +19006,13 @@ - + - - + + @@ -19021,10 +19026,10 @@ - - + + - + @@ -19276,14 +19281,14 @@ - - - + + + - + - + @@ -19459,8 +19464,8 @@ - - + + @@ -19540,14 +19545,83 @@ - - + + - + + + + + + + +

+ Assignment-Operatoren binden weniger stark als Wertevergleiche, daher ist er immer nach dem ersten Reduktionsschritt ausgestiegen +

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

+ ...weil der Constraint ja gelockert sein könnte +

+ +
+ + + + + +

+ das heißt, wenn das Label schon eingeblendet ist, aber nun zusätzlicher Platz verfügbar wird; deshalb dürfen wir hier bei einem bereits eingeblendeten Label nicht pauschal aussteigen, sondern müssen jedesmal die ganze Prüfung machen +

+ +
+
+ + + + + + +

+ weil in dem Fall jedesmal das Label wieder ausgeblendet wird, und dazu insgesamt drei mal die requested_width ermittelt werden muß +

+ +
+
+ + + + + + +

+ ...unter der Annahme, daß das Kürzen ggfs.auch verlängern kann, und damit schon relativ nahe am verfügbaren Platz ist. Dann verhindert die Hysterese, daß nochmal geprüft wird +

+ +
+
+ + +
+ + +
@@ -19559,17 +19633,17 @@
- - + + - - - + + + @@ -19580,22 +19654,57 @@

- +
- - - - + + + + + - - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + +
    +
  • + Alle solchen UI-Aktionen kommen aus dem Event-Thread. +
  • +
  • + Jede Änderung der Visibility zieht eine resize-Kalkulation nach sich +
  • +
  • + dabei werden unsere Hooks aufgerufen, stellen die Änderung fest, und setzten ggfs. visible = false +
  • +
  • + Ergebnis: keinerlei sichtbarer Effekt (es sei denn, der Text wird tatsächlich angezeigt) +
  • +
+ +
+
@@ -19994,7 +20103,7 @@ - +