diff --git a/apps/shared/interactive_curve_view_range_delegate.cpp b/apps/shared/interactive_curve_view_range_delegate.cpp index 0c78f3dc2..1f61f1e5d 100644 --- a/apps/shared/interactive_curve_view_range_delegate.cpp +++ b/apps/shared/interactive_curve_view_range_delegate.cpp @@ -22,6 +22,12 @@ bool InteractiveCurveViewRangeDelegate::didChangeRange(InteractiveCurveViewRange if (interactiveCurveViewRange->yMin() == addMargin(min, range, true) && interactiveCurveViewRange->yMax() == addMargin(max, range, false)) { return false; } + if (min == max) { + // Add same margin on top of / below the curve, to center it on the screen + float step = max != 0.0f ? 2.0f * interactiveCurveViewRange->defaultRangeLengthFor(max) : 1.0f; + min = min - step; + max = max + step; + } if (min == FLT_MAX && max == -FLT_MAX) { min = -1.0f; max = 1.0f; diff --git a/apps/shared/memoized_curve_view_range.h b/apps/shared/memoized_curve_view_range.h index e3a78998b..3b5ff15f9 100644 --- a/apps/shared/memoized_curve_view_range.h +++ b/apps/shared/memoized_curve_view_range.h @@ -19,9 +19,9 @@ public: virtual void setXMax(float f); virtual void setYMin(float f); virtual void setYMax(float f); + float defaultRangeLengthFor(float position) const; protected: - float defaultRangeLengthFor(float position) const; // Window bounds of the data float m_xMin; float m_xMax;