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_spacing (double s);
41 void set_padding (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
42 void set_margin (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
44 /* aliases so that CSS box model terms work */
45 void set_border_width (double w) { set_outline_width (w); }
46 void set_border_color (Color c) { set_outline_color (c); }
48 void place (Item*, Duple coord);
50 void set_collapse_on_hide (bool);
51 void set_homogenous (bool);
53 void compute_bounding_box () const;
54 void render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
58 double top_padding, right_padding, bottom_padding, left_padding;
59 double top_margin, right_margin, bottom_margin, left_margin;
61 void child_changed ();
63 typedef std::map<Item*,Duple> CoordsByItem;
64 CoordsByItem coords_by_item;
67 bool collapse_on_hide;
71 void reposition_children ();