#include "gtkmm2ext/rgb_macros.h"
#include "actions.h"
-#include "ardour_ui.h"
#include "rgb_macros.h"
#include "shuttle_control.h"
+#include "tooltips.h"
#include "i18n.h"
using namespace Gtk;
using namespace Gtkmm2ext;
using namespace ARDOUR;
+using namespace ARDOUR_UI_UTILS;
using std::min;
using std::max;
: _controllable (new ShuttleControllable (*this))
, binding_proxy (_controllable)
{
- ARDOUR_UI::instance()->set_tip (*this, _("Shuttle speed control (Context-click for options)"));
+ set_tooltip (*this, _("Shuttle speed control (Context-click for options)"));
pattern = 0;
shine_pattern = 0;
set_size_request (85, 20);
set_name (X_("ShuttleControl"));
+ shuttle_max_speed = Config->get_shuttle_max_speed();
+
+ if (shuttle_max_speed >= 8.f) { shuttle_max_speed = 8.0f; }
+ else if (shuttle_max_speed >= 6.f) { shuttle_max_speed = 6.0f; }
+ else if (shuttle_max_speed >= 4.f) { shuttle_max_speed = 4.0f; }
+ else if (shuttle_max_speed >= 3.f) { shuttle_max_speed = 3.0f; }
+ else if (shuttle_max_speed >= 2.f) { shuttle_max_speed = 2.0f; }
+ else { shuttle_max_speed = 1.5f; }
+
Config->ParameterChanged.connect (parameter_connection, MISSING_INVALIDATOR, boost::bind (&ShuttleControl::parameter_changed, this, _1), gui_context());
/* gtkmm 2.4: the C++ wrapper doesn't work */
//background
pattern = cairo_pattern_create_linear (0, 0, 0, alloc.get_height());
- uint32_t col = ARDOUR_UI::config()->color ("shuttle");
+ uint32_t col = UIConfiguration::instance().color ("shuttle");
int r,b,g,a;
UINT_TO_RGBA(col, &r, &g, &b, &a);
cairo_pattern_add_color_stop_rgb (pattern, 0.0, r/400.0, g/400.0, b/400.0);
items.push_back (MenuElem (_("Maximum speed"), *speed_menu));
+ items.push_back (SeparatorElem ());
+ items.push_back (MenuElem (_("Reset to 100%"), sigc::mem_fun (*this, &ShuttleControl::reset_speed)));
}
void
shuttle_context_menu->popup (1, gtk_get_current_event_time());
}
+void
+ShuttleControl::reset_speed ()
+{
+ if (_session->transport_rolling()) {
+ _session->request_transport_speed (1.0, true);
+ } else {
+ _session->request_transport_speed (0.0, true);
+ }
+}
+
void
ShuttleControl::set_shuttle_max_speed (float speed)
{
+ Config->set_shuttle_max_speed (speed);
shuttle_max_speed = speed;
last_speed_displayed = -99999999;
}
shuttle_grabbed = false;
remove_modal_grab ();
gdk_pointer_ungrab (GDK_CURRENT_TIME);
-
+
if (Config->get_shuttle_behaviour() == Sprung) {
if (shuttle_speed_on_grab == 0 ) {
- _session->request_transport_speed (1.0);
+ _session->request_stop ();
+ } else {
+ _session->request_transport_speed (shuttle_speed_on_grab);
}
- _session->request_transport_speed (shuttle_speed_on_grab);
} else {
mouse_shuttle (ev->x, true);
}
default:
return false;
}
-
+
if (semis) {
float lower_side_of_dead_zone = semitones_as_fract (-24, true);
snprintf (buf, sizeof (buf), "%s", _("Playing"));
} else {
if (speed < 0.0) {
- snprintf (buf, sizeof (buf), "<<< %d%%", (int) round (-speed * 100));
+ snprintf (buf, sizeof (buf), "<<< %.1f%%", -speed * 100.f);
} else {
- snprintf (buf, sizeof (buf), ">>> %d%%", (int) round (speed * 100));
+ snprintf (buf, sizeof (buf), ">>> %.1f%%", speed * 100.f);
}
}
cairo_move_to (cr, get_width() - (fabs(extents.x_advance) + 5), text_ypos);
cairo_show_text (cr, buf);
- if (ARDOUR_UI::config()->get_widget_prelight()) {
+ if (UIConfiguration::instance().get_widget_prelight()) {
if (_hovering) {
rounded_rectangle (cr, 1, 1, get_width()-2, get_height()-2, 4.0);
cairo_set_source_rgba (cr, 1, 1, 1, 0.2);
}
void
-ShuttleControl::ShuttleControllable::set_value (double val)
+ShuttleControl::ShuttleControllable::set_value (double val, PBD::Controllable::GroupControlDisposition /*group_override*/)
{
sc.set_shuttle_fract ((val - lower()) / (upper() - lower()), true);
}
{
_hovering = true;
- if (ARDOUR_UI::config()->get_widget_prelight()) {
+ if (UIConfiguration::instance().get_widget_prelight()) {
queue_draw ();
}
{
_hovering = false;
- if (ARDOUR_UI::config()->get_widget_prelight()) {
+ if (UIConfiguration::instance().get_widget_prelight()) {
queue_draw ();
}