Browse Source

Move module selection key commands to Scene so they are handled regardless of mouse position.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
b017ebf887
4 changed files with 61 additions and 20 deletions
  1. +1
    -0
      include/app/RackWidget.hpp
  2. +23
    -20
      src/app/ModuleWidget.cpp
  3. +10
    -0
      src/app/RackWidget.cpp
  4. +27
    -0
      src/app/Scene.cpp

+ 1
- 0
include/app/RackWidget.hpp View File

@@ -72,6 +72,7 @@ struct RackWidget : widget::OpaqueWidget {

void updateModuleSelections();
void clearModuleSelections();
bool hasSelectedModules();
int getNumSelectedModules();
std::list<ModuleWidget*> getSelectedModules();
void resetSelectedModulesAction();


+ 23
- 20
src/app/ModuleWidget.cpp View File

@@ -316,18 +316,17 @@ void ModuleWidget::onHoverKey(const HoverKeyEvent& e) {

if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) {
if (e.keyName == "i" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
if (internal->selected)
APP->scene->rack->resetSelectedModulesAction();
else
// Don't handle key commands if modules are selected, since it will interfere with Scene's module selection key commands
if (!APP->scene->rack->hasSelectedModules()) {
resetAction();
e.consume(this);
e.consume(this);
}
}
if (e.keyName == "r" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
if (internal->selected)
APP->scene->rack->randomizeSelectedModulesAction();
else
if (!APP->scene->rack->hasSelectedModules()) {
randomizeAction();
e.consume(this);
e.consume(this);
}
}
if (e.keyName == "c" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
copyClipboard();
@@ -342,28 +341,32 @@ void ModuleWidget::onHoverKey(const HoverKeyEvent& e) {
e.consume(this);
}
if (e.keyName == "u" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
if (internal->selected)
APP->scene->rack->disconnectSelectedModulesAction();
else
if (!APP->scene->rack->hasSelectedModules()) {
disconnectAction();
e.consume(this);
e.consume(this);
}
}
if (e.keyName == "e" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
if (internal->selected)
APP->scene->rack->bypassSelectedModulesAction(!APP->scene->rack->areSelectedModulesBypassed());
else
if (!APP->scene->rack->hasSelectedModules()) {
bypassAction(!module->isBypassed());
e.consume(this);
e.consume(this);
}
}
if ((e.key == GLFW_KEY_DELETE || e.key == GLFW_KEY_BACKSPACE) && (e.mods & RACK_MOD_MASK) == 0) {
if (!APP->scene->rack->hasSelectedModules()) {
removeAction();
e.consume(this);
}
}
}

if (e.action == RACK_HELD) {
// Also handle Delete/Backspace when holding the key while hovering
if ((e.key == GLFW_KEY_DELETE || e.key == GLFW_KEY_BACKSPACE) && (e.mods & RACK_MOD_MASK) == 0) {
if (internal->selected)
APP->scene->rack->deleteSelectedModulesAction();
else
if (!APP->scene->rack->hasSelectedModules()) {
removeAction();
e.consume(NULL);
e.consume(NULL);
}
}
}
}


+ 10
- 0
src/app/RackWidget.cpp View File

@@ -659,6 +659,16 @@ void RackWidget::clearModuleSelections() {
}
}

bool RackWidget::hasSelectedModules() {
for (widget::Widget* w : internal->moduleContainer->children) {
ModuleWidget* mw = dynamic_cast<ModuleWidget*>(w);
assert(mw);
if (mw->selected())
return true;
}
return false;
}

int RackWidget::getNumSelectedModules() {
int count = 0;
for (widget::Widget* w : internal->moduleContainer->children) {


+ 27
- 0
src/app/Scene.cpp View File

@@ -210,6 +210,33 @@ void Scene::onHoverKey(const HoverKeyEvent& e) {
APP->window->setFullScreen(false);
e.consume(this);
}

// Module selections
if (e.keyName == "i" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
if (rack->hasSelectedModules())
rack->resetSelectedModulesAction();
e.consume(this);
}
if (e.keyName == "r" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
if (rack->hasSelectedModules())
rack->randomizeSelectedModulesAction();
e.consume(this);
}
if (e.keyName == "u" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
if (rack->hasSelectedModules())
rack->disconnectSelectedModulesAction();
e.consume(this);
}
if (e.keyName == "e" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
if (rack->hasSelectedModules())
rack->bypassSelectedModulesAction(!rack->areSelectedModulesBypassed());
e.consume(this);
}
if ((e.key == GLFW_KEY_DELETE || e.key == GLFW_KEY_BACKSPACE) && (e.mods & RACK_MOD_MASK) == 0) {
if (rack->hasSelectedModules())
rack->deleteSelectedModulesAction();
e.consume(this);
}
}
}



Loading…
Cancel
Save