Browse Source

Handle arrow key scrolling in Scene instead of RackScrollWidget in case the mouse is not hovering the RackScrollWidget.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
04be72fc54
2 changed files with 28 additions and 30 deletions
  1. +0
    -30
      src/app/RackScrollWidget.cpp
  2. +28
    -0
      src/app/Scene.cpp

+ 0
- 30
src/app/RackScrollWidget.cpp View File

@@ -110,36 +110,6 @@ void RackScrollWidget::draw(const DrawArgs& args) {

void RackScrollWidget::onHoverKey(const HoverKeyEvent& e) {
ScrollWidget::onHoverKey(e);
if (e.isConsumed())
return;

// Scroll with arrow keys
float arrowSpeed = 32.f;
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL)
arrowSpeed /= 4.f;
if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT)
arrowSpeed *= 4.f;
if ((e.mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT))
arrowSpeed /= 16.f;

if (e.action == RACK_HELD) {
if (e.key == GLFW_KEY_LEFT) {
offset.x -= arrowSpeed;
e.consume(this);
}
if (e.key == GLFW_KEY_RIGHT) {
offset.x += arrowSpeed;
e.consume(this);
}
if (e.key == GLFW_KEY_UP) {
offset.y -= arrowSpeed;
e.consume(this);
}
if (e.key == GLFW_KEY_DOWN) {
offset.y += arrowSpeed;
e.consume(this);
}
}
}




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

@@ -238,6 +238,34 @@ void Scene::onHoverKey(const HoverKeyEvent& e) {
e.consume(this);
}
}

// Scroll RackScrollWidget with arrow keys
if (e.action == RACK_HELD) {
float arrowSpeed = 32.f;
if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL)
arrowSpeed /= 4.f;
if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT)
arrowSpeed *= 4.f;
if ((e.mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT))
arrowSpeed /= 16.f;

if (e.key == GLFW_KEY_LEFT) {
rackScroll->offset.x -= arrowSpeed;
e.consume(this);
}
if (e.key == GLFW_KEY_RIGHT) {
rackScroll->offset.x += arrowSpeed;
e.consume(this);
}
if (e.key == GLFW_KEY_UP) {
rackScroll->offset.y -= arrowSpeed;
e.consume(this);
}
if (e.key == GLFW_KEY_DOWN) {
rackScroll->offset.y += arrowSpeed;
e.consume(this);
}
}
}

void Scene::onPathDrop(const PathDropEvent& e) {


Loading…
Cancel
Save