From 87cc6e3edb25dfe6d04c966e53dba63f6e438cbb Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 8 Jan 2019 21:23:58 -0500 Subject: [PATCH] Param event tweaking --- src/app/ParamQuantity.cpp | 2 ++ src/app/ParamWidget.cpp | 9 ++++++--- src/app/ToggleSwitch.cpp | 8 +++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/app/ParamQuantity.cpp b/src/app/ParamQuantity.cpp index f03c4152..35e9b4fc 100644 --- a/src/app/ParamQuantity.cpp +++ b/src/app/ParamQuantity.cpp @@ -86,6 +86,8 @@ int ParamQuantity::getDisplayPrecision() { float displayValue = getDisplayValue(); if (displayValue == 0.f) return 0; + if (std::round(displayValue) == displayValue) + return 0; float log = std::log10(std::abs(getDisplayValue())); return (int) std::ceil(math::clamp(-log + 3.f, 0.f, 6.f)); } diff --git a/src/app/ParamWidget.cpp b/src/app/ParamWidget.cpp index e15dc5be..1c42edc0 100644 --- a/src/app/ParamWidget.cpp +++ b/src/app/ParamWidget.cpp @@ -93,15 +93,16 @@ void ParamWidget::fromJson(json_t *rootJ) { void ParamWidget::onButton(const event::Button &e) { // Right click to reset - if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { + if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT && !(e.mods & WINDOW_MOD) && !(e.mods & GLFW_MOD_SHIFT)) { if (quantity) quantity->reset(); // Here's another way of doing it, but either works. // dynamic_cast(quantity)->getParam()->reset(); + e.consume(this); } // Shift-click to open value entry - if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & GLFW_MOD_SHIFT) && !(e.mods & GLFW_MOD_CONTROL)) { + if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && !(e.mods & WINDOW_MOD) && (e.mods & GLFW_MOD_SHIFT)) { // Create ParamField MenuOverlay *overlay = new MenuOverlay; app()->scene->addChild(overlay); @@ -111,9 +112,11 @@ void ParamWidget::onButton(const event::Button &e) { paramField->box.pos = getAbsoluteOffset(box.size).round(); paramField->setParamWidget(this); overlay->addChild(paramField); + e.consume(this); } - OpaqueWidget::onButton(e); + if (!e.getConsumed()) + OpaqueWidget::onButton(e); } void ParamWidget::onEnter(const event::Enter &e) { diff --git a/src/app/ToggleSwitch.cpp b/src/app/ToggleSwitch.cpp index e0d2cc02..c0f7ed7b 100644 --- a/src/app/ToggleSwitch.cpp +++ b/src/app/ToggleSwitch.cpp @@ -8,10 +8,12 @@ void ToggleSwitch::onDragStart(const event::DragStart &e) { // Cycle through values // e.g. a range of [0.0, 3.0] would have modes 0, 1, 2, and 3. if (quantity) { - if (quantity->isMax()) + if (quantity->isMax()) { quantity->setMin(); - else - quantity->moveValue(1.f); + } + else { + quantity->setValue(std::floor(quantity->getValue() + 1)); + } } }