@@ -8,9 +8,9 @@ namespace rack { | |||||
#ifdef ARCH_MAC | #ifdef ARCH_MAC | ||||
#define MOD_KEY_NAME "Cmd" | |||||
#define GUI_MOD_KEY_NAME "Cmd" | |||||
#else | #else | ||||
#define MOD_KEY_NAME "Ctrl" | |||||
#define GUI_MOD_KEY_NAME "Ctrl" | |||||
#endif | #endif | ||||
@@ -32,6 +32,23 @@ will expand to | |||||
namespace rack { | namespace rack { | ||||
/** C#-style property constructor | |||||
Example: | |||||
Foo *foo = construct<Foo>(&Foo::greeting, "Hello world"); | |||||
*/ | |||||
template<typename T> | |||||
T *construct() { | |||||
return new T(); | |||||
} | |||||
template<typename T, typename F, typename V, typename... Args> | |||||
T *construct(F f, V v, Args... args) { | |||||
T *o = construct<T>(args...); | |||||
o->*f = v; | |||||
return o; | |||||
} | |||||
//////////////////// | //////////////////// | ||||
// RNG | // RNG | ||||
//////////////////// | //////////////////// | ||||
@@ -236,13 +236,13 @@ Menu *ModuleWidget::createContextMenu() { | |||||
InitializeMenuItem *resetItem = new InitializeMenuItem(); | InitializeMenuItem *resetItem = new InitializeMenuItem(); | ||||
resetItem->text = "Initialize"; | resetItem->text = "Initialize"; | ||||
resetItem->rightText = MOD_KEY_NAME "+I"; | |||||
resetItem->rightText = GUI_MOD_KEY_NAME "+I"; | |||||
resetItem->moduleWidget = this; | resetItem->moduleWidget = this; | ||||
menu->pushChild(resetItem); | menu->pushChild(resetItem); | ||||
RandomizeMenuItem *randomizeItem = new RandomizeMenuItem(); | RandomizeMenuItem *randomizeItem = new RandomizeMenuItem(); | ||||
randomizeItem->text = "Randomize"; | randomizeItem->text = "Randomize"; | ||||
randomizeItem->rightText = MOD_KEY_NAME "+R"; | |||||
randomizeItem->rightText = GUI_MOD_KEY_NAME "+R"; | |||||
randomizeItem->moduleWidget = this; | randomizeItem->moduleWidget = this; | ||||
menu->pushChild(randomizeItem); | menu->pushChild(randomizeItem); | ||||
@@ -253,7 +253,7 @@ Menu *ModuleWidget::createContextMenu() { | |||||
CloneMenuItem *cloneItem = new CloneMenuItem(); | CloneMenuItem *cloneItem = new CloneMenuItem(); | ||||
cloneItem->text = "Duplicate"; | cloneItem->text = "Duplicate"; | ||||
cloneItem->rightText = MOD_KEY_NAME "+D"; | |||||
cloneItem->rightText = GUI_MOD_KEY_NAME "+D"; | |||||
cloneItem->moduleWidget = this; | cloneItem->moduleWidget = this; | ||||
menu->pushChild(cloneItem); | menu->pushChild(cloneItem); | ||||
@@ -39,18 +39,22 @@ struct FileChoice : ChoiceButton { | |||||
{ | { | ||||
MenuItem *newItem = new NewItem(); | MenuItem *newItem = new NewItem(); | ||||
newItem->text = "New"; | newItem->text = "New"; | ||||
newItem->rightText = GUI_MOD_KEY_NAME "+N"; | |||||
menu->pushChild(newItem); | menu->pushChild(newItem); | ||||
MenuItem *openItem = new OpenItem(); | MenuItem *openItem = new OpenItem(); | ||||
openItem->text = "Open"; | openItem->text = "Open"; | ||||
openItem->rightText = GUI_MOD_KEY_NAME "+O"; | |||||
menu->pushChild(openItem); | menu->pushChild(openItem); | ||||
MenuItem *saveItem = new SaveItem(); | MenuItem *saveItem = new SaveItem(); | ||||
saveItem->text = "Save"; | saveItem->text = "Save"; | ||||
saveItem->rightText = GUI_MOD_KEY_NAME "+S"; | |||||
menu->pushChild(saveItem); | menu->pushChild(saveItem); | ||||
MenuItem *saveAsItem = new SaveAsItem(); | MenuItem *saveAsItem = new SaveAsItem(); | ||||
saveAsItem->text = "Save As"; | saveAsItem->text = "Save As"; | ||||
saveAsItem->rightText = GUI_MOD_KEY_NAME "+Shift+S"; | |||||
menu->pushChild(saveAsItem); | menu->pushChild(saveAsItem); | ||||
} | } | ||||
} | } | ||||
@@ -206,7 +206,7 @@ void AudioInterface::stepStream(const float *input, float *output, int numFrames | |||||
break; | break; | ||||
Frame<8> f = inputSrcBuffer.shift(); | Frame<8> f = inputSrcBuffer.shift(); | ||||
for (int c = 0; c < numOutputs; c++) { | for (int c = 0; c < numOutputs; c++) { | ||||
output[i*numOutputs + c] = (c < 8) ? f.samples[c] : 0.0; | |||||
output[i*numOutputs + c] = (c < 8) ? clampf(f.samples[c], -1.0, 1.0) : 0.0; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -155,6 +155,10 @@ void cursorEnterCallback(GLFWwindow* window, int entered) { | |||||
void scrollCallback(GLFWwindow *window, double x, double y) { | void scrollCallback(GLFWwindow *window, double x, double y) { | ||||
Vec scrollRel = Vec(x, y); | Vec scrollRel = Vec(x, y); | ||||
#if ARCH_LIN || ARCH_WIN | |||||
if (guiIsShiftPressed()) | |||||
scrollRel = Vec(y, x); | |||||
#endif | |||||
// onScroll | // onScroll | ||||
gScene->onScroll(gMousePos, scrollRel.mult(50.0)); | gScene->onScroll(gMousePos, scrollRel.mult(50.0)); | ||||
} | } | ||||
@@ -36,10 +36,10 @@ void MenuItem::onMouseEnter() { | |||||
// Try to create child menu | // Try to create child menu | ||||
Menu *childMenu = createChildMenu(); | Menu *childMenu = createChildMenu(); | ||||
if (childMenu) { | if (childMenu) { | ||||
childMenu->box.pos = parent->box.pos.plus(box.getTopRight()); | |||||
parentMenu->setChildMenu(childMenu); | |||||
parentMenu->activeEntry = this; | parentMenu->activeEntry = this; | ||||
childMenu->box.pos = parent->box.pos.plus(box.getTopRight()); | |||||
} | } | ||||
parentMenu->setChildMenu(childMenu); | |||||
} | } | ||||
void MenuItem::onDragDrop(Widget *origin) { | void MenuItem::onDragDrop(Widget *origin) { | ||||