Remove unused declaration.
[ardour.git] / gtk2_ardour / ardour_button.h
1 /*
2     Copyright (C) 2010 Paul Davis
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
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __gtk2_ardour_ardour_button_h__
21 #define __gtk2_ardour_ardour_button_h__
22
23 #include <list>
24 #include <stdint.h>
25
26 #include <gtkmm/action.h>
27
28 #include "pbd/signals.h"
29 #include "gtkmm2ext/binding_proxy.h"
30 #include "gtkmm2ext/activatable.h"
31 #include "gtkmm2ext/cairo_widget.h"
32
33 class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
34 {
35   public:
36         enum Element {
37                 Edge = 0x1,
38                 Body = 0x2,
39                 Text = 0x4,
40                 Indicator = 0x8,
41         };
42
43         static Element default_elements;
44         static Element led_default_elements;
45         static Element just_led_default_elements;
46
47         ArdourButton (Element e = default_elements);
48         ArdourButton (const std::string&, Element e = default_elements);
49         virtual ~ArdourButton ();
50
51         enum Tweaks {
52                 ShowClick = 0x1,
53                 NoModel = 0x4,
54         };
55
56         Tweaks tweaks() const { return _tweaks; }
57         void set_tweaks (Tweaks);
58
59         void set_active_state (Gtkmm2ext::ActiveState);
60         void set_visual_state (Gtkmm2ext::VisualState);
61
62         Element elements() const { return _elements; }
63
64         void set_corner_radius (float);
65         void set_diameter (float);
66
67         void set_text (const std::string&);
68         void set_markup (const std::string&);
69
70         void set_led_left (bool yn);
71         void set_distinct_led_click (bool yn);
72
73         Glib::RefPtr<Pango::Layout> layout() const { return _layout; }
74
75         sigc::signal<void> signal_led_clicked;
76         sigc::signal<void> signal_clicked;
77
78         boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
79         void set_controllable (boost::shared_ptr<PBD::Controllable> c);
80         void watch ();
81
82         void set_related_action (Glib::RefPtr<Gtk::Action>);
83
84         bool on_button_press_event (GdkEventButton*);
85         bool on_button_release_event (GdkEventButton*);
86
87         void set_image (const Glib::RefPtr<Gdk::Pixbuf>&);
88
89   protected:
90         void render (cairo_t *);
91         void on_size_request (Gtk::Requisition* req);
92         void on_size_allocate (Gtk::Allocation&);
93         void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
94         bool on_enter_notify_event (GdkEventCrossing*);
95         bool on_leave_notify_event (GdkEventCrossing*);
96
97         void controllable_changed ();
98         PBD::ScopedConnection watch_connection;
99
100   private:
101         Glib::RefPtr<Pango::Layout> _layout;
102         Glib::RefPtr<Gdk::Pixbuf>   _pixbuf;
103         std::string                 _text;
104         Element                     _elements;
105         Tweaks                      _tweaks;
106         BindingProxy                binding_proxy;
107
108         int   _text_width;
109         int   _text_height;
110         float _diameter;
111         float _corner_radius;
112
113         cairo_pattern_t* edge_pattern;
114         cairo_pattern_t* fill_pattern;
115         cairo_pattern_t* led_inset_pattern;
116         cairo_pattern_t* reflection_pattern;
117
118         cairo_rectangle_t* _led_rect;
119
120         double text_r;
121         double text_g;
122         double text_b;
123         double text_a;
124
125         double led_r;
126         double led_g;
127         double led_b;
128         double led_a;
129
130         bool _act_on_release;
131         bool _led_left;
132         bool _fixed_diameter;
133         bool _distinct_led_click;
134         bool _hovering;
135
136         void setup_led_rect ();
137         void set_colors ();
138         void color_handler ();
139
140         void action_toggled ();
141
142         void action_sensitivity_changed ();
143         void action_visibility_changed ();
144         void action_tooltip_changed ();
145 };
146
147 #endif /* __gtk2_ardour_ardour_button_h__ */