#include <algorithm>
-#include <cairo/cairo.h>
+#include <cairo.h>
#include "ardour/ardour.h"
#include "ardour/audioengine.h"
#include "gtkmm2ext/utils.h"
#include "gtkmm2ext/rgb_macros.h"
+#include "actions.h"
#include "ardour_ui.h"
#include "rgb_macros.h"
#include "shuttle_control.h"
//background
pattern = cairo_pattern_create_linear (0, 0, 0, alloc.get_height());
- uint32_t col = ARDOUR_UI::config()->canvasvar_Shuttle.get();
+ uint32_t col = ARDOUR_UI::config()->get_canvasvar_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);
}
void
-ShuttleControl::set_shuttle_fract (double f)
+ShuttleControl::set_shuttle_fract (double f, bool zero_ok)
{
shuttle_fract = f;
- use_shuttle_fract (false);
+ use_shuttle_fract (false, zero_ok);
}
int
}
void
-ShuttleControl::use_shuttle_fract (bool force)
+ShuttleControl::use_shuttle_fract (bool force, bool zero_ok)
{
microseconds_t now = get_microseconds();
speed = shuttle_max_speed * shuttle_fract;
}
- _session->request_transport_speed_nonzero (speed, Config->get_shuttle_behaviour() == Wheel);
+ if (zero_ok) {
+ _session->request_transport_speed (speed, Config->get_shuttle_behaviour() == Wheel);
+ } else {
+ _session->request_transport_speed_nonzero (speed, Config->get_shuttle_behaviour() == Wheel);
+ }
}
void
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);
+ sc.set_shuttle_fract ((val - lower()) / (upper() - lower()), true);
}
double
ShuttleControl::ShuttleControllable::get_value () const
{
- return sc.get_shuttle_fract ();
+ return lower() + (sc.get_shuttle_fract () * (upper() - lower()));
}
void