2 Copyright (C) 2011 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_shuttle_control_h__
20 #define __gtk2_ardour_shuttle_control_h__
22 #include <gtkmm/drawingarea.h>
24 #include "gtkmm2ext/binding_proxy.h"
25 #include "gtkmm2ext/cairo_widget.h"
27 #include "pbd/controllable.h"
29 #include "ardour/session_handle.h"
30 #include "ardour/types.h"
32 #include "ardour_button.h"
38 class ShuttleControl : public CairoWidget, public ARDOUR::SessionHandlePtr
44 void map_transport_state ();
45 void set_shuttle_fract (double, bool zero_ok = false);
46 double get_shuttle_fract () const { return shuttle_fract; }
47 void set_session (ARDOUR::Session*);
49 struct ShuttleControllable : public PBD::Controllable {
50 ShuttleControllable (ShuttleControl&);
51 void set_value (double, PBD::Controllable::GroupControlDisposition group_override);
52 double get_value (void) const;
54 double lower() const { return -1.0; }
55 double upper() const { return 1.0; }
60 boost::shared_ptr<ShuttleControllable> controllable() const { return _controllable; }
63 ArdourButton* info_button () { return &_info_button; }
67 float shuttle_max_speed;
68 float last_speed_displayed;
70 double shuttle_speed_on_grab;
71 double requested_speed;
73 boost::shared_ptr<ShuttleControllable> _controllable;
74 cairo_pattern_t* pattern;
75 cairo_pattern_t* shine_pattern;
76 ARDOUR::microseconds_t last_shuttle_request;
77 PBD::ScopedConnection parameter_connection;
78 ArdourButton _info_button;
79 Gtk::Menu* shuttle_unit_menu;
80 Gtk::Menu* shuttle_style_menu;
81 Gtk::Menu* shuttle_context_menu;
82 BindingProxy binding_proxy;
83 float bg_r, bg_g, bg_b;
84 void build_shuttle_context_menu ();
85 void show_shuttle_context_menu ();
86 void shuttle_style_changed();
87 void shuttle_unit_clicked ();
88 void set_shuttle_max_speed (float);
91 bool on_enter_notify_event (GdkEventCrossing*);
92 bool on_leave_notify_event (GdkEventCrossing*);
93 bool on_button_press_event (GdkEventButton*);
94 bool on_button_release_event(GdkEventButton*);
95 bool on_scroll_event (GdkEventScroll*);
96 bool on_motion_notify_event(GdkEventMotion*);
98 void render (cairo_t *, cairo_rectangle_t*);
100 void on_size_allocate (Gtk::Allocation&);
101 bool on_query_tooltip (int, int, bool, const Glib::RefPtr<Gtk::Tooltip>&);
103 gint mouse_shuttle (double x, bool force);
104 void use_shuttle_fract (bool force, bool zero_ok = false);
105 void parameter_changed (std::string);
107 void set_shuttle_units (ARDOUR::ShuttleUnits);
108 void set_shuttle_style (ARDOUR::ShuttleBehaviour);
110 int speed_as_semitones (float, bool&);
111 int fract_as_semitones (float, bool&);
113 float semitones_as_speed (int, bool);
114 float semitones_as_fract (int, bool);
117 #endif /* __gtk2_ardour_shuttle_control_h__ */