2 Copyright (C) 2010 Paul Davis
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.
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.
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.
20 #ifndef __gtk2_ardour_ardour_button_h__
21 #define __gtk2_ardour_ardour_button_h__
26 #include <gtkmm/action.h>
28 #include "pbd/signals.h"
29 #include "gtkmm2ext/binding_proxy.h"
31 #include "cairo_widget.h"
33 class ArdourButton : public CairoWidget
43 static Element default_elements;
44 static Element led_default_elements;
45 static Element just_led_default_elements;
47 ArdourButton (Element e = default_elements);
48 ArdourButton (const std::string&, Element e = default_elements);
49 virtual ~ArdourButton ();
56 Tweaks tweaks() const { return _tweaks; }
57 void set_tweaks (Tweaks);
59 void set_active_state (Gtkmm2ext::ActiveState);
60 void set_visual_state (Gtkmm2ext::VisualState);
62 /* this is an API simplification for buttons
63 that only use the Active and Normal active states.
65 void set_active (bool);
66 bool get_active () { return active_state() != Gtkmm2ext::ActiveState (0); }
68 void set_elements (Element);
69 Element elements() const { return _elements; }
71 void set_corner_radius (float);
72 void set_diameter (float);
74 void set_text (const std::string&);
75 void set_markup (const std::string&);
77 void set_led_left (bool yn);
78 void set_distinct_led_click (bool yn);
80 sigc::signal<void> signal_led_clicked;
81 sigc::signal<void> signal_clicked;
83 boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
84 void set_controllable (boost::shared_ptr<PBD::Controllable> c);
87 void set_related_action (Glib::RefPtr<Gtk::Action>);
89 bool on_button_press_event (GdkEventButton*);
90 bool on_button_release_event (GdkEventButton*);
92 void set_image (const Glib::RefPtr<Gdk::Pixbuf>&);
95 void render (cairo_t *);
96 void on_size_request (Gtk::Requisition* req);
97 void on_size_allocate (Gtk::Allocation&);
98 void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
99 bool on_enter_notify_event (GdkEventCrossing*);
100 bool on_leave_notify_event (GdkEventCrossing*);
102 void controllable_changed ();
103 PBD::ScopedConnection watch_connection;
106 Glib::RefPtr<Pango::Layout> _layout;
107 Glib::RefPtr<Gdk::Pixbuf> _pixbuf;
111 BindingProxy binding_proxy;
112 bool _act_on_release;
117 float _corner_radius;
119 cairo_pattern_t* edge_pattern;
120 cairo_pattern_t* fill_pattern;
121 cairo_pattern_t* led_inset_pattern;
122 cairo_pattern_t* reflection_pattern;
135 bool _fixed_diameter;
136 bool _distinct_led_click;
137 cairo_rectangle_t* _led_rect;
140 void setup_led_rect ();
142 void color_handler ();
144 Glib::RefPtr<Gtk::Action> _action;
145 void action_activated ();
146 void action_toggled ();
148 void action_sensitivity_changed ();
149 void action_visibility_changed ();
150 void action_tooltip_changed ();
153 #endif /* __gtk2_ardour_ardour_button_h__ */