diff --git a/apps/graph/graph/calculation_graph_controller.cpp b/apps/graph/graph/calculation_graph_controller.cpp index ff2c56079..192301fd9 100644 --- a/apps/graph/graph/calculation_graph_controller.cpp +++ b/apps/graph/graph/calculation_graph_controller.cpp @@ -27,7 +27,7 @@ void CalculationGraphController::viewWillAppear() { } else { m_isActive = true; m_cursor->moveTo(pointOfInterest.abscissa, pointOfInterest.value); - m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio); + m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), cursorTopMarginRatio(), k_cursorRightMarginRatio, cursorBottomMarginRatio(), k_cursorLeftMarginRatio); reloadBannerView(); } m_graphView->setOkView(nullptr); @@ -76,7 +76,7 @@ bool CalculationGraphController::moveCursorHorizontally(int direction) { return false; } m_cursor->moveTo(newPointOfInterest.abscissa, newPointOfInterest.value); - m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio); + m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), cursorTopMarginRatio(), k_cursorRightMarginRatio, cursorBottomMarginRatio(), k_cursorLeftMarginRatio); return true; } diff --git a/apps/graph/graph/calculation_graph_controller.h b/apps/graph/graph/calculation_graph_controller.h index 8dff41540..976a63f6c 100644 --- a/apps/graph/graph/calculation_graph_controller.h +++ b/apps/graph/graph/calculation_graph_controller.h @@ -17,8 +17,7 @@ public: void viewWillAppear() override; void setRecord(Ion::Storage::Record record); protected: - constexpr static float k_cursorTopMarginRatio = 0.07f; // (cursorHeight/2)/graphViewHeight - constexpr static float k_cursorBottomMarginRatio = 0.15f; // (cursorHeight/2+bannerHeigh)/graphViewHeight + float cursorBottomMarginRatio() override { return 0.15f; } BannerView * bannerView() override { return m_bannerView; } void reloadBannerView() override; Poincare::Expression::Coordinate2D computeNewPointOfInteresetFromAbscissa(double start, int direction); diff --git a/apps/graph/graph/tangent_graph_controller.cpp b/apps/graph/graph/tangent_graph_controller.cpp index e2bdfd301..68acdedf9 100644 --- a/apps/graph/graph/tangent_graph_controller.cpp +++ b/apps/graph/graph/tangent_graph_controller.cpp @@ -21,7 +21,7 @@ const char * TangentGraphController::title() { } void TangentGraphController::viewWillAppear() { - m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio); + m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), cursorTopMarginRatio(), k_cursorRightMarginRatio, cursorBottomMarginRatio(), k_cursorLeftMarginRatio); m_graphView->drawTangent(true); m_graphView->setOkView(nullptr); m_graphView->selectMainView(true); @@ -61,7 +61,7 @@ void TangentGraphController::reloadBannerView() { bool TangentGraphController::moveCursorHorizontally(int direction) { App * myApp = static_cast(app()); - return privateMoveCursorHorizontally(m_cursor, direction, m_graphRange, k_numberOfCursorStepsInGradUnit, m_record, myApp, k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio); + return privateMoveCursorHorizontally(m_cursor, direction, m_graphRange, k_numberOfCursorStepsInGradUnit, m_record, myApp, cursorTopMarginRatio(), k_cursorRightMarginRatio, cursorBottomMarginRatio(), k_cursorLeftMarginRatio); } bool TangentGraphController::handleEnter() { diff --git a/apps/graph/graph/tangent_graph_controller.h b/apps/graph/graph/tangent_graph_controller.h index 7067d80de..2a04f4e99 100644 --- a/apps/graph/graph/tangent_graph_controller.h +++ b/apps/graph/graph/tangent_graph_controller.h @@ -17,8 +17,7 @@ public: void viewWillAppear() override; void setRecord(Ion::Storage::Record record); private: - constexpr static float k_cursorTopMarginRatio = 0.07f; // (cursorHeight/2)/graphViewHeight - constexpr static float k_cursorBottomMarginRatio = 0.22f; // (cursorHeight/2+bannerHeigh)/graphViewHeight + float cursorBottomMarginRatio() override { return 0.22f; } Shared::InteractiveCurveViewRange * interactiveCurveViewRange() override { return m_graphRange; } Shared::CurveView * curveView() override { return m_graphView; } BannerView * bannerView() override { return m_bannerView; }; diff --git a/apps/regression/graph_controller.h b/apps/regression/graph_controller.h index b30ac092e..252fd5e72 100644 --- a/apps/regression/graph_controller.h +++ b/apps/regression/graph_controller.h @@ -34,8 +34,7 @@ private: constexpr static float k_viewHeight = 174.0f; Poincare::Context * globalContext(); - float cursorTopMarginRatio() { return 0.07f; } // (cursorHeight/2) / graphViewHeight - float cursorBottomMarginRatio(); + float cursorBottomMarginRatio() override; float estimatedBannerHeight() const; // SimpleInteractiveCurveViewController diff --git a/apps/shared/function_graph_controller.h b/apps/shared/function_graph_controller.h index a88f90268..0300c47c7 100644 --- a/apps/shared/function_graph_controller.h +++ b/apps/shared/function_graph_controller.h @@ -19,8 +19,8 @@ public: void viewWillAppear() override; protected: - float cursorTopMarginRatio() { return 0.068f; } // (cursorHeight/2)/graphViewHeight - float cursorBottomMarginRatio(); + float cursorTopMarginRatio() override { return 0.068f; } + float cursorBottomMarginRatio() override; void reloadBannerView() override; bool handleEnter() override; int indexFunctionSelectedByCursor() const { return *m_indexFunctionSelectedByCursor; } diff --git a/apps/shared/simple_interactive_curve_view_controller.h b/apps/shared/simple_interactive_curve_view_controller.h index 6c1139a39..b25397e41 100644 --- a/apps/shared/simple_interactive_curve_view_controller.h +++ b/apps/shared/simple_interactive_curve_view_controller.h @@ -19,6 +19,8 @@ public: protected: constexpr static float k_cursorRightMarginRatio = 0.04f; // (cursorWidth/2)/graphViewWidth constexpr static float k_cursorLeftMarginRatio = 0.04f; // (cursorWidth/2)/graphViewWidth + virtual float cursorTopMarginRatio() { return 0.07f; } // (cursorHeight/2)/graphViewHeight + virtual float cursorBottomMarginRatio() = 0; // (cursorHeight/2+bannerHeight)/graphViewHeight constexpr static float k_numberOfCursorStepsInGradUnit = 5.0f; virtual bool handleZoom(Ion::Events::Event event); virtual bool handleLeftRightEvent(Ion::Events::Event event); diff --git a/apps/shared/sum_graph_controller.cpp b/apps/shared/sum_graph_controller.cpp index 9e5cda01d..21e6dc03d 100644 --- a/apps/shared/sum_graph_controller.cpp +++ b/apps/shared/sum_graph_controller.cpp @@ -28,7 +28,7 @@ SumGraphController::SumGraphController(Responder * parentResponder, InputEventHa } void SumGraphController::viewWillAppear() { - m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio); + m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), cursorTopMarginRatio(), k_cursorRightMarginRatio, cursorBottomMarginRatio(), k_cursorLeftMarginRatio); m_graphView->setBannerView(&m_legendView); m_graphView->setCursorView(&m_cursorView); m_graphView->setOkView(nullptr); @@ -80,7 +80,7 @@ bool SumGraphController::moveCursorHorizontallyToPosition(double x) { m_graphView->setAreaHighlight(m_startSum, m_endSum); } m_legendView.setEditableZone(m_cursor->x()); - m_graphRange->panToMakePointVisible(x, y, k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio); + m_graphRange->panToMakePointVisible(x, y, cursorTopMarginRatio(), k_cursorRightMarginRatio, cursorBottomMarginRatio(), k_cursorLeftMarginRatio); m_graphView->reload(); return true; } diff --git a/apps/shared/sum_graph_controller.h b/apps/shared/sum_graph_controller.h index 3a9e24573..b33d4e0a8 100644 --- a/apps/shared/sum_graph_controller.h +++ b/apps/shared/sum_graph_controller.h @@ -34,8 +34,8 @@ protected: Ion::Storage::Record m_record; InteractiveCurveViewRange * m_graphRange; private: - constexpr static float k_cursorTopMarginRatio = 0.06f; // (cursorHeight/2)/graphViewHeight - constexpr static float k_cursorBottomMarginRatio = 0.28f; // (cursorHeight/2+bannerHeigh)/graphViewHeight + float cursorTopMarginRatio() override { return 0.06f; } + float cursorBottomMarginRatio() override { return 0.28f; } bool handleLeftRightEvent(Ion::Events::Event event) override; bool handleEnter() override; void reloadBannerView() override;