diff --git a/src/gui/panel/timeline-panel.cpp b/src/gui/panel/timeline-panel.cpp index fd9a90305..9e097b8a0 100644 --- a/src/gui/panel/timeline-panel.cpp +++ b/src/gui/panel/timeline-panel.cpp @@ -128,7 +128,7 @@ namespace panel { scroller_.set_border_width(10); scroller_.add(canvas_); - adjustToNecessaryCanvasSize(); + canvas_.adjustSize(); // show everything.... this->add(twoParts_); @@ -148,24 +148,6 @@ namespace panel { } - void - TimelinePanel::adjustToNecessaryCanvasSize() - { - uint sizeX = 10; - uint sizeY = 10; - for (Widget* chld : childz_) - { - uint x = canvas_.child_property_x(*chld); - uint y = canvas_.child_property_y(*chld); - x += chld->get_allocated_width(); - y += chld->get_allocated_height(); - sizeX = max (sizeX, x); - sizeY = max (sizeY, y); - } - - canvas_.set_size (sizeX, sizeY); - } - void TimelinePanel::experiment_1() @@ -178,7 +160,7 @@ namespace panel { uint y = rand() % 500; canvas_.put(*chld, x, y); chld->show(); - adjustToNecessaryCanvasSize(); + canvas_.adjustSize(); } @@ -197,7 +179,7 @@ namespace panel { canvas_.move (*chld, x,y); } - adjustToNecessaryCanvasSize(); + canvas_.adjustSize(); } @@ -214,7 +196,7 @@ namespace panel { int width = chld->get_allocated_width(); pos += 0.6 * width; } - adjustToNecessaryCanvasSize(); + canvas_.adjustSize(); } @@ -258,10 +240,42 @@ namespace panel { } + + void + Canvas::adjustSize() + { + recalcExtension_ = true; + } + + void + Canvas::determineExtension() + { + if (not recalcExtension_) return; + + uint extH=20, extV=20; + Gtk::Container::ForeachSlot callback + = [&](Gtk::Widget& chld) + { + cout << "hoya "< const& cox) { @@ -269,8 +283,8 @@ namespace panel { { int h = get_allocation().get_width(); int v = get_allocation().get_height(); - - uint extH, extV; + uint extH=20, extV=20; + determineExtension(); get_size (extH, extV); auto adjH = get_hadjustment(); @@ -295,8 +309,10 @@ namespace panel { cox->stroke(); cox->restore(); + // cause child widgets to be redrawn Gtk::Layout::on_draw(cox); + // any drawing which follows happens on top of child widgets... cox->save(); cox->translate(-offH, -offV); diff --git a/src/gui/panel/timeline-panel.hpp b/src/gui/panel/timeline-panel.hpp index ac3c1a731..3e1b38e6b 100644 --- a/src/gui/panel/timeline-panel.hpp +++ b/src/gui/panel/timeline-panel.hpp @@ -75,12 +75,16 @@ namespace panel { : public Gtk::Layout { bool shallDraw_; + bool recalcExtension_ = false; public: void enableDraw (bool); + void adjustSize(); private: virtual bool on_draw (Cairo::RefPtr const&) override; + + void determineExtension(); }; @@ -138,8 +142,6 @@ namespace panel { using ChildV = std::vector; ChildV childz_; - void adjustToNecessaryCanvasSize(); - void experiment_1(); void experiment_2(); void experiment_3(); diff --git a/wiki/renderengine.html b/wiki/renderengine.html index 380857fb2..f14b614cc 100644 --- a/wiki/renderengine.html +++ b/wiki/renderengine.html @@ -2411,7 +2411,7 @@ Typically, when starting the draw operation, we retrieve our //allocation.// Thi Thus, if we want to use absolute canvas coordinates for our drawing, we need to adjust the cairo context prior to any drawing operations: we translate it in the opposite direction of the values retrieved from the scrollbar {{{Gtk::Adjustment}}}s. This causes the //user coordinates// to coincede with the absolute canvas coordinates. -
+
//This is the canvas widget of ~GTK-3//
 It allows not only custom drawing, but also to embed other widgets at defined coordinates.
 
@@ -2425,9 +2425,9 @@ In order to build a sensible plan for our timeline structure, we need to investi
 
 !test setup
 we need a test setup for this investigation.
- * easy to launch
- * don't waste much time, it is disposable
- * realistic: shall reflect the situation in our actual UI
+* easy to launch
+* don't waste much time, it is disposable
+* realistic: shall reflect the situation in our actual UI
 
@@ -2648,7 +2648,7 @@ In the most general case, there can be per-track content and nested content at t &rarr; important question: how to [[organise the widgets|GuiTimelineWidgetStructure]]
-
+
The Timeline is probably the most prominent place in the GUI where we need to come up with a custom UI design.
 Instead of combining standard components in one of the well-known ways, here we need to come up with our own handling solution -- which also means to write one or several custom GTK widgets. Thus the question of layout and screen space division and organisation becomes a crucial design decision. The ~GTK-2 Gui, as implemented currently, did already take some steps along this route, yet this kind of decision should be cast and documented explicitly (be it after the fact).
 
@@ -2736,6 +2736,28 @@ In order to build a sensible plan for our timeline structure, we need to investi
 :** when invoked //after// our custom drawing, the embedded widgets stay on top
 :* the {{{Gtk::Allocation}}} is precisely the visible screen area reserved for the widget.<br/>It is //not// the extension of the virtual canvas.
 :* ...consequently, if our drawing shall be stitched to the canvas, we need to care for translation and for clipping ourselves. &rarr; see [[here|GtkCustomDrawing]]
+;determine canvas extension
+:when the extension of the (virtual) canvas area depends on position and size of child widgets, //we need to calculate this extension manually.//
+:* beware: the allocation for child widgets is not setup immediately, when adding or moving children
+:* rather, we need to wait until in the {{{on_draw()}}} callback for the {{{Gtk::Layout}}}
+:* at this point, we may use the //foreach// mechanism of the container
+{{{
+      uint extH=20, extV=20;
+      Gtk::Container::ForeachSlot callback
+        = [&](Gtk::Widget& chld)
+                {
+                  cout << "hoya "<<chld;
+                  auto allo = chld.get_allocation();
+                  uint x = allo.get_x();
+                  uint y = allo.get_y();
+                  x += allo.get_width();
+                  y += allo.get_height();
+                  extH = max (extH, x);
+                  extV = max (extV, y);
+                };
+      foreach(callback);
+      set_size (extH, extV);
+}}}
 
diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 7c66f6706..56479b5b9 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -57,8 +57,7 @@ und welchen Teil des Verhaltens überlassen wir GTK

- - + @@ -119,8 +118,7 @@ mehr als ein top-level Fenster offen

- - +
@@ -142,8 +140,7 @@ which reference actions from one or more action groups.

- - +
@@ -162,8 +159,7 @@ realisiert Vererbung zu fuß

- - + @@ -182,8 +178,7 @@ AUA!

- -
+
@@ -227,8 +222,7 @@ auch nicht im Application-Shutdown!

- - +
@@ -243,8 +237,7 @@ dock_.add_item(timelinePanel->getDockItem(),Gdl::DOCK_BOTTOM);

- -
+
@@ -260,8 +253,7 @@ Helper to build the menu and for registering and handling of user action events

- - + @@ -287,8 +279,7 @@ aber es kann davon mehrere geben

- - +
@@ -9277,8 +9268,7 @@ ...nicht mehr das klassische gtk::Main

- - + @@ -9314,8 +9304,7 @@ Siehe Beschreibung im Beispiel/Tutorial

- - +
@@ -9337,8 +9326,7 @@ und auch ein Signal für Parse-Fehler anschließt

- - + @@ -9434,12 +9422,11 @@ i.e. the enclosing parent widget also gets a chance to redraw itself

- - + - - + + @@ -9450,8 +9437,7 @@ Warning: allocation is the visible area

- -
+
@@ -9486,8 +9472,7 @@ by printing values from the on_draw() callback

- - +
@@ -9506,8 +9491,7 @@ causing us to adjust too much

- - +
@@ -9515,6 +9499,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ ...die anderen, die noch in Frage kommen würden, +

+

+ sind nur für den Fall, daß ein Widget neu instantiiert wird +

+

+ oder neu in das Window-System gemappt wird. +

+

+ +

+ + +
+
+ + + + + + +

+ on_check_resize() wird nicht aufgerufen +

+ + +
+ +
+
+ + + +