Inv(#1020): place widgets on canvas

- randomly
- partially overlapping
- event dispatch works as expected
This commit is contained in:
Fischlurch 2016-10-28 17:32:43 +02:00
parent 5897d1ffad
commit e7d284783b
4 changed files with 44 additions and 9 deletions

View file

@ -40,6 +40,7 @@
#include "lib/format-cout.hpp"
//#include "lib/util.hpp"
#include <cstdlib>
@ -50,6 +51,7 @@ using util::_Fmt;
using sigc::mem_fun;
using std::cout;
using std::endl;
using std::rand;
namespace gui {
@ -66,6 +68,7 @@ namespace panel {
, button_2_()
, frame_("Gtk::Layout Experiments")
, scroller_()
, canvas_()
{
twoParts_.pack_start(buttons_, Gtk::PACK_SHRINK);
twoParts_.pack_start(frame_);
@ -87,10 +90,11 @@ namespace panel {
scroller_.set_shadow_type(Gtk::SHADOW_NONE);
scroller_.set_border_width(10);
scroller_.add(canvas_);
chldEx_ = Gtk::manage(new ChildEx);
scroller_.add(*chldEx_);
canvas_.set_size(1000,500);
// show everything....
this->add(twoParts_);
this->show_all();
}
@ -112,6 +116,13 @@ namespace panel {
TimelinePanel::experiment_1()
{
frame_.set_label("Experiment 1...");
ChildEx* chld = makeChld();
childz_.push_back(chld);
uint x = rand() % 1000;
uint y = rand() % 500;
canvas_.put(*chld, x, y);
chld->show();
}
@ -145,12 +156,19 @@ namespace panel {
}
ChildEx*
TimelinePanel::makeChld()
{
return Gtk::manage(new ChildEx);
}
////////////////////////////////////////////////////////////////////TICKET #1020 : verification code for instance management
ChildEx::~ChildEx()
{
--instanceCnt;
if (instanceCnt > 0)
cout << " 💀 still "<<instanceCnt<<" children to kill...";
cout << " ↯↯ still "<<instanceCnt<<" children to kill..."<<endl;
else
if (instanceCnt == 0)
cout << "+++ Success: all children are dead..."<<endl;

View file

@ -35,6 +35,7 @@
#include "gui/panel/panel.hpp"
//#include <memory>
#include <vector>
@ -42,7 +43,7 @@ namespace gui {
namespace model{
class Sequence;
}
namespace panel {
namespace panel {
//using std::shared_ptr;
@ -74,7 +75,7 @@ namespace model{
* As of 10/2016, we start this task with an exploration of GTK behaviour
*
* \par Plan of investigation
* 1. place some simple widgets (Buttons)
* 1. place some simple widgets (Buttons)
* 2. learn how to draw
* 3. place a huge number of widgets, to scrutinise scrolling and performance
* 4. place widgets overlapping
@ -108,8 +109,12 @@ namespace model{
Gtk::Button button_2_;
Gtk::Frame frame_;
Gtk::ScrolledWindow scroller_;
Gtk::Layout canvas_;
ChildEx* chldEx_;
ChildEx* makeChld();
using ChildV = std::vector<ChildEx*>;
ChildV childz_;
void experiment_1();
void experiment_2();

View file

@ -2635,7 +2635,7 @@ In the most general case, there can be per-track content and nested content at t
&amp;rarr; important question: how to [[organise the widgets|GuiTimelineWidgetStructure]]
</pre>
</div>
<div title="GuiTimelineWidgetStructure" creator="Ichthyostega" modifier="Ichthyostega" created="201410250002" modified="201610271909" tags="GuiPattern discuss decision impl" changecount="36">
<div title="GuiTimelineWidgetStructure" creator="Ichthyostega" modifier="Ichthyostega" created="201410250002" modified="201610281529" tags="GuiPattern discuss decision impl" changecount="37">
<pre>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).
@ -2689,6 +2689,13 @@ In order to build a sensible plan for our timeline structure, we need to investi
# retrofit all preceding tests to use this &quot;''clip''&quot; widget
!!!Observations
* the size of the scrollable area needs to be setup beforehand, otherwise children won't show up
* children need to be made visible, otherwise they are added, but remain hidden
* the coordinate of children (upper left corner) is within the scrollable area, but the extension might well be beyond
* children may be so close to the boundary, that it is not possible to click on them
* after receiving an onClic event, the scrollable area jumps back to (left, top).
* when overall window is enlarged, the visible area seems to be expanded. Then even children close to boundary come into sight and are clickable.
</pre>
</div>
<div title="HighLevelModel" modifier="Ichthyostega" created="200808152311" modified="201505310109" tags="Model spec design discuss img" changecount="2">

View file

@ -9345,9 +9345,10 @@
<node CREATED="1476468292805" ID="ID_472068538" MODIFIED="1476468383131" TEXT="custom drawing and widget drawing"/>
</node>
<node CREATED="1477595408918" ID="ID_387371672" MODIFIED="1477595438110" TEXT="Tasks">
<node CREATED="1477595418669" ID="ID_1316314985" MODIFIED="1477596119220" TEXT="# place some simple widgets (Buttons)">
<node CREATED="1477595418669" FOLDED="true" ID="ID_1316314985" MODIFIED="1477668302459" TEXT="# place some simple widgets (Buttons)">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
<icon BUILTIN="full-1"/>
<icon BUILTIN="button_ok"/>
<node CREATED="1477601706168" ID="ID_130395672" MODIFIED="1477601711906" TEXT="Kind-Klasse anlegen"/>
<node CREATED="1477601712063" ID="ID_1720776876" MODIFIED="1477601717354" TEXT="Kinder managen"/>
</node>
@ -9359,9 +9360,13 @@
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
<icon BUILTIN="full-3"/>
</node>
<node CREATED="1477595418670" ID="ID_423514526" MODIFIED="1477596119220" TEXT="# place widgets overlapping">
<node CREATED="1477595418670" ID="ID_423514526" MODIFIED="1477668704361" TEXT="# place widgets overlapping / irregularily">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
<icon BUILTIN="full-4"/>
<node CREATED="1477668663507" ID="ID_1576657272" MODIFIED="1477668671481" TEXT="order: later on top">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1477668674577" ID="ID_431152757" MODIFIED="1477668679556" TEXT="place widgets out of sight"/>
</node>
<node CREATED="1477595418670" ID="ID_1370967982" MODIFIED="1477596119220" TEXT="# bind signals to those widgets, to verify event dispatching">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>