mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
Revert "towards a very different constraint layout tester"
This reverts commit 7f65ffe576.
This commit is contained in:
parent
11931f5ffb
commit
711c1520b5
4 changed files with 102 additions and 73 deletions
|
|
@ -168,13 +168,13 @@ cBox::preferred_size (Duple& min, Duple& natural) const
|
|||
Distance largest_opposite = 0;
|
||||
Duple i_min, i_natural;
|
||||
|
||||
//cerr << "cbox::prefsize (" << (orientation == Vertical ? " vert) " : " horiz) ") << endl;
|
||||
cerr << "cbox::prefsize (" << (orientation == Vertical ? " vert) " : " horiz) ") << endl;
|
||||
|
||||
for (Order::const_iterator o = order.begin(); o != order.end(); ++o) {
|
||||
|
||||
(*o)->item().preferred_size (i_min, i_natural);
|
||||
|
||||
// cerr << '\t' << (*o)->item().whoami() << " min " << i_min << " nat " << i_natural << endl;
|
||||
cerr << '\t' << (*o)->item().whoami() << " min " << i_min << " nat " << i_natural << endl;
|
||||
|
||||
if ((*o)->primary_axis_pack_options() & PackExpand) {
|
||||
n_expanding++;
|
||||
|
|
@ -218,17 +218,17 @@ cBox::preferred_size (Duple& min, Duple& natural) const
|
|||
Duple r;
|
||||
|
||||
if (orientation == Vertical) {
|
||||
//cerr << "+++ vertical box, neu = " << non_expanding_used << " largest = " << largest << " opp " << largest_opposite << " total " << total << endl;
|
||||
cerr << "+++ vertical box, neu = " << non_expanding_used << " largest = " << largest << " opp " << largest_opposite << " total " << total << endl;
|
||||
min.x = non_expanding_used + (n_expanding * largest_opposite) + _left_margin + _right_margin + ((total - 1) * _spacing);
|
||||
min.y = non_expanding_used + (n_expanding * largest) + _top_margin + _bottom_margin + ((total - 1) * _spacing);
|
||||
} else {
|
||||
// cerr << "+++ horiz box, neu = " << non_expanding_used << " largest = " << largest << " opp " << largest_opposite << " total " << total << endl;
|
||||
cerr << "+++ horiz box, neu = " << non_expanding_used << " largest = " << largest << " opp " << largest_opposite << " total " << total << endl;
|
||||
min.x = non_expanding_used + (n_expanding * largest) + _left_margin + _right_margin + ((total - 1) * _spacing);
|
||||
min.y = non_expanding_used + (n_expanding * largest_opposite) + _top_margin + _bottom_margin + ((total - 1) * _spacing);
|
||||
|
||||
}
|
||||
|
||||
// cerr << "++++ " << whoami() << " rpref " << min << endl;
|
||||
cerr << "++++ " << whoami() << " rpref " << min << endl;
|
||||
|
||||
natural = min;
|
||||
}
|
||||
|
|
@ -274,7 +274,7 @@ cBox::size_allocate (Rect const & r)
|
|||
expanded_size = (r.width() - _left_margin - _right_margin - ((total - 1) * _spacing) - non_expanding_used) / n_expanding;
|
||||
}
|
||||
|
||||
// cerr << "\n\n\n" << whoami() << " SIZE-ALLOC " << r << " expanded items (" << n_expanding << ")will be " << expanded_size << " neu " << non_expanding_used << " t = " << total << " s " << _spacing << '\n';
|
||||
cerr << "\n\n\n" << whoami() << " SIZE-ALLOC " << r << " expanded items (" << n_expanding << ")will be " << expanded_size << " neu " << non_expanding_used << " t = " << total << " s " << _spacing << '\n';
|
||||
|
||||
Order::size_type n = 0;
|
||||
Order::iterator prev = order.end();
|
||||
|
|
@ -284,7 +284,7 @@ cBox::size_allocate (Rect const & r)
|
|||
Duple min, natural;
|
||||
(*o)->item().preferred_size (min, natural);
|
||||
|
||||
// cerr << "\t" << (*o)->item().whoami() << " min " << min << " nat " << natural << endl;
|
||||
cerr << "\t" << (*o)->item().whoami() << " min " << min << " nat " << natural << endl;
|
||||
|
||||
/* setup center_{x,y} variables in case calling/using
|
||||
* code wants to use them for additional constraints
|
||||
|
|
@ -337,7 +337,7 @@ cBox::size_allocate (Rect const & r)
|
|||
* height.
|
||||
*/
|
||||
|
||||
// cerr << (*o)->item().whoami() << " will use natural height of " << natural.height() << endl;
|
||||
cerr << (*o)->item().whoami() << " will use natural height of " << natural.height() << endl;
|
||||
solver.addConstraint ((*o)->height() == natural.height());
|
||||
solver.addConstraint ((*o)->top_padding() == 0.);
|
||||
solver.addConstraint ((*o)->bottom_padding() == 0.);
|
||||
|
|
@ -365,10 +365,10 @@ cBox::size_allocate (Rect const & r)
|
|||
solver.addConstraint ((*o)->left() == _left_margin + (*o)->left_padding() | kiwi::strength::strong);
|
||||
|
||||
if (!((*o)->secondary_axis_pack_options() & PackExpand) && natural.width() > 0) {
|
||||
// cerr << "\t\t also using natural width of " << natural.width() << endl;
|
||||
cerr << "\t\t also using natural width of " << natural.width() << endl;
|
||||
solver.addConstraint ((*o)->width() == natural.width());
|
||||
} else {
|
||||
// cerr << "\t\t also using container width of " << r.width() << endl;
|
||||
cerr << "\t\t also using container width of " << r.width() << endl;
|
||||
solver.addConstraint ((*o)->width() == r.width() - (_left_margin + _right_margin + (*o)->right_padding()) | kiwi::strength::strong);
|
||||
}
|
||||
|
||||
|
|
@ -442,10 +442,10 @@ cBox::size_allocate (Rect const & r)
|
|||
solver.addConstraint ((*o)->top() == _top_margin + (*o)->top_padding() | kiwi::strength::strong);
|
||||
|
||||
if (!((*o)->secondary_axis_pack_options() & PackExpand) && natural.height() > 0) {
|
||||
// cerr << "\t\tand natural height of " << natural.height() << endl;
|
||||
cerr << "\t\tand natural height of " << natural.height() << endl;
|
||||
solver.addConstraint ((*o)->height() == natural.height());
|
||||
} else {
|
||||
// cerr << "\t\tand container height of " << r.height() << endl;
|
||||
cerr << "\t\tand container height of " << r.height() << endl;
|
||||
solver.addConstraint ((*o)->height() == r.height() - (_top_margin + _bottom_margin + (*o)->bottom_padding()) | kiwi::strength::strong);
|
||||
}
|
||||
}
|
||||
|
|
@ -471,7 +471,7 @@ cBox::size_allocate (Rect const & r)
|
|||
//solver.dump (cerr);
|
||||
|
||||
for (Order::iterator o = order.begin(); o != order.end(); ++o, ++n) {
|
||||
// (*o)->dump (cerr);
|
||||
(*o)->dump (cerr);
|
||||
}
|
||||
|
||||
apply (&solver);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ ConstrainedItem::constrained (ConstraintPacker const & parent)
|
|||
/* our variables should be set. Deliver computed size to item */
|
||||
|
||||
Rect r (_left.value(), _top.value(), _right.value(), _bottom.value());
|
||||
//cerr << _item.whatami() << '/' << _item.name << " constrained-alloc " << r << endl;
|
||||
dump (cerr);
|
||||
cerr << _item.whatami() << '/' << _item.name << " constrained-alloc " << r << endl;
|
||||
|
||||
_item.size_allocate (r);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,19 +20,6 @@ using namespace Gtk;
|
|||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
struct Column {
|
||||
Column (Canvas* c) {
|
||||
box = new cBox (c, Vertical);
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
rects[i] = new Rectangle (box);
|
||||
rects[i]->set_fill_color (Gtkmm2ext::random_color());
|
||||
}
|
||||
}
|
||||
|
||||
cBox* box;
|
||||
Rectangle* rects[16];
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char* argv[])
|
||||
{
|
||||
|
|
@ -52,57 +39,26 @@ main (int argc, char* argv[])
|
|||
|
||||
win.add (cview);
|
||||
|
||||
cBox* main_hbox = new cBox (c->root(), Horizontal);
|
||||
Rectangle* r1 = new Rectangle (c);
|
||||
Rectangle* r2 = new Rectangle (c);
|
||||
Rectangle* r3 = new Rectangle (c);
|
||||
|
||||
Column* cols[16];
|
||||
r1->set_fill_color (Gtkmm2ext::random_color());
|
||||
r2->set_fill_color (Gtkmm2ext::random_color());
|
||||
r3->set_fill_color (Gtkmm2ext::random_color());
|
||||
|
||||
for (size_t i = 0; i < sizeof (cols) / sizeof (cols[0]); ++i) {
|
||||
cols[i] = new Column (c);
|
||||
main_hbox->pack_start (cols[i]->box, PackOptions (PackExpand|PackFill));
|
||||
}
|
||||
r1->name = "r1";
|
||||
r2->name = "r2";
|
||||
r3->name = "r3";
|
||||
|
||||
//r1->set_intrinsic_size (20, 20);
|
||||
//r2->set_intrinsic_size (30, 30);
|
||||
//r3->set_intrinsic_size (40, 40);
|
||||
|
||||
#if 0
|
||||
Circle* circle = new Circle (c);
|
||||
circle->name = "circle";
|
||||
//circle->set_radius (30);
|
||||
circle->set_fill_color (Gtkmm2ext::random_color());
|
||||
circle->set_outline_color (Gtkmm2ext::random_color());
|
||||
|
||||
ci = vbox->pack_start (circle, PackOptions (PackExpand|PackFill));
|
||||
ci->add_constraint (ci->height() == 0.5 * hb1->height());
|
||||
|
||||
cBox* hbox2 = new cBox (c, Horizontal);
|
||||
hbox2->name = "hbox2";
|
||||
hbox2->set_fill (true);
|
||||
hbox2->set_fill_color (Gtkmm2ext::random_color());
|
||||
|
||||
Text* txt = new Text (c);
|
||||
txt->name = "text";
|
||||
|
||||
Pango::FontDescription font ("Sans");
|
||||
|
||||
txt->set_font_description (font);
|
||||
txt->set ("hello, world");
|
||||
|
||||
ConstrainedItem* ti = hbox2->pack_start (txt, PackExpand);
|
||||
ti->add_constraint (ti->left() == 25);
|
||||
|
||||
vbox->pack_start (hbox2, PackOptions (PackExpand|PackFill));
|
||||
#endif
|
||||
|
||||
|
||||
win.show_all ();
|
||||
app.run ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
/* code test arbitrary constraint layout */
|
||||
//#define FULL_PACKER
|
||||
#define CBOX_PACKER
|
||||
|
||||
#ifdef FULL_PACKER
|
||||
ConstraintPacker* packer = new ConstraintPacker (c->root());
|
||||
|
||||
ConstrainedItem* left = packer->add_constrained (r1);
|
||||
|
|
@ -136,5 +92,74 @@ main (int argc, char* argv[])
|
|||
packer->constrain (left->bottom() == left->top() + left->height());
|
||||
packer->constrain (center->bottom() == center->top() + center->height());
|
||||
packer->constrain (right->bottom() == right->top() + right->height());
|
||||
|
||||
#elif defined(CBOX_PACKER)
|
||||
|
||||
cBox* vbox = new cBox (c->root(), Vertical);
|
||||
vbox->name = "vbox";
|
||||
|
||||
vbox->set_margin (10, 20, 30, 40);
|
||||
|
||||
vbox->pack_start (r1, PackOptions(PackExpand|PackFill));
|
||||
vbox->pack_start (r2, PackOptions(PackExpand|PackFill));
|
||||
vbox->pack_start (r3, PackOptions(PackExpand|PackFill));
|
||||
|
||||
cBox* hbox1 = new cBox (c, Horizontal);
|
||||
hbox1->name = "hbox1";
|
||||
|
||||
hbox1->set_margin (10, 10, 10, 10);
|
||||
|
||||
Rectangle* r4 = new Rectangle (c);
|
||||
Rectangle* r5 = new Rectangle (c);
|
||||
Rectangle* r6 = new Rectangle (c);
|
||||
|
||||
r4->set_fill_color (Gtkmm2ext::random_color());
|
||||
r5->set_fill_color (Gtkmm2ext::random_color());
|
||||
r6->set_fill_color (Gtkmm2ext::random_color());
|
||||
|
||||
r4->name = "r4";
|
||||
r5->name = "r5";
|
||||
r6->name = "r6";
|
||||
hbox1->pack_start (r4, PackOptions(PackExpand|PackFill));
|
||||
hbox1->pack_start (r5, PackOptions(PackExpand|PackFill));
|
||||
hbox1->pack_start (r6, PackOptions(PackExpand|PackFill));
|
||||
|
||||
BoxConstrainedItem* hb1;
|
||||
ConstrainedItem* ci;
|
||||
|
||||
hb1 = vbox->pack_start (hbox1, PackOptions (PackExpand|PackFill));
|
||||
|
||||
Circle* circle = new Circle (c);
|
||||
circle->name = "circle";
|
||||
//circle->set_radius (30);
|
||||
circle->set_fill_color (Gtkmm2ext::random_color());
|
||||
circle->set_outline_color (Gtkmm2ext::random_color());
|
||||
|
||||
ci = vbox->pack_start (circle, PackOptions (PackExpand|PackFill));
|
||||
ci->add_constraint (ci->height() == 0.5 * hb1->height());
|
||||
|
||||
cBox* hbox2 = new cBox (c, Horizontal);
|
||||
hbox2->name = "hbox2";
|
||||
hbox2->set_fill (true);
|
||||
hbox2->set_fill_color (Gtkmm2ext::random_color());
|
||||
|
||||
Text* txt = new Text (c);
|
||||
txt->name = "text";
|
||||
|
||||
Pango::FontDescription font ("Sans");
|
||||
|
||||
txt->set_font_description (font);
|
||||
txt->set ("hello, world");
|
||||
|
||||
ConstrainedItem* ti = hbox2->pack_start (txt, PackExpand);
|
||||
ti->add_constraint (ti->left() == 25);
|
||||
|
||||
vbox->pack_start (hbox2, PackOptions (PackExpand|PackFill));
|
||||
|
||||
#endif
|
||||
|
||||
win.show_all ();
|
||||
app.run ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,6 +180,8 @@ Rectangle::set (Rect const & r)
|
|||
as cheap to do it when asked.
|
||||
*/
|
||||
|
||||
cerr << name << " setting self rect\n";
|
||||
|
||||
if (r != _rect) {
|
||||
|
||||
begin_change ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue