diff --git a/include/math.hpp b/include/math.hpp index ca83a664..134546d3 100644 --- a/include/math.hpp +++ b/include/math.hpp @@ -59,9 +59,11 @@ inline float eucmodf(float a, float base) { return mod < 0.0 ? mod + base : mod; } -/** Limits a value between a minimum and maximum */ +/** Limits a value between a minimum and maximum +If min < max, returns max +*/ inline float clampf(float x, float min, float max) { - return x > max ? max : x < min ? min : x; + return fmaxf(min, fminf(max, x)); } /** If the magnitude of x if less than eps, return 0 */ diff --git a/src/widgets/MenuOverlay.cpp b/src/widgets/MenuOverlay.cpp index 72c4bcbd..240875c0 100644 --- a/src/widgets/MenuOverlay.cpp +++ b/src/widgets/MenuOverlay.cpp @@ -6,7 +6,7 @@ namespace rack { void MenuOverlay::step() { // Try to fit all children into the overlay's box for (Widget *child : children) { - child->box = child->box.clamp(box); + child->box = child->box.clamp(Rect(Vec(0, 0), box.size)); } }