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);
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)
{ }
{
ConstraintType type;
Slot ⌖
+ int spacing;
Constraint(ConstraintType, Slot &);
};
virtual Slot *create_slot(Widget &);
Slot &get_slot_for_widget(Widget &);
static ConstraintType complement(ConstraintType);
+ void create_constraint(Widget &, ConstraintType, Widget &, int);
+
public:
- void add_constraint(Widget &, ConstraintType, Widget &);
+ /** Adds a constraint between two widgets. */
+ void add_constraint(Widget &src, ConstraintType type, Widget &tgt);
+
+ /** Adds a constraint between two widgets, overriding the default spacing.
+ Not all constraint types use a spacing. */
+ void add_constraint(Widget &src, ConstraintType type, Widget &tgt, unsigned);
+
void set_gravity(Widget &, int, int);
void set_expand(Widget &, bool, bool);