Browse Source

Add Ctrl+Plus key command for keyboard layouts that have a "+" key.

tags/v2.6.1
Andrew Belt 3 months ago
parent
commit
89e5b460eb
2 changed files with 11 additions and 5 deletions
  1. +8
    -3
      src/app/Scene.cpp
  2. +3
    -2
      src/widget/event.cpp

+ 8
- 3
src/app/Scene.cpp View File

@@ -170,7 +170,7 @@ void Scene::onDragHover(const DragHoverEvent& e) {
void Scene::onHoverKey(const HoverKeyEvent& e) {
// Key commands that override children
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) {
// DEBUG("key %d '%c' scancode %d keyName '%s'", e.key, e.key, e.scancode, e.keyName.c_str());
// DEBUG("key %d '%c' scancode %d keyName '%s' mods %02x", e.key, e.key, e.scancode, e.keyName.c_str(), e.mods);
if (e.isKeyCommand(GLFW_KEY_N, RACK_MOD_CTRL)) {
APP->patch->loadTemplateDialog();
e.consume(this);
@@ -211,8 +211,13 @@ void Scene::onHoverKey(const HoverKeyEvent& e) {
APP->scene->rackScroll->setZoom(std::pow(2.f, zoom));
e.consume(this);
}
// Numpad has a "+" key, but the main keyboard section hides it under "="
if (e.isKeyCommand(GLFW_KEY_EQUAL, RACK_MOD_CTRL) || e.isKeyCommand(GLFW_KEY_KP_ADD, RACK_MOD_CTRL)) {
if (e.isKeyCommand(GLFW_KEY_EQUAL, RACK_MOD_CTRL)
// The user might hold shift to access the + character
|| e.isKeyCommand(GLFW_KEY_EQUAL, RACK_MOD_CTRL | GLFW_MOD_SHIFT)
// Numpad + key
|| e.isKeyCommand(GLFW_KEY_KP_ADD, RACK_MOD_CTRL)
// Some layouts (e.g. QWERTZ) have a + key, but GLFW doesn't have a macro for it
|| e.isKeyCommand('+', RACK_MOD_CTRL)) {
float zoom = std::log2(APP->scene->rackScroll->getZoom());
zoom *= 2;
zoom = std::floor(zoom + 0.01f) + 1;


+ 3
- 2
src/widget/event.cpp View File

@@ -74,10 +74,11 @@ std::string getKeyCommandName(int key, int mods) {


bool Widget::KeyBaseEvent::isKeyCommand(int key, int mods) const {
// DEBUG("this key '%c' %d keyName \"%s\" mods 0x%02x | checked key '%c' %d mods 0x%02x", this->key, this->key, this->keyName.c_str(), this->mods, key, key, mods);
// Reject if mods don't match
if ((this->mods & RACK_MOD_MASK) != mods)
return false;
// Reject invalid keys
// Reject control characters. GLFW shouldn't generate these anyway.
if (this->key < 32)
return false;
// Are both keys printable?
@@ -91,7 +92,7 @@ bool Widget::KeyBaseEvent::isKeyCommand(int key, int mods) const {
return k == key;
}
}
// Check equal QWERTY keys, printable or not
// Check equal GLFW key ID, printable or not
return this->key == key;
}



Loading…
Cancel
Save