Canvas: remove cBox (API fully merged into ConstraintPacker)
This commit is contained in:
parent
1b66890547
commit
1d96bad59f
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Carl Hetherington <carl@carlh.net>
|
||||
* Copyright (C) 2016 Paul Davis <paul@linuxaudiosystems.com>
|
||||
* Copyright (C) 2017 Robin Gareus <robin@gareus.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __CANVAS_CBOX_H__
|
||||
#define __CANVAS_CBOX_H__
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "canvas/constraint_packer.h"
|
||||
|
||||
namespace ArdourCanvas
|
||||
{
|
||||
|
||||
class Rectangle;
|
||||
class BoxConstrainedItem;
|
||||
|
||||
class LIBCANVAS_API cBox : public ConstraintPacker
|
||||
{
|
||||
public:
|
||||
cBox (Canvas *, Orientation);
|
||||
cBox (Item *, Orientation);
|
||||
|
||||
void set_collapse_on_hide (bool);
|
||||
void set_homogenous (bool);
|
||||
|
||||
protected:
|
||||
void child_changed (bool bbox_changed);
|
||||
|
||||
private:
|
||||
bool collapse_on_hide;
|
||||
bool homogenous;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* __CANVAS_CBOX_H__ */
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Paul Davis <paul@linuxaudiosystems.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "pbd/unwind.h"
|
||||
|
||||
#include "canvas/canvas.h"
|
||||
#include "canvas/cbox.h"
|
||||
#include "canvas/constrained_item.h"
|
||||
|
||||
using namespace ArdourCanvas;
|
||||
using namespace kiwi;
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
cBox::cBox (Canvas* c, Orientation o)
|
||||
: ConstraintPacker (c)
|
||||
, collapse_on_hide (false)
|
||||
, homogenous (true)
|
||||
{
|
||||
}
|
||||
|
||||
cBox::cBox (Item* i, Orientation o)
|
||||
: ConstraintPacker (i)
|
||||
, collapse_on_hide (false)
|
||||
, homogenous (true)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
cBox::child_changed (bool bbox_changed)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -256,20 +256,21 @@ ConstraintPacker::non_const_preferred_size (Duple& minimum, Duple& natural)
|
||||
We may have no intrinsic dimensions at all. This is the tricky one.
|
||||
*/
|
||||
|
||||
if (_intrinsic_width == 0 && _intrinsic_height == 0) {
|
||||
|
||||
if (packed.size() == constrained_map.size()) {
|
||||
/* All child items were packed using ::pack() */
|
||||
Duple m, n;
|
||||
|
||||
/* we can use the size of things packed using the box
|
||||
interface
|
||||
*/
|
||||
|
||||
box_preferred_size (m, n);
|
||||
natural = Duple (std::min (100.0, n.x), std::min (100.0, n.y));
|
||||
minimum = natural;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_intrinsic_width == 0 && _intrinsic_height == 0) {
|
||||
natural = Duple (100.0, 100.0);
|
||||
minimum = natural;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_need_constraint_update) {
|
||||
const_cast<ConstraintPacker*>(this)->update_constraints ();
|
||||
}
|
||||
@ -297,8 +298,6 @@ ConstraintPacker::non_const_preferred_size (Duple& minimum, Duple& natural)
|
||||
|
||||
_solver.reset ();
|
||||
_need_constraint_update = true;
|
||||
|
||||
cerr << "CP min " << minimum << " pref " << natural << endl;
|
||||
}
|
||||
|
||||
void
|
||||
@ -494,6 +493,7 @@ ConstraintPacker::update_constraints ()
|
||||
for (ConstrainedItemMap::iterator x = constrained_map.begin(); x != constrained_map.end(); ++x) {
|
||||
|
||||
if (std::find (packed.begin(), packed.end(), x->second) != packed.end()) {
|
||||
add_constraints (_solver, x->second);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "canvas/box.h"
|
||||
#include "canvas/canvas.h"
|
||||
#include "canvas/cbox.h"
|
||||
#include "canvas/circle.h"
|
||||
#include "canvas/constrained_item.h"
|
||||
#include "canvas/constraint_packer.h"
|
||||
@ -55,7 +54,7 @@ main (int argc, char* argv[])
|
||||
//r2->set_intrinsic_size (30, 30);
|
||||
//r3->set_intrinsic_size (40, 40);
|
||||
|
||||
cBox* vbox = new cBox (c->root(), Vertical);
|
||||
ConstraintPacker* vbox = new ConstraintPacker (c->root(), Vertical);
|
||||
vbox->name = "vbox";
|
||||
vbox->set_fill (true);
|
||||
vbox->set_fill_color (0xff0000ff);
|
||||
@ -65,7 +64,7 @@ main (int argc, char* argv[])
|
||||
vbox->pack_start (r2, PackOptions(PackExpand|PackFill));
|
||||
vbox->pack_start (r3, PackOptions(PackExpand|PackFill));
|
||||
|
||||
cBox* hbox1 = new cBox (c, Horizontal);
|
||||
ConstraintPacker* hbox1 = new ConstraintPacker (c, Horizontal);
|
||||
hbox1->name = "hbox1";
|
||||
hbox1->set_fill (true);
|
||||
hbox1->set_fill_color (0x00ff00ff);
|
||||
@ -107,7 +106,7 @@ main (int argc, char* argv[])
|
||||
ci->add_constraint (ci->top_padding() == 10);
|
||||
ci->add_constraint (ci->bottom_padding() == 10);
|
||||
|
||||
cBox* hbox2 = new cBox (c, Horizontal);
|
||||
ConstraintPacker* hbox2 = new ConstraintPacker (c, Horizontal);
|
||||
hbox2->name = "hbox2";
|
||||
hbox2->set_fill (true);
|
||||
hbox2->set_fill_color (Gtkmm2ext::random_color());
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "canvas/box.h"
|
||||
#include "canvas/canvas.h"
|
||||
#include "canvas/cbox.h"
|
||||
#include "canvas/circle.h"
|
||||
#include "canvas/constrained_item.h"
|
||||
#include "canvas/constraint_packer.h"
|
||||
@ -26,7 +25,7 @@ using std::endl;
|
||||
|
||||
struct Column {
|
||||
Column (Canvas* c, uint32_t num) : number (num) {
|
||||
box = new cBox (c, Vertical);
|
||||
box = new ConstraintPacker (c, Vertical);
|
||||
box->name = string_compose ("col%1", num);
|
||||
box->set_spacing (12);
|
||||
|
||||
@ -56,6 +55,11 @@ using std::endl;
|
||||
* the current text contents of labels[i].
|
||||
*/
|
||||
|
||||
l->centered_on (*b);
|
||||
l->add_constraint (l->width() == labels[i]->width());
|
||||
l->add_constraint (l->height() == labels[i]->height());
|
||||
|
||||
#if 0
|
||||
l->add_constraint (l->left() == b->center_x() - (labels[i]->width() / 2.));
|
||||
l->add_constraint (l->width() == labels[i]->width());
|
||||
l->add_constraint (l->right() == l->left() + labels[i]->width());
|
||||
@ -63,10 +67,11 @@ using std::endl;
|
||||
l->add_constraint (l->top() == b->center_y() - (labels[i]->height() / 2));
|
||||
l->add_constraint (l->height() == labels[i]->height());
|
||||
l->add_constraint (l->bottom() == l->top() + l->height());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
cBox* box;
|
||||
ConstraintPacker* box;
|
||||
Rectangle* rects[SQUARED];
|
||||
Text* labels[SQUARED];
|
||||
uint32_t number;
|
||||
@ -91,7 +96,7 @@ main (int argc, char* argv[])
|
||||
|
||||
win.add (cview);
|
||||
|
||||
cBox* main_hbox = new cBox (c->root(), Horizontal);
|
||||
ConstraintPacker* main_hbox = new ConstraintPacker (c->root(), Horizontal);
|
||||
main_hbox->name = "main";
|
||||
main_hbox->set_spacing (12);
|
||||
main_hbox->set_margin (24);
|
||||
@ -114,7 +119,7 @@ main (int argc, char* argv[])
|
||||
ci = vbox->pack_start (circle, PackOptions (PackExpand|PackFill));
|
||||
ci->add_constraint (ci->height() == 0.5 * hb1->height());
|
||||
|
||||
cBox* hbox2 = new cBox (c, Horizontal);
|
||||
ConstraintPacker* hbox2 = new ConstraintPacker (c, Horizontal);
|
||||
hbox2->name = "hbox2";
|
||||
hbox2->set_fill (true);
|
||||
hbox2->set_fill_color (Gtkmm2ext::random_color());
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "canvas/box.h"
|
||||
#include "canvas/canvas.h"
|
||||
#include "canvas/cbox.h"
|
||||
#include "canvas/circle.h"
|
||||
#include "canvas/constrained_item.h"
|
||||
#include "canvas/constraint_packer.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "canvas/box.h"
|
||||
#include "canvas/canvas.h"
|
||||
#include "canvas/cbox.h"
|
||||
#include "canvas/circle.h"
|
||||
#include "canvas/constrained_item.h"
|
||||
#include "canvas/constraint_packer.h"
|
||||
|
@ -32,7 +32,6 @@ canvas_sources = [
|
||||
'arrow.cc',
|
||||
'box.cc',
|
||||
'canvas.cc',
|
||||
'cbox.cc',
|
||||
'circle.cc',
|
||||
'container.cc',
|
||||
'constrained_item.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user