2 Copyright (C) 2014 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.
19 #ifndef __gtk2_ardour_ardour_knob_h__
20 #define __gtk2_ardour_ardour_knob_h__
25 #include <gtkmm/action.h>
27 #include "pbd/signals.h"
29 #include "gtkmm2ext/activatable.h"
30 #include "gtkmm2ext/cairo_widget.h"
31 #include "gtkmm2ext/persistent_tooltip.h"
33 #include "widgets/binding_proxy.h"
34 #include "widgets/visibility.h"
36 namespace ArdourWidgets {
38 class LIBWIDGETS_API KnobPersistentTooltip : public Gtkmm2ext::PersistentTooltip
41 KnobPersistentTooltip (Gtk::Widget* w);
45 bool dragging () const;
52 class LIBWIDGETS_API ArdourKnob : public CairoWidget , public Gtkmm2ext::Activatable
71 ArdourKnob (Element e = default_elements, Flags flags = NoFlags);
72 virtual ~ArdourKnob ();
74 void set_active_state (Gtkmm2ext::ActiveState);
75 void set_visual_state (Gtkmm2ext::VisualState);
77 Element elements() const { return _elements; }
78 void set_elements (Element);
79 void add_elements (Element);
80 static Element default_elements;
82 void set_tooltip_prefix (std::string pfx) { _tooltip_prefix = pfx; controllable_changed (true); }
84 boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
85 void set_controllable (boost::shared_ptr<PBD::Controllable> c);
87 bool on_button_press_event (GdkEventButton*);
88 bool on_button_release_event (GdkEventButton*);
89 bool on_scroll_event (GdkEventScroll* ev);
90 bool on_motion_notify_event (GdkEventMotion *ev) ;
92 void color_handler ();
94 sigc::signal<void> StartGesture;
95 sigc::signal<void> StopGesture;
98 void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
99 void on_size_request (Gtk::Requisition* req);
100 void on_size_allocate (Gtk::Allocation&);
101 void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
102 void on_name_changed ();
103 bool on_enter_notify_event (GdkEventCrossing*);
104 bool on_leave_notify_event (GdkEventCrossing*);
105 bool on_focus_in_event (GdkEventFocus*);
106 bool on_focus_out_event (GdkEventFocus*);
108 void controllable_changed (bool force_update = false);
109 PBD::ScopedConnection watch_connection;
114 BindingProxy binding_proxy;
120 float _val; // current value [0..1]
121 float _normal; // default value, arc
122 float _dead_zone_delta;
126 void action_sensitivity_changed ();
127 void action_visibility_changed ();
128 void action_tooltip_changed ();
130 std::string _tooltip_prefix;
131 KnobPersistentTooltip _tooltip;
136 #endif /* __gtk2_ardour_ardour_knob_h__ */