2011-10-26 17:01:14 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __gtk2_ardour_ardour_button_h__
|
|
|
|
#define __gtk2_ardour_ardour_button_h__
|
|
|
|
|
2011-11-03 17:35:20 -04:00
|
|
|
#include <list>
|
2011-10-26 17:01:14 -04:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2011-10-29 11:54:30 -04:00
|
|
|
#include <gtkmm/action.h>
|
|
|
|
|
|
|
|
#include "pbd/signals.h"
|
|
|
|
#include "gtkmm2ext/binding_proxy.h"
|
2011-11-24 00:36:31 -05:00
|
|
|
#include "gtkmm2ext/activatable.h"
|
2011-12-07 08:57:45 -05:00
|
|
|
#include "gtkmm2ext/cairo_widget.h"
|
2011-10-26 17:01:14 -04:00
|
|
|
|
2011-11-24 00:36:31 -05:00
|
|
|
class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
|
2011-10-26 17:01:14 -04:00
|
|
|
{
|
|
|
|
public:
|
2011-10-27 07:53:16 -04:00
|
|
|
enum Element {
|
|
|
|
Edge = 0x1,
|
|
|
|
Body = 0x2,
|
|
|
|
Text = 0x4,
|
|
|
|
Indicator = 0x8,
|
2014-03-26 12:31:35 -04:00
|
|
|
Inset = 0x10,
|
2014-03-23 19:11:42 -04:00
|
|
|
Menu = 0x20,
|
2011-10-27 07:53:16 -04:00
|
|
|
};
|
2011-11-07 14:14:31 -05:00
|
|
|
|
2011-10-27 07:53:16 -04:00
|
|
|
static Element default_elements;
|
|
|
|
static Element led_default_elements;
|
2011-10-29 11:54:30 -04:00
|
|
|
static Element just_led_default_elements;
|
2011-10-27 07:53:16 -04:00
|
|
|
|
2012-05-21 08:31:05 -04:00
|
|
|
static void set_flat_buttons (bool yn);
|
|
|
|
static bool flat_buttons() { return _flat_buttons; }
|
|
|
|
|
2011-10-27 07:53:16 -04:00
|
|
|
ArdourButton (Element e = default_elements);
|
2011-11-03 17:35:20 -04:00
|
|
|
ArdourButton (const std::string&, Element e = default_elements);
|
2011-10-26 17:01:14 -04:00
|
|
|
virtual ~ArdourButton ();
|
|
|
|
|
2011-11-07 14:14:31 -05:00
|
|
|
enum Tweaks {
|
|
|
|
ShowClick = 0x1,
|
2012-12-06 15:48:44 -05:00
|
|
|
NoModel = 0x2,
|
2012-12-11 21:22:12 -05:00
|
|
|
ImplicitUsesSolidColor = 0x4,
|
2011-11-07 14:14:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
Tweaks tweaks() const { return _tweaks; }
|
|
|
|
void set_tweaks (Tweaks);
|
|
|
|
|
2011-11-03 17:35:20 -04:00
|
|
|
void set_active_state (Gtkmm2ext::ActiveState);
|
|
|
|
void set_visual_state (Gtkmm2ext::VisualState);
|
|
|
|
|
2011-10-27 07:53:16 -04:00
|
|
|
Element elements() const { return _elements; }
|
2012-02-06 13:38:02 -05:00
|
|
|
void set_elements (Element);
|
2012-12-06 15:48:44 -05:00
|
|
|
void add_elements (Element);
|
2012-02-06 13:38:02 -05:00
|
|
|
|
2011-10-27 07:53:16 -04:00
|
|
|
void set_corner_radius (float);
|
2012-02-02 23:17:25 -05:00
|
|
|
void set_rounded_corner_mask (int);
|
2011-10-27 16:10:49 -04:00
|
|
|
void set_diameter (float);
|
2011-10-26 17:01:14 -04:00
|
|
|
|
|
|
|
void set_text (const std::string&);
|
2014-03-23 19:11:42 -04:00
|
|
|
const std::string& get_text () {return _text;}
|
2011-10-26 17:01:14 -04:00
|
|
|
void set_markup (const std::string&);
|
2013-07-03 12:56:30 -04:00
|
|
|
void set_angle (const double);
|
2013-07-04 21:04:40 -04:00
|
|
|
void set_alignment (const float, const float);
|
|
|
|
void get_alignment (float& xa, float& ya) {xa = _xalign; ya = _yalign;};
|
2011-10-26 17:01:14 -04:00
|
|
|
|
|
|
|
void set_led_left (bool yn);
|
|
|
|
void set_distinct_led_click (bool yn);
|
|
|
|
|
2011-12-01 11:57:29 -05:00
|
|
|
Glib::RefPtr<Pango::Layout> layout() const { return _layout; }
|
|
|
|
|
2011-10-27 07:53:16 -04:00
|
|
|
sigc::signal<void> signal_led_clicked;
|
2011-11-11 12:24:05 -05:00
|
|
|
sigc::signal<void> signal_clicked;
|
2011-10-26 17:01:14 -04:00
|
|
|
|
2011-10-29 11:54:30 -04:00
|
|
|
boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
|
|
|
|
void set_controllable (boost::shared_ptr<PBD::Controllable> c);
|
2011-11-24 00:36:31 -05:00
|
|
|
void watch ();
|
2011-10-29 11:54:30 -04:00
|
|
|
|
|
|
|
void set_related_action (Glib::RefPtr<Gtk::Action>);
|
|
|
|
|
2011-11-02 12:46:49 -04:00
|
|
|
bool on_button_press_event (GdkEventButton*);
|
|
|
|
bool on_button_release_event (GdkEventButton*);
|
|
|
|
|
2011-11-02 14:47:14 -04:00
|
|
|
void set_image (const Glib::RefPtr<Gdk::Pixbuf>&);
|
|
|
|
|
2014-03-06 08:05:33 -05:00
|
|
|
void set_fixed_colors (const uint32_t active_color, const uint32_t inactive_color);
|
|
|
|
|
2011-10-26 17:01:14 -04:00
|
|
|
protected:
|
2014-03-20 18:50:40 -04:00
|
|
|
void render (cairo_t *, cairo_rectangle_t *);
|
2011-10-27 16:10:49 -04:00
|
|
|
void on_size_request (Gtk::Requisition* req);
|
2011-10-27 07:53:16 -04:00
|
|
|
void on_size_allocate (Gtk::Allocation&);
|
2011-10-31 11:28:21 -04:00
|
|
|
void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
|
2014-03-06 09:49:00 -05:00
|
|
|
void on_name_changed ();
|
2011-11-07 14:14:31 -05:00
|
|
|
bool on_enter_notify_event (GdkEventCrossing*);
|
|
|
|
bool on_leave_notify_event (GdkEventCrossing*);
|
2014-06-13 17:50:07 -04:00
|
|
|
bool on_focus_in_event (GdkEventFocus*);
|
|
|
|
bool on_focus_out_event (GdkEventFocus*);
|
|
|
|
bool on_key_release_event (GdkEventKey *);
|
2011-10-26 17:01:14 -04:00
|
|
|
|
2011-11-24 00:36:31 -05:00
|
|
|
void controllable_changed ();
|
|
|
|
PBD::ScopedConnection watch_connection;
|
2011-10-29 11:54:30 -04:00
|
|
|
|
2011-10-26 17:01:14 -04:00
|
|
|
private:
|
|
|
|
Glib::RefPtr<Pango::Layout> _layout;
|
2011-11-02 14:47:14 -04:00
|
|
|
Glib::RefPtr<Gdk::Pixbuf> _pixbuf;
|
2011-10-27 16:10:49 -04:00
|
|
|
std::string _text;
|
|
|
|
Element _elements;
|
2011-11-07 14:14:31 -05:00
|
|
|
Tweaks _tweaks;
|
2011-11-24 00:36:31 -05:00
|
|
|
BindingProxy binding_proxy;
|
2011-10-27 16:10:49 -04:00
|
|
|
|
|
|
|
int _text_width;
|
|
|
|
int _text_height;
|
|
|
|
float _diameter;
|
|
|
|
float _corner_radius;
|
2012-02-02 23:17:25 -05:00
|
|
|
int _corner_mask;
|
2011-10-26 17:01:14 -04:00
|
|
|
|
2013-07-03 12:56:30 -04:00
|
|
|
double _angle;
|
2013-07-04 21:04:40 -04:00
|
|
|
float _xalign, _yalign;
|
2013-07-03 12:56:30 -04:00
|
|
|
|
2012-12-06 15:48:44 -05:00
|
|
|
uint32_t bg_color;
|
2012-11-16 14:27:39 -05:00
|
|
|
uint32_t border_color;
|
2014-03-05 17:51:51 -05:00
|
|
|
uint32_t fill_start_inactive_color;
|
|
|
|
uint32_t fill_end_inactive_color;
|
|
|
|
uint32_t fill_start_active_color;
|
|
|
|
uint32_t fill_end_active_color;
|
|
|
|
uint32_t text_active_color;
|
|
|
|
uint32_t text_inactive_color;
|
|
|
|
uint32_t led_active_color;
|
|
|
|
uint32_t led_inactive_color;
|
|
|
|
|
2012-11-16 14:27:39 -05:00
|
|
|
cairo_pattern_t* fill_pattern;
|
|
|
|
cairo_pattern_t* fill_pattern_active;
|
|
|
|
cairo_pattern_t* shine_pattern;
|
2011-10-26 17:01:14 -04:00
|
|
|
cairo_pattern_t* led_inset_pattern;
|
|
|
|
cairo_pattern_t* reflection_pattern;
|
2014-03-05 17:51:51 -05:00
|
|
|
|
2011-11-24 00:36:31 -05:00
|
|
|
cairo_rectangle_t* _led_rect;
|
|
|
|
|
2011-10-26 17:01:14 -04:00
|
|
|
double text_r;
|
|
|
|
double text_g;
|
|
|
|
double text_b;
|
|
|
|
double text_a;
|
|
|
|
|
|
|
|
double led_r;
|
|
|
|
double led_g;
|
|
|
|
double led_b;
|
|
|
|
double led_a;
|
|
|
|
|
2012-02-07 12:43:55 -05:00
|
|
|
double active_r;
|
|
|
|
double active_g;
|
|
|
|
double active_b;
|
|
|
|
double active_a;
|
|
|
|
|
2011-11-24 00:36:31 -05:00
|
|
|
bool _act_on_release;
|
2011-10-27 16:10:49 -04:00
|
|
|
bool _led_left;
|
|
|
|
bool _fixed_diameter;
|
|
|
|
bool _distinct_led_click;
|
2011-11-07 14:14:31 -05:00
|
|
|
bool _hovering;
|
2014-06-13 17:50:07 -04:00
|
|
|
bool _focused;
|
2014-07-06 13:55:49 -04:00
|
|
|
bool _fixed_colors_set;
|
2013-10-12 14:56:57 -04:00
|
|
|
|
2012-05-21 08:31:05 -04:00
|
|
|
static bool _flat_buttons;
|
|
|
|
|
2011-10-31 14:32:19 -04:00
|
|
|
void setup_led_rect ();
|
2011-10-27 16:10:49 -04:00
|
|
|
void set_colors ();
|
2011-10-26 17:01:14 -04:00
|
|
|
void color_handler ();
|
2014-03-05 17:51:51 -05:00
|
|
|
void build_patterns ();
|
2011-10-29 11:54:30 -04:00
|
|
|
|
|
|
|
void action_toggled ();
|
2011-11-10 13:04:34 -05:00
|
|
|
|
|
|
|
void action_sensitivity_changed ();
|
|
|
|
void action_visibility_changed ();
|
|
|
|
void action_tooltip_changed ();
|
2011-10-26 17:01:14 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __gtk2_ardour_ardour_button_h__ */
|