Ardour  9.0-pre0-582-g084a23a80d
canvas/canvas/box.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Carl Hetherington <carl@carlh.net>
3  * Copyright (C) 2016 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __CANVAS_BOX_H__
22 #define __CANVAS_BOX_H__
23 
24 #include "canvas/rectangle.h"
25 
26 namespace ArdourCanvas
27 {
28 
29 class Rectangle;
30 
42 class LIBCANVAS_API Box : public Rectangle
43 {
44 public:
45  enum Orientation {
48  };
49 
53 
54  void set_spacing (double s);
55  void set_padding (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
56  void set_margin (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
57 
58  /* aliases so that CSS box model terms work */
59  void set_border_width (double w) { set_outline_width (w); }
60  void set_border_color (Gtkmm2ext::Color c) { set_outline_color (c); }
61 
62  void add (Item*);
63  void add_front (Item*);
64  void layout ();
65 
66  void set_collapse_on_hide (bool);
67  void set_homogenous (bool);
68 
69  void compute_bounding_box () const;
70  void size_request (double& w, double& h) const;
71  void size_allocate_children (Rect const & r);
72  void _size_allocate (Rect const & r);
73 
74  protected:
76  double spacing;
77  double top_padding, right_padding, bottom_padding, left_padding;
78  double top_margin, right_margin, bottom_margin, left_margin;
79 
80  void child_changed (bool bbox_changed);
81  private:
83  bool homogenous;
84  mutable bool ignore_child_changes;
85 
86  void reposition_children (Distance width, Distance height, bool width_shrink, bool height_shrink);
87 };
88 
89 class LIBCANVAS_API VBox : public Box
90 {
91  public:
92  VBox (Canvas *);
93  VBox (Item *);
94  VBox (Item *, Duple const & position);
95 };
96 
97 class LIBCANVAS_API HBox : public Box
98 {
99  public:
101  HBox (Item *);
102  HBox (Item *, Duple const & position);
103 };
104 
105 }
106 
107 #endif
#define LIBCANVAS_API
void compute_bounding_box() const
void set_border_color(Gtkmm2ext::Color c)
Box(Canvas *, Orientation)
void set_margin(double top, double right=-1.0, double bottom=-1.0, double left=-1.0)
void reposition_children(Distance width, Distance height, bool width_shrink, bool height_shrink)
void size_request(double &w, double &h) const
void size_allocate_children(Rect const &r)
Orientation orientation
void child_changed(bool bbox_changed)
void set_collapse_on_hide(bool)
void set_homogenous(bool)
void set_border_width(double w)
void _size_allocate(Rect const &r)
Box(Item *, Duple const &position, Orientation)
void add_front(Item *)
Box(Item *, Orientation)
void set_padding(double top, double right=-1.0, double bottom=-1.0, double left=-1.0)
void set_spacing(double s)
void add(Item *)
HBox(Item *, Duple const &position)
VBox(Item *, Duple const &position)
uint32_t Color
Definition: colors.h:33
gint height
Definition: xcursors.h:1
gint width
Definition: xcursors.h:1