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
|
|
|
{
|
2014-09-05 18:41:56 -04:00
|
|
|
public:
|
2011-10-27 07:53:16 -04:00
|
|
|
enum Element {
|
|
|
|
Edge = 0x1,
|
|
|
|
Body = 0x2,
|
|
|
|
Text = 0x4,
|
|
|
|
Indicator = 0x8,
|
2014-08-22 12:45:34 -04:00
|
|
|
unused = 0x10,
|
2014-03-23 19:11:42 -04:00
|
|
|
Menu = 0x20,
|
2014-08-29 15:08:49 -04:00
|
|
|
Inactive = 0x40, // no _action is defined AND state is not used
|
2014-09-02 23:18:45 -04:00
|
|
|
RecButton = 0x80, // tentative, see commit message
|
|
|
|
RecTapeMode = 0x100, // tentative
|
2014-09-03 16:07:25 -04:00
|
|
|
CloseCross = 0x200, // tentative
|
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
|
|
|
|
|
|
|
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 {
|
2014-09-03 12:56:31 -04:00
|
|
|
Square = 0x1,
|
2014-09-07 12:50:34 -04:00
|
|
|
TrackHeader = 0x2,
|
2014-08-22 12:45:34 -04:00
|
|
|
unused3 = 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);
|
|
|
|
|
2014-08-22 12:45:34 -04:00
|
|
|
void set_act_on_release (bool onRelease) { _act_on_release = onRelease; }
|
|
|
|
|
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);
|
2014-09-05 18:41:56 -04:00
|
|
|
|
2011-10-27 07:53:16 -04:00
|
|
|
void set_corner_radius (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;}
|
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);
|
|
|
|
|
2014-09-05 18:41:56 -04:00
|
|
|
void set_layout_ellisize_width (int w);
|
2014-10-21 17:25:50 -04:00
|
|
|
void set_layout_font (const Pango::FontDescription&);
|
2014-09-05 18:41:56 -04:00
|
|
|
void set_text_ellipsize (Pango::EllipsizeMode);
|
2014-10-21 17:25:50 -04:00
|
|
|
|
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(); }
|
2014-09-05 18:41:56 -04:00
|
|
|
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-08-28 15:25:19 -04:00
|
|
|
void set_fixed_colors (const uint32_t active_color, const uint32_t inactive_color);
|
|
|
|
|
|
|
|
void set_fallthrough_to_parent(bool fall) { _fallthrough_to_parent = fall; }
|
2014-03-06 08:05:33 -05:00
|
|
|
|
2014-09-02 13:23:18 -04:00
|
|
|
unsigned int char_pixel_width() { if (_char_pixel_width < 1) recalc_char_pixel_geometry() ; return _char_pixel_width; }
|
|
|
|
unsigned int char_pixel_height() { if (_char_pixel_height < 1) recalc_char_pixel_geometry() ; return _char_pixel_height; }
|
2014-09-07 12:50:34 -04:00
|
|
|
float char_avg_pixel_width() { if (_char_pixel_width < 1) recalc_char_pixel_geometry() ; return _char_avg_pixel_width; }
|
2014-09-02 13:23:18 -04:00
|
|
|
|
2014-09-05 18:41:56 -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 ();
|
2014-09-05 18:41:56 -04:00
|
|
|
void on_realize ();
|
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
|
|
|
|
2014-09-05 18:41:56 -04:00
|
|
|
protected:
|
2011-10-26 17:01:14 -04:00
|
|
|
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
|
|
|
|
2014-09-02 13:23:18 -04:00
|
|
|
void recalc_char_pixel_geometry ();
|
|
|
|
unsigned int _char_pixel_width;
|
|
|
|
unsigned int _char_pixel_height;
|
2014-09-07 12:50:34 -04:00
|
|
|
float _char_avg_pixel_width;
|
2014-09-02 13:23:18 -04:00
|
|
|
|
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
|
|
|
|
2014-08-22 12:45:34 -04:00
|
|
|
uint32_t fill_inactive_color;
|
|
|
|
uint32_t fill_active_color;
|
|
|
|
|
|
|
|
uint32_t text_active_color;
|
|
|
|
uint32_t text_inactive_color;
|
|
|
|
|
|
|
|
uint32_t led_active_color;
|
|
|
|
uint32_t led_inactive_color;
|
2014-09-05 18:41:56 -04:00
|
|
|
|
2014-08-22 12:45:34 -04:00
|
|
|
cairo_pattern_t* convex_pattern;
|
|
|
|
cairo_pattern_t* concave_pattern;
|
2011-10-26 17:01:14 -04:00
|
|
|
cairo_pattern_t* led_inset_pattern;
|
2011-11-24 00:36:31 -05:00
|
|
|
cairo_rectangle_t* _led_rect;
|
|
|
|
|
|
|
|
bool _act_on_release;
|
2011-10-27 16:10:49 -04:00
|
|
|
bool _led_left;
|
|
|
|
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;
|
2014-08-28 15:25:19 -04:00
|
|
|
bool _fallthrough_to_parent;
|
2014-09-05 18:41:56 -04:00
|
|
|
int _layout_ellipsize_width;
|
|
|
|
Pango::EllipsizeMode _ellipsis;
|
2014-09-05 20:04:59 -04:00
|
|
|
bool _update_colors;
|
|
|
|
int _pattern_height;
|
2014-09-05 18:41:56 -04:00
|
|
|
|
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-09-05 18:41:56 -04:00
|
|
|
void build_patterns ();
|
|
|
|
void ensure_layout ();
|
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__ */
|