void Arrangement::add_constraint(Widget &wdg, Layout::ConstraintType type, const Edge &edge)
{
for(list<Widget *>::const_iterator i=edge.widgets.begin(); i!=edge.widgets.end(); ++i)
- layout.add_constraint(wdg, type, **i);
+ if(*i!=&wdg)
+ layout.add_constraint(wdg, type, **i);
}
Layout::ConstraintType Arrangement::get_order_constraint(Side s, bool slack)
aligned = algn;
}
+void Arrangement::Edge::align()
+{
+ if(aligned || widgets.empty())
+ return;
+
+ list<Widget *>::iterator second = widgets.begin();
+ ++second;
+
+ widgets.erase(second, widgets.end());
+ aligned = true;
+}
+
} // namespace GLtk
} // namespace Msp
gravity = primary;
}
+void LinearArrangement::expand()
+{
+ if(gravity==primary)
+ throw arrangement_error("already split");
+ if(edges[primary].empty())
+ throw arrangement_error("no widgets");
+
+ add_constraint(*edges[primary].widgets.front(), get_align_constraint(primary), primary);
+ layout.set_expand(*edges[primary].widgets.front(), false, true);
+ edges[primary].align();
+ gravity = primary;
+}
+
void LinearArrangement::process_widget(Widget &wdg, Side side, bool aligned)
{
if(side==opposite)
LinearArrangement::Loader::Loader(LinearArrangement &c):
DataFile::ObjectLoader<LinearArrangement>(c)
{
+ add("expand", &Loader::expand);
add("split", &Loader::split);
}
+void LinearArrangement::Loader::expand()
+{
+ obj.expand();
+}
+
void LinearArrangement::Loader::split()
{
obj.split();