@@ -2,10 +2,6 @@ | |||||
#include "common.hpp" | #include "common.hpp" | ||||
/** Accesses the global App pointer */ | |||||
#define APP rack::appGet() | |||||
namespace rack { | namespace rack { | ||||
@@ -52,5 +48,8 @@ void appDestroy(); | |||||
/** Returns the global App pointer */ | /** Returns the global App pointer */ | ||||
App *appGet(); | App *appGet(); | ||||
/** Accesses the global App pointer */ | |||||
#define APP appGet() | |||||
} // namespace rack | } // namespace rack |
@@ -18,21 +18,21 @@ | |||||
Use this instead of GLFW_MOD_CONTROL, since Cmd should be used on Mac in place of Ctrl on Linux/Windows. | Use this instead of GLFW_MOD_CONTROL, since Cmd should be used on Mac in place of Ctrl on Linux/Windows. | ||||
*/ | */ | ||||
#if defined ARCH_MAC | #if defined ARCH_MAC | ||||
#define WINDOW_MOD_CTRL GLFW_MOD_SUPER | |||||
#define WINDOW_MOD_CTRL_NAME "Cmd" | |||||
#define RACK_MOD_CTRL GLFW_MOD_SUPER | |||||
#define RACK_MOD_CTRL_NAME "Cmd" | |||||
#else | #else | ||||
#define WINDOW_MOD_CTRL GLFW_MOD_CONTROL | |||||
#define WINDOW_MOD_CTRL_NAME "Ctrl" | |||||
#define RACK_MOD_CTRL GLFW_MOD_CONTROL | |||||
#define RACK_MOD_CTRL_NAME "Ctrl" | |||||
#endif | #endif | ||||
#define WINDOW_MOD_SHIFT_NAME "Shift" | |||||
#define WINDOW_MOD_ALT_NAME "Alt" | |||||
#define RACK_MOD_SHIFT_NAME "Shift" | |||||
#define RACK_MOD_ALT_NAME "Alt" | |||||
/** Filters actual mod keys from the mod flags. | /** Filters actual mod keys from the mod flags. | ||||
Use this if you don't care about GLFW_MOD_CAPS_LOCK and GLFW_MOD_NUM_LOCK. | Use this if you don't care about GLFW_MOD_CAPS_LOCK and GLFW_MOD_NUM_LOCK. | ||||
Example usage: | Example usage: | ||||
if ((e.mod & WINDOW_MOD_MASK) == (WINDOW_MOD | GLFW_MOD_SHIFT)) ... | |||||
if ((e.mod & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) ... | |||||
*/ | */ | ||||
#define WINDOW_MOD_MASK (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL | GLFW_MOD_ALT | GLFW_MOD_SUPER) | |||||
#define RACK_MOD_MASK (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL | GLFW_MOD_ALT | GLFW_MOD_SUPER) | |||||
namespace rack { | namespace rack { | ||||
@@ -127,7 +127,7 @@ struct CcChoice : LedDisplayChoice { | |||||
} | } | ||||
void onSelectKey(const event::SelectKey &e) override { | void onSelectKey(const event::SelectKey &e) override { | ||||
if ((e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) && e.action == GLFW_PRESS && (e.mods & WINDOW_MOD_MASK) == 0) { | |||||
if ((e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) && e.action == GLFW_PRESS && (e.mods & RACK_MOD_MASK) == 0) { | |||||
event::Deselect eDeselect; | event::Deselect eDeselect; | ||||
onDeselect(eDeselect); | onDeselect(eDeselect); | ||||
APP->event->selectedWidget = NULL; | APP->event->selectedWidget = NULL; | ||||
@@ -82,11 +82,11 @@ void Knob::onDragMove(const event::DragMove &e) { | |||||
// Drag slower if mod is held | // Drag slower if mod is held | ||||
int mods = APP->window->getMods(); | int mods = APP->window->getMods(); | ||||
if ((mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
delta /= 16.f; | delta /= 16.f; | ||||
} | } | ||||
// Drag even slower if mod+shift is held | // Drag even slower if mod+shift is held | ||||
if ((mods & WINDOW_MOD_MASK) == (WINDOW_MOD_CTRL | GLFW_MOD_SHIFT)) { | |||||
if ((mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) { | |||||
delta /= 256.f; | delta /= 256.f; | ||||
} | } | ||||
@@ -178,13 +178,13 @@ struct ModulePresetItem : ui::MenuItem { | |||||
ModuleCopyItem *copyItem = new ModuleCopyItem; | ModuleCopyItem *copyItem = new ModuleCopyItem; | ||||
copyItem->text = "Copy"; | copyItem->text = "Copy"; | ||||
copyItem->rightText = WINDOW_MOD_CTRL_NAME "+C"; | |||||
copyItem->rightText = RACK_MOD_CTRL_NAME "+C"; | |||||
copyItem->moduleWidget = moduleWidget; | copyItem->moduleWidget = moduleWidget; | ||||
menu->addChild(copyItem); | menu->addChild(copyItem); | ||||
ModulePasteItem *pasteItem = new ModulePasteItem; | ModulePasteItem *pasteItem = new ModulePasteItem; | ||||
pasteItem->text = "Paste"; | pasteItem->text = "Paste"; | ||||
pasteItem->rightText = WINDOW_MOD_CTRL_NAME "+V"; | |||||
pasteItem->rightText = RACK_MOD_CTRL_NAME "+V"; | |||||
pasteItem->moduleWidget = moduleWidget; | pasteItem->moduleWidget = moduleWidget; | ||||
menu->addChild(pasteItem); | menu->addChild(pasteItem); | ||||
@@ -308,7 +308,7 @@ void ModuleWidget::onHover(const event::Hover &e) { | |||||
// Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. | // Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. | ||||
if ((glfwGetKey(APP->window->win, GLFW_KEY_DELETE) == GLFW_PRESS | if ((glfwGetKey(APP->window->win, GLFW_KEY_DELETE) == GLFW_PRESS | ||||
|| glfwGetKey(APP->window->win, GLFW_KEY_BACKSPACE) == GLFW_PRESS) | || glfwGetKey(APP->window->win, GLFW_KEY_BACKSPACE) == GLFW_PRESS) | ||||
&& (APP->window->getMods() & WINDOW_MOD_MASK) == 0) { | |||||
&& (APP->window->getMods() & RACK_MOD_MASK) == 0) { | |||||
removeAction(); | removeAction(); | ||||
e.consume(NULL); | e.consume(NULL); | ||||
return; | return; | ||||
@@ -336,43 +336,43 @@ void ModuleWidget::onHoverKey(const event::HoverKey &e) { | |||||
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | ||||
switch (e.key) { | switch (e.key) { | ||||
case GLFW_KEY_I: { | case GLFW_KEY_I: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
resetAction(); | resetAction(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_R: { | case GLFW_KEY_R: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
randomizeAction(); | randomizeAction(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_C: { | case GLFW_KEY_C: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
copyClipboard(); | copyClipboard(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_V: { | case GLFW_KEY_V: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
pasteClipboardAction(); | pasteClipboardAction(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_D: { | case GLFW_KEY_D: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
cloneAction(); | cloneAction(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_U: { | case GLFW_KEY_U: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
disconnectAction(); | disconnectAction(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_E: { | case GLFW_KEY_E: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
bypassAction(); | bypassAction(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
@@ -403,7 +403,7 @@ void ModuleWidget::onDragEnd(const event::DragEnd &e) { | |||||
void ModuleWidget::onDragMove(const event::DragMove &e) { | void ModuleWidget::onDragMove(const event::DragMove &e) { | ||||
if (!settings::lockModules) { | if (!settings::lockModules) { | ||||
math::Vec pos = APP->scene->rack->mousePos.minus(dragPos); | math::Vec pos = APP->scene->rack->mousePos.minus(dragPos); | ||||
if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) | |||||
if ((APP->window->getMods() & RACK_MOD_MASK) == RACK_MOD_CTRL) | |||||
APP->scene->rack->setModulePosForce(this, pos); | APP->scene->rack->setModulePosForce(this, pos); | ||||
else | else | ||||
APP->scene->rack->setModulePosNearest(this, pos); | APP->scene->rack->setModulePosNearest(this, pos); | ||||
@@ -822,31 +822,31 @@ void ModuleWidget::createContextMenu() { | |||||
ModuleResetItem *resetItem = new ModuleResetItem; | ModuleResetItem *resetItem = new ModuleResetItem; | ||||
resetItem->text = "Initialize"; | resetItem->text = "Initialize"; | ||||
resetItem->rightText = WINDOW_MOD_CTRL_NAME "+I"; | |||||
resetItem->rightText = RACK_MOD_CTRL_NAME "+I"; | |||||
resetItem->moduleWidget = this; | resetItem->moduleWidget = this; | ||||
menu->addChild(resetItem); | menu->addChild(resetItem); | ||||
ModuleRandomizeItem *randomizeItem = new ModuleRandomizeItem; | ModuleRandomizeItem *randomizeItem = new ModuleRandomizeItem; | ||||
randomizeItem->text = "Randomize"; | randomizeItem->text = "Randomize"; | ||||
randomizeItem->rightText = WINDOW_MOD_CTRL_NAME "+R"; | |||||
randomizeItem->rightText = RACK_MOD_CTRL_NAME "+R"; | |||||
randomizeItem->moduleWidget = this; | randomizeItem->moduleWidget = this; | ||||
menu->addChild(randomizeItem); | menu->addChild(randomizeItem); | ||||
ModuleDisconnectItem *disconnectItem = new ModuleDisconnectItem; | ModuleDisconnectItem *disconnectItem = new ModuleDisconnectItem; | ||||
disconnectItem->text = "Disconnect cables"; | disconnectItem->text = "Disconnect cables"; | ||||
disconnectItem->rightText = WINDOW_MOD_CTRL_NAME "+U"; | |||||
disconnectItem->rightText = RACK_MOD_CTRL_NAME "+U"; | |||||
disconnectItem->moduleWidget = this; | disconnectItem->moduleWidget = this; | ||||
menu->addChild(disconnectItem); | menu->addChild(disconnectItem); | ||||
ModuleCloneItem *cloneItem = new ModuleCloneItem; | ModuleCloneItem *cloneItem = new ModuleCloneItem; | ||||
cloneItem->text = "Duplicate"; | cloneItem->text = "Duplicate"; | ||||
cloneItem->rightText = WINDOW_MOD_CTRL_NAME "+D"; | |||||
cloneItem->rightText = RACK_MOD_CTRL_NAME "+D"; | |||||
cloneItem->moduleWidget = this; | cloneItem->moduleWidget = this; | ||||
menu->addChild(cloneItem); | menu->addChild(cloneItem); | ||||
ModuleBypassItem *bypassItem = new ModuleBypassItem; | ModuleBypassItem *bypassItem = new ModuleBypassItem; | ||||
bypassItem->text = "Disable"; | bypassItem->text = "Disable"; | ||||
bypassItem->rightText = WINDOW_MOD_CTRL_NAME "+E"; | |||||
bypassItem->rightText = RACK_MOD_CTRL_NAME "+E"; | |||||
if (module && module->bypass) | if (module && module->bypass) | ||||
bypassItem->rightText = CHECKMARK_STRING " " + bypassItem->rightText; | bypassItem->rightText = CHECKMARK_STRING " " + bypassItem->rightText; | ||||
bypassItem->moduleWidget = this; | bypassItem->moduleWidget = this; | ||||
@@ -143,7 +143,7 @@ void ParamWidget::onButton(const event::Button &e) { | |||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
// Touch parameter | // Touch parameter | ||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & WINDOW_MOD_MASK) == 0) { | |||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & RACK_MOD_MASK) == 0) { | |||||
if (paramQuantity) { | if (paramQuantity) { | ||||
APP->scene->rack->touchedParam = this; | APP->scene->rack->touchedParam = this; | ||||
} | } | ||||
@@ -151,7 +151,7 @@ void ParamWidget::onButton(const event::Button &e) { | |||||
} | } | ||||
// Right click to open context menu | // Right click to open context menu | ||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT && (e.mods & WINDOW_MOD_MASK) == 0) { | |||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT && (e.mods & RACK_MOD_MASK) == 0) { | |||||
createContextMenu(); | createContextMenu(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
@@ -206,7 +206,7 @@ void ParamWidget::createContextMenu() { | |||||
// ParamFineItem *fineItem = new ParamFineItem; | // ParamFineItem *fineItem = new ParamFineItem; | ||||
// fineItem->text = "Fine adjust"; | // fineItem->text = "Fine adjust"; | ||||
// fineItem->rightText = WINDOW_MOD_CTRL_NAME "+drag"; | |||||
// fineItem->rightText = RACK_MOD_CTRL_NAME "+drag"; | |||||
// fineItem->disabled = true; | // fineItem->disabled = true; | ||||
// menu->addChild(fineItem); | // menu->addChild(fineItem); | ||||
@@ -91,7 +91,7 @@ void PortWidget::onDragStart(const event::DragStart &e) { | |||||
return; | return; | ||||
CableWidget *cw = NULL; | CableWidget *cw = NULL; | ||||
if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((APP->window->getMods() & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
if (type == OUTPUT) { | if (type == OUTPUT) { | ||||
// Keep cable NULL. Will be created below | // Keep cable NULL. Will be created below | ||||
} | } | ||||
@@ -77,11 +77,11 @@ void RackScrollWidget::draw(const DrawArgs &args) { | |||||
void RackScrollWidget::onHover(const event::Hover &e) { | void RackScrollWidget::onHover(const event::Hover &e) { | ||||
// Scroll with arrow keys | // Scroll with arrow keys | ||||
float arrowSpeed = 30.0; | float arrowSpeed = 30.0; | ||||
if ((APP->window->getMods() & WINDOW_MOD_MASK) == (WINDOW_MOD_CTRL |GLFW_MOD_SHIFT)) | |||||
if ((APP->window->getMods() & RACK_MOD_MASK) == (RACK_MOD_CTRL |GLFW_MOD_SHIFT)) | |||||
arrowSpeed /= 16.0; | arrowSpeed /= 16.0; | ||||
else if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) | |||||
else if ((APP->window->getMods() & RACK_MOD_MASK) == RACK_MOD_CTRL) | |||||
arrowSpeed *= 4.0; | arrowSpeed *= 4.0; | ||||
else if ((APP->window->getMods() & WINDOW_MOD_MASK) == GLFW_MOD_SHIFT) | |||||
else if ((APP->window->getMods() & RACK_MOD_MASK) == GLFW_MOD_SHIFT) | |||||
arrowSpeed /= 4.0; | arrowSpeed /= 4.0; | ||||
if (glfwGetKey(APP->window->win, GLFW_KEY_LEFT) == GLFW_PRESS) | if (glfwGetKey(APP->window->win, GLFW_KEY_LEFT) == GLFW_PRESS) | ||||
@@ -97,7 +97,7 @@ void RackScrollWidget::onHover(const event::Hover &e) { | |||||
} | } | ||||
void RackScrollWidget::onHoverScroll(const event::HoverScroll &e) { | void RackScrollWidget::onHoverScroll(const event::HoverScroll &e) { | ||||
if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((APP->window->getMods() & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
// Increase zoom | // Increase zoom | ||||
float zoomDelta = e.scrollDelta.y / 50 / 4; | float zoomDelta = e.scrollDelta.y / 50 / 4; | ||||
if (settings::invertZoom) | if (settings::invertZoom) | ||||
@@ -131,7 +131,7 @@ void RackWidget::onHoverKey(const event::HoverKey &e) { | |||||
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | ||||
switch (e.key) { | switch (e.key) { | ||||
case GLFW_KEY_V: { | case GLFW_KEY_V: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
pastePresetClipboardAction(); | pastePresetClipboardAction(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
@@ -79,49 +79,49 @@ void Scene::onHoverKey(const event::HoverKey &e) { | |||||
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | ||||
switch (e.key) { | switch (e.key) { | ||||
case GLFW_KEY_N: { | case GLFW_KEY_N: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
APP->patch->resetDialog(); | APP->patch->resetDialog(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_Q: { | case GLFW_KEY_Q: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
APP->window->close(); | APP->window->close(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_O: { | case GLFW_KEY_O: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
APP->patch->loadDialog(); | APP->patch->loadDialog(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
if ((e.mods & WINDOW_MOD_MASK) == (WINDOW_MOD_CTRL | GLFW_MOD_SHIFT)) { | |||||
if ((e.mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) { | |||||
APP->patch->revertDialog(); | APP->patch->revertDialog(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_S: { | case GLFW_KEY_S: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
APP->patch->saveDialog(); | APP->patch->saveDialog(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
if ((e.mods & WINDOW_MOD_MASK) == (WINDOW_MOD_CTRL | GLFW_MOD_SHIFT)) { | |||||
if ((e.mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) { | |||||
APP->patch->saveAsDialog(); | APP->patch->saveAsDialog(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_Z: { | case GLFW_KEY_Z: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
APP->history->undo(); | APP->history->undo(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
if ((e.mods & WINDOW_MOD_MASK) == (WINDOW_MOD_CTRL | GLFW_MOD_SHIFT)) { | |||||
if ((e.mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) { | |||||
APP->history->redo(); | APP->history->redo(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_MINUS: { | case GLFW_KEY_MINUS: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
float z = std::log2(settings::zoom); | float z = std::log2(settings::zoom); | ||||
z *= 2; | z *= 2; | ||||
z = std::ceil(z - 0.01) - 1; | z = std::ceil(z - 0.01) - 1; | ||||
@@ -131,7 +131,7 @@ void Scene::onHoverKey(const event::HoverKey &e) { | |||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_EQUAL: { | case GLFW_KEY_EQUAL: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
float z = std::log2(settings::zoom); | float z = std::log2(settings::zoom); | ||||
z *= 2; | z *= 2; | ||||
z = std::floor(z + 0.01) + 1; | z = std::floor(z + 0.01) + 1; | ||||
@@ -97,22 +97,22 @@ struct FileButton : MenuButton { | |||||
NewItem *newItem = new NewItem; | NewItem *newItem = new NewItem; | ||||
newItem->text = "New"; | newItem->text = "New"; | ||||
newItem->rightText = WINDOW_MOD_CTRL_NAME "+N"; | |||||
newItem->rightText = RACK_MOD_CTRL_NAME "+N"; | |||||
menu->addChild(newItem); | menu->addChild(newItem); | ||||
OpenItem *openItem = new OpenItem; | OpenItem *openItem = new OpenItem; | ||||
openItem->text = "Open"; | openItem->text = "Open"; | ||||
openItem->rightText = WINDOW_MOD_CTRL_NAME "+O"; | |||||
openItem->rightText = RACK_MOD_CTRL_NAME "+O"; | |||||
menu->addChild(openItem); | menu->addChild(openItem); | ||||
SaveItem *saveItem = new SaveItem; | SaveItem *saveItem = new SaveItem; | ||||
saveItem->text = "Save"; | saveItem->text = "Save"; | ||||
saveItem->rightText = WINDOW_MOD_CTRL_NAME "+S"; | |||||
saveItem->rightText = RACK_MOD_CTRL_NAME "+S"; | |||||
menu->addChild(saveItem); | menu->addChild(saveItem); | ||||
SaveAsItem *saveAsItem = new SaveAsItem; | SaveAsItem *saveAsItem = new SaveAsItem; | ||||
saveAsItem->text = "Save as"; | saveAsItem->text = "Save as"; | ||||
saveAsItem->rightText = WINDOW_MOD_CTRL_NAME "+Shift+S"; | |||||
saveAsItem->rightText = RACK_MOD_CTRL_NAME "+Shift+S"; | |||||
menu->addChild(saveAsItem); | menu->addChild(saveAsItem); | ||||
SaveTemplateItem *saveTemplateItem = new SaveTemplateItem; | SaveTemplateItem *saveTemplateItem = new SaveTemplateItem; | ||||
@@ -129,7 +129,7 @@ struct FileButton : MenuButton { | |||||
QuitItem *quitItem = new QuitItem; | QuitItem *quitItem = new QuitItem; | ||||
quitItem->text = "Quit"; | quitItem->text = "Quit"; | ||||
quitItem->rightText = WINDOW_MOD_CTRL_NAME "+Q"; | |||||
quitItem->rightText = RACK_MOD_CTRL_NAME "+Q"; | |||||
menu->addChild(quitItem); | menu->addChild(quitItem); | ||||
} | } | ||||
}; | }; | ||||
@@ -157,13 +157,13 @@ struct EditButton : MenuButton { | |||||
UndoItem *undoItem = new UndoItem; | UndoItem *undoItem = new UndoItem; | ||||
undoItem->text = "Undo " + APP->history->getUndoName(); | undoItem->text = "Undo " + APP->history->getUndoName(); | ||||
undoItem->rightText = WINDOW_MOD_CTRL_NAME "+Z"; | |||||
undoItem->rightText = RACK_MOD_CTRL_NAME "+Z"; | |||||
undoItem->disabled = !APP->history->canUndo(); | undoItem->disabled = !APP->history->canUndo(); | ||||
menu->addChild(undoItem); | menu->addChild(undoItem); | ||||
RedoItem *redoItem = new RedoItem; | RedoItem *redoItem = new RedoItem; | ||||
redoItem->text = "Redo " + APP->history->getRedoName(); | redoItem->text = "Redo " + APP->history->getRedoName(); | ||||
redoItem->rightText = WINDOW_MOD_CTRL_NAME "+" WINDOW_MOD_SHIFT_NAME "+Z"; | |||||
redoItem->rightText = RACK_MOD_CTRL_NAME "+" RACK_MOD_SHIFT_NAME "+Z"; | |||||
redoItem->disabled = !APP->history->canRedo(); | redoItem->disabled = !APP->history->canRedo(); | ||||
menu->addChild(redoItem); | menu->addChild(redoItem); | ||||
} | } | ||||
@@ -102,7 +102,7 @@ void ScrollWidget::onHoverScroll(const event::HoverScroll &e) { | |||||
math::Vec scrollDelta = e.scrollDelta; | math::Vec scrollDelta = e.scrollDelta; | ||||
// Flip coordinates if shift is held | // Flip coordinates if shift is held | ||||
if ((APP->window->getMods() & WINDOW_MOD_MASK) == GLFW_MOD_SHIFT) | |||||
if ((APP->window->getMods() & RACK_MOD_MASK) == GLFW_MOD_SHIFT) | |||||
scrollDelta = scrollDelta.flip(); | scrollDelta = scrollDelta.flip(); | ||||
offset = offset.minus(scrollDelta); | offset = offset.minus(scrollDelta); | ||||
@@ -93,7 +93,7 @@ void TextField::onSelectKey(const event::SelectKey &e) { | |||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_LEFT: { | case GLFW_KEY_LEFT: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
while (--cursor > 0) { | while (--cursor > 0) { | ||||
if (text[cursor] == ' ') | if (text[cursor] == ' ') | ||||
break; | break; | ||||
@@ -102,12 +102,12 @@ void TextField::onSelectKey(const event::SelectKey &e) { | |||||
else { | else { | ||||
cursor--; | cursor--; | ||||
} | } | ||||
if ((e.mods & WINDOW_MOD_MASK) == 0) { | |||||
if ((e.mods & RACK_MOD_MASK) == 0) { | |||||
selection = cursor; | selection = cursor; | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_RIGHT: { | case GLFW_KEY_RIGHT: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
while (++cursor < (int) text.size()) { | while (++cursor < (int) text.size()) { | ||||
if (text[cursor] == ' ') | if (text[cursor] == ' ') | ||||
break; | break; | ||||
@@ -116,7 +116,7 @@ void TextField::onSelectKey(const event::SelectKey &e) { | |||||
else { | else { | ||||
cursor++; | cursor++; | ||||
} | } | ||||
if ((e.mods & WINDOW_MOD_MASK) == 0) { | |||||
if ((e.mods & RACK_MOD_MASK) == 0) { | |||||
selection = cursor; | selection = cursor; | ||||
} | } | ||||
} break; | } break; | ||||
@@ -127,14 +127,14 @@ void TextField::onSelectKey(const event::SelectKey &e) { | |||||
selection = cursor = text.size(); | selection = cursor = text.size(); | ||||
} break; | } break; | ||||
case GLFW_KEY_V: { | case GLFW_KEY_V: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
const char *newText = glfwGetClipboardString(APP->window->win); | const char *newText = glfwGetClipboardString(APP->window->win); | ||||
if (newText) | if (newText) | ||||
insertText(newText); | insertText(newText); | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_X: { | case GLFW_KEY_X: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
if (cursor != selection) { | if (cursor != selection) { | ||||
int begin = std::min(cursor, selection); | int begin = std::min(cursor, selection); | ||||
std::string selectedText = text.substr(begin, std::abs(selection - cursor)); | std::string selectedText = text.substr(begin, std::abs(selection - cursor)); | ||||
@@ -144,7 +144,7 @@ void TextField::onSelectKey(const event::SelectKey &e) { | |||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_C: { | case GLFW_KEY_C: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
if (cursor != selection) { | if (cursor != selection) { | ||||
int begin = std::min(cursor, selection); | int begin = std::min(cursor, selection); | ||||
std::string selectedText = text.substr(begin, std::abs(selection - cursor)); | std::string selectedText = text.substr(begin, std::abs(selection - cursor)); | ||||
@@ -153,7 +153,7 @@ void TextField::onSelectKey(const event::SelectKey &e) { | |||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_A: { | case GLFW_KEY_A: { | ||||
if ((e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||||
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { | |||||
selectAll(); | selectAll(); | ||||
} | } | ||||
} break; | } break; | ||||
@@ -159,7 +159,7 @@ static void keyCallback(GLFWwindow *win, int key, int scancode, int action, int | |||||
return; | return; | ||||
// Keyboard MIDI driver | // Keyboard MIDI driver | ||||
if ((mods & WINDOW_MOD_MASK) == 0) { | |||||
if ((mods & RACK_MOD_MASK) == 0) { | |||||
if (action == GLFW_PRESS) { | if (action == GLFW_PRESS) { | ||||
keyboard::press(key); | keyboard::press(key); | ||||
} | } | ||||