factor out shuttle controller to its own class, new design
git-svn-id: svn://localhost/ardour2/branches/3.0@9391 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
c3f458816f
commit
718b2eab67
|
@ -103,6 +103,7 @@ typedef uint64_t microseconds_t;
|
|||
#include "public_editor.h"
|
||||
#include "route_time_axis.h"
|
||||
#include "session_metadata_dialog.h"
|
||||
#include "shuttle_control.h"
|
||||
#include "speaker_dialog.h"
|
||||
#include "splash.h"
|
||||
#include "startup.h"
|
||||
|
@ -155,7 +156,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
|
|||
auto_loop_controllable (new TransportControllable ("transport auto loop", *this, TransportControllable::AutoLoop)),
|
||||
play_selection_controllable (new TransportControllable ("transport play selection", *this, TransportControllable::PlaySelection)),
|
||||
rec_controllable (new TransportControllable ("transport rec-enable", *this, TransportControllable::RecordEnable)),
|
||||
shuttle_controllable (new TransportControllable ("shuttle", *this, TransportControllable::ShuttleControl)),
|
||||
shuttle_controller_binding_proxy (shuttle_controllable),
|
||||
|
||||
roll_button (roll_controllable),
|
||||
|
@ -166,8 +166,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
|
|||
play_selection_button (play_selection_controllable),
|
||||
rec_button (rec_controllable),
|
||||
|
||||
shuttle_units_button (_("% ")),
|
||||
|
||||
punch_in_button (_("Punch In")),
|
||||
punch_out_button (_("Punch Out")),
|
||||
auto_return_button (_("Auto Return")),
|
||||
|
@ -227,7 +225,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
|
|||
have_configure_timeout = false;
|
||||
have_disk_speed_dialog_displayed = false;
|
||||
session_loaded = false;
|
||||
last_speed_displayed = -1.0f;
|
||||
ignore_dual_punch = false;
|
||||
original_big_clock_width = -1;
|
||||
original_big_clock_height = -1;
|
||||
|
@ -240,19 +237,9 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
|
|||
auto_loop_button.unset_flags (Gtk::CAN_FOCUS);
|
||||
play_selection_button.unset_flags (Gtk::CAN_FOCUS);
|
||||
rec_button.unset_flags (Gtk::CAN_FOCUS);
|
||||
|
||||
join_play_range_button.unset_flags (Gtk::CAN_FOCUS);
|
||||
last_configure_time= 0;
|
||||
|
||||
shuttle_grabbed = false;
|
||||
shuttle_fract = 0.0;
|
||||
shuttle_max_speed = 8.0f;
|
||||
|
||||
shuttle_style_menu = 0;
|
||||
shuttle_unit_menu = 0;
|
||||
|
||||
// We do not have jack linked in yet so;
|
||||
|
||||
last_shuttle_request = last_peak_grab = 0; // get_microseconds();
|
||||
last_peak_grab = 0;
|
||||
|
||||
ARDOUR::Diskstream::DiskOverrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_overrun_handler, this), gui_context());
|
||||
ARDOUR::Diskstream::DiskUnderrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_underrun_handler, this), gui_context());
|
||||
|
@ -568,8 +555,9 @@ ARDOUR_UI::set_transport_controllable_state (const XMLNode& node)
|
|||
rec_controllable->set_id (prop->value());
|
||||
}
|
||||
if ((prop = node.property ("shuttle")) != 0) {
|
||||
shuttle_controllable->set_id (prop->value());
|
||||
shuttle_box->controllable().set_id (prop->value());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
|
@ -592,7 +580,7 @@ ARDOUR_UI::get_transport_controllable_state ()
|
|||
node->add_property (X_("play_selection"), buf);
|
||||
rec_controllable->id().print (buf, sizeof (buf));
|
||||
node->add_property (X_("rec"), buf);
|
||||
shuttle_controllable->id().print (buf, sizeof (buf));
|
||||
shuttle_box->controllable().id().print (buf, sizeof (buf));
|
||||
node->add_property (X_("shuttle"), buf);
|
||||
|
||||
return *node;
|
||||
|
@ -953,7 +941,7 @@ ARDOUR_UI::every_second ()
|
|||
gint
|
||||
ARDOUR_UI::every_point_one_seconds ()
|
||||
{
|
||||
update_speed_display ();
|
||||
shuttle_box->update_speed_display ();
|
||||
RapidScreenUpdate(); /* EMIT_SIGNAL */
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1824,8 +1812,6 @@ ARDOUR_UI::toggle_record_enable (uint32_t rid)
|
|||
void
|
||||
ARDOUR_UI::map_transport_state ()
|
||||
{
|
||||
ENSURE_GUI_THREAD (*this, &ARDOUR_UI::map_transport_state)
|
||||
|
||||
if (!_session) {
|
||||
auto_loop_button.set_visual_state (0);
|
||||
play_selection_button.set_visual_state (0);
|
||||
|
@ -1834,18 +1820,11 @@ ARDOUR_UI::map_transport_state ()
|
|||
return;
|
||||
}
|
||||
|
||||
shuttle_box->map_transport_state ();
|
||||
|
||||
float sp = _session->transport_speed();
|
||||
|
||||
if (sp == 1.0f) {
|
||||
shuttle_fract = SHUTTLE_FRACT_SPEED1; /* speed = 1.0, believe it or not */
|
||||
shuttle_box.queue_draw ();
|
||||
} else if (sp == 0.0f) {
|
||||
shuttle_fract = 0;
|
||||
shuttle_box.queue_draw ();
|
||||
update_disk_space ();
|
||||
}
|
||||
|
||||
if (sp != 0.0) {
|
||||
if (sp != 0.0f) {
|
||||
|
||||
/* we're rolling */
|
||||
|
||||
|
@ -1882,6 +1861,7 @@ ARDOUR_UI::map_transport_state ()
|
|||
roll_button.set_visual_state (0);
|
||||
play_selection_button.set_visual_state (0);
|
||||
auto_loop_button.set_visual_state (0);
|
||||
update_disk_space ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3606,23 +3586,6 @@ ARDOUR_UI::TransportControllable::TransportControllable (std::string name, ARDOU
|
|||
void
|
||||
ARDOUR_UI::TransportControllable::set_value (double val)
|
||||
{
|
||||
if (type == ShuttleControl) {
|
||||
double fract;
|
||||
|
||||
if (val == 0.5) {
|
||||
fract = 0.0;
|
||||
} else {
|
||||
if (val < 0.5) {
|
||||
fract = -((0.5 - val)/0.5);
|
||||
} else {
|
||||
fract = ((val - 0.5)/0.5);
|
||||
}
|
||||
}
|
||||
|
||||
ui.set_shuttle_fract (fract);
|
||||
return;
|
||||
}
|
||||
|
||||
if (val < 0.5) {
|
||||
/* do nothing: these are radio-style actions */
|
||||
return;
|
||||
|
@ -3687,8 +3650,6 @@ ARDOUR_UI::TransportControllable::get_value (void) const
|
|||
break;
|
||||
case RecordEnable:
|
||||
break;
|
||||
case ShuttleControl:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ class PublicEditor;
|
|||
class RCOptionEditor;
|
||||
class RouteParams_UI;
|
||||
class SessionOptionEditor;
|
||||
class ShuttleControl;
|
||||
class Splash;
|
||||
class SpeakerDialog;
|
||||
class ThemeManager;
|
||||
|
@ -368,8 +369,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
|||
Gtkmm2ext::TearOff* transport_tearoff;
|
||||
Gtk::Frame transport_frame;
|
||||
Gtk::HBox transport_tearoff_hbox;
|
||||
Gtk::HBox play_range_hbox;
|
||||
Gtk::VBox play_range_vbox;
|
||||
Gtk::HBox _editor_transport_box;
|
||||
Gtk::HBox transport_hbox;
|
||||
Gtk::Fixed transport_base;
|
||||
|
@ -384,7 +383,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
|||
Gtk::HBox primary_clock_hbox;
|
||||
Gtk::HBox secondary_clock_hbox;
|
||||
|
||||
|
||||
struct TransportControllable : public PBD::Controllable {
|
||||
enum ToggleType {
|
||||
Roll = 0,
|
||||
|
@ -394,8 +392,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
|||
GotoEnd,
|
||||
AutoLoop,
|
||||
PlaySelection,
|
||||
ShuttleControl
|
||||
|
||||
};
|
||||
|
||||
TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
|
||||
|
@ -416,6 +412,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
|||
boost::shared_ptr<TransportControllable> play_selection_controllable;
|
||||
boost::shared_ptr<TransportControllable> rec_controllable;
|
||||
boost::shared_ptr<TransportControllable> shuttle_controllable;
|
||||
boost::shared_ptr<TransportControllable> join_play_range_controllable;
|
||||
BindingProxy shuttle_controller_binding_proxy;
|
||||
|
||||
void set_transport_controllable_state (const XMLNode&);
|
||||
|
@ -428,40 +425,13 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
|||
BindableButton auto_loop_button;
|
||||
BindableButton play_selection_button;
|
||||
BindableButton rec_button;
|
||||
Gtk::ToggleButton join_play_range_button;
|
||||
BindableToggleButton join_play_range_button;
|
||||
|
||||
void toggle_external_sync ();
|
||||
void toggle_time_master ();
|
||||
void toggle_video_sync ();
|
||||
|
||||
Gtk::DrawingArea shuttle_box;
|
||||
Gtk::EventBox speed_display_box;
|
||||
Gtk::Label speed_display_label;
|
||||
Gtk::Button shuttle_units_button;
|
||||
Gtk::ComboBoxText shuttle_style_button;
|
||||
Gtk::Menu* shuttle_unit_menu;
|
||||
Gtk::Menu* shuttle_style_menu;
|
||||
float shuttle_max_speed;
|
||||
Gtk::Menu* shuttle_context_menu;
|
||||
|
||||
void build_shuttle_context_menu ();
|
||||
void show_shuttle_context_menu ();
|
||||
void shuttle_style_changed();
|
||||
void shuttle_unit_clicked ();
|
||||
void set_shuttle_max_speed (float);
|
||||
void update_speed_display ();
|
||||
float last_speed_displayed;
|
||||
|
||||
gint shuttle_box_button_press (GdkEventButton*);
|
||||
gint shuttle_box_button_release (GdkEventButton*);
|
||||
gint shuttle_box_scroll (GdkEventScroll*);
|
||||
gint shuttle_box_motion (GdkEventMotion*);
|
||||
gint shuttle_box_expose (GdkEventExpose*);
|
||||
gint mouse_shuttle (double x, bool force);
|
||||
void use_shuttle_fract (bool force);
|
||||
|
||||
bool shuttle_grabbed;
|
||||
double shuttle_fract;
|
||||
ShuttleControl* shuttle_box;
|
||||
|
||||
Gtkmm2ext::StatefulToggleButton punch_in_button;
|
||||
Gtkmm2ext::StatefulToggleButton punch_out_button;
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "utils.h"
|
||||
#include "theme_manager.h"
|
||||
#include "midi_tracer.h"
|
||||
#include "shuttle_control.h"
|
||||
#include "global_port_matrix.h"
|
||||
#include "location_ui.h"
|
||||
#include "rc_option_editor.h"
|
||||
|
@ -137,9 +138,6 @@ ARDOUR_UI::setup_tooltips ()
|
|||
set_tip (punch_out_button, _("Stop recording at auto-punch end"));
|
||||
set_tip (click_button, _("Enable/Disable audio click"));
|
||||
set_tip (time_master_button, string_compose (_("Does %1 control the time?"), PROGRAM_NAME));
|
||||
set_tip (shuttle_box, _("Shuttle speed control"));
|
||||
set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
|
||||
set_tip (speed_display_box, _("Current transport speed"));
|
||||
set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything"));
|
||||
set_tip (auditioning_alert_button, _("When active, auditioning is taking place\nClick to stop the audition"));
|
||||
set_tip (primary_clock, _("Primary Clock"));
|
||||
|
@ -238,7 +236,6 @@ ARDOUR_UI::setup_transport ()
|
|||
transport_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
|
||||
static_cast<Widget*> (&transport_frame), 1));
|
||||
|
||||
shuttle_box.set_name ("TransportButton");
|
||||
goto_start_button.set_name ("TransportButton");
|
||||
goto_end_button.set_name ("TransportButton");
|
||||
roll_button.set_name ("TransportButton");
|
||||
|
@ -290,7 +287,7 @@ ARDOUR_UI::setup_transport ()
|
|||
w = manage (new Image (get_icon (X_("transport_loop"))));
|
||||
w->show();
|
||||
auto_loop_button.add (*w);
|
||||
w = manage (new Image (get_icon (X_("join_tools"))));
|
||||
w = manage (new Image (get_icon (X_("tool_object_range"))));
|
||||
w->show ();
|
||||
join_play_range_button.add (*w);
|
||||
|
||||
|
@ -315,15 +312,6 @@ ARDOUR_UI::setup_transport ()
|
|||
act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
|
||||
act->connect_proxy (sync_button);
|
||||
|
||||
shuttle_box.set_flags (CAN_FOCUS);
|
||||
shuttle_box.add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK);
|
||||
shuttle_box.set_size_request (100, 15);
|
||||
|
||||
shuttle_box.signal_button_press_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
|
||||
shuttle_box.signal_button_release_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
|
||||
shuttle_box.signal_scroll_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_scroll));
|
||||
shuttle_box.signal_motion_notify_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_motion));
|
||||
shuttle_box.signal_expose_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_expose));
|
||||
|
||||
/* clocks, etc. */
|
||||
|
||||
|
@ -363,65 +351,38 @@ ARDOUR_UI::setup_transport ()
|
|||
alert_box.pack_start (solo_alert_button, false, false);
|
||||
alert_box.pack_start (auditioning_alert_button, false, false);
|
||||
|
||||
HBox* transport_hbox = manage (new HBox);
|
||||
|
||||
transport_tearoff_hbox.set_border_width (3);
|
||||
|
||||
transport_tearoff_hbox.pack_start (goto_start_button, false, false);
|
||||
transport_tearoff_hbox.pack_start (goto_end_button, false, false);
|
||||
|
||||
Frame* sframe = manage (new Frame);
|
||||
VBox* svbox = manage (new VBox);
|
||||
HBox* shbox = manage (new HBox);
|
||||
|
||||
sframe->set_shadow_type (SHADOW_IN);
|
||||
sframe->add (shuttle_box);
|
||||
|
||||
shuttle_box.set_name (X_("ShuttleControl"));
|
||||
|
||||
speed_display_box.add (speed_display_label);
|
||||
speed_display_box.set_name (X_("ShuttleDisplay"));
|
||||
set_size_request_to_display_given_text (speed_display_label, X_("> 24.0"), 2, 2);
|
||||
|
||||
shuttle_units_button.set_name (X_("ShuttleButton"));
|
||||
shuttle_units_button.signal_clicked().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
|
||||
|
||||
shuttle_style_button.set_name (X_("ShuttleStyleButton"));
|
||||
|
||||
vector<string> shuttle_strings;
|
||||
shuttle_strings.push_back (_("sprung"));
|
||||
shuttle_strings.push_back (_("wheel"));
|
||||
set_popdown_strings (shuttle_style_button, shuttle_strings, true);
|
||||
shuttle_style_button.signal_changed().connect (sigc::mem_fun (*this, &ARDOUR_UI::shuttle_style_changed));
|
||||
|
||||
Frame* sdframe = manage (new Frame);
|
||||
|
||||
sdframe->set_shadow_type (SHADOW_IN);
|
||||
sdframe->add (speed_display_box);
|
||||
transport_hbox->pack_start (goto_start_button, false, false);
|
||||
transport_hbox->pack_start (goto_end_button, false, false);
|
||||
|
||||
/* translators: Egternal is "External" with a descender character */
|
||||
set_size_request_to_display_given_text (sync_button, X_("Egternal"), 4, 10);
|
||||
|
||||
shbox->pack_start (*sdframe, false, false);
|
||||
shbox->pack_start (shuttle_units_button, true, true);
|
||||
shbox->pack_start (shuttle_style_button, false, false);
|
||||
|
||||
svbox->pack_start (*sframe, false, false);
|
||||
svbox->pack_start (*shbox, false, false);
|
||||
|
||||
transport_tearoff_hbox.pack_start (*svbox, false, false, 3);
|
||||
// transport_tearoff_hbox.pack_start (*svbox, false, false, 3);
|
||||
|
||||
if (Profile->get_sae()) {
|
||||
transport_tearoff_hbox.pack_start (auto_loop_button);
|
||||
transport_tearoff_hbox.pack_start (roll_button);
|
||||
transport_hbox->pack_start (auto_loop_button);
|
||||
transport_hbox->pack_start (roll_button);
|
||||
} else {
|
||||
transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
|
||||
play_range_hbox.pack_start (play_selection_button, false, false);
|
||||
play_range_hbox.pack_start (roll_button, false, false);
|
||||
play_range_vbox.pack_start (play_range_hbox, false, false);
|
||||
play_range_vbox.pack_start (join_play_range_button, false, false);
|
||||
transport_tearoff_hbox.pack_start (play_range_vbox, false, false);
|
||||
transport_hbox->pack_start (auto_loop_button, false, false);
|
||||
|
||||
Frame* jpframe = manage (new Frame);
|
||||
HBox* jpbox = manage (new HBox);
|
||||
|
||||
jpframe->add (*jpbox);
|
||||
jpframe->set_shadow_type (SHADOW_NONE);
|
||||
|
||||
jpbox->pack_start (play_selection_button, false, false);
|
||||
jpbox->pack_start (join_play_range_button, false, false);
|
||||
jpbox->pack_start (roll_button, false, false);
|
||||
|
||||
transport_hbox->pack_start (*jpframe, false, false);
|
||||
}
|
||||
transport_tearoff_hbox.pack_start (stop_button, false, false);
|
||||
transport_tearoff_hbox.pack_start (rec_button, false, false, 6);
|
||||
transport_hbox->pack_start (stop_button, false, false);
|
||||
transport_hbox->pack_start (rec_button, false, false, 6);
|
||||
|
||||
HBox* clock_box = manage (new HBox);
|
||||
clock_box->pack_start (primary_clock, false, false);
|
||||
|
@ -436,6 +397,17 @@ ARDOUR_UI::setup_transport ()
|
|||
clock_box->pack_start (*time_controls_box, false, false, 1);
|
||||
}
|
||||
|
||||
shuttle_box = new ShuttleControl;
|
||||
shuttle_box->show ();
|
||||
|
||||
VBox* transport_vbox = manage (new VBox);
|
||||
transport_vbox->set_name ("TransportBase");
|
||||
transport_vbox->set_border_width (3);
|
||||
transport_vbox->set_spacing (3);
|
||||
transport_vbox->pack_start (*transport_hbox, true, true, 0);
|
||||
transport_vbox->pack_start (*shuttle_box, false, false, 0);
|
||||
|
||||
transport_tearoff_hbox.pack_start (*transport_vbox, false, false, 0);
|
||||
transport_tearoff_hbox.pack_start (*clock_box, false, false, 0);
|
||||
|
||||
HBox* toggle_box = manage(new HBox);
|
||||
|
@ -614,331 +586,11 @@ ARDOUR_UI::audition_blink (bool onoff)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::build_shuttle_context_menu ()
|
||||
{
|
||||
using namespace Menu_Helpers;
|
||||
|
||||
shuttle_context_menu = new Menu();
|
||||
MenuList& items = shuttle_context_menu->items();
|
||||
|
||||
Menu* speed_menu = manage (new Menu());
|
||||
MenuList& speed_items = speed_menu->items();
|
||||
|
||||
RadioMenuItem::Group group;
|
||||
|
||||
speed_items.push_back (RadioMenuElem (group, "8", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 8.0f)));
|
||||
if (shuttle_max_speed == 8.0) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
speed_items.push_back (RadioMenuElem (group, "6", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 6.0f)));
|
||||
if (shuttle_max_speed == 6.0) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
speed_items.push_back (RadioMenuElem (group, "4", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 4.0f)));
|
||||
if (shuttle_max_speed == 4.0) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
speed_items.push_back (RadioMenuElem (group, "3", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 3.0f)));
|
||||
if (shuttle_max_speed == 3.0) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
speed_items.push_back (RadioMenuElem (group, "2", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 2.0f)));
|
||||
if (shuttle_max_speed == 2.0) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
speed_items.push_back (RadioMenuElem (group, "1.5", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 1.5f)));
|
||||
if (shuttle_max_speed == 1.5) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
|
||||
items.push_back (MenuElem (_("Maximum speed"), *speed_menu));
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::show_shuttle_context_menu ()
|
||||
{
|
||||
if (shuttle_context_menu == 0) {
|
||||
build_shuttle_context_menu ();
|
||||
}
|
||||
|
||||
shuttle_context_menu->popup (1, gtk_get_current_event_time());
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::set_shuttle_max_speed (float speed)
|
||||
{
|
||||
shuttle_max_speed = speed;
|
||||
}
|
||||
|
||||
gint
|
||||
ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
|
||||
{
|
||||
if (!_session) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (shuttle_controller_binding_proxy.button_press_handler (ev)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Keyboard::is_context_menu_event (ev)) {
|
||||
show_shuttle_context_menu ();
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (ev->button) {
|
||||
case 1:
|
||||
shuttle_box.add_modal_grab ();
|
||||
shuttle_grabbed = true;
|
||||
mouse_shuttle (ev->x, true);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
gint
|
||||
ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
|
||||
{
|
||||
if (!_session) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (ev->button) {
|
||||
case 1:
|
||||
mouse_shuttle (ev->x, true);
|
||||
shuttle_grabbed = false;
|
||||
shuttle_box.remove_modal_grab ();
|
||||
if (Config->get_shuttle_behaviour() == Sprung) {
|
||||
if (_session->config.get_auto_play() || roll_button.get_visual_state()) {
|
||||
shuttle_fract = SHUTTLE_FRACT_SPEED1;
|
||||
_session->request_transport_speed (1.0);
|
||||
stop_button.set_visual_state (0);
|
||||
roll_button.set_visual_state (1);
|
||||
} else {
|
||||
shuttle_fract = 0;
|
||||
_session->request_transport_speed (0.0);
|
||||
}
|
||||
shuttle_box.queue_draw ();
|
||||
}
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (_session->transport_rolling()) {
|
||||
shuttle_fract = SHUTTLE_FRACT_SPEED1;
|
||||
_session->request_transport_speed (1.0);
|
||||
stop_button.set_visual_state (0);
|
||||
roll_button.set_visual_state (1);
|
||||
} else {
|
||||
shuttle_fract = 0;
|
||||
}
|
||||
shuttle_box.queue_draw ();
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
default:
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
use_shuttle_fract (true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
gint
|
||||
ARDOUR_UI::shuttle_box_scroll (GdkEventScroll* ev)
|
||||
{
|
||||
if (!_session) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (ev->direction) {
|
||||
|
||||
case GDK_SCROLL_UP:
|
||||
shuttle_fract += 0.005;
|
||||
break;
|
||||
case GDK_SCROLL_DOWN:
|
||||
shuttle_fract -= 0.005;
|
||||
break;
|
||||
default:
|
||||
/* scroll left/right */
|
||||
return false;
|
||||
}
|
||||
|
||||
use_shuttle_fract (true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
gint
|
||||
ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
|
||||
{
|
||||
if (!_session || !shuttle_grabbed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return mouse_shuttle (ev->x, false);
|
||||
}
|
||||
|
||||
gint
|
||||
ARDOUR_UI::mouse_shuttle (double x, bool force)
|
||||
{
|
||||
double const half_width = shuttle_box.get_width() / 2.0;
|
||||
double distance = x - half_width;
|
||||
|
||||
if (distance > 0) {
|
||||
distance = min (distance, half_width);
|
||||
} else {
|
||||
distance = max (distance, -half_width);
|
||||
}
|
||||
|
||||
shuttle_fract = distance / half_width;
|
||||
use_shuttle_fract (force);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::set_shuttle_fract (double f)
|
||||
{
|
||||
shuttle_fract = f;
|
||||
use_shuttle_fract (false);
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::use_shuttle_fract (bool force)
|
||||
{
|
||||
microseconds_t now = get_microseconds();
|
||||
|
||||
/* do not attempt to submit a motion-driven transport speed request
|
||||
more than once per process cycle.
|
||||
*/
|
||||
|
||||
if (!force && (last_shuttle_request - now) < (microseconds_t) engine->usecs_per_cycle()) {
|
||||
return;
|
||||
}
|
||||
|
||||
last_shuttle_request = now;
|
||||
|
||||
double speed = 0;
|
||||
|
||||
if (Config->get_shuttle_units() == Semitones) {
|
||||
|
||||
double const step = 1.0 / 24.0; // range is 24 semitones up & down
|
||||
double const semitones = round (shuttle_fract / step);
|
||||
speed = pow (2.0, (semitones / 12.0));
|
||||
|
||||
} else {
|
||||
|
||||
bool const neg = (shuttle_fract < 0.0);
|
||||
double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
|
||||
|
||||
if (neg) {
|
||||
fract = -fract;
|
||||
}
|
||||
|
||||
speed = shuttle_max_speed * fract;
|
||||
}
|
||||
|
||||
_session->request_transport_speed_nonzero (speed);
|
||||
|
||||
shuttle_box.queue_draw ();
|
||||
}
|
||||
|
||||
gint
|
||||
ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
|
||||
{
|
||||
gint x;
|
||||
Glib::RefPtr<Gdk::Window> win (shuttle_box.get_window());
|
||||
|
||||
/* redraw the background */
|
||||
|
||||
win->draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
|
||||
true,
|
||||
event->area.x, event->area.y,
|
||||
event->area.width, event->area.height);
|
||||
|
||||
|
||||
x = (gint) floor ((shuttle_box.get_width() / 2.0) + (0.5 * (shuttle_box.get_width() * shuttle_fract)));
|
||||
|
||||
/* draw line */
|
||||
|
||||
win->draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
|
||||
x,
|
||||
0,
|
||||
x,
|
||||
shuttle_box.get_height());
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::shuttle_unit_clicked ()
|
||||
{
|
||||
if (shuttle_unit_menu == 0) {
|
||||
shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
|
||||
}
|
||||
shuttle_unit_menu->popup (1, gtk_get_current_event_time());
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::shuttle_style_changed ()
|
||||
{
|
||||
string str = shuttle_style_button.get_active_text ();
|
||||
|
||||
if (str == _("sprung")) {
|
||||
Config->set_shuttle_behaviour (Sprung);
|
||||
} else if (str == _("wheel")) {
|
||||
Config->set_shuttle_behaviour (Wheel);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::update_speed_display ()
|
||||
{
|
||||
if (!_session) {
|
||||
if (last_speed_displayed != 0) {
|
||||
speed_display_label.set_text (_("stop"));
|
||||
last_speed_displayed = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[32];
|
||||
float x = _session->transport_speed ();
|
||||
|
||||
if (x != last_speed_displayed) {
|
||||
|
||||
if (x != 0) {
|
||||
if (Config->get_shuttle_units() == Percentage) {
|
||||
snprintf (buf, sizeof (buf), "%d", (int) round (x * 100));
|
||||
} else {
|
||||
|
||||
if (x < 0) {
|
||||
snprintf (buf, sizeof (buf), "< %d", (int) round (12.0 * fast_log2 (-x)));
|
||||
} else {
|
||||
snprintf (buf, sizeof (buf), "> %d", (int) round (12.0 * fast_log2 (x)));
|
||||
}
|
||||
}
|
||||
speed_display_label.set_text (buf);
|
||||
} else {
|
||||
speed_display_label.set_text (_("stop"));
|
||||
}
|
||||
|
||||
last_speed_displayed = x;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::set_transport_sensitivity (bool yn)
|
||||
{
|
||||
ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
|
||||
shuttle_box.set_sensitive (yn);
|
||||
shuttle_box->set_sensitive (yn);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -947,7 +599,6 @@ ARDOUR_UI::editor_realized ()
|
|||
boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
|
||||
Config->map_parameters (pc);
|
||||
|
||||
set_size_request_to_display_given_text (speed_display_box, _("-0.55"), 2, 2);
|
||||
reset_dpi ();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "public_editor.h"
|
||||
#include "rc_option_editor.h"
|
||||
#include "route_params_ui.h"
|
||||
#include "shuttle_control.h"
|
||||
#include "session_option_editor.h"
|
||||
#include "speaker_dialog.h"
|
||||
#include "sfdb_ui.h"
|
||||
|
@ -81,6 +82,10 @@ ARDOUR_UI::set_session (Session *s)
|
|||
session_option_editor->set_session (s);
|
||||
}
|
||||
|
||||
if (shuttle_box) {
|
||||
shuttle_box->set_session (s);
|
||||
}
|
||||
|
||||
for (ARDOUR::DataType::iterator i = ARDOUR::DataType::begin(); i != ARDOUR::DataType::end(); ++i) {
|
||||
if (_global_port_matrix[*i]->get()) {
|
||||
_global_port_matrix[*i]->get()->set_session (_session);
|
||||
|
@ -127,7 +132,7 @@ ARDOUR_UI::set_session (Session *s)
|
|||
ActionManager::set_sensitive (ActionManager::playlist_selection_sensitive_actions, false);
|
||||
|
||||
rec_button.set_sensitive (true);
|
||||
shuttle_box.set_sensitive (true);
|
||||
|
||||
solo_alert_button.set_active (_session->soloing());
|
||||
|
||||
setup_session_options ();
|
||||
|
@ -205,7 +210,6 @@ ARDOUR_UI::unload_session (bool hide_stuff)
|
|||
ActionManager::set_sensitive (ActionManager::session_sensitive_actions, false);
|
||||
|
||||
rec_button.set_sensitive (false);
|
||||
shuttle_box.set_sensitive (false);
|
||||
|
||||
stop_blinking ();
|
||||
stop_clocking ();
|
||||
|
|
|
@ -383,35 +383,6 @@ ARDOUR_UI::parameter_changed (std::string p)
|
|||
ActionManager::map_some_state ("Transport", "ToggleTimeMaster", sigc::mem_fun (_session->config, &SessionConfiguration::get_jack_time_master));
|
||||
} else if (p == "use-video-sync") {
|
||||
ActionManager::map_some_state ("Transport", "ToggleVideoSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_use_video_sync));
|
||||
} else if (p == "shuttle-behaviour") {
|
||||
|
||||
switch (Config->get_shuttle_behaviour ()) {
|
||||
case Sprung:
|
||||
shuttle_style_button.set_active_text (_("sprung"));
|
||||
shuttle_fract = 0.0;
|
||||
shuttle_box.queue_draw ();
|
||||
if (_session) {
|
||||
if (_session->transport_rolling()) {
|
||||
shuttle_fract = SHUTTLE_FRACT_SPEED1;
|
||||
_session->request_transport_speed (1.0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Wheel:
|
||||
shuttle_style_button.set_active_text (_("wheel"));
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (p == "shuttle-units") {
|
||||
|
||||
switch (Config->get_shuttle_units()) {
|
||||
case Percentage:
|
||||
shuttle_units_button.set_label("% ");
|
||||
break;
|
||||
case Semitones:
|
||||
shuttle_units_button.set_label(_("ST"));
|
||||
break;
|
||||
}
|
||||
} else if (p == "video-pullup" || p == "timecode-format") {
|
||||
|
||||
synchronize_sync_source_and_video_pullup ();
|
||||
|
|
|
@ -0,0 +1,547 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
|
||||
#include <pbd/stacktrace.h>
|
||||
|
||||
#include "ardour/ardour.h"
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/rc_configuration.h"
|
||||
#include "ardour/session.h"
|
||||
|
||||
#include "gtkmm2ext/keyboard.h"
|
||||
#include "gtkmm2ext/gui_thread.h"
|
||||
|
||||
#include "ardour_ui.h"
|
||||
#include "shuttle_control.h"
|
||||
|
||||
using namespace Gtk;
|
||||
using namespace Gtkmm2ext;
|
||||
using namespace ARDOUR;
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
ShuttleControl::ShuttleControl ()
|
||||
: _controllable (*this)
|
||||
{
|
||||
ARDOUR_UI::instance()->set_tip (*this, _("Shuttle speed control"));
|
||||
|
||||
pattern = 0;
|
||||
last_shuttle_request = 0;
|
||||
last_speed_displayed = -99999999;
|
||||
shuttle_grabbed = false;
|
||||
shuttle_fract = 0.0;
|
||||
shuttle_max_speed = 8.0f;
|
||||
shuttle_style_menu = 0;
|
||||
shuttle_unit_menu = 0;
|
||||
shuttle_context_menu = 0;
|
||||
|
||||
set_flags (CAN_FOCUS);
|
||||
add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK);
|
||||
set_size_request (100, 15);
|
||||
set_name (X_("ShuttleControl"));
|
||||
|
||||
Config->ParameterChanged.connect (parameter_connection, MISSING_INVALIDATOR, ui_bind (&ShuttleControl::parameter_changed, this, _1), gui_context());
|
||||
}
|
||||
|
||||
ShuttleControl::~ShuttleControl ()
|
||||
{
|
||||
cairo_pattern_destroy (pattern);
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::set_session (Session *s)
|
||||
{
|
||||
SessionHandlePtr::set_session (s);
|
||||
|
||||
if (_session) {
|
||||
set_sensitive (true);
|
||||
} else {
|
||||
set_sensitive (false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::on_size_allocate (Gtk::Allocation& alloc)
|
||||
{
|
||||
if (pattern) {
|
||||
cairo_pattern_destroy (pattern);
|
||||
pattern = 0;
|
||||
}
|
||||
|
||||
pattern = cairo_pattern_create_linear (0, 0, alloc.get_width(), alloc.get_height());
|
||||
|
||||
/* add 3 color stops */
|
||||
|
||||
cairo_pattern_add_color_stop_rgb (pattern, 0.0, 0, 0, 0);
|
||||
cairo_pattern_add_color_stop_rgb (pattern, 0.5, 0.0, 0.0, 1.0);
|
||||
cairo_pattern_add_color_stop_rgb (pattern, 1.0, 0, 0, 0);
|
||||
|
||||
DrawingArea::on_size_allocate (alloc);
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::map_transport_state ()
|
||||
{
|
||||
float speed = _session->transport_speed ();
|
||||
|
||||
if (speed != 0.0) {
|
||||
shuttle_fract = SHUTTLE_FRACT_SPEED1; /* speed = 1.0, believe it or not */
|
||||
} else {
|
||||
shuttle_fract = 0;
|
||||
}
|
||||
|
||||
queue_draw ();
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::build_shuttle_context_menu ()
|
||||
{
|
||||
using namespace Menu_Helpers;
|
||||
|
||||
shuttle_context_menu = new Menu();
|
||||
MenuList& items = shuttle_context_menu->items();
|
||||
|
||||
Menu* speed_menu = manage (new Menu());
|
||||
MenuList& speed_items = speed_menu->items();
|
||||
|
||||
RadioMenuItem::Group group;
|
||||
|
||||
speed_items.push_back (RadioMenuElem (group, "8", sigc::bind (sigc::mem_fun (*this, &ShuttleControl::set_shuttle_max_speed), 8.0f)));
|
||||
if (shuttle_max_speed == 8.0) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
speed_items.push_back (RadioMenuElem (group, "6", sigc::bind (sigc::mem_fun (*this, &ShuttleControl::set_shuttle_max_speed), 6.0f)));
|
||||
if (shuttle_max_speed == 6.0) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
speed_items.push_back (RadioMenuElem (group, "4", sigc::bind (sigc::mem_fun (*this, &ShuttleControl::set_shuttle_max_speed), 4.0f)));
|
||||
if (shuttle_max_speed == 4.0) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
speed_items.push_back (RadioMenuElem (group, "3", sigc::bind (sigc::mem_fun (*this, &ShuttleControl::set_shuttle_max_speed), 3.0f)));
|
||||
if (shuttle_max_speed == 3.0) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
speed_items.push_back (RadioMenuElem (group, "2", sigc::bind (sigc::mem_fun (*this, &ShuttleControl::set_shuttle_max_speed), 2.0f)));
|
||||
if (shuttle_max_speed == 2.0) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
speed_items.push_back (RadioMenuElem (group, "1.5", sigc::bind (sigc::mem_fun (*this, &ShuttleControl::set_shuttle_max_speed), 1.5f)));
|
||||
if (shuttle_max_speed == 1.5) {
|
||||
static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
|
||||
}
|
||||
|
||||
items.push_back (MenuElem (_("Maximum speed"), *speed_menu));
|
||||
|
||||
Menu* units_menu = manage (new Menu);
|
||||
MenuList& units_items = units_menu->items();
|
||||
RadioMenuItem::Group units_group;
|
||||
|
||||
units_items.push_back (RadioMenuElem (units_group, _("Percent"), sigc::bind (sigc::mem_fun (*this, &ShuttleControl::set_shuttle_units), Percentage)));
|
||||
if (Config->get_shuttle_units() == Percentage) {
|
||||
static_cast<RadioMenuItem*>(&units_items.back())->set_active();
|
||||
}
|
||||
units_items.push_back (RadioMenuElem (units_group, _("Semitones"), sigc::bind (sigc::mem_fun (*this, &ShuttleControl::set_shuttle_units), Semitones)));
|
||||
if (Config->get_shuttle_units() == Semitones) {
|
||||
static_cast<RadioMenuItem*>(&units_items.back())->set_active();
|
||||
}
|
||||
items.push_back (MenuElem (_("Units"), *units_menu));
|
||||
|
||||
Menu* style_menu = manage (new Menu);
|
||||
MenuList& style_items = style_menu->items();
|
||||
RadioMenuItem::Group style_group;
|
||||
|
||||
style_items.push_back (RadioMenuElem (style_group, _("Sprung"), sigc::bind (sigc::mem_fun (*this, &ShuttleControl::set_shuttle_style), Sprung)));
|
||||
if (Config->get_shuttle_behaviour() == Sprung) {
|
||||
static_cast<RadioMenuItem*>(&style_items.back())->set_active();
|
||||
}
|
||||
style_items.push_back (RadioMenuElem (style_group, _("Wheel"), sigc::bind (sigc::mem_fun (*this, &ShuttleControl::set_shuttle_style), Wheel)));
|
||||
if (Config->get_shuttle_behaviour() == Wheel) {
|
||||
static_cast<RadioMenuItem*>(&style_items.back())->set_active();
|
||||
}
|
||||
|
||||
items.push_back (MenuElem (_("Mode"), *style_menu));
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::show_shuttle_context_menu ()
|
||||
{
|
||||
if (shuttle_context_menu == 0) {
|
||||
build_shuttle_context_menu ();
|
||||
}
|
||||
|
||||
shuttle_context_menu->popup (1, gtk_get_current_event_time());
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::set_shuttle_max_speed (float speed)
|
||||
{
|
||||
shuttle_max_speed = speed;
|
||||
}
|
||||
|
||||
bool
|
||||
ShuttleControl::on_button_press_event (GdkEventButton* ev)
|
||||
{
|
||||
if (!_session) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (shuttle_controller_binding_proxy.button_press_handler (ev)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Keyboard::is_context_menu_event (ev)) {
|
||||
show_shuttle_context_menu ();
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (ev->button) {
|
||||
case 1:
|
||||
add_modal_grab ();
|
||||
shuttle_grabbed = true;
|
||||
mouse_shuttle (ev->x, true);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ShuttleControl::on_button_release_event (GdkEventButton* ev)
|
||||
{
|
||||
if (!_session) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (ev->button) {
|
||||
case 1:
|
||||
mouse_shuttle (ev->x, true);
|
||||
shuttle_grabbed = false;
|
||||
remove_modal_grab ();
|
||||
if (Config->get_shuttle_behaviour() == Sprung) {
|
||||
if (_session->config.get_auto_play()) {
|
||||
shuttle_fract = SHUTTLE_FRACT_SPEED1;
|
||||
_session->request_transport_speed (1.0);
|
||||
} else {
|
||||
shuttle_fract = 0;
|
||||
_session->request_transport_speed (0.0);
|
||||
}
|
||||
queue_draw ();
|
||||
}
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (_session->transport_rolling()) {
|
||||
shuttle_fract = SHUTTLE_FRACT_SPEED1;
|
||||
_session->request_transport_speed (1.0);
|
||||
} else {
|
||||
shuttle_fract = 0;
|
||||
}
|
||||
queue_draw ();
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
default:
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
use_shuttle_fract (true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ShuttleControl::on_scroll_event (GdkEventScroll* ev)
|
||||
{
|
||||
if (!_session) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (ev->direction) {
|
||||
|
||||
case GDK_SCROLL_UP:
|
||||
shuttle_fract += 0.005;
|
||||
break;
|
||||
case GDK_SCROLL_DOWN:
|
||||
shuttle_fract -= 0.005;
|
||||
break;
|
||||
default:
|
||||
/* scroll left/right */
|
||||
return false;
|
||||
}
|
||||
|
||||
use_shuttle_fract (true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ShuttleControl::on_motion_notify_event (GdkEventMotion* ev)
|
||||
{
|
||||
if (!_session || !shuttle_grabbed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return mouse_shuttle (ev->x, false);
|
||||
}
|
||||
|
||||
gint
|
||||
ShuttleControl::mouse_shuttle (double x, bool force)
|
||||
{
|
||||
double const half_width = get_width() / 2.0;
|
||||
double distance = x - half_width;
|
||||
|
||||
if (distance > 0) {
|
||||
distance = min (distance, half_width);
|
||||
} else {
|
||||
distance = max (distance, -half_width);
|
||||
}
|
||||
|
||||
shuttle_fract = distance / half_width;
|
||||
use_shuttle_fract (force);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::set_shuttle_fract (double f)
|
||||
{
|
||||
shuttle_fract = f;
|
||||
use_shuttle_fract (false);
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::use_shuttle_fract (bool force)
|
||||
{
|
||||
microseconds_t now = get_microseconds();
|
||||
|
||||
/* do not attempt to submit a motion-driven transport speed request
|
||||
more than once per process cycle.
|
||||
*/
|
||||
|
||||
if (!force && (last_shuttle_request - now) < (microseconds_t) AudioEngine::instance()->usecs_per_cycle()) {
|
||||
return;
|
||||
}
|
||||
|
||||
last_shuttle_request = now;
|
||||
|
||||
double speed = 0;
|
||||
|
||||
if (Config->get_shuttle_units() == Semitones) {
|
||||
|
||||
double const step = 1.0 / 24.0; // range is 24 semitones up & down
|
||||
double const semitones = round (shuttle_fract / step);
|
||||
speed = pow (2.0, (semitones / 12.0));
|
||||
|
||||
} else {
|
||||
|
||||
bool const neg = (shuttle_fract < 0.0);
|
||||
double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
|
||||
|
||||
if (neg) {
|
||||
fract = -fract;
|
||||
}
|
||||
|
||||
speed = shuttle_max_speed * fract;
|
||||
}
|
||||
|
||||
_session->request_transport_speed_nonzero (speed);
|
||||
}
|
||||
|
||||
bool
|
||||
ShuttleControl::on_expose_event (GdkEventExpose* event)
|
||||
{
|
||||
cairo_text_extents_t extents;
|
||||
Glib::RefPtr<Gdk::Window> win (get_window());
|
||||
Glib::RefPtr<Gtk::Style> style (get_style());
|
||||
|
||||
cairo_t* cr = gdk_cairo_create (win->gobj());
|
||||
|
||||
cairo_set_source (cr, pattern);
|
||||
cairo_rectangle (cr, 0.0, 0.0, get_width(), get_height());
|
||||
cairo_fill_preserve (cr);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0.0);
|
||||
cairo_stroke (cr);
|
||||
|
||||
/* Marker */
|
||||
|
||||
double x = (get_width() / 2.0) + (0.5 * (get_width() * shuttle_fract));
|
||||
cairo_move_to (cr, x, 0);
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
|
||||
cairo_line_to (cr, x, get_height());
|
||||
cairo_stroke (cr);
|
||||
|
||||
/* speed text */
|
||||
|
||||
char buf[32];
|
||||
float speed = 0.0;
|
||||
|
||||
if (_session) {
|
||||
speed = _session->transport_speed ();
|
||||
}
|
||||
|
||||
if (speed != 0) {
|
||||
if (Config->get_shuttle_units() == Percentage) {
|
||||
snprintf (buf, sizeof (buf), "%d%%", (int) round (speed * 100));
|
||||
} else {
|
||||
if (speed < 0) {
|
||||
snprintf (buf, sizeof (buf), "< %d semitones", (int) round (12.0 * fast_log2 (-speed)));
|
||||
} else {
|
||||
snprintf (buf, sizeof (buf), "> %d semitones", (int) round (12.0 * fast_log2 (speed)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
snprintf (buf, sizeof (buf), _("stop"));
|
||||
}
|
||||
|
||||
last_speed_displayed = speed;
|
||||
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
|
||||
cairo_text_extents (cr, buf, &extents);
|
||||
cairo_move_to (cr, 10, extents.height + 2);
|
||||
cairo_show_text (cr, buf);
|
||||
|
||||
/* style text */
|
||||
|
||||
|
||||
switch (Config->get_shuttle_behaviour()) {
|
||||
case Sprung:
|
||||
snprintf (buf, sizeof (buf), _("Sprung"));
|
||||
break;
|
||||
case Wheel:
|
||||
snprintf (buf, sizeof (buf), _("Wheel"));
|
||||
break;
|
||||
}
|
||||
|
||||
cairo_text_extents (cr, buf, &extents);
|
||||
|
||||
cairo_move_to (cr, get_width() - (fabs(extents.x_advance) + 5), extents.height + 2);
|
||||
cairo_show_text (cr, buf);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::shuttle_unit_clicked ()
|
||||
{
|
||||
if (shuttle_unit_menu == 0) {
|
||||
shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
|
||||
}
|
||||
shuttle_unit_menu->popup (1, gtk_get_current_event_time());
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::set_shuttle_style (ShuttleBehaviour s)
|
||||
{
|
||||
Config->set_shuttle_behaviour (s);
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::set_shuttle_units (ShuttleUnits s)
|
||||
{
|
||||
Config->set_shuttle_units (s);
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::update_speed_display ()
|
||||
{
|
||||
if (_session->transport_speed() != last_speed_displayed) {
|
||||
queue_draw ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
|
||||
set_tip (speed_display_box, _("Current transport speed"));
|
||||
|
||||
|
||||
*/
|
||||
|
||||
ShuttleControl::ShuttleControllable::ShuttleControllable (ShuttleControl& s)
|
||||
: PBD::Controllable (X_("Shuttle"))
|
||||
, sc (s)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::ShuttleControllable::set_id (const std::string& str)
|
||||
{
|
||||
_id = str;
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::ShuttleControllable::set_value (double val)
|
||||
{
|
||||
double fract;
|
||||
|
||||
if (val == 0.5) {
|
||||
fract = 0.0;
|
||||
} else {
|
||||
if (val < 0.5) {
|
||||
fract = -((0.5 - val)/0.5);
|
||||
} else {
|
||||
fract = ((val - 0.5)/0.5);
|
||||
}
|
||||
}
|
||||
|
||||
sc.set_shuttle_fract (fract);
|
||||
}
|
||||
|
||||
double
|
||||
ShuttleControl::ShuttleControllable::get_value () const
|
||||
{
|
||||
return sc.get_shuttle_fract ();
|
||||
}
|
||||
|
||||
void
|
||||
ShuttleControl::parameter_changed (std::string p)
|
||||
{
|
||||
if (p == "shuttle-behaviour") {
|
||||
switch (Config->get_shuttle_behaviour ()) {
|
||||
case Sprung:
|
||||
shuttle_fract = 0.0;
|
||||
if (_session) {
|
||||
if (_session->transport_rolling()) {
|
||||
shuttle_fract = SHUTTLE_FRACT_SPEED1;
|
||||
_session->request_transport_speed (1.0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Wheel:
|
||||
break;
|
||||
}
|
||||
queue_draw ();
|
||||
|
||||
} else if (p == "shuttle-units") {
|
||||
queue_draw ();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
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>
|
||||
|
||||
#include "pbd/controllable.h"
|
||||
#include "ardour/session_handle.h"
|
||||
|
||||
namespace Gtk {
|
||||
class Menu;
|
||||
}
|
||||
|
||||
#include "ardour/types.h"
|
||||
|
||||
class ShuttleControl : public Gtk::DrawingArea, public ARDOUR::SessionHandlePtr
|
||||
{
|
||||
public:
|
||||
ShuttleControl ();
|
||||
~ShuttleControl ();
|
||||
|
||||
void map_transport_state ();
|
||||
void update_speed_display ();
|
||||
void set_shuttle_fract (double);
|
||||
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;
|
||||
|
||||
void set_id (const std::string&);
|
||||
|
||||
ShuttleControl& sc;
|
||||
};
|
||||
|
||||
ShuttleControllable& controllable() { return _controllable; }
|
||||
|
||||
protected:
|
||||
float shuttle_max_speed;
|
||||
float last_speed_displayed;
|
||||
bool shuttle_grabbed;
|
||||
double shuttle_fract;
|
||||
ShuttleControllable _controllable;
|
||||
cairo_pattern_t* pattern;
|
||||
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;
|
||||
|
||||
void build_shuttle_context_menu ();
|
||||
void show_shuttle_context_menu ();
|
||||
void shuttle_style_changed();
|
||||
void shuttle_unit_clicked ();
|
||||
void set_shuttle_max_speed (float);
|
||||
|
||||
bool on_button_press_event (GdkEventButton*);
|
||||
bool on_button_release_event(GdkEventButton*);
|
||||
bool on_scroll_event (GdkEventScroll*);
|
||||
bool on_motion_notify_event(GdkEventMotion*);
|
||||
bool on_expose_event(GdkEventExpose*);
|
||||
void on_size_allocate (Gtk::Allocation&);
|
||||
|
||||
gint mouse_shuttle (double x, bool force);
|
||||
void use_shuttle_fract (bool force);
|
||||
void parameter_changed (std::string);
|
||||
|
||||
void set_shuttle_units (ARDOUR::ShuttleUnits);
|
||||
void set_shuttle_style (ARDOUR::ShuttleBehaviour);
|
||||
};
|
||||
|
||||
#endif /* __gtk2_ardour_shuttle_control_h__ */
|
Loading…
Reference in New Issue