From 3f87ef43ecdefee398d4d54af53dd59cb4aee12e Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 7 Oct 2018 17:31:49 +0200 Subject: [PATCH] ...tidy.up: preserve the Gtk::Canvas experiment (see #1020) Turning this investigation experiment from 2016 into a stand-alone Gtk application. Using the research folder as final disposal site for now... --- research/gtk-canvas-experiment.cpp | 67 +++++++++++++----------------- research/gtk-canvas-experiment.hpp | 40 ++++-------------- research/gtk-canvas-main.cpp | 28 +++++++++++-- 3 files changed, 63 insertions(+), 72 deletions(-) diff --git a/research/gtk-canvas-experiment.cpp b/research/gtk-canvas-experiment.cpp index 272ffe9ef..af3132789 100644 --- a/research/gtk-canvas-experiment.cpp +++ b/research/gtk-canvas-experiment.cpp @@ -24,8 +24,8 @@ /** @file gtk-canvas-experiment.cpp ** Implementation of gtk canvas experiments. ** - ** @todo as of 10/2016 this is WIP-WIP-WIP : canvas widgets experiment - ** @todo as of 10/2018 we start to build a new timeline widget, connected to the UI-Bus + ** @remark as of 10/2018 we start to build a new timeline widget, + ** based on this technology demo. ** @see timeline-widget.hpp ** */ @@ -33,11 +33,10 @@ #include "gtk-canvas-experiment.hpp" -//#include "gui/workspace/workspace-window.hpp" #include "lib/format-string.hpp" #include "lib/format-cout.hpp" +#include "lib/util.hpp" -//#include "lib/util.hpp" #include #include #include @@ -45,9 +44,7 @@ using util::_Fmt; -//using std::shared_ptr; -//using std::weak_ptr; -//using util::contains; +using util::isnil; using Gtk::Widget; using sigc::mem_fun; using sigc::ptr_fun; @@ -56,12 +53,10 @@ using std::rand; using std::max; -namespace gui { -namespace panel { - +namespace demo { - TimelinePanel::TimelinePanel () + CanvasDemoPanel::CanvasDemoPanel () : Box{} , twoParts_(Gtk::ORIENTATION_VERTICAL) , buttons_() @@ -79,35 +74,35 @@ namespace panel { button_1_.set_use_underline(); button_1_.set_tooltip_markup("Experiment 1:\nplace new child widget\nat random position on the canvas"); button_1_.signal_clicked().connect( - mem_fun(*this, &TimelinePanel::experiment_1)); + mem_fun(*this, &CanvasDemoPanel::experiment_1)); buttons_.add(button_1_); button_2_.set_label("_move"); button_2_.set_use_underline(); button_2_.set_tooltip_markup("Experiment 2:\nmove all child widgets randomly"); button_2_.signal_clicked().connect( - mem_fun(*this, &TimelinePanel::experiment_2)); + mem_fun(*this, &CanvasDemoPanel::experiment_2)); buttons_.add(button_2_); button_3_.set_label("a_lign"); button_3_.set_use_underline(); button_3_.set_tooltip_markup("Experiment 3:\nalign all child widgets in a row\nwith silight random vertical offset"); button_3_.signal_clicked().connect( - mem_fun(*this, &TimelinePanel::experiment_3)); + mem_fun(*this, &CanvasDemoPanel::experiment_3)); buttons_.add(button_3_); button_4_.set_label("_grow"); button_4_.set_use_underline(); button_4_.set_tooltip_markup("Experiment 4:\nextend arbitrary child widget's text"); button_4_.signal_clicked().connect( - mem_fun(*this, &TimelinePanel::experiment_4)); + mem_fun(*this, &CanvasDemoPanel::experiment_4)); buttons_.add(button_4_); button_5_.set_label("_kill"); button_5_.set_use_underline(); button_5_.set_tooltip_markup("Experiment 5:\nkill arbitrary child widget"); button_5_.signal_clicked().connect( - mem_fun(*this, &TimelinePanel::experiment_5)); + mem_fun(*this, &CanvasDemoPanel::experiment_5)); buttons_.add(button_5_); toggleDraw_.set_label("draw"); @@ -121,7 +116,8 @@ namespace panel { frame_.add(scroller_); frame_.set_border_width(5); - scroller_.set_shadow_type(Gtk::SHADOW_NONE); + scroller_.set_shadow_type(Gtk::SHADOW_IN); + scroller_.property_expand() = true; // dynamically grab any available additional space scroller_.set_border_width(10); scroller_.add(canvas_); @@ -132,22 +128,9 @@ namespace panel { this->show_all(); } - const char* - TimelinePanel::getTitle() - { - return _("Timeline"); - } - - const gchar* - TimelinePanel::getStockID() - { - return "panel_timeline"; - } - - void - TimelinePanel::experiment_1() + CanvasDemoPanel::experiment_1() { frame_.set_label("Experiment 1... PLACE"); @@ -162,7 +145,7 @@ namespace panel { void - TimelinePanel::experiment_2() + CanvasDemoPanel::experiment_2() { frame_.set_label("Experiment 2... MOVE"); for (Widget* chld : childz_) @@ -181,7 +164,7 @@ namespace panel { void - TimelinePanel::experiment_3() + CanvasDemoPanel::experiment_3() { frame_.set_label("Experiment 3... ALIGN"); uint pos=0; @@ -198,9 +181,14 @@ namespace panel { void - TimelinePanel::experiment_4() + CanvasDemoPanel::experiment_4() { frame_.set_label("Experiment 4... GROW"); + if (isnil (childz_)) + { + ERROR (test, "need to fabricate more childz before you can grow 'em..."); + return; + } uint selector = rand() % childz_.size(); ChildEx& toGrow = *childz_[selector]; toGrow.set_label ("***"+toGrow.get_label()+"***"); @@ -208,9 +196,14 @@ namespace panel { void - TimelinePanel::experiment_5() + CanvasDemoPanel::experiment_5() { frame_.set_label("Experiment 5... KILL"); + if (isnil (childz_)) + { + WARN (test, "no children to kill. so sad."); + return; + } uint killPos = rand() % childz_.size(); ChildV::iterator killThat(&childz_[killPos]); ChildEx* victim = *killThat; @@ -339,7 +332,7 @@ namespace panel { ChildEx* - TimelinePanel::makeChld() + CanvasDemoPanel::makeChld() { return Gtk::manage(new ChildEx); } @@ -372,4 +365,4 @@ namespace panel { -}} // namespace gui::panel +} // namespace demo diff --git a/research/gtk-canvas-experiment.hpp b/research/gtk-canvas-experiment.hpp index 565ff6635..84a22509f 100644 --- a/research/gtk-canvas-experiment.hpp +++ b/research/gtk-canvas-experiment.hpp @@ -1,5 +1,5 @@ /* - GTK-CANVAS-EXPERIMENT.hpp - Explore capabilities of the GTK canvas widget + GTK-CANVAS-EXPERIMENT.hpp - Explore capabilities of the GTK canvas widget Copyright (C) Lumiera.org 2016, Hermann Vosseler @@ -23,20 +23,8 @@ /** @file gtk-canvas-experiment.hpp ** A custom widget using a canvas to draw and to place widgets. - ** - ** ## planned design 2/2017 - ** The architecture of the UI is in a state of transition right now, working towards the goal - ** of interconnected layers and an operative session and engine. Within the new control structure - ** about to be built, there is an UI top-level circle of managing entities to handle global concerns - ** and actions. The ctrl::InteractionDirector incorporates the role of _model root_ and thus manages - ** a collection of timelines. The timeline panel exposes this collection and allows to view and - ** interact with one of the given timelines. The build-up of the timeline display and thus the - ** initiative to expose a timeline comes from the interaction director -- but as usual with - ** graphical user interfaces, any user interaction after this point is handled autonomously - ** by the gui::timeline::TimelineWidget and gui::timeline::TimelineController - ** - ** @todo as of 10/2016 this is WIP-WIP-WIP : canvas widgets experiment - ** @todo as of 10/2018 we start to build a new timeline widget, connected to the UI-Bus + ** @remark as of 10/2018 we start to build a new timeline widget, + ** based on this technology demo. */ @@ -45,18 +33,11 @@ #include "gui/gtk-base.hpp" -//#include #include - -namespace gui { -namespace model{ - class Sequence; - } -namespace panel { +namespace demo { -//using std::shared_ptr; /** * "experimental" child widget for investigation of Gtk::Layout @@ -117,10 +98,10 @@ namespace panel { * 7. hide and re-show a partially and a totally overlapped 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 + * 10. build a custom "clip" widget ✘ + * 11. retrofit all preceding tests to use this "clip" widget ✘ */ - class TimelinePanel + class CanvasDemoPanel : public Gtk::Box { public: @@ -128,12 +109,9 @@ namespace panel { * @param panel_manager The owner panel manager widget. * @param dock_item The GdlDockItem that will host this panel. */ - TimelinePanel(); + CanvasDemoPanel(); - static const char* getTitle(); - static const gchar* getStockID(); - private: Gtk::Box twoParts_; @@ -161,5 +139,5 @@ namespace panel { }; -}}// namespace gui::panel +}// namespace demo #endif /*RESEARCH_GTK_CANVAS_EXPERIMENT_H*/ diff --git a/research/gtk-canvas-main.cpp b/research/gtk-canvas-main.cpp index db0dce685..e949c675e 100644 --- a/research/gtk-canvas-main.cpp +++ b/research/gtk-canvas-main.cpp @@ -22,6 +22,10 @@ /** @file gtk-canvas-main.cpp ** Simple GTK Application frame to explore canvas handling. + ** This demo application was extracted in 10/2018 to preserve + ** [exploration experiments](\ref demo::CanvasDemoPanel), carried + ** out in 2016 to decide upon the technology to support Lumiera's + ** gui::timeline::TimelineWidget. */ @@ -30,15 +34,31 @@ #include "lib/error.hpp" -namespace { -} +namespace demo { + + class Window + : public Gtk::Window + { + CanvasDemoPanel demoPanel_; + + public: + Window() + : demoPanel_{} + { + this->add (demoPanel_); + } + }; +}//namespace int -main (int argc, const char* argv[]) +main (int argc, char* argv[]) { NOTICE (main, "*** GTK-Canvas Experiment ***"); - return 0; + auto guiApp = Gtk::Application::create (argc, argv); + + demo::Window window; + return guiApp->run(window); }