]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/column.cpp
Replace the derived layout classes with a more flexible design
[libs/gltk.git] / source / column.cpp
index 3a7a149f98ebce3a524cfd25538883d64cb75108..6c225ee994a52171fbc041a3e13c499b068b6702 100644 (file)
@@ -3,26 +3,49 @@
 namespace Msp {
 namespace GLtk {
 
-Column::Column(bool u):
-       uniform(u)
+Column::Column(Layout &l):
+       Arrangement(l),
+       first(true),
+       split_here(false),
+       gravity(1)
 { }
 
-Layout::Slot *Column::create_slot(Widget &w)
+void Column::split()
 {
-       Slot *slot = new Slot(*this, w);
+       split_here = true;
+       gravity = -1;
+}
 
-       if(!slots.empty())
+void Column::process_widget(Widget &wdg, Side side, bool aligned)
+{
+       if(side==TOP)
        {
-               Slot &prev = *slots.back();
-               slot->constraints.push_back(Constraint(BELOW, prev));
-               slot->constraints.push_back(Constraint(ALIGN_LEFT, prev));
-               slot->constraints.push_back(Constraint(ALIGN_RIGHT, prev));
-               if(uniform)
-                       slot->constraints.push_back(Constraint(COPY_HEIGHT, prev));
+               bool snug = (edges[BOTTOM].aligned && aligned && !split_here);
+               add_constraint(wdg, (snug ? Layout::BELOW : Layout::FAR_BELOW), BOTTOM);
+               if(first)
+                       edges[TOP].add(wdg, aligned);
        }
-       slot->horiz_pack.expand = true;
+       else if(side==BOTTOM)
+               next_bottom.add(wdg, (aligned && gravity<0));
+       else
+       {
+               if(edges[side].aligned && aligned)
+                       add_constraint(wdg, (side==LEFT ? Layout::ALIGN_LEFT : Layout::ALIGN_RIGHT), side);
+               edges[side].add(wdg, aligned);
+       }
+}
 
-       return slot;
+void Column::finish_widget(Widget &wdg)
+{
+       layout.set_gravity(wdg, -1, gravity);
+}
+
+void Column::finish_slot()
+{
+       edges[BOTTOM] = next_bottom;
+       next_bottom.clear();
+       split_here = false;
+       first = false;
 }
 
 } // namespace GLtk