namespace Msp {
namespace GLtk {
-Row::Row(bool u):
- uniform(u)
+Row::Row(Layout &l):
+ Arrangement(l),
+ first(true),
+ split_here(false),
+ gravity(-1)
{ }
-Layout::Slot *Row::create_slot(Widget &w)
+void Row::split()
{
- Slot *slot = new Slot(*this, w);
+ split_here = true;
+ gravity = 1;
+}
- if(!slots.empty())
+void Row::process_widget(Widget &wdg, Side side, bool aligned)
+{
+ if(side==LEFT)
{
- Slot &prev = *slots.back();
- slot->constraints.push_back(Constraint(RIGHT_OF, prev));
- slot->constraints.push_back(Constraint(ALIGN_TOP, prev));
- slot->constraints.push_back(Constraint(ALIGN_BOTTOM, prev));
- if(uniform)
- slot->constraints.push_back(Constraint(COPY_WIDTH, prev));
+ bool snug = (edges[RIGHT].aligned && aligned && !split_here);
+ add_constraint(wdg, (snug ? Layout::RIGHT_OF : Layout::FAR_RIGHT_OF), RIGHT);
+ if(first)
+ edges[LEFT].add(wdg, aligned);
}
- slot->vert_pack.expand = true;
+ else if(side==RIGHT)
+ next_right.add(wdg, (aligned && gravity>0));
+ else
+ {
+ if(edges[side].aligned && aligned)
+ add_constraint(wdg, (side==TOP ? Layout::ALIGN_TOP : Layout::ALIGN_BOTTOM), side);
+ edges[side].add(wdg, aligned);
+ }
+}
- return slot;
+void Row::finish_widget(Widget &wdg)
+{
+ layout.set_gravity(wdg, gravity, 1);
+}
+
+void Row::finish_slot()
+{
+ edges[RIGHT] = next_right;
+ next_right.clear();
+ split_here = false;
+ first = false;
}
} // namespace GLtk