n_active_slots = 0;
for(list<Slot *>::iterator i=slots.begin(); i!=slots.end(); ++i)
{
- if((*i)->widget.is_visible())
+ if((*i)->widget.is_visible() || (*i)->ghost)
(*i)->index = n_active_slots++;
else
(*i)->index = -1;
update();
}
+void Layout::set_ghost(Widget &wdg, bool g)
+{
+ Slot &slot = get_slot_for_widget(wdg);
+
+ slot.ghost = g;
+
+ if(!wdg.is_visible())
+ {
+ update_slot_indices();
+ update();
+ }
+}
+
void Layout::update()
{
solve_constraints(HORIZONTAL, UPDATE);
Layout::Slot::Slot(Layout &l, Widget &w):
layout(l),
index(0),
- widget(w)
+ widget(w),
+ ghost(false)
{
vert_pack.gravity = 1;
widget.signal_autosize_changed.connect(sigc::mem_fun(this, &Slot::autosize_changed));
widget.autosize();
autosize_geom = widget.get_geometry();
- if(!widget.is_visible())
+ if(!widget.is_visible() && !ghost)
return;
// If the widget fits in the area it had, just leave it there.
void Layout::Slot::visibility_changed(bool v)
{
layout.update_slot_indices();
- if(v)
+ if(v || ghost)
{
layout.container->signal_autosize_changed.emit();
layout.update();
{
add("constraint", &WidgetLoader::constraint);
add("expand", &WidgetLoader::expand);
+ add("ghost", &WidgetLoader::ghost);
add("gravity", &WidgetLoader::gravity);
}
layout.set_expand(widget, h, v);
}
+void Layout::WidgetLoader::ghost(bool g)
+{
+ layout.set_ghost(widget, g);
+}
+
void Layout::WidgetLoader::gravity(int h, int v)
{
layout.set_gravity(widget, h, v);
private:
void constraint(ConstraintType, const std::string &);
void expand(bool, bool);
+ void ghost(bool);
void gravity(int, int);
};
std::list<Constraint> constraints;
Packing horiz_pack;
Packing vert_pack;
+ bool ghost;
Slot(Layout &, Widget &);
void set_gravity(Widget &, int, int);
void set_expand(Widget &, bool, bool);
+ /// Sets a widget as a ghost, taking up space even if it is hidden.
+ void set_ghost(Widget &, bool);
+
void update();
void autosize();
add("dropdown", &Loader::child<Dropdown>);
add("entry", &Loader::child<Entry>);
add("expand", &Loader::expand);
+ add("ghost", &Loader::ghost);
add("gravity", &Loader::gravity);
add("grid", &Loader::grid);
add("hslider", &Loader::child<HSlider>);
get_layout().set_expand(get_last_widget(), h, v);
}
+void Panel::Loader::ghost(bool g)
+{
+ get_layout().set_ghost(get_last_widget(), g);
+}
+
void Panel::Loader::gravity(int h, int v)
{
get_layout().set_gravity(get_last_widget(), h, v);