2 * Copyright (C) 2011-2016 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef __gtk2_ardour_shuttle_control_h__
21 #define __gtk2_ardour_shuttle_control_h__
23 #include <gtkmm/drawingarea.h>
25 #include "pbd/controllable.h"
27 #include "ardour/session_handle.h"
28 #include "ardour/types.h"
30 #include "gtkmm2ext/cairo_widget.h"
32 #include "widgets/ardour_button.h"
33 #include "widgets/binding_proxy.h"
39 class ShuttleControl : public CairoWidget, public ARDOUR::SessionHandlePtr
45 void map_transport_state ();
46 void set_shuttle_fract (double, bool zero_ok = false);
47 double get_shuttle_fract () const { return shuttle_fract; }
48 void set_session (ARDOUR::Session*);
50 struct ShuttleControllable : public PBD::Controllable {
51 ShuttleControllable (ShuttleControl&);
52 void set_value (double, PBD::Controllable::GroupControlDisposition group_override);
53 double get_value (void) const;
55 double lower() const { return -1.0; }
56 double upper() const { return 1.0; }
61 boost::shared_ptr<ShuttleControllable> controllable() const { return _controllable; }
64 ArdourWidgets::ArdourButton* info_button () { return &_info_button; }
68 float shuttle_max_speed;
69 float last_speed_displayed;
71 double shuttle_speed_on_grab;
72 double requested_speed;
74 boost::shared_ptr<ShuttleControllable> _controllable;
75 cairo_pattern_t* pattern;
76 cairo_pattern_t* shine_pattern;
77 ARDOUR::microseconds_t last_shuttle_request;
78 PBD::ScopedConnection parameter_connection;
79 ArdourWidgets::ArdourButton _info_button;
80 Gtk::Menu* shuttle_context_menu;
81 ArdourWidgets::BindingProxy binding_proxy;
82 float bg_r, bg_g, bg_b;
83 void build_shuttle_context_menu ();
84 void shuttle_style_changed();
85 void set_shuttle_max_speed (float);
88 bool on_enter_notify_event (GdkEventCrossing*);
89 bool on_leave_notify_event (GdkEventCrossing*);
90 bool on_button_press_event (GdkEventButton*);
91 bool on_button_release_event(GdkEventButton*);
92 bool on_scroll_event (GdkEventScroll*);
93 bool on_motion_notify_event(GdkEventMotion*);
95 void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
97 void on_size_allocate (Gtk::Allocation&);
98 bool on_query_tooltip (int, int, bool, const Glib::RefPtr<Gtk::Tooltip>&);
100 gint mouse_shuttle (double x, bool force);
101 void use_shuttle_fract (bool force, bool zero_ok = false);
102 void parameter_changed (std::string);
104 void set_shuttle_units (ARDOUR::ShuttleUnits);
105 void set_shuttle_style (ARDOUR::ShuttleBehaviour);
107 int speed_as_semitones (float, bool&);
108 int fract_as_semitones (float, bool&);
110 float semitones_as_speed (int, bool);
111 float semitones_as_fract (int, bool);
114 #endif /* __gtk2_ardour_shuttle_control_h__ */