Inv(#1020): control extension of the scrollable area

this uncovers some possible problem in GTK (#1037)
This commit is contained in:
Fischlurch 2016-10-29 17:53:52 +02:00
parent 9397f064c7
commit 1b9a45930b
4 changed files with 42 additions and 10 deletions

View file

@ -113,7 +113,7 @@ namespace panel {
scroller_.set_border_width(10);
scroller_.add(canvas_);
canvas_.set_size(1000,500);
adjustToNecessaryCanvasSize();
// show everything....
this->add(twoParts_);
@ -133,6 +133,28 @@ 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);
}
// additional leeway for the scrollbars
sizeX += 10;
sizeY += 10;
canvas_.set_size (sizeX, sizeY);
}
void
TimelinePanel::experiment_1()
{
@ -144,6 +166,7 @@ namespace panel {
uint y = rand() % 500;
canvas_.put(*chld, x, y);
chld->show();
adjustToNecessaryCanvasSize();
}
@ -162,6 +185,7 @@ namespace panel {
canvas_.move (*chld, x,y);
}
adjustToNecessaryCanvasSize();
}
@ -178,6 +202,7 @@ namespace panel {
int width = chld->get_allocated_width();
pos += 0.6 * width;
}
adjustToNecessaryCanvasSize();
}

View file

@ -118,6 +118,8 @@ namespace panel {
using ChildV = std::vector<ChildEx*>;
ChildV childz_;
void adjustToNecessaryCanvasSize();
void experiment_1();
void experiment_2();
void experiment_3();

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="201610291403" tags="GuiPattern discuss decision impl" changecount="45">
<div title="GuiTimelineWidgetStructure" creator="Ichthyostega" modifier="Ichthyostega" created="201410250002" modified="201610291551" tags="GuiPattern discuss decision impl" changecount="48">
<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).
@ -2690,16 +2690,20 @@ In order to build a sensible plan for our timeline structure, we need to investi
!!!Observations
* children need to be made visible, otherwise they are added, but remain hidden
* the size of the scrollable area is independent of the actual size extension of the canvas
* the scrollable area determines when scrollbars are visible and what area can be reached through them
* but children can well be placed beyond; they are fully functional then, just covered and out of sight
* enlarging the enclosing window and thus enlarging the layout canvas will uncover such stray children.
* when in sight, children receive events and are fully functional, even when placed out of the scrollable area.
* the coordinate of children is their upper left corner, but they may extend beyond that and even beyond the scrollable area
* children may be so close to the boundary, that it is not possible to click on them
* when children close to the boundary receive an onClick event, the scrollable area might jumps back slightly..
;layering
:children added later are always on top.
;scrolling and size
:the {{{Gtk::Layout}}} widget has a canvas size, which is defined implicitly, by placing child elements
:* the size of the scrollable area is independent of the actual size extension of the canvas
:* the scrollable area determines when scrollbars are visible and what area can be reached through them
:* but children can well be placed beyond; they are fully functional then, just covered and out of sight
:* enlarging the enclosing window and thus enlarging the layout canvas will uncover such stray children.
:* //problematic//
:** children may be so close to the boundary, that it is not possible to click on them
:** when children close to the boundary receive an onClick event, the scrollable area might jump back slightly..
:** the management of visible viewport within {{{Gtk::ScrolledWindow}}} is not correct (see [[ticket #1037|http://issues.lumiera.org/ticket/1037]])&lt;br/&gt;it does not account properly for the area covered by the scrollbars themselves
;moving child widgets
:works as expected
;delete child widgets
@ -2707,7 +2711,7 @@ In order to build a sensible plan for our timeline structure, we need to investi
: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
://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
:* the interface {{{Gtk::Container}}} exposes a {{{get_children}}} function, but this returns a //copy// of the vector with pointers to all child widgets
</pre>

View file

@ -9386,9 +9386,10 @@
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
<icon BUILTIN="full-7"/>
</node>
<node CREATED="1477595418670" ID="ID_1516591439" MODIFIED="1477694985862" TEXT="# move and delete widgets">
<node CREATED="1477595418670" ID="ID_1516591439" MODIFIED="1477754020121" TEXT="# move and delete widgets">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
<icon BUILTIN="full-8"/>
<icon BUILTIN="button_ok"/>
<node CREATED="1477703725690" ID="ID_554135449" MODIFIED="1477703778772" TEXT="move">
<icon BUILTIN="button_ok"/>
<node CREATED="1477703730073" ID="ID_1070867956" MODIFIED="1477703771801" TEXT="foreach doesn&apos;t work">