X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flayout.cpp;h=5ebb55ccf4f8822de2423427d4c795c8d906ecf8;hb=fea22d7bdfae9e2cb70a6c0c1a3f85da531e2de2;hp=c616ff6fc7caff9833070cf1c30e7c7710e20ad9;hpb=8eeb6ee5d40c21150839e24996cc3e9ef308374d;p=libs%2Fgltk.git diff --git a/source/layout.cpp b/source/layout.cpp index c616ff6..5ebb55c 100644 --- a/source/layout.cpp +++ b/source/layout.cpp @@ -213,7 +213,7 @@ void Layout::update_slot_indices() n_active_slots = 0; for(list::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; @@ -295,6 +295,19 @@ void Layout::set_expand(Widget &wdg, bool h, bool v) 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); @@ -304,12 +317,13 @@ void Layout::update() (*i)->widget.set_geometry((*i)->geom); } -void Layout::autosize() +void Layout::autosize(Geometry &geom) { solve_constraints(HORIZONTAL, AUTOSIZE); solve_constraints(VERTICAL, AUTOSIZE); - container->set_size(autosize_geom.w, autosize_geom.h); + geom.w = max(geom.w, autosize_geom.w); + geom.h = max(geom.h, autosize_geom.h); } void Layout::solve_constraints(int dir, SolveMode mode) @@ -326,6 +340,7 @@ void Layout::solve_constraints(int dir, SolveMode mode) remaining three are slack columns; see below for their purposes. */ LinearProgram linprog(n_active_slots*5+n_slack_constraints[dir]+1); float weight = slots.size(); + unsigned k = n_active_slots*5; for(list::iterator i=slots.begin(); i!=slots.end(); ++i) { if((*i)->index<0) @@ -382,7 +397,6 @@ void Layout::solve_constraints(int dir, SolveMode mode) /* Add rows for user-defined constraints. Constraints are always added in pairs, so it's only necessary to create a row for one half. */ - unsigned k = n_active_slots*5; for(list::iterator j=(*i)->constraints.begin(); j!=(*i)->constraints.end(); ++j) if(j->target.index>(*i)->index && (j->type&1)==dir) { @@ -444,7 +458,8 @@ Layout::Packing::Packing(): 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)); @@ -458,7 +473,7 @@ void Layout::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. @@ -474,7 +489,7 @@ void Layout::Slot::autosize_changed() void Layout::Slot::visibility_changed(bool v) { layout.update_slot_indices(); - if(v) + if(v || ghost) { layout.container->signal_autosize_changed.emit(); layout.update(); @@ -530,6 +545,7 @@ Layout::WidgetLoader::WidgetLoader(Layout &l, Widget &w, const Layout::Loader::W { add("constraint", &WidgetLoader::constraint); add("expand", &WidgetLoader::expand); + add("ghost", &WidgetLoader::ghost); add("gravity", &WidgetLoader::gravity); } @@ -544,6 +560,11 @@ void Layout::WidgetLoader::expand(bool h, bool v) 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);