Skip to content

Commit

Permalink
Don't clip numbox values when setting with message, similar to pd-van…
Browse files Browse the repository at this point in the history
…illa
  • Loading branch information
timothyschoen committed Jan 9, 2025
1 parent 355c313 commit ee66019
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
6 changes: 4 additions & 2 deletions Source/Components/DraggableNumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ class DraggableNumber : public Label
return false;
}

void setValue(double newValue, NotificationType const notification = sendNotification)
void setValue(double newValue, NotificationType const notification = sendNotification, bool clip = true)
{
wasReset = false;

newValue = limitValue(newValue);
if(clip) {
newValue = limitValue(newValue);
}

setText(formatNumber(newValue, decimalDrag), notification);

Expand Down
12 changes: 2 additions & 10 deletions Source/Objects/FloatAtomObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,8 @@ class FloatAtomObject final : public ObjectBase {
case hash("list"): {
if (atoms.size() < 1 || !atoms[0].isFloat())
break;

auto const min = atomHelper.getMinimum();
auto const max = atomHelper.getMaximum();

if (!approximatelyEqual(min, 0.0f) || !approximatelyEqual(max, 0.0f)) {
value = std::clamp(atoms[0].getFloat(), min, max);
} else {
value = atoms[0].getFloat();
}
input.setValue(value, dontSendNotification);
value = atoms[0].getFloat();
input.setValue(value, dontSendNotification, false);
break;
}
case hash("send"): {
Expand Down
4 changes: 2 additions & 2 deletions Source/Objects/NumberObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ class NumberObject final : public ObjectBase {
case hash("list"):
case hash("set"): {
if (atoms.size() > 0 && atoms[0].isFloat()) {
value = std::clamp(atoms[0].getFloat(), ::getValue<float>(min), ::getValue<float>(max));
input.setValue(value, dontSendNotification);
value = atoms[0].getFloat();
input.setValue(value, dontSendNotification, false);
}
break;
}
Expand Down

0 comments on commit ee66019

Please sign in to comment.