Browse Source

RackWidget ignore arrow keys for scrolling if widget is selected.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
aa16adc196
3 changed files with 39 additions and 30 deletions
  1. +0
    -1
      include/rack.hpp
  2. +16
    -8
      src/Core/MIDI_Map.cpp
  3. +23
    -21
      src/app/RackWidget.cpp

+ 0
- 1
include/rack.hpp View File

@@ -72,7 +72,6 @@
#include "engine/Module.hpp"
#include "engine/Param.hpp"
#include "engine/Cable.hpp"
#include "engine/ParamMap.hpp"

#include "plugin/Plugin.hpp"
#include "plugin/Model.hpp"


+ 16
- 8
src/Core/MIDI_Map.cpp View File

@@ -105,6 +105,12 @@ struct MIDI_MapChoice : LedDisplayChoice {
this->module = module;
}

void onAction(const event::Action &e) override {
if (!module)
return;
module->lastLearnedCc = -1;
}

void onSelect(const event::Select &e) override {
if (!module)
return;
@@ -133,15 +139,17 @@ struct MIDI_MapChoice : LedDisplayChoice {
if (APP->event->selectedWidget != this)
APP->event->setSelected(this);
}
else if (module->learnedCcs[id] >= 0) {
text = string::f("CC%d", module->learnedCcs[id]);
color.a = 1.0;
bgColor = nvgRGBA(0, 0, 0, 0);
}
else {
text = "Unmapped";
color.a = 0.5;
bgColor = nvgRGBA(0, 0, 0, 0);
if (module->learnedCcs[id] >= 0) {
text = string::f("CC%d", module->learnedCcs[id]);
color.a = 1.0;
bgColor = nvgRGBA(0, 0, 0, 0);
}
else {
text = "Unmapped";
color.a = 0.5;
bgColor = nvgRGBA(0, 0, 0, 0);
}

// HACK
if (APP->event->selectedWidget == this)


+ 23
- 21
src/app/RackWidget.cpp View File

@@ -122,27 +122,29 @@ void RackWidget::draw(const widget::DrawContext &ctx) {
}

void RackWidget::onHover(const event::Hover &e) {
// Scroll with arrow keys
float arrowSpeed = 30.0;
if ((APP->window->getMods() & WINDOW_MOD_MASK) == (WINDOW_MOD_CTRL |GLFW_MOD_SHIFT))
arrowSpeed /= 16.0;
else if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL)
arrowSpeed *= 4.0;
else if ((APP->window->getMods() & WINDOW_MOD_MASK) == GLFW_MOD_SHIFT)
arrowSpeed /= 4.0;

ui::ScrollWidget *scrollWidget = APP->scene->scrollWidget;
if (glfwGetKey(APP->window->win, GLFW_KEY_LEFT) == GLFW_PRESS) {
scrollWidget->offset.x -= arrowSpeed;
}
if (glfwGetKey(APP->window->win, GLFW_KEY_RIGHT) == GLFW_PRESS) {
scrollWidget->offset.x += arrowSpeed;
}
if (glfwGetKey(APP->window->win, GLFW_KEY_UP) == GLFW_PRESS) {
scrollWidget->offset.y -= arrowSpeed;
}
if (glfwGetKey(APP->window->win, GLFW_KEY_DOWN) == GLFW_PRESS) {
scrollWidget->offset.y += arrowSpeed;
if (!APP->event->selectedWidget) {
// Scroll with arrow keys
float arrowSpeed = 30.0;
if ((APP->window->getMods() & WINDOW_MOD_MASK) == (WINDOW_MOD_CTRL |GLFW_MOD_SHIFT))
arrowSpeed /= 16.0;
else if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL)
arrowSpeed *= 4.0;
else if ((APP->window->getMods() & WINDOW_MOD_MASK) == GLFW_MOD_SHIFT)
arrowSpeed /= 4.0;

ui::ScrollWidget *scrollWidget = APP->scene->scrollWidget;
if (glfwGetKey(APP->window->win, GLFW_KEY_LEFT) == GLFW_PRESS) {
scrollWidget->offset.x -= arrowSpeed;
}
if (glfwGetKey(APP->window->win, GLFW_KEY_RIGHT) == GLFW_PRESS) {
scrollWidget->offset.x += arrowSpeed;
}
if (glfwGetKey(APP->window->win, GLFW_KEY_UP) == GLFW_PRESS) {
scrollWidget->offset.y -= arrowSpeed;
}
if (glfwGetKey(APP->window->win, GLFW_KEY_DOWN) == GLFW_PRESS) {
scrollWidget->offset.y += arrowSpeed;
}
}

widget::OpaqueWidget::onHover(e);


Loading…
Cancel
Save