new ArdourButton class, to start to provide more control over how our buttons work...
[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 <stdint.h>
24
25 #include <gtkmm/activatable.h>
26
27 #include "cairo_widget.h"
28
29 class ArdourButton : public CairoWidget, Gtk::Activatable
30 {
31   public:
32         ArdourButton ();
33         virtual ~ArdourButton ();
34
35         void set_diameter (float);
36
37         void set_text (const std::string&);
38         void set_markup (const std::string&);
39
40         void set_led_left (bool yn);
41         void set_distinct_led_click (bool yn);
42
43         sigc::signal<void> signal_clicked;
44
45         void set_state (State s, bool);
46
47   protected:
48         void render (cairo_t *);
49         void on_size_request (Gtk::Requisition* req);
50         void on_realize ();
51         bool on_button_press_event (GdkEventButton*);
52         bool on_button_release_event (GdkEventButton*);
53
54   private:
55         Glib::RefPtr<Pango::Layout> _layout;
56         std::string _text;
57         int     _text_width;
58         int     _text_height;
59         bool    _led_left;
60         float   _diameter;
61         bool    _fixed_diameter;
62         bool    _distinct_led_click;
63
64         cairo_pattern_t* edge_pattern;
65         cairo_pattern_t* fill_pattern;
66         cairo_pattern_t* led_inset_pattern;
67         cairo_pattern_t* reflection_pattern;
68
69         double text_r;
70         double text_g;
71         double text_b;
72         double text_a;
73
74         double led_r;
75         double led_g;
76         double led_b;
77         double led_a;
78
79         void set_colors ();
80         void color_handler ();
81 };
82
83 #endif /* __gtk2_ardour_ardour_button_h__ */