From e95ea50d3cb1246ebb5a36fe1970d7af34a2e9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 29 Mar 2017 16:30:37 +0200 Subject: [PATCH] [apps/shared] Fix bug in go to parameter controllers Change-Id: I196378c4921583af42dc4a2e64e3a6c32038f9d1 --- apps/regression/go_to_parameter_controller.cpp | 6 ++---- apps/shared/go_to_parameter_controller.cpp | 4 ++-- apps/shared/interactive_curve_view_controller.cpp | 8 +++----- apps/shared/interactive_curve_view_range.cpp | 4 ++++ apps/shared/interactive_curve_view_range.h | 1 + 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/regression/go_to_parameter_controller.cpp b/apps/regression/go_to_parameter_controller.cpp index f0d45e799..c27d5109a 100644 --- a/apps/regression/go_to_parameter_controller.cpp +++ b/apps/regression/go_to_parameter_controller.cpp @@ -56,8 +56,6 @@ bool GoToParameterController::setParameterAtIndex(int parameterIndex, float f) { app()->displayWarning(I18n::Message::ForbiddenValue); return false; } - m_store->centerAxisAround(CurveViewRange::Axis::X, f); - m_store->centerAxisAround(CurveViewRange::Axis::Y, y); m_cursor->moveTo(f, y); } else { float x = m_store->xValueForYValue(f); @@ -65,8 +63,6 @@ bool GoToParameterController::setParameterAtIndex(int parameterIndex, float f) { app()->displayWarning(I18n::Message::ForbiddenValue); return false; } - m_store->centerAxisAround(CurveViewRange::Axis::X, x); - m_store->centerAxisAround(CurveViewRange::Axis::Y, f); m_cursor->moveTo(x, f); } return true; @@ -114,6 +110,8 @@ void GoToParameterController::viewWillAppear() { } void GoToParameterController::buttonAction() { + m_store->centerAxisAround(CurveViewRange::Axis::X, m_cursor->x()); + m_store->centerAxisAround(CurveViewRange::Axis::Y, m_cursor->y()); StackViewController * stack = (StackViewController *)parentResponder(); stack->pop(); stack->pop(); diff --git a/apps/shared/go_to_parameter_controller.cpp b/apps/shared/go_to_parameter_controller.cpp index a895d25b1..760d4195a 100644 --- a/apps/shared/go_to_parameter_controller.cpp +++ b/apps/shared/go_to_parameter_controller.cpp @@ -44,8 +44,6 @@ bool GoToParameterController::setParameterAtIndex(int parameterIndex, float f) { app()->displayWarning(I18n::Message::ForbiddenValue); return false; } - m_graphRange->centerAxisAround(CurveViewRange::Axis::X, f); - m_graphRange->centerAxisAround(CurveViewRange::Axis::Y, y); m_cursor->moveTo(f, y); return true; } @@ -64,6 +62,8 @@ void GoToParameterController::setFunction(Function * function) { } void GoToParameterController::buttonAction() { + m_graphRange->centerAxisAround(CurveViewRange::Axis::X, m_cursor->x()); + m_graphRange->centerAxisAround(CurveViewRange::Axis::Y, m_cursor->y()); StackViewController * stack = (StackViewController *)parentResponder(); stack->pop(); stack->pop(); diff --git a/apps/shared/interactive_curve_view_controller.cpp b/apps/shared/interactive_curve_view_controller.cpp index d0f61710c..0208d93b7 100644 --- a/apps/shared/interactive_curve_view_controller.cpp +++ b/apps/shared/interactive_curve_view_controller.cpp @@ -137,15 +137,13 @@ void InteractiveCurveViewController::viewWillAppear() { * reloading banner view needs an updated cursor to load the right data. */ initCursorParameters(); centerCursorVertically(); - reloadBannerView(); - curveView()->reload(); } uint32_t newRangeVersion = rangeVersion(); if (m_rangeVersion != newRangeVersion) { m_rangeVersion = newRangeVersion; - initCursorParameters(); - reloadBannerView(); - curveView()->reload(); + if (!interactiveCurveViewRange()->isCursorVisible()) { + initCursorParameters(); + } } curveView()->selectMainView(true); header()->setSelectedButton(-1); diff --git a/apps/shared/interactive_curve_view_range.cpp b/apps/shared/interactive_curve_view_range.cpp index d1573ad58..7b4bc14de 100644 --- a/apps/shared/interactive_curve_view_range.cpp +++ b/apps/shared/interactive_curve_view_range.cpp @@ -201,6 +201,10 @@ void InteractiveCurveViewRange::panToMakePointVisible(float x, float y, float to } } +bool InteractiveCurveViewRange::isCursorVisible() { + return m_cursor->x() >= m_xMin && m_cursor->x() <= m_xMax && m_cursor->y() >= m_yMin && m_cursor->y() <= m_yMax; +} + float InteractiveCurveViewRange::clipped(float x, bool isMax) { float max = isMax ? k_upperMaxFloat : k_lowerMaxFloat; float min = isMax ? -k_lowerMaxFloat : -k_upperMaxFloat; diff --git a/apps/shared/interactive_curve_view_range.h b/apps/shared/interactive_curve_view_range.h index f4b39a141..f1f7fca7c 100644 --- a/apps/shared/interactive_curve_view_range.h +++ b/apps/shared/interactive_curve_view_range.h @@ -31,6 +31,7 @@ public: virtual void setDefault(); void centerAxisAround(Axis axis, float position); void panToMakePointVisible(float x, float y, float topMarginRatio, float rightMarginRatio, float bottomMarginRation, float leftMarginRation); + bool isCursorVisible(); protected: bool m_yAuto; InteractiveCurveViewRangeDelegate * m_delegate;