2011-04-19 22:48:20 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2011 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_shuttle_control_h__
|
|
|
|
#define __gtk2_ardour_shuttle_control_h__
|
|
|
|
|
|
|
|
#include <gtkmm/drawingarea.h>
|
|
|
|
|
2011-04-20 01:07:41 -04:00
|
|
|
#include "gtkmm2ext/binding_proxy.h"
|
2015-01-05 00:14:30 -05:00
|
|
|
#include "gtkmm2ext/cairo_widget.h"
|
2011-04-20 01:07:41 -04:00
|
|
|
|
2011-04-19 22:48:20 -04:00
|
|
|
#include "pbd/controllable.h"
|
2016-12-19 16:08:20 -05:00
|
|
|
|
2011-04-19 22:48:20 -04:00
|
|
|
#include "ardour/session_handle.h"
|
2016-12-19 16:08:20 -05:00
|
|
|
#include "ardour/types.h"
|
|
|
|
|
|
|
|
#include "ardour_button.h"
|
2011-04-19 22:48:20 -04:00
|
|
|
|
|
|
|
namespace Gtk {
|
|
|
|
class Menu;
|
|
|
|
}
|
|
|
|
|
2012-12-06 14:09:16 -05:00
|
|
|
class ShuttleControl : public CairoWidget, public ARDOUR::SessionHandlePtr
|
2011-04-19 22:48:20 -04:00
|
|
|
{
|
2016-12-19 16:08:20 -05:00
|
|
|
public:
|
2011-04-19 22:48:20 -04:00
|
|
|
ShuttleControl ();
|
|
|
|
~ShuttleControl ();
|
|
|
|
|
|
|
|
void map_transport_state ();
|
2015-03-10 05:52:44 -04:00
|
|
|
void set_shuttle_fract (double, bool zero_ok = false);
|
2011-04-19 22:48:20 -04:00
|
|
|
double get_shuttle_fract () const { return shuttle_fract; }
|
|
|
|
void set_session (ARDOUR::Session*);
|
|
|
|
|
|
|
|
struct ShuttleControllable : public PBD::Controllable {
|
|
|
|
ShuttleControllable (ShuttleControl&);
|
2016-01-02 04:58:23 -05:00
|
|
|
void set_value (double, PBD::Controllable::GroupControlDisposition group_override);
|
2011-04-19 22:48:20 -04:00
|
|
|
double get_value (void) const;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2016-12-19 16:08:20 -05:00
|
|
|
double lower() const { return -1.0; }
|
|
|
|
double upper() const { return 1.0; }
|
2013-01-17 09:48:17 -05:00
|
|
|
|
2011-04-19 22:48:20 -04:00
|
|
|
ShuttleControl& sc;
|
|
|
|
};
|
|
|
|
|
2011-04-20 01:07:41 -04:00
|
|
|
boost::shared_ptr<ShuttleControllable> controllable() const { return _controllable; }
|
2016-06-13 17:25:31 -04:00
|
|
|
void set_colors ();
|
2011-04-19 22:48:20 -04:00
|
|
|
|
2016-12-19 16:08:20 -05:00
|
|
|
ArdourButton* info_button () { return &_info_button; }
|
|
|
|
|
|
|
|
protected:
|
2012-12-06 14:09:16 -05:00
|
|
|
bool _hovering;
|
2011-04-19 22:48:20 -04:00
|
|
|
float shuttle_max_speed;
|
|
|
|
float last_speed_displayed;
|
|
|
|
bool shuttle_grabbed;
|
2011-05-13 13:25:02 -04:00
|
|
|
double shuttle_speed_on_grab;
|
2016-07-25 13:43:57 -04:00
|
|
|
double requested_speed;
|
2011-04-21 17:49:47 -04:00
|
|
|
float shuttle_fract;
|
2011-04-20 01:07:41 -04:00
|
|
|
boost::shared_ptr<ShuttleControllable> _controllable;
|
2011-04-19 22:48:20 -04:00
|
|
|
cairo_pattern_t* pattern;
|
2012-12-06 14:09:16 -05:00
|
|
|
cairo_pattern_t* shine_pattern;
|
2011-04-19 22:48:20 -04:00
|
|
|
ARDOUR::microseconds_t last_shuttle_request;
|
|
|
|
PBD::ScopedConnection parameter_connection;
|
2016-12-19 16:08:20 -05:00
|
|
|
ArdourButton _info_button;
|
2011-04-19 22:48:20 -04:00
|
|
|
Gtk::Menu* shuttle_unit_menu;
|
|
|
|
Gtk::Menu* shuttle_style_menu;
|
|
|
|
Gtk::Menu* shuttle_context_menu;
|
2011-04-20 01:07:41 -04:00
|
|
|
BindingProxy binding_proxy;
|
2016-06-13 17:25:31 -04:00
|
|
|
float bg_r, bg_g, bg_b;
|
2011-04-19 22:48:20 -04:00
|
|
|
void build_shuttle_context_menu ();
|
|
|
|
void shuttle_style_changed();
|
|
|
|
void set_shuttle_max_speed (float);
|
2015-08-21 22:32:14 -04:00
|
|
|
void reset_speed ();
|
2011-04-19 22:48:20 -04:00
|
|
|
|
2012-12-06 14:09:16 -05:00
|
|
|
bool on_enter_notify_event (GdkEventCrossing*);
|
|
|
|
bool on_leave_notify_event (GdkEventCrossing*);
|
2011-04-19 22:48:20 -04:00
|
|
|
bool on_button_press_event (GdkEventButton*);
|
|
|
|
bool on_button_release_event(GdkEventButton*);
|
|
|
|
bool on_scroll_event (GdkEventScroll*);
|
|
|
|
bool on_motion_notify_event(GdkEventMotion*);
|
2012-12-06 14:09:16 -05:00
|
|
|
|
2017-03-20 12:11:56 -04:00
|
|
|
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
|
2012-12-06 14:09:16 -05:00
|
|
|
|
2011-04-19 22:48:20 -04:00
|
|
|
void on_size_allocate (Gtk::Allocation&);
|
2011-04-20 18:53:41 -04:00
|
|
|
bool on_query_tooltip (int, int, bool, const Glib::RefPtr<Gtk::Tooltip>&);
|
2011-04-19 22:48:20 -04:00
|
|
|
|
2016-12-19 16:08:20 -05:00
|
|
|
gint mouse_shuttle (double x, bool force);
|
|
|
|
void use_shuttle_fract (bool force, bool zero_ok = false);
|
2011-04-19 22:48:20 -04:00
|
|
|
void parameter_changed (std::string);
|
|
|
|
|
|
|
|
void set_shuttle_units (ARDOUR::ShuttleUnits);
|
|
|
|
void set_shuttle_style (ARDOUR::ShuttleBehaviour);
|
2011-04-21 17:49:47 -04:00
|
|
|
|
2011-04-22 12:18:51 -04:00
|
|
|
int speed_as_semitones (float, bool&);
|
|
|
|
int fract_as_semitones (float, bool&);
|
|
|
|
|
|
|
|
float semitones_as_speed (int, bool);
|
|
|
|
float semitones_as_fract (int, bool);
|
2011-04-19 22:48:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __gtk2_ardour_shuttle_control_h__ */
|