2 Copyright (C) 2018 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __CANVAS_GRID_H__
20 #define __CANVAS_GRID_H__
24 #include "canvas/item.h"
26 namespace ArdourCanvas
31 /** Canvas container that renders its children in a grid layout
33 class LIBCANVAS_API Grid : public Item
38 Grid (Item *, Duple const & position);
40 void set_row_spacing (double s);
41 void set_col_spacing (double s);
43 void set_padding (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
44 void set_margin (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
46 /* aliases so that CSS box model terms work */
47 void set_border_width (double w) { set_outline_width (w); }
48 void set_border_color (Gtkmm2ext::Color c) { set_outline_color (c); }
50 void place (Item*, double x, double y, double col_span = 1, double row_span = 1);
52 void set_collapse_on_hide (bool);
53 void set_homogenous (bool);
55 void compute_bounding_box () const;
56 void render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
61 double top_padding, right_padding, bottom_padding, left_padding;
62 double top_margin, right_margin, bottom_margin, left_margin;
64 void child_changed ();
74 typedef std::map<Item*,ChildInfo> CoordsByItem;
75 CoordsByItem coords_by_item;
78 bool collapse_on_hide;
82 void reposition_children ();