mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-21 14:16:31 +01:00
Canvas: next step of merging cBox and ConstraintPacker
This commit is contained in:
parent
af60c50990
commit
4e82279ce4
2 changed files with 54 additions and 0 deletions
|
|
@ -43,6 +43,9 @@ public:
|
||||||
void remove (Item *);
|
void remove (Item *);
|
||||||
void constrain (kiwi::Constraint const &);
|
void constrain (kiwi::Constraint const &);
|
||||||
|
|
||||||
|
BoxConstrainedItem* pack_start (Item*, PackOptions primary_axis_packing = PackOptions (0), PackOptions secondary_axis_packing = PackOptions (PackExpand|PackFill));
|
||||||
|
BoxConstrainedItem* pack_end (Item*, PackOptions primary_axis_packing = PackOptions (0), PackOptions secondary_axis_packing = PackOptions (PackExpand|PackFill));
|
||||||
|
|
||||||
virtual ConstrainedItem* add_constrained (Item* item);
|
virtual ConstrainedItem* add_constrained (Item* item);
|
||||||
|
|
||||||
void solve ();
|
void solve ();
|
||||||
|
|
@ -79,6 +82,8 @@ public:
|
||||||
typedef std::list<BoxConstrainedItem*> BoxPackedItems;
|
typedef std::list<BoxConstrainedItem*> BoxPackedItems;
|
||||||
BoxPackedItems vpacked;
|
BoxPackedItems vpacked;
|
||||||
BoxPackedItems hpacked;
|
BoxPackedItems hpacked;
|
||||||
|
|
||||||
|
BoxConstrainedItem* pack (Item*, PackOptions primary_axis_packing, PackOptions secondary_axis_packing);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,26 @@ ConstraintPacker::remove (Item* item)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool found_packed = false;
|
||||||
|
|
||||||
|
for (BoxPackedItems::iterator t = hpacked.begin(); t != hpacked.end(); ++t) {
|
||||||
|
if (&(*t)->item() == item) {
|
||||||
|
hpacked.erase (t);
|
||||||
|
found_packed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found_packed) {
|
||||||
|
for (BoxPackedItems::iterator t = vpacked.begin(); t != vpacked.end(); ++t) {
|
||||||
|
if (&(*t)->item() == item) {
|
||||||
|
vpacked.erase (t);
|
||||||
|
found_packed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_need_constraint_update = true;
|
_need_constraint_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -331,3 +351,32 @@ ConstraintPacker::update_constraints ()
|
||||||
_solver.addConstraint (*c);
|
_solver.addConstraint (*c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BoxConstrainedItem*
|
||||||
|
ConstraintPacker::pack_start (Item* item, PackOptions primary_axis_opts, PackOptions secondary_axis_opts)
|
||||||
|
{
|
||||||
|
return pack (item, PackOptions (primary_axis_opts|PackFromStart), secondary_axis_opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
BoxConstrainedItem*
|
||||||
|
ConstraintPacker::pack_end (Item* item, PackOptions primary_axis_opts, PackOptions secondary_axis_opts)
|
||||||
|
{
|
||||||
|
return pack (item, PackOptions (primary_axis_opts|PackFromEnd), secondary_axis_opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
BoxConstrainedItem*
|
||||||
|
ConstraintPacker::pack (Item* item, PackOptions primary_axis_opts, PackOptions secondary_axis_opts)
|
||||||
|
{
|
||||||
|
BoxConstrainedItem* ci = new BoxConstrainedItem (*item, primary_axis_opts, secondary_axis_opts);
|
||||||
|
|
||||||
|
add_constrained_internal (item, ci);
|
||||||
|
|
||||||
|
if (_orientation == Horizontal) {
|
||||||
|
hpacked.push_back (ci);
|
||||||
|
} else {
|
||||||
|
vpacked.push_back (ci);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ci;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue