Fix the User button for Mixbus; we use it as a button, not a modifier.
[ardour.git] / libs / canvas / canvas / box.h
1 /*
2     Copyright (C) 2011-2014 Paul Davis
3     Original Author: Carl Hetherington <cth@carlh.net>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __CANVAS_BOX_H__
21 #define __CANVAS_BOX_H__
22
23 #include "canvas/item.h"
24
25 namespace ArdourCanvas
26 {
27
28 class Rectangle;
29
30 /** a Container is an item which has no content of its own
31  * but renders its children in some geometrical arrangement.
32  *
33  * Imagined examples of containers:
34  *
35  *   Container: renders each child at the child's self-determined position
36  *   Box: renders each child along an axis (vertical or horizontal)
37  *   Table/Grid: renders each child within a two-dimensional grid
38  *
39  *   Other?
40  */
41 class LIBCANVAS_API Box : public Item
42 {
43 public:
44         enum Orientation {
45                 Vertical,
46                 Horizontal
47         };
48
49         Box (Canvas *, Orientation);
50         Box (Item *, Orientation);
51         Box (Item *, Duple const & position, Orientation);
52
53         void set_spacing (double s);
54         void set_padding (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
55         void set_margin (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
56
57         /* aliases so that CSS box model terms work */
58         void set_border_width (double w) { set_outline_width (w); }
59         void set_border_color (Gtkmm2ext::Color c)  { set_outline_color (c); }
60
61         void add (Item*);
62         void pack_start (Item*, double extra_padding = 0);
63         void pack_end (Item*, double extra_padding = 0);
64
65         void set_collapse_on_hide (bool);
66         void set_homogenous (bool);
67
68         void compute_bounding_box () const;
69         void render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
70
71   protected:
72         Orientation orientation;
73         double spacing;
74         double top_padding, right_padding, bottom_padding, left_padding;
75         double top_margin, right_margin, bottom_margin, left_margin;
76
77         void child_changed ();
78   private:
79         Rectangle *self;
80         bool collapse_on_hide;
81         bool homogenous;
82
83         void reset_self ();
84         void reposition_children ();
85 };
86
87 class LIBCANVAS_API VBox : public Box
88 {
89   public:
90         VBox (Canvas *);
91         VBox (Item *);
92         VBox (Item *, Duple const & position);
93 };
94
95 class LIBCANVAS_API HBox : public Box
96 {
97   public:
98         HBox (Canvas *);
99         HBox (Item *);
100         HBox (Item *, Duple const & position);
101 };
102
103 }
104
105 #endif