...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...
This commit is contained in:
parent
76dd4fb5dc
commit
3f87ef43ec
3 changed files with 63 additions and 72 deletions
|
|
@ -24,8 +24,8 @@
|
||||||
/** @file gtk-canvas-experiment.cpp
|
/** @file gtk-canvas-experiment.cpp
|
||||||
** Implementation of gtk canvas experiments.
|
** Implementation of gtk canvas experiments.
|
||||||
**
|
**
|
||||||
** @todo as of 10/2016 this is WIP-WIP-WIP : canvas widgets experiment
|
** @remark as of 10/2018 we start to build a new timeline widget,
|
||||||
** @todo as of 10/2018 we start to build a new timeline widget, connected to the UI-Bus
|
** based on this technology demo.
|
||||||
** @see timeline-widget.hpp
|
** @see timeline-widget.hpp
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,11 +33,10 @@
|
||||||
|
|
||||||
#include "gtk-canvas-experiment.hpp"
|
#include "gtk-canvas-experiment.hpp"
|
||||||
|
|
||||||
//#include "gui/workspace/workspace-window.hpp"
|
|
||||||
#include "lib/format-string.hpp"
|
#include "lib/format-string.hpp"
|
||||||
#include "lib/format-cout.hpp"
|
#include "lib/format-cout.hpp"
|
||||||
|
#include "lib/util.hpp"
|
||||||
|
|
||||||
//#include "lib/util.hpp"
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -45,9 +44,7 @@
|
||||||
|
|
||||||
|
|
||||||
using util::_Fmt;
|
using util::_Fmt;
|
||||||
//using std::shared_ptr;
|
using util::isnil;
|
||||||
//using std::weak_ptr;
|
|
||||||
//using util::contains;
|
|
||||||
using Gtk::Widget;
|
using Gtk::Widget;
|
||||||
using sigc::mem_fun;
|
using sigc::mem_fun;
|
||||||
using sigc::ptr_fun;
|
using sigc::ptr_fun;
|
||||||
|
|
@ -56,12 +53,10 @@ using std::rand;
|
||||||
using std::max;
|
using std::max;
|
||||||
|
|
||||||
|
|
||||||
namespace gui {
|
namespace demo {
|
||||||
namespace panel {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TimelinePanel::TimelinePanel ()
|
CanvasDemoPanel::CanvasDemoPanel ()
|
||||||
: Box{}
|
: Box{}
|
||||||
, twoParts_(Gtk::ORIENTATION_VERTICAL)
|
, twoParts_(Gtk::ORIENTATION_VERTICAL)
|
||||||
, buttons_()
|
, buttons_()
|
||||||
|
|
@ -79,35 +74,35 @@ namespace panel {
|
||||||
button_1_.set_use_underline();
|
button_1_.set_use_underline();
|
||||||
button_1_.set_tooltip_markup("<b>Experiment 1</b>:\nplace new child widget\nat random position on the canvas");
|
button_1_.set_tooltip_markup("<b>Experiment 1</b>:\nplace new child widget\nat random position on the canvas");
|
||||||
button_1_.signal_clicked().connect(
|
button_1_.signal_clicked().connect(
|
||||||
mem_fun(*this, &TimelinePanel::experiment_1));
|
mem_fun(*this, &CanvasDemoPanel::experiment_1));
|
||||||
buttons_.add(button_1_);
|
buttons_.add(button_1_);
|
||||||
|
|
||||||
button_2_.set_label("_move");
|
button_2_.set_label("_move");
|
||||||
button_2_.set_use_underline();
|
button_2_.set_use_underline();
|
||||||
button_2_.set_tooltip_markup("<b>Experiment 2</b>:\nmove all child widgets randomly");
|
button_2_.set_tooltip_markup("<b>Experiment 2</b>:\nmove all child widgets randomly");
|
||||||
button_2_.signal_clicked().connect(
|
button_2_.signal_clicked().connect(
|
||||||
mem_fun(*this, &TimelinePanel::experiment_2));
|
mem_fun(*this, &CanvasDemoPanel::experiment_2));
|
||||||
buttons_.add(button_2_);
|
buttons_.add(button_2_);
|
||||||
|
|
||||||
button_3_.set_label("a_lign");
|
button_3_.set_label("a_lign");
|
||||||
button_3_.set_use_underline();
|
button_3_.set_use_underline();
|
||||||
button_3_.set_tooltip_markup("<b>Experiment 3</b>:\nalign all child widgets in a row\nwith silight random vertical offset");
|
button_3_.set_tooltip_markup("<b>Experiment 3</b>:\nalign all child widgets in a row\nwith silight random vertical offset");
|
||||||
button_3_.signal_clicked().connect(
|
button_3_.signal_clicked().connect(
|
||||||
mem_fun(*this, &TimelinePanel::experiment_3));
|
mem_fun(*this, &CanvasDemoPanel::experiment_3));
|
||||||
buttons_.add(button_3_);
|
buttons_.add(button_3_);
|
||||||
|
|
||||||
button_4_.set_label("_grow");
|
button_4_.set_label("_grow");
|
||||||
button_4_.set_use_underline();
|
button_4_.set_use_underline();
|
||||||
button_4_.set_tooltip_markup("<b>Experiment 4</b>:\nextend arbitrary child widget's text");
|
button_4_.set_tooltip_markup("<b>Experiment 4</b>:\nextend arbitrary child widget's text");
|
||||||
button_4_.signal_clicked().connect(
|
button_4_.signal_clicked().connect(
|
||||||
mem_fun(*this, &TimelinePanel::experiment_4));
|
mem_fun(*this, &CanvasDemoPanel::experiment_4));
|
||||||
buttons_.add(button_4_);
|
buttons_.add(button_4_);
|
||||||
|
|
||||||
button_5_.set_label("_kill");
|
button_5_.set_label("_kill");
|
||||||
button_5_.set_use_underline();
|
button_5_.set_use_underline();
|
||||||
button_5_.set_tooltip_markup("<b>Experiment 5</b>:\nkill arbitrary child widget");
|
button_5_.set_tooltip_markup("<b>Experiment 5</b>:\nkill arbitrary child widget");
|
||||||
button_5_.signal_clicked().connect(
|
button_5_.signal_clicked().connect(
|
||||||
mem_fun(*this, &TimelinePanel::experiment_5));
|
mem_fun(*this, &CanvasDemoPanel::experiment_5));
|
||||||
buttons_.add(button_5_);
|
buttons_.add(button_5_);
|
||||||
|
|
||||||
toggleDraw_.set_label("draw");
|
toggleDraw_.set_label("draw");
|
||||||
|
|
@ -121,7 +116,8 @@ namespace panel {
|
||||||
frame_.add(scroller_);
|
frame_.add(scroller_);
|
||||||
frame_.set_border_width(5);
|
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_.set_border_width(10);
|
||||||
scroller_.add(canvas_);
|
scroller_.add(canvas_);
|
||||||
|
|
||||||
|
|
@ -132,22 +128,9 @@ namespace panel {
|
||||||
this->show_all();
|
this->show_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
|
||||||
TimelinePanel::getTitle()
|
|
||||||
{
|
|
||||||
return _("Timeline");
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar*
|
|
||||||
TimelinePanel::getStockID()
|
|
||||||
{
|
|
||||||
return "panel_timeline";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelinePanel::experiment_1()
|
CanvasDemoPanel::experiment_1()
|
||||||
{
|
{
|
||||||
frame_.set_label("Experiment 1... PLACE");
|
frame_.set_label("Experiment 1... PLACE");
|
||||||
|
|
||||||
|
|
@ -162,7 +145,7 @@ namespace panel {
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelinePanel::experiment_2()
|
CanvasDemoPanel::experiment_2()
|
||||||
{
|
{
|
||||||
frame_.set_label("Experiment 2... MOVE");
|
frame_.set_label("Experiment 2... MOVE");
|
||||||
for (Widget* chld : childz_)
|
for (Widget* chld : childz_)
|
||||||
|
|
@ -181,7 +164,7 @@ namespace panel {
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelinePanel::experiment_3()
|
CanvasDemoPanel::experiment_3()
|
||||||
{
|
{
|
||||||
frame_.set_label("Experiment 3... ALIGN");
|
frame_.set_label("Experiment 3... ALIGN");
|
||||||
uint pos=0;
|
uint pos=0;
|
||||||
|
|
@ -198,9 +181,14 @@ namespace panel {
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelinePanel::experiment_4()
|
CanvasDemoPanel::experiment_4()
|
||||||
{
|
{
|
||||||
frame_.set_label("Experiment 4... GROW");
|
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();
|
uint selector = rand() % childz_.size();
|
||||||
ChildEx& toGrow = *childz_[selector];
|
ChildEx& toGrow = *childz_[selector];
|
||||||
toGrow.set_label ("***"+toGrow.get_label()+"***");
|
toGrow.set_label ("***"+toGrow.get_label()+"***");
|
||||||
|
|
@ -208,9 +196,14 @@ namespace panel {
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelinePanel::experiment_5()
|
CanvasDemoPanel::experiment_5()
|
||||||
{
|
{
|
||||||
frame_.set_label("Experiment 5... KILL");
|
frame_.set_label("Experiment 5... KILL");
|
||||||
|
if (isnil (childz_))
|
||||||
|
{
|
||||||
|
WARN (test, "no children to kill. so sad.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
uint killPos = rand() % childz_.size();
|
uint killPos = rand() % childz_.size();
|
||||||
ChildV::iterator killThat(&childz_[killPos]);
|
ChildV::iterator killThat(&childz_[killPos]);
|
||||||
ChildEx* victim = *killThat;
|
ChildEx* victim = *killThat;
|
||||||
|
|
@ -339,7 +332,7 @@ namespace panel {
|
||||||
|
|
||||||
|
|
||||||
ChildEx*
|
ChildEx*
|
||||||
TimelinePanel::makeChld()
|
CanvasDemoPanel::makeChld()
|
||||||
{
|
{
|
||||||
return Gtk::manage(new ChildEx);
|
return Gtk::manage(new ChildEx);
|
||||||
}
|
}
|
||||||
|
|
@ -372,4 +365,4 @@ namespace panel {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}} // namespace gui::panel
|
} // namespace demo
|
||||||
|
|
|
||||||
|
|
@ -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
|
Copyright (C) Lumiera.org
|
||||||
2016, Hermann Vosseler <Ichthyostega@web.de>
|
2016, Hermann Vosseler <Ichthyostega@web.de>
|
||||||
|
|
@ -23,20 +23,8 @@
|
||||||
|
|
||||||
/** @file gtk-canvas-experiment.hpp
|
/** @file gtk-canvas-experiment.hpp
|
||||||
** A custom widget using a canvas to draw and to place widgets.
|
** A custom widget using a canvas to draw and to place widgets.
|
||||||
**
|
** @remark as of 10/2018 we start to build a new timeline widget,
|
||||||
** ## planned design 2/2017
|
** based on this technology demo.
|
||||||
** 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
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -45,18 +33,11 @@
|
||||||
|
|
||||||
#include "gui/gtk-base.hpp"
|
#include "gui/gtk-base.hpp"
|
||||||
|
|
||||||
//#include <memory>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
namespace demo {
|
||||||
namespace gui {
|
|
||||||
namespace model{
|
|
||||||
class Sequence;
|
|
||||||
}
|
|
||||||
namespace panel {
|
|
||||||
|
|
||||||
//using std::shared_ptr;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "experimental" child widget for investigation of Gtk::Layout
|
* "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
|
* 7. hide and re-show a partially and a totally overlapped widget
|
||||||
* 8. find a way to move a widget ✔ and delete arbitrary widgets ✔
|
* 8. find a way to move a widget ✔ and delete arbitrary widgets ✔
|
||||||
* 9. expand an existing widget (text change) ✔
|
* 9. expand an existing widget (text change) ✔
|
||||||
* 10. build a custom "clip" widget
|
* 10. build a custom "clip" widget ✘
|
||||||
* 11. retrofit all preceding tests to use this "clip" widget
|
* 11. retrofit all preceding tests to use this "clip" widget ✘
|
||||||
*/
|
*/
|
||||||
class TimelinePanel
|
class CanvasDemoPanel
|
||||||
: public Gtk::Box
|
: public Gtk::Box
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -128,12 +109,9 @@ namespace panel {
|
||||||
* @param panel_manager The owner panel manager widget.
|
* @param panel_manager The owner panel manager widget.
|
||||||
* @param dock_item The GdlDockItem that will host this panel.
|
* @param dock_item The GdlDockItem that will host this panel.
|
||||||
*/
|
*/
|
||||||
TimelinePanel();
|
CanvasDemoPanel();
|
||||||
|
|
||||||
|
|
||||||
static const char* getTitle();
|
|
||||||
static const gchar* getStockID();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Gtk::Box twoParts_;
|
Gtk::Box twoParts_;
|
||||||
|
|
@ -161,5 +139,5 @@ namespace panel {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}}// namespace gui::panel
|
}// namespace demo
|
||||||
#endif /*RESEARCH_GTK_CANVAS_EXPERIMENT_H*/
|
#endif /*RESEARCH_GTK_CANVAS_EXPERIMENT_H*/
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
/** @file gtk-canvas-main.cpp
|
/** @file gtk-canvas-main.cpp
|
||||||
** Simple GTK Application frame to explore canvas handling.
|
** 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"
|
#include "lib/error.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace demo {
|
||||||
}
|
|
||||||
|
class Window
|
||||||
|
: public Gtk::Window
|
||||||
|
{
|
||||||
|
CanvasDemoPanel demoPanel_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Window()
|
||||||
|
: demoPanel_{}
|
||||||
|
{
|
||||||
|
this->add (demoPanel_);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}//namespace
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, const char* argv[])
|
main (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
NOTICE (main, "*** GTK-Canvas Experiment ***");
|
NOTICE (main, "*** GTK-Canvas Experiment ***");
|
||||||
|
|
||||||
return 0;
|
auto guiApp = Gtk::Application::create (argc, argv);
|
||||||
|
|
||||||
|
demo::Window window;
|
||||||
|
return guiApp->run(window);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue