return type;
}
-void Layout::add_constraint(Widget &src, ConstraintType type, Widget &tgt)
+void Layout::create_constraint(Widget &src, ConstraintType type, Widget &tgt, int sp)
{
if(&src==&tgt)
throw invalid_argument("&src==&tgt");
return;
src_slot.constraints.push_back(Constraint(type, tgt_slot));
+ src_slot.constraints.back().spacing = sp;
tgt_slot.constraints.push_back(Constraint(complement(type), src_slot));
+ tgt_slot.constraints.back().spacing = sp;
update();
}
+void Layout::add_constraint(Widget &src, ConstraintType type, Widget &tgt)
+{
+ create_constraint(src, type, tgt, -1);
+}
+
+void Layout::add_constraint(Widget &src, ConstraintType type, Widget &tgt, unsigned spacing)
+{
+ create_constraint(src, type, tgt, spacing);
+}
+
void Layout::set_gravity(Widget &wdg, int h, int v)
{
Slot &slot = get_slot_for_widget(wdg);
row.back() = geom.*(ptrs.dim)-margin.*(ptrs.high_margin);
}
+ if(((*i)->*(ptrs.packing)).gravity==0)
+ {
+ /* This forces the widget's distance from the left and right edge of
+ the container to be equal. It's a bit of a hack, but more time and
+ thought is needed for a better solution. */
+ LinearProgram::Row row = linprog.add_row();
+ row[(*i)->index*5+2] = 1;
+ row[(*i)->index*5+3] = -1;
+ }
+
{
/* Only allow the widget's dimension to increase. The geometry has
previously been set to the smallest allowable size. */
if(j->type&TARGET_DIM)
row[j->target.index*5+1] = -1;
if(j->type&SPACING)
- row.back() = this->*(ptrs.spacing);
+ row.back() = (j->spacing>=0 ? j->spacing : this->*(ptrs.spacing));
}
}
Layout::Constraint::Constraint(ConstraintType t, Slot &s):
type(t),
- target(s)
+ target(s),
+ spacing(-1)
{ }