summaryrefslogtreecommitdiff
path: root/libs/canvas/canvas
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2017-01-14 11:45:47 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2017-01-15 12:13:03 +0000
commit9ed87f66932b415a9d784b59157b4a6cd2a783f0 (patch)
tree315e0be6f31af13f85d2781b931c640edb0aaddb /libs/canvas/canvas
parent1570b6c088ef6c2d7d4794e543fb643435ee7f43 (diff)
initial skeleton for a Grid canvas item
Diffstat (limited to 'libs/canvas/canvas')
-rw-r--r--libs/canvas/canvas/grid.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/libs/canvas/canvas/grid.h b/libs/canvas/canvas/grid.h
new file mode 100644
index 0000000000..a13cdf0a22
--- /dev/null
+++ b/libs/canvas/canvas/grid.h
@@ -0,0 +1,71 @@
+/*
+ Copyright (C) 2018 Paul Davis
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CANVAS_GRID_H__
+#define __CANVAS_GRID_H__
+
+#include "canvas/item.h"
+
+namespace ArdourCanvas
+{
+
+class Rectangle;
+
+/** Canvas container that renders its children in a grid layout
+ */
+class LIBCANVAS_API Grid : public Item
+{
+public:
+ Grid (Canvas *);
+ Grid (Item *);
+ Grid (Item *, Duple const & position);
+
+ void set_spacing (double s);
+ void set_padding (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
+ void set_margin (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
+
+ /* aliases so that CSS box model terms work */
+ void set_border_width (double w) { set_outline_width (w); }
+ void set_border_color (Color c) { set_outline_color (c); }
+
+ void place(Item*, Duple coord);
+
+ void set_collapse_on_hide (bool);
+ void set_homogenous (bool);
+
+ void compute_bounding_box () const;
+ void render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
+
+ protected:
+ double spacing;
+ double top_padding, right_padding, bottom_padding, left_padding;
+ double top_margin, right_margin, bottom_margin, left_margin;
+
+ void child_changed ();
+ private:
+ Rectangle *self;
+ bool collapse_on_hide;
+ bool homogenous;
+
+ void reset_self ();
+ void reposition_children ();
+};
+
+}
+
+#endif