@@ -312,15 +312,17 @@ class PropertiesPanel : public Component {
312312 Value property;
313313 String allowedCharacters = " " ;
314314 double min, max;
315+ bool limit;
315316
316317 public:
317318 std::unique_ptr<Component> label;
318319
319- EditableComponent (String const & propertyName, Value const & value, double minimum = 0.0 , double maximum = 0.0 , std::function<void (bool )> onInteractionFn = nullptr )
320+ EditableComponent (String const & propertyName, Value const & value, bool clip = false , double minimum = 0.0 , double maximum = 1 << 30 , std::function<void (bool )> onInteractionFn = nullptr )
320321 : PropertiesPanelProperty(propertyName)
321322 , property(value)
322323 , min(minimum)
323324 , max(maximum)
325+ , limit(clip)
324326 {
325327 if constexpr (std::is_arithmetic_v<T>) {
326328 auto * draggableNumber = new DraggableNumber (std::is_integral_v<T>);
@@ -331,29 +333,30 @@ class PropertiesPanel : public Component {
331333 draggableNumber->setFont (draggableNumber->getFont ().withHeight (14 .5f ));
332334 draggableNumber->setEditableOnClick (true );
333335
334- if (minimum != 0 .0f )
336+ if (clip)
337+ {
335338 draggableNumber->setMinimum (minimum);
336- if (maximum != 0 .0f )
337339 draggableNumber->setMaximum (maximum);
340+ }
338341
339342 if (onInteractionFn)
340343 draggableNumber->onInteraction = onInteractionFn;
341-
344+
342345 draggableNumber->setPrecision (3 );
343346
344347 draggableNumber->onValueChange = [this ](double const newValue) {
345- if (min != 0 . 0f || max != 0 . 0f ) {
346- property = std::clamp (newValue, min, max);
348+ if (limit ) {
349+ property = std::clamp<T> (newValue, min, max);
347350 } else {
348- property = newValue;
351+ property = static_cast <T>( newValue) ;
349352 }
350353 };
351354
352355 draggableNumber->onReturnKey = [this ](double const newValue) {
353- if (min != 0 . 0f || max != 0 . 0f ) {
354- property = std::clamp (newValue, min, max);
356+ if (limit ) {
357+ property = std::clamp<T> (newValue, min, max);
355358 } else {
356- property = newValue;
359+ property = static_cast <T>( newValue) ;
357360 }
358361 };
359362
@@ -382,7 +385,7 @@ class PropertiesPanel : public Component {
382385
383386 labelComp->onEditorHide = [this ] {
384387 // synchronise the value to the canvas when updated
385- if (PluginEditor * pluginEditor = findParentComponentOfClass<PluginEditor>()) {
388+ if (auto * pluginEditor = findParentComponentOfClass<PluginEditor>()) {
386389 if (auto const cnv = pluginEditor->getCurrentCanvas ())
387390 cnv->synchronise ();
388391 }
@@ -398,8 +401,8 @@ class PropertiesPanel : public Component {
398401 {
399402 if constexpr (std::is_arithmetic_v<T>) {
400403 auto const draggableNumber = reinterpret_cast <DraggableNumber*>(label.get ());
401- auto const value = getValue<double >(v);
402- if (value != draggableNumber->getValue ()) {
404+ auto const value = getValue<T >(v);
405+ if (value != static_cast <T>( draggableNumber->getValue () )) {
403406 draggableNumber->setValue (value, dontSendNotification);
404407 }
405408 }
@@ -415,22 +418,6 @@ class PropertiesPanel : public Component {
415418 allowedCharacters = newAllowedCharacters;
416419 }
417420
418- void setRangeMin (float const minimum)
419- {
420- min = minimum;
421- if constexpr (std::is_arithmetic_v<T>) {
422- dynamic_cast <DraggableNumber*>(label.get ())->setMinimum (minimum);
423- }
424- }
425-
426- void setRangeMax (float const maximum)
427- {
428- max = maximum;
429- if constexpr (std::is_arithmetic_v<T>) {
430- dynamic_cast <DraggableNumber*>(label.get ())->setMaximum (maximum);
431- }
432- }
433-
434421 void resized () override
435422 {
436423 label->setBounds (getLocalBounds ().removeFromRight (getWidth () / (2 - hideLabel)));
0 commit comments