ardour
ardour_knob.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 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 #ifndef __gtk2_ardour_ardour_knob_h__
20 #define __gtk2_ardour_ardour_knob_h__
21 
22 #include <list>
23 #include <stdint.h>
24 
25 #include <gtkmm/action.h>
26 
27 #include "pbd/signals.h"
29 #include "gtkmm2ext/activatable.h"
30 #include "gtkmm2ext/cairo_widget.h"
32 
34 {
35 public:
36  KnobPersistentTooltip (Gtk::Widget* w);
37 
38  void start_drag ();
39  void stop_drag ();
40  bool dragging () const;
41 
42 private:
43  bool _dragging;
44 };
45 
46 
48 {
49 public:
50 
51  enum Element {
52  Arc = 0x1,
53  Bevel = 0x2,
54  unused2 = 0x4,
55  unused3 = 0x8,
56  unused4 = 0x10,
57  unused5 = 0x20,
58  };
59 
60  enum Flags {
61  NoFlags = 0,
62  Detent = 0x1,
63  ArcToZero = 0x2,
64  };
65 
67  virtual ~ArdourKnob ();
68 
69  void set_active_state (Gtkmm2ext::ActiveState);
70  void set_visual_state (Gtkmm2ext::VisualState);
71 
72  Element elements() const { return _elements; }
73  void set_elements (Element);
74  void add_elements (Element);
76 
77  void set_tooltip_prefix (std::string pfx) { _tooltip_prefix = pfx; }
78 
81 
82  bool on_button_press_event (GdkEventButton*);
83  bool on_button_release_event (GdkEventButton*);
84  bool on_scroll_event (GdkEventScroll* ev);
85  bool on_motion_notify_event (GdkEventMotion *ev) ;
86 
87  void color_handler ();
88 
89  protected:
90  void render (cairo_t *, cairo_rectangle_t *);
91  void on_size_request (Gtk::Requisition* req);
92  void on_size_allocate (Gtk::Allocation&);
93  void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
94  void on_name_changed ();
95  bool on_enter_notify_event (GdkEventCrossing*);
96  bool on_leave_notify_event (GdkEventCrossing*);
97  bool on_focus_in_event (GdkEventFocus*);
98  bool on_focus_out_event (GdkEventFocus*);
99 
100  void controllable_changed ();
102 
103 
104  private:
106 
108 
109  bool _hovering;
110  float _grabbed_x;
111  float _grabbed_y;
112 
113  float _val; // current value [0..1]
114  float _normal; // default value, arc
116 
118 
121  void action_tooltip_changed ();
122 
123  std::string _tooltip_prefix;
125 };
126 
127 #endif /* __gtk2_ardour_ardour_knob_h__ */
bool on_focus_in_event(GdkEventFocus *)
Definition: ardour_knob.cc:519
KnobPersistentTooltip _tooltip
Definition: ardour_knob.h:124
void set_tooltip_prefix(std::string pfx)
Definition: ardour_knob.h:77
void set_elements(Element)
Definition: ardour_knob.cc:553
void on_style_changed(const Glib::RefPtr< Gtk::Style > &)
Definition: ardour_knob.cc:491
boost::shared_ptr< PBD::Controllable > get_controllable() const
Definition: binding_proxy.h:48
float _val
Definition: ardour_knob.h:113
float _grabbed_x
Definition: ardour_knob.h:110
bool on_scroll_event(GdkEventScroll *ev)
Definition: ardour_knob.cc:292
void add_elements(Element)
Definition: ardour_knob.cc:559
bool dragging() const
Definition: ardour_knob.cc:584
Element elements() const
Definition: ardour_knob.h:72
float _normal
Definition: ardour_knob.h:114
void render(cairo_t *, cairo_rectangle_t *)
Definition: ardour_knob.cc:80
virtual ~ArdourKnob()
Definition: ardour_knob.cc:75
float _grabbed_y
Definition: ardour_knob.h:111
static Element default_elements
Definition: ardour_knob.h:75
std::string _tooltip_prefix
Definition: ardour_knob.h:123
void on_size_request(Gtk::Requisition *req)
Definition: ardour_knob.cc:277
void action_tooltip_changed()
bool on_focus_out_event(GdkEventFocus *)
Definition: ardour_knob.cc:526
void set_controllable(boost::shared_ptr< PBD::Controllable > c)
Definition: ardour_knob.cc:455
KnobPersistentTooltip(Gtk::Widget *w)
Definition: ardour_knob.cc:565
void color_handler()
Definition: ardour_knob.cc:443
float _dead_zone_delta
Definition: ardour_knob.h:115
bool on_leave_notify_event(GdkEventCrossing *)
Definition: ardour_knob.cc:543
Element _elements
Definition: ardour_knob.h:105
void set_active_state(Gtkmm2ext::ActiveState)
Definition: ardour_knob.cc:504
void action_visibility_changed()
void set_visual_state(Gtkmm2ext::VisualState)
Definition: ardour_knob.cc:511
void on_size_allocate(Gtk::Allocation &)
Definition: ardour_knob.cc:449
bool on_button_press_event(GdkEventButton *)
Definition: ardour_knob.cc:390
boost::shared_ptr< PBD::Controllable > get_controllable()
Definition: ardour_knob.h:79
void action_sensitivity_changed()
void controllable_changed()
Definition: ardour_knob.cc:471
ArdourKnob(Element e=default_elements, Flags flags=NoFlags)
Definition: ardour_knob.cc:58
PBD::ScopedConnection watch_connection
Definition: ardour_knob.h:101
bool _hovering
Definition: ardour_knob.h:109
Flags _flags
Definition: ardour_knob.h:117
bool on_button_release_event(GdkEventButton *)
Definition: ardour_knob.cc:423
BindingProxy binding_proxy
Definition: ardour_knob.h:107
void on_name_changed()
Definition: ardour_knob.cc:497
bool on_enter_notify_event(GdkEventCrossing *)
Definition: ardour_knob.cc:533
bool on_motion_notify_event(GdkEventMotion *ev)
Definition: ardour_knob.cc:321