Ardour  9.0-pre0-582-g084a23a80d
grid.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Paul Davis <paul@linuxaudiosystems.com>
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __CANVAS_GRID_H__
20 #define __CANVAS_GRID_H__
21 
22 #include <map>
23 
24 #include "canvas/item.h"
25 
26 namespace ArdourCanvas
27 {
28 
29 class Rectangle;
30 
33 class LIBCANVAS_API Grid : public Item
34 {
35 public:
36  Grid (Canvas *);
37  Grid (Item *);
38  Grid (Item *, Duple const & position);
39 
40  void set_row_spacing (double s);
41  void set_col_spacing (double s);
42 
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);
45 
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); }
49 
50  void place (Item*, double x, double y, double col_span = 1, double row_span = 1);
51 
52  void set_collapse_on_hide (bool);
53  void set_homogenous (bool);
54 
55  void compute_bounding_box () const;
56  void render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
57 
58  protected:
59  double row_spacing;
60  double col_spacing;
61  double top_padding, right_padding, bottom_padding, left_padding;
62  double top_margin, right_margin, bottom_margin, left_margin;
63 
64  void child_changed (bool bbox_changed);
65  private:
66  struct ChildInfo {
68  double x;
69  double y;
70  double col_span;
71  double row_span;
72  };
73 
74  typedef std::map<Item*,ChildInfo> CoordsByItem;
76 
79  bool homogenous;
80 
81  void reset_bg ();
83 };
84 
85 }
86 
87 #endif
#define LIBCANVAS_API
void reposition_children()
bool collapse_on_hide
Definition: grid.h:78
void set_border_width(double w)
Definition: grid.h:47
Grid(Item *, Duple const &position)
void set_row_spacing(double s)
void set_border_color(Gtkmm2ext::Color c)
Definition: grid.h:48
void child_changed(bool bbox_changed)
void set_col_spacing(double s)
void render(Rect const &area, Cairo::RefPtr< Cairo::Context > context) const
void set_margin(double top, double right=-1.0, double bottom=-1.0, double left=-1.0)
double bottom_padding
Definition: grid.h:61
void place(Item *, double x, double y, double col_span=1, double row_span=1)
double row_spacing
Definition: grid.h:59
double col_spacing
Definition: grid.h:60
void set_padding(double top, double right=-1.0, double bottom=-1.0, double left=-1.0)
Rectangle * bg
Definition: grid.h:77
void compute_bounding_box() const
std::map< Item *, ChildInfo > CoordsByItem
Definition: grid.h:74
bool homogenous
Definition: grid.h:79
double bottom_margin
Definition: grid.h:62
void set_homogenous(bool)
void set_collapse_on_hide(bool)
CoordsByItem coords_by_item
Definition: grid.h:75
uint32_t Color
Definition: colors.h:33