X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcolumn.cpp;h=6c225ee994a52171fbc041a3e13c499b068b6702;hb=646af3dd91a6ca981572a5b69a0f0bd205d9af49;hp=3a7a149f98ebce3a524cfd25538883d64cb75108;hpb=df07e8f3e239b146cbc458d3cbd69758e590d255;p=libs%2Fgltk.git diff --git a/source/column.cpp b/source/column.cpp index 3a7a149..6c225ee 100644 --- a/source/column.cpp +++ b/source/column.cpp @@ -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