From e4bf84657cab95a7cd0659bf2c97ff865f89cd9f Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 29 Oct 2016 16:05:37 +0200 Subject: [PATCH] Inv(#1020): erase arbitrary child widgets --- src/gui/panel/timeline-panel.cpp | 26 +++++++++++++++++++++++--- src/gui/panel/timeline-panel.hpp | 4 +++- wiki/renderengine.html | 6 +++++- wiki/thinkPad.ichthyo.mm | 3 +++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/gui/panel/timeline-panel.cpp b/src/gui/panel/timeline-panel.cpp index 5695d6377..bda2b7aea 100644 --- a/src/gui/panel/timeline-panel.cpp +++ b/src/gui/panel/timeline-panel.cpp @@ -78,22 +78,29 @@ namespace panel { twoParts_.pack_start(buttons_, Gtk::PACK_SHRINK); twoParts_.pack_start(frame_); - buttons_.add(button_1_); - buttons_.add(button_2_); - buttons_.add(button_3_); buttons_.set_layout(Gtk::BUTTONBOX_START); + // buttons to trigger experiments button_1_.set_label("Experiment _1"); button_1_.signal_clicked().connect( mem_fun(*this, &TimelinePanel::experiment_1)); + buttons_.add(button_1_); button_2_.set_label("Experiment _2"); button_2_.signal_clicked().connect( mem_fun(*this, &TimelinePanel::experiment_2)); + buttons_.add(button_2_); button_3_.set_label("Experiment _3"); button_3_.signal_clicked().connect( mem_fun(*this, &TimelinePanel::experiment_3)); + buttons_.add(button_3_); + + button_4_.set_label("Experiment _4"); + button_4_.signal_clicked().connect( + mem_fun(*this, &TimelinePanel::experiment_4)); + buttons_.add(button_4_); + //(End)buttons... frame_.add(scroller_); frame_.set_border_width(5); @@ -170,6 +177,19 @@ namespace panel { } + void + TimelinePanel::experiment_4() + { + frame_.set_label("Experiment 4..."); + uint killPos = rand() % childz_.size(); + ChildV::iterator killThat(&childz_[killPos]); + ChildEx* victim = *killThat; + childz_.erase (killThat); + canvas_.remove (*victim); + delete victim; + } + + /* === Support for Investigation === */ namespace { diff --git a/src/gui/panel/timeline-panel.hpp b/src/gui/panel/timeline-panel.hpp index 46d93599b..6e33d8ba3 100644 --- a/src/gui/panel/timeline-panel.hpp +++ b/src/gui/panel/timeline-panel.hpp @@ -82,7 +82,7 @@ namespace panel { * 5. bind signals to those widgets, to verify event dispatching * 6. bind some further signal(s) to the ~GtkLayout container * 7. hide and re-show a partially and a totally overlapped widget - * 8. find a way to move a widget ✔ + * 8. find a way to move a widget ✔ and delete arbitrary widgets ✔ * 9. expand an existing widget (text change) * 10. build a custom "clip" widget * 11. retrofit all preceding tests to use this "clip" widget @@ -108,6 +108,7 @@ namespace panel { Gtk::Button button_1_; Gtk::Button button_2_; Gtk::Button button_3_; + Gtk::Button button_4_; Gtk::Frame frame_; Gtk::ScrolledWindow scroller_; Gtk::Layout canvas_; @@ -120,6 +121,7 @@ namespace panel { void experiment_1(); void experiment_2(); void experiment_3(); + void experiment_4(); }; diff --git a/wiki/renderengine.html b/wiki/renderengine.html index c678541ed..406696b00 100644 --- a/wiki/renderengine.html +++ b/wiki/renderengine.html @@ -2635,7 +2635,7 @@ In the most general case, there can be per-track content and nested content at t → 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).
 
@@ -2702,6 +2702,10 @@ In order to build a sensible plan for our timeline structure, we need to investi
 :children added later are always on top.
 ;moving child widgets
 :works as expected
+;delete child widgets
+:is possible by the {{{Container::remove(Widget*)}}} function
+:removed child widgets will also removed from display (hidden)
+:but the widget object needs to be deleted manually, because detached widgets are no longer managed by GTK
 ;iteration over child widgets
 :problematic
 :* the signal based {{{foreach}}} does not work -- there seems to be a problem with the slot's signature causing a wrong address to be passed in
diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm
index 56cad8456..1a33fe7d3 100644
--- a/wiki/thinkPad.ichthyo.mm
+++ b/wiki/thinkPad.ichthyo.mm
@@ -9401,6 +9401,9 @@
 
 
 
+
+
+