Browse Source

Param event tweaking

tags/v1.0.0
Andrew Belt 6 years ago
parent
commit
87cc6e3edb
3 changed files with 13 additions and 6 deletions
  1. +2
    -0
      src/app/ParamQuantity.cpp
  2. +6
    -3
      src/app/ParamWidget.cpp
  3. +5
    -3
      src/app/ToggleSwitch.cpp

+ 2
- 0
src/app/ParamQuantity.cpp View File

@@ -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));
}


+ 6
- 3
src/app/ParamWidget.cpp View File

@@ -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<ParamQuantity*>(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) {


+ 5
- 3
src/app/ToggleSwitch.cpp View File

@@ -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));
}
}
}



Loading…
Cancel
Save