Ardour  9.0-pre0-822-g12e3bc5c20
frame.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Robin Gareus <robin@gareus.org>
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 _WIDGETS_FRAME_H_
20 #define _WIDGETS_FRAME_H_
21 
22 #include <optional>
23 #include <ytkmm/bin.h>
24 
25 #include "gtkmm2ext/colors.h"
26 #include "gtkmm2ext/cairo_theme.h"
27 #include "widgets/visibility.h"
28 
29 namespace ArdourWidgets {
30 
31 class LIBWIDGETS_API Frame : public Gtk::Bin, public Gtkmm2ext::CairoTheme
32 {
33 public:
34  enum Orientation {
36  Vertical
37  };
38 
39  Frame (Orientation orientation = Horizontal, bool force_boxy = false);
40  ~Frame ();
41 
42  void set_label (std::string const&);
43  void set_padding (int);
46 
47  void set_draw (bool yn);
48  bool draw() const { return _draw; }
49 
50 protected:
51  void on_add (Gtk::Widget*);
52  void on_remove (Gtk::Widget*);
53  void on_size_request (GtkRequisition*);
54  void on_size_allocate (Gtk::Allocation&);
55  bool on_expose_event (GdkEventExpose*);
56  void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
57  void on_name_changed ();
58 
59 private:
60  Glib::RefPtr<Gtk::Style> get_parent_style ();
61 
63  Gtk::Widget* _w;
64  Gtk::Widget* _current_parent;
65  sigc::connection _parent_style_change;
66  Glib::RefPtr<Pango::Layout> _layout;
67  std::string _label_text;
68  std::optional<Gdk::Color> _edge_color;
69  GtkRequisition _min_size;
70 
71  int _border;
72  int _padding;
78  int _alloc_x0;
79  int _alloc_y0;
80  bool _boxy;
81  bool _draw;
82 };
83 
84 } // namespace ArdourWidgets
85 
86 #endif
void on_size_request(GtkRequisition *)
sigc::connection _parent_style_change
Definition: frame.h:65
void set_label(std::string const &)
void on_add(Gtk::Widget *)
void on_size_allocate(Gtk::Allocation &)
bool draw() const
Definition: frame.h:48
bool on_expose_event(GdkEventExpose *)
GtkRequisition _min_size
Definition: frame.h:69
Gtk::Widget * _current_parent
Definition: frame.h:64
Gtk::Widget * _w
Definition: frame.h:63
void set_draw(bool yn)
std::string _label_text
Definition: frame.h:67
Orientation _orientation
Definition: frame.h:62
Frame(Orientation orientation=Horizontal, bool force_boxy=false)
void set_edge_color(Gtkmm2ext::Color)
Glib::RefPtr< Pango::Layout > _layout
Definition: frame.h:66
Glib::RefPtr< Gtk::Style > get_parent_style()
void on_remove(Gtk::Widget *)
std::optional< Gdk::Color > _edge_color
Definition: frame.h:68
void on_style_changed(const Glib::RefPtr< Gtk::Style > &)
@ Horizontal
Definition: editing.h:250
@ Vertical
Definition: editing.h:249
uint32_t Color
Definition: colors.h:33
#define LIBWIDGETS_API