summaryrefslogtreecommitdiff
path: root/libs/canvas
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2017-01-30 16:31:35 +0100
committerPaul Davis <paul@linuxaudiosystems.com>2017-02-01 21:58:20 +0100
commit14cb9ec795ba524275dfeb8bf0f9f0582523bb66 (patch)
tree6e1e5e770560e87cf3a0cfc6a88c0bc31b3bbc8a /libs/canvas
parente616324683b33d7e911745a19cf202d1f609dfc4 (diff)
canvas::grid starts being able to do its job a little
Diffstat (limited to 'libs/canvas')
-rw-r--r--libs/canvas/canvas/item.h2
-rw-r--r--libs/canvas/canvas/widget.h2
-rw-r--r--libs/canvas/grid.cc25
-rw-r--r--libs/canvas/widget.cc12
4 files changed, 35 insertions, 6 deletions
diff --git a/libs/canvas/canvas/item.h b/libs/canvas/canvas/item.h
index a480ec38a1..02f84a62ee 100644
--- a/libs/canvas/canvas/item.h
+++ b/libs/canvas/canvas/item.h
@@ -138,7 +138,7 @@ public:
/* item implementations can override this if they need to */
virtual Rect size_request() const { return bounding_box (true); }
- void size_allocate (Rect const&);
+ virtual void size_allocate (Rect const&);
/** bounding box is the public API to get the size of the item.
If @param for_own_purposes is false, then it will return the
diff --git a/libs/canvas/canvas/widget.h b/libs/canvas/canvas/widget.h
index c1f6dc1f36..4c00592403 100644
--- a/libs/canvas/canvas/widget.h
+++ b/libs/canvas/canvas/widget.h
@@ -37,6 +37,8 @@ public:
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const;
+ void size_allocate (Rect const &);
+
CairoWidget const & get () const {
return _widget;
}
diff --git a/libs/canvas/grid.cc b/libs/canvas/grid.cc
index fe23ea3aec..323cdbf1ad 100644
--- a/libs/canvas/grid.cc
+++ b/libs/canvas/grid.cc
@@ -33,7 +33,7 @@ Grid::Grid (Canvas* canvas)
, spacing (0)
, top_padding (0), right_padding (0), bottom_padding (0), left_padding (0)
, top_margin (0), right_margin (0), bottom_margin (0), left_margin (0)
- , homogenous (true)
+ , homogenous (false)
{
self = new Rectangle (this);
self->set_outline (false);
@@ -45,7 +45,7 @@ Grid::Grid (Item* parent)
, spacing (0)
, top_padding (0), right_padding (0), bottom_padding (0), left_padding (0)
, top_margin (0), right_margin (0), bottom_margin (0), left_margin (0)
- , homogenous (true)
+ , homogenous (false)
{
self = new Rectangle (this);
self->set_outline (false);
@@ -65,6 +65,12 @@ Grid::Grid (Item* parent, Duple const & p)
}
void
+Grid::set_homogenous (bool yn)
+{
+ homogenous = yn;
+}
+
+void
Grid::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
Item::render_children (area, context);
@@ -193,12 +199,16 @@ Grid::reposition_children ()
if (homogenous) {
for (std::list<Item*>::iterator i = _items.begin(); i != _items.end(); ++i) {
+ if (*i == self) {
+ continue;
+ }
+
Rect bb = (*i)->bounding_box();
if (!bb) {
continue;
}
- cerr << "\tbb is " << bb << endl;
+ cerr << "\tbb for " << (*i)->whatami() << " is " << bb << endl;
uniform_size.y1 = max (uniform_size.y1, bb.height());
uniform_size.x1 = max (uniform_size.x1, bb.width());
}
@@ -211,10 +221,10 @@ Grid::reposition_children ()
continue;
}
(*i)->size_allocate (uniform_size);
- for (uint32_t n = 0; n < max_row; ++n) {
+ for (uint32_t n = 0; n < max_col; ++n) {
col_dimens[n] = uniform_size.width();
}
- for (uint32_t n = 0; n < max_col; ++n) {
+ for (uint32_t n = 0; n < max_row; ++n) {
row_dimens[n] = uniform_size.height();
}
}
@@ -252,6 +262,7 @@ Grid::reposition_children ()
/* height defined for this row */
const double h = row_dimens[n]; /* save height */
row_dimens[n] = current_top_edge;
+ cerr << "row[" << n << "] @ " << row_dimens[n] << endl;
current_top_edge = current_top_edge + h + top_padding + bottom_padding;
}
}
@@ -263,6 +274,7 @@ Grid::reposition_children ()
/* a width was defined for this column */
const double w = col_dimens[n]; /* save width of this column */
col_dimens[n] = current_right_edge;
+ cerr << "col[" << n << "] @ " << col_dimens[n] << endl;
current_right_edge = current_right_edge + w + left_padding + right_padding;
}
}
@@ -279,6 +291,9 @@ Grid::reposition_children ()
}
(*i)->set_position (Duple (col_dimens[c->second.x], row_dimens[c->second.y]));
+ cerr << "place " << (*i)->whatami() << " @ " << c->second.x << ", " << c->second.y << " at "
+ << Duple (col_dimens[c->second.x], row_dimens[c->second.y])
+ << endl;
}
_bounding_box_dirty = true;
diff --git a/libs/canvas/widget.cc b/libs/canvas/widget.cc
index db43a68119..4c98d6651d 100644
--- a/libs/canvas/widget.cc
+++ b/libs/canvas/widget.cc
@@ -110,6 +110,18 @@ Widget::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
}
void
+Widget::size_allocate (Rect const & r)
+{
+ Item::size_allocate (r);
+ Gtk::Allocation alloc;
+ alloc.set_x (0);
+ alloc.set_y (0);
+ alloc.set_width (r.width());
+ alloc.set_height (r.height());
+ _widget.size_allocate (alloc);
+}
+
+void
Widget::compute_bounding_box () const
{
std::cerr << "cbbox for widget\n";