diff --git a/apps/shared/interactive_curve_view_range.cpp b/apps/shared/interactive_curve_view_range.cpp index 1f39cf56b..3f9f1e6ab 100644 --- a/apps/shared/interactive_curve_view_range.cpp +++ b/apps/shared/interactive_curve_view_range.cpp @@ -19,12 +19,10 @@ uint32_t InteractiveCurveViewRange::rangeChecksum() { void InteractiveCurveViewRange::setXMin(float xMin) { MemoizedCurveViewRange::protectedSetXMin(xMin, k_lowerMaxFloat, k_upperMaxFloat); - notifyRangeChange(); } void InteractiveCurveViewRange::setXMax(float xMax) { MemoizedCurveViewRange::protectedSetXMax(xMax, k_lowerMaxFloat, k_upperMaxFloat); - notifyRangeChange(); } void InteractiveCurveViewRange::setYMin(float yMin) { @@ -176,10 +174,10 @@ void InteractiveCurveViewRange::panToMakePointVisible(float x, float y, float to } } -void InteractiveCurveViewRange::notifyRangeChange() { - if (m_delegate) { - m_delegate->didChangeRange(this); - } +void InteractiveCurveViewRange::checkForNormalizedRange() { + float pixelHeight = std::round(Ion::Display::Height * (NormalizedYHalfRange(100.f) / Ion::Display::HeightInTenthOfMillimeter)); + float pixelWidth = std::round(Ion::Display::Width * (NormalizedXHalfRange(100.f) / Ion::Display::WidthInTenthOfMillimeter)); + m_zoomNormalize = std::round(pixelHeight * (xMax() - xMin())) == std::round(pixelWidth * (yMax() - yMin())); } } diff --git a/apps/shared/interactive_curve_view_range.h b/apps/shared/interactive_curve_view_range.h index 17d91220d..4b1c389bd 100644 --- a/apps/shared/interactive_curve_view_range.h +++ b/apps/shared/interactive_curve_view_range.h @@ -13,12 +13,19 @@ class InteractiveCurveViewRange : public MemoizedCurveViewRange { public: InteractiveCurveViewRange(InteractiveCurveViewRangeDelegate * delegate = nullptr) : MemoizedCurveViewRange(), - m_delegate(delegate) + m_delegate(delegate), + m_zoomAuto(true), + m_zoomNormalize(false) {} void setDelegate(InteractiveCurveViewRangeDelegate * delegate) { m_delegate = delegate; } uint32_t rangeChecksum() override; + bool zoomAuto() const { return m_zoomAuto; } + void setZoomAuto(bool v) { m_zoomAuto = v; } + bool zoomNormalize() const { return m_zoomNormalize; } + void setZoomNormalize(bool v) { m_zoomNormalize = v; } + // CurveViewWindow void setXMin(float f) override; void setXMax(float f) override; @@ -32,6 +39,8 @@ public: virtual void setDefault(); void centerAxisAround(Axis axis, float position); void panToMakePointVisible(float x, float y, float topMarginRatio, float rightMarginRatio, float bottomMarginRation, float leftMarginRation, float pixelWidth); + void checkForNormalizedRange(); + protected: constexpr static float k_upperMaxFloat = 1E+8f; constexpr static float k_lowerMaxFloat = 9E+7f; @@ -53,7 +62,8 @@ protected: constexpr static float NormalizedYHalfRange(float unit) { return 3.06f * unit; } InteractiveCurveViewRangeDelegate * m_delegate; private: - void notifyRangeChange(); + bool m_zoomAuto; + bool m_zoomNormalize; }; static_assert(Ion::Display::WidthInTenthOfMillimeter == 576, "Use the new screen width to compute Shared::InteractiveCurveViewRange::NormalizedXHalfRange"); diff --git a/apps/shared/range_parameter_controller.cpp b/apps/shared/range_parameter_controller.cpp index 62a0f77e7..d841783d0 100644 --- a/apps/shared/range_parameter_controller.cpp +++ b/apps/shared/range_parameter_controller.cpp @@ -81,6 +81,9 @@ int RangeParameterController::reusableParameterCellCount(int type) { void RangeParameterController::buttonAction() { *m_interactiveRange = m_tempInteractiveRange; + m_interactiveRange->setZoomAuto(false); + m_interactiveRange->checkForNormalizedRange(); + StackViewController * stack = stackController(); stack->pop(); }