@@ -27,12 +27,11 @@ extern float zoom; | |||
extern bool invertZoom; | |||
extern float cableOpacity; | |||
extern float cableTension; | |||
extern bool allowCursorLock; | |||
enum KnobMode { | |||
KNOB_MODE_LINEAR_LOCKED = 0, | |||
KNOB_MODE_LINEAR, | |||
KNOB_MODE_SCALED_LINEAR_LOCKED = 100, | |||
KNOB_MODE_SCALED_LINEAR, | |||
KNOB_MODE_ROTARY_ABSOLUTE = 200, | |||
KNOB_MODE_ROTARY_ABSOLUTE, | |||
KNOB_MODE_ROTARY_RELATIVE, | |||
}; | |||
extern KnobMode knobMode; | |||
@@ -71,7 +71,7 @@ void Knob::onDragStart(const event::DragStart& e) { | |||
} | |||
settings::KnobMode km = settings::knobMode; | |||
if (km == settings::KNOB_MODE_LINEAR_LOCKED || km == settings::KNOB_MODE_SCALED_LINEAR_LOCKED) { | |||
if (km == settings::KNOB_MODE_LINEAR || km == settings::KNOB_MODE_SCALED_LINEAR) { | |||
APP->window->cursorLock(); | |||
} | |||
// Only changed for KNOB_MODE_LINEAR_*. | |||
@@ -88,7 +88,7 @@ void Knob::onDragEnd(const event::DragEnd& e) { | |||
return; | |||
settings::KnobMode km = settings::knobMode; | |||
if (km == settings::KNOB_MODE_LINEAR_LOCKED || km == settings::KNOB_MODE_SCALED_LINEAR_LOCKED) { | |||
if (km == settings::KNOB_MODE_LINEAR || km == settings::KNOB_MODE_SCALED_LINEAR) { | |||
APP->window->cursorUnlock(); | |||
} | |||
@@ -115,7 +115,7 @@ void Knob::onDragMove(const event::DragMove& e) { | |||
return; | |||
settings::KnobMode km = settings::knobMode; | |||
bool linearMode = (km < settings::KNOB_MODE_ROTARY_ABSOLUTE) || forceLinear; | |||
bool linearMode = (km == settings::KNOB_MODE_LINEAR || km == settings::KNOB_MODE_SCALED_LINEAR) || forceLinear; | |||
engine::ParamQuantity* pq = getParamQuantity(); | |||
if (pq) { | |||
@@ -150,7 +150,7 @@ void Knob::onDragMove(const event::DragMove& e) { | |||
delta *= rangeRatio; | |||
// Scale delta if in scaled linear knob mode | |||
if (km == settings::KNOB_MODE_SCALED_LINEAR_LOCKED || km == settings::KNOB_MODE_SCALED_LINEAR) { | |||
if (km == settings::KNOB_MODE_SCALED_LINEAR) { | |||
float deltaY = (horizontal ? -e.mouseDelta.y : -e.mouseDelta.x); | |||
const float pixelTau = 200.f; | |||
internal->linearScale *= std::pow(2.f, deltaY / pixelTau); | |||
@@ -317,6 +317,12 @@ struct ParamTooltipItem : ui::MenuItem { | |||
} | |||
}; | |||
struct AllowCursorLockItem : ui::MenuItem { | |||
void onAction(const event::Action& e) override { | |||
settings::allowCursorLock ^= true; | |||
} | |||
}; | |||
struct KnobModeValueItem : ui::MenuItem { | |||
settings::KnobMode knobMode; | |||
void onAction(const event::Action& e) override { | |||
@@ -329,9 +335,7 @@ struct KnobModeItem : ui::MenuItem { | |||
ui::Menu* menu = new ui::Menu; | |||
static const std::vector<std::pair<settings::KnobMode, std::string>> knobModes = { | |||
{settings::KNOB_MODE_LINEAR_LOCKED, "Linear (locked cursor)"}, | |||
{settings::KNOB_MODE_LINEAR, "Linear"}, | |||
{settings::KNOB_MODE_SCALED_LINEAR_LOCKED, "Scaled linear (locked cursor)"}, | |||
{settings::KNOB_MODE_SCALED_LINEAR, "Scaled linear"}, | |||
{settings::KNOB_MODE_ROTARY_ABSOLUTE, "Absolute rotary"}, | |||
{settings::KNOB_MODE_ROTARY_RELATIVE, "Relative rotary"}, | |||
@@ -394,6 +398,11 @@ struct ViewButton : MenuButton { | |||
paramTooltipItem->rightText = CHECKMARK(settings::paramTooltip); | |||
menu->addChild(paramTooltipItem); | |||
AllowCursorLockItem* allowCursorLockItem = new AllowCursorLockItem; | |||
allowCursorLockItem->text = "Allow cursor lock"; | |||
allowCursorLockItem->rightText = CHECKMARK(settings::allowCursorLock); | |||
menu->addChild(allowCursorLockItem); | |||
KnobModeItem* knobModeItem = new KnobModeItem; | |||
knobModeItem->text = "Knob mode"; | |||
knobModeItem->rightText = RIGHT_ARROW; | |||
@@ -22,7 +22,8 @@ float zoom = 0.0; | |||
bool invertZoom = false; | |||
float cableOpacity = 0.5; | |||
float cableTension = 0.5; | |||
KnobMode knobMode = KNOB_MODE_LINEAR_LOCKED; | |||
bool allowCursorLock = true; | |||
KnobMode knobMode = KNOB_MODE_LINEAR; | |||
float knobLinearSensitivity = 0.001f; | |||
float sampleRate = 44100.0; | |||
int threadCount = 1; | |||
@@ -66,6 +67,8 @@ json_t* toJson() { | |||
json_object_set_new(rootJ, "cableTension", json_real(cableTension)); | |||
json_object_set_new(rootJ, "allowCursorLock", json_boolean(allowCursorLock)); | |||
json_object_set_new(rootJ, "knobMode", json_integer((int) knobMode)); | |||
json_object_set_new(rootJ, "knobLinearSensitivity", json_real(knobLinearSensitivity)); | |||
@@ -144,12 +147,9 @@ void fromJson(json_t* rootJ) { | |||
if (cableTensionJ) | |||
cableTension = json_number_value(cableTensionJ); | |||
// legacy v1 | |||
json_t* allowCursorLockJ = json_object_get(rootJ, "allowCursorLock"); | |||
if (allowCursorLockJ) { | |||
if (json_is_false(allowCursorLockJ)) | |||
knobMode = KNOB_MODE_LINEAR; | |||
} | |||
if (allowCursorLockJ) | |||
allowCursorLock = json_boolean_value(allowCursorLockJ); | |||
json_t* knobModeJ = json_object_get(rootJ, "knobMode"); | |||
if (knobModeJ) | |||
@@ -478,6 +478,9 @@ void Window::close() { | |||
} | |||
void Window::cursorLock() { | |||
if (!settings::allowCursorLock) | |||
return; | |||
#if defined ARCH_MAC | |||
glfwSetInputMode(win, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); | |||
#else | |||
@@ -487,6 +490,9 @@ void Window::cursorLock() { | |||
} | |||
void Window::cursorUnlock() { | |||
if (!settings::allowCursorLock) | |||
return; | |||
glfwSetInputMode(win, GLFW_CURSOR, GLFW_CURSOR_NORMAL); | |||
internal->ignoreNextMouseDelta = true; | |||
} | |||