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"
|
|
|
|
|
2011-04-19 22:48:20 -04:00
|
|
|
#include "pbd/controllable.h"
|
|
|
|
#include "ardour/session_handle.h"
|
|
|
|
|
|
|
|
namespace Gtk {
|
|
|
|
class Menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "ardour/types.h"
|
|
|
|
|
2012-12-06 14:09:16 -05:00
|
|
|
class ShuttleControl : public CairoWidget, public ARDOUR::SessionHandlePtr
|
2011-04-19 22:48:20 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShuttleControl ();
|
|
|
|
~ShuttleControl ();
|
|
|
|
|
|
|
|
void map_transport_state ();
|
|
|
|
void update_speed_display ();
|
2013-01-17 09:48:17 -05: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&);
|
|
|
|
void set_value (double);
|
|
|
|
double get_value (void) const;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-01-17 09:48:17 -05:00
|
|
|
double lower() const { return -1.0; }
|
|
|
|
double upper() const { return 1.0; }
|
|
|
|
|
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; }
|
2011-04-19 22:48:20 -04:00
|
|
|
|
|
|
|
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;
|
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;
|
|
|
|
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;
|
2011-04-19 22:48:20 -04:00
|
|
|
|
|
|
|
void build_shuttle_context_menu ();
|
|
|
|
void show_shuttle_context_menu ();
|
|
|
|
void shuttle_style_changed();
|
|
|
|
void shuttle_unit_clicked ();
|
|
|
|
void set_shuttle_max_speed (float);
|
|
|
|
|
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
|
|
|
|
|
|
|
void render (cairo_t *);
|
|
|
|
|
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
|
|
|
|
2013-01-17 09:48:17 -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__ */
|