Browse Source

Added C#-style property constructor, explicitly clamp samples in Audio Interface, scroll horizontally if Shift is held

tags/v0.4.0
Andrew Belt 7 years ago
parent
commit
6239856310
7 changed files with 33 additions and 8 deletions
  1. +2
    -2
      include/gui.hpp
  2. +17
    -0
      include/util.hpp
  3. +3
    -3
      src/app/ModuleWidget.cpp
  4. +4
    -0
      src/app/Toolbar.cpp
  5. +1
    -1
      src/core/AudioInterface.cpp
  6. +4
    -0
      src/gui.cpp
  7. +2
    -2
      src/widgets/MenuItem.cpp

+ 2
- 2
include/gui.hpp View File

@@ -8,9 +8,9 @@ namespace rack {


#ifdef ARCH_MAC
#define MOD_KEY_NAME "Cmd"
#define GUI_MOD_KEY_NAME "Cmd"
#else
#define MOD_KEY_NAME "Ctrl"
#define GUI_MOD_KEY_NAME "Ctrl"
#endif




+ 17
- 0
include/util.hpp View File

@@ -32,6 +32,23 @@ will expand to
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
////////////////////


+ 3
- 3
src/app/ModuleWidget.cpp View File

@@ -236,13 +236,13 @@ Menu *ModuleWidget::createContextMenu() {

InitializeMenuItem *resetItem = new InitializeMenuItem();
resetItem->text = "Initialize";
resetItem->rightText = MOD_KEY_NAME "+I";
resetItem->rightText = GUI_MOD_KEY_NAME "+I";
resetItem->moduleWidget = this;
menu->pushChild(resetItem);

RandomizeMenuItem *randomizeItem = new RandomizeMenuItem();
randomizeItem->text = "Randomize";
randomizeItem->rightText = MOD_KEY_NAME "+R";
randomizeItem->rightText = GUI_MOD_KEY_NAME "+R";
randomizeItem->moduleWidget = this;
menu->pushChild(randomizeItem);

@@ -253,7 +253,7 @@ Menu *ModuleWidget::createContextMenu() {

CloneMenuItem *cloneItem = new CloneMenuItem();
cloneItem->text = "Duplicate";
cloneItem->rightText = MOD_KEY_NAME "+D";
cloneItem->rightText = GUI_MOD_KEY_NAME "+D";
cloneItem->moduleWidget = this;
menu->pushChild(cloneItem);



+ 4
- 0
src/app/Toolbar.cpp View File

@@ -39,18 +39,22 @@ struct FileChoice : ChoiceButton {
{
MenuItem *newItem = new NewItem();
newItem->text = "New";
newItem->rightText = GUI_MOD_KEY_NAME "+N";
menu->pushChild(newItem);

MenuItem *openItem = new OpenItem();
openItem->text = "Open";
openItem->rightText = GUI_MOD_KEY_NAME "+O";
menu->pushChild(openItem);

MenuItem *saveItem = new SaveItem();
saveItem->text = "Save";
saveItem->rightText = GUI_MOD_KEY_NAME "+S";
menu->pushChild(saveItem);

MenuItem *saveAsItem = new SaveAsItem();
saveAsItem->text = "Save As";
saveAsItem->rightText = GUI_MOD_KEY_NAME "+Shift+S";
menu->pushChild(saveAsItem);
}
}


+ 1
- 1
src/core/AudioInterface.cpp View File

@@ -206,7 +206,7 @@ void AudioInterface::stepStream(const float *input, float *output, int numFrames
break;
Frame<8> f = inputSrcBuffer.shift();
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;
}
}
}


+ 4
- 0
src/gui.cpp View File

@@ -155,6 +155,10 @@ void cursorEnterCallback(GLFWwindow* window, int entered) {

void scrollCallback(GLFWwindow *window, double x, double y) {
Vec scrollRel = Vec(x, y);
#if ARCH_LIN || ARCH_WIN
if (guiIsShiftPressed())
scrollRel = Vec(y, x);
#endif
// onScroll
gScene->onScroll(gMousePos, scrollRel.mult(50.0));
}


+ 2
- 2
src/widgets/MenuItem.cpp View File

@@ -36,10 +36,10 @@ void MenuItem::onMouseEnter() {
// Try to create child menu
Menu *childMenu = createChildMenu();
if (childMenu) {
childMenu->box.pos = parent->box.pos.plus(box.getTopRight());
parentMenu->setChildMenu(childMenu);
parentMenu->activeEntry = this;
childMenu->box.pos = parent->box.pos.plus(box.getTopRight());
}
parentMenu->setChildMenu(childMenu);
}

void MenuItem::onDragDrop(Widget *origin) {


Loading…
Cancel
Save