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-10-26 17:01:14 -04:00
|
|
|
|
|
|
|
#include "cairo_widget.h"
|
|
|
|
|
2011-10-29 11:54:30 -04:00
|
|
|
class ArdourButton : public CairoWidget
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
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-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
|
|
|
void set_elements (Element);
|
|
|
|
Element elements() const { return _elements; }
|
|
|
|
|
|
|
|
void set_corner_radius (float);
|
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&);
|
|
|
|
void set_markup (const std::string&);
|
|
|
|
|
|
|
|
void set_led_left (bool yn);
|
|
|
|
void set_distinct_led_click (bool yn);
|
|
|
|
|
2011-10-27 07:53:16 -04:00
|
|
|
sigc::signal<void> signal_led_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);
|
|
|
|
void watch ();
|
|
|
|
|
|
|
|
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>&);
|
|
|
|
|
2011-10-26 17:01:14 -04:00
|
|
|
protected:
|
|
|
|
void render (cairo_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>&);
|
2011-10-26 17:01:14 -04:00
|
|
|
|
2011-10-29 11:54:30 -04:00
|
|
|
void controllable_changed ();
|
|
|
|
PBD::ScopedConnection watch_connection;
|
|
|
|
|
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-10-29 11:54:30 -04:00
|
|
|
BindingProxy binding_proxy;
|
|
|
|
bool _act_on_release;
|
2011-10-27 16:10:49 -04:00
|
|
|
|
|
|
|
int _text_width;
|
|
|
|
int _text_height;
|
|
|
|
float _diameter;
|
|
|
|
float _corner_radius;
|
2011-10-26 17:01:14 -04:00
|
|
|
|
|
|
|
cairo_pattern_t* edge_pattern;
|
|
|
|
cairo_pattern_t* fill_pattern;
|
|
|
|
cairo_pattern_t* led_inset_pattern;
|
|
|
|
cairo_pattern_t* reflection_pattern;
|
|
|
|
|
|
|
|
double text_r;
|
|
|
|
double text_g;
|
|
|
|
double text_b;
|
|
|
|
double text_a;
|
|
|
|
|
|
|
|
double led_r;
|
|
|
|
double led_g;
|
|
|
|
double led_b;
|
|
|
|
double led_a;
|
|
|
|
|
2011-10-27 16:10:49 -04:00
|
|
|
bool _led_left;
|
|
|
|
bool _fixed_diameter;
|
|
|
|
bool _distinct_led_click;
|
2011-10-31 14:32:19 -04:00
|
|
|
cairo_rectangle_t* _led_rect;
|
2011-10-27 16:10:49 -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 ();
|
2011-10-29 11:54:30 -04:00
|
|
|
|
|
|
|
Glib::RefPtr<Gtk::Action> _action;
|
|
|
|
void action_activated ();
|
|
|
|
void action_toggled ();
|
2011-10-26 17:01:14 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __gtk2_ardour_ardour_button_h__ */
|