Browse Source

Improve behavior for unbounded params

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
ec83a4dacb
4 changed files with 13 additions and 3 deletions
  1. +2
    -0
      include/app/ParamQuantity.hpp
  2. +8
    -0
      src/app/ParamQuantity.cpp
  3. +1
    -1
      src/app/ParamWidget.cpp
  4. +2
    -2
      src/app/SVGKnob.cpp

+ 2
- 0
include/app/ParamQuantity.hpp View File

@@ -24,6 +24,8 @@ struct ParamQuantity : Quantity {
float getDefaultValue() override;
float getDisplayValue() override;
void setDisplayValue(float displayValue) override;
std::string getDisplayValueString() override;
void setDisplayValueString(std::string s) override;
int getDisplayPrecision() override;
std::string getLabel() override;
std::string getUnit() override;


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

@@ -101,6 +101,14 @@ int ParamQuantity::getDisplayPrecision() {
return (int) std::ceil(math::clamp(-log + 3.f, 0.f, 6.f));
}

std::string ParamQuantity::getDisplayValueString() {
return Quantity::getDisplayValueString();
}

void ParamQuantity::setDisplayValueString(std::string s) {
Quantity::setDisplayValueString(s);
}

std::string ParamQuantity::getLabel() {
if (!module)
return Quantity::getLabel();


+ 1
- 1
src/app/ParamWidget.cpp View File

@@ -104,7 +104,7 @@ 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 && !(e.mods & WINDOW_MOD) && !(e.mods & GLFW_MOD_SHIFT)) {
if (paramQuantity) {
if (paramQuantity && paramQuantity->isBounded()) {
float oldValue = paramQuantity->getValue();
paramQuantity->reset();
float newValue = paramQuantity->getValue();


+ 2
- 2
src/app/SVGKnob.cpp View File

@@ -36,11 +36,11 @@ void SVGKnob::onChange(const event::Change &e) {
float angle;
if (paramQuantity->isBounded()) {
angle = math::rescale(paramQuantity->getScaledValue(), 0.f, 1.f, minAngle, maxAngle);
angle = std::fmod(angle, 2*M_PI);
}
else {
angle = math::rescale(paramQuantity->getValue(), 0.f, 1.f, minAngle, maxAngle);
angle = math::rescale(paramQuantity->getValue(), -1.f, 1.f, minAngle, maxAngle);
}
angle = std::fmod(angle, 2*M_PI);
tw->identity();
// Rotate SVG
math::Vec center = sw->box.getCenter();


Loading…
Cancel
Save