diff --git a/apps/regression/graph_controller.cpp b/apps/regression/graph_controller.cpp index d77a194ef..192201d8a 100644 --- a/apps/regression/graph_controller.cpp +++ b/apps/regression/graph_controller.cpp @@ -75,19 +75,6 @@ Poincare::Context * GraphController::globalContext() { return const_cast(static_cast(app()->container()))->globalContext(); } -float GraphController::cursorBottomMarginRatio() { - float f = (m_view.cursorView()->minimalSizeForOptimalDisplay().height()/2 + 2 + estimatedBannerHeight())/k_viewHeight; - return f; -} - -float GraphController::estimatedBannerHeight() const { - if (selectedSeriesIndex() < 0) { - return KDFont::SmallFont->glyphSize().height() * 3; - } - float result = KDFont::SmallFont->glyphSize().height() * m_store->modelForSeries(selectedSeriesIndex())->bannerLinesCount(); - return result; -} - // SimpleInteractiveCurveViewController void GraphController::reloadBannerView() { @@ -382,13 +369,12 @@ int GraphController::numberOfCurves() const { return Store::k_numberOfSeries; } -float GraphController::displayTopMarginRatio() { - return 0.12f; // cursorHeight/graphViewHeight +int GraphController::estimatedBannerNumberOfLines() const { + return (selectedSeriesIndex() < 0) ? 3 : m_store->modelForSeries(selectedSeriesIndex())->bannerLinesCount(); } -float GraphController::displayBottomMarginRatio() { - float f = (m_view.cursorView()->minimalSizeForOptimalDisplay().height() + 2 + estimatedBannerHeight())/k_viewHeight; - return f; +float GraphController::displayTopMarginRatio() { + return 0.12f; // cursorHeight/graphViewHeight } InteractiveCurveViewRangeDelegate::Range GraphController::computeYRange(InteractiveCurveViewRange * interactiveCurveViewRange) { diff --git a/apps/regression/graph_controller.h b/apps/regression/graph_controller.h index 2f7d59e25..a44da8f1e 100644 --- a/apps/regression/graph_controller.h +++ b/apps/regression/graph_controller.h @@ -31,11 +31,8 @@ public: private: constexpr static int k_maxLegendLength = 16; constexpr static int k_maxNumberOfCharacters = 50; - constexpr static float k_viewHeight = 174.0f; Poincare::Context * globalContext(); - float cursorBottomMarginRatio() override; - float estimatedBannerHeight() const; // SimpleInteractiveCurveViewController void reloadBannerView() override; @@ -52,10 +49,10 @@ private: double yValue(int curveIndex, double x, Poincare::Context * context) const override; bool suitableYValue(double y) const override; int numberOfCurves() const override; + int estimatedBannerNumberOfLines() const override; // InteractiveCurveViewRangeDelegate float displayTopMarginRatio() override; - float displayBottomMarginRatio() override; Shared::InteractiveCurveViewRangeDelegate::Range computeYRange(Shared::InteractiveCurveViewRange * interactiveCurveViewRange) override; Shared::CursorView m_crossCursorView; diff --git a/apps/shared/function_graph_controller.cpp b/apps/shared/function_graph_controller.cpp index 7e9b78cb1..56776141e 100644 --- a/apps/shared/function_graph_controller.cpp +++ b/apps/shared/function_graph_controller.cpp @@ -55,10 +55,6 @@ void FunctionGraphController::selectFunctionWithCursor(int functionIndex) { *m_indexFunctionSelectedByCursor = functionIndex; } -float FunctionGraphController::cursorBottomMarginRatio() { - return (curveView()->cursorView()->minimalSizeForOptimalDisplay().height()/2+estimatedBannerHeight())/k_viewHeight; -} - void FunctionGraphController::reloadBannerView() { if (functionStore()->numberOfActiveFunctions() == 0) { return; @@ -67,14 +63,6 @@ void FunctionGraphController::reloadBannerView() { reloadBannerViewForCursorOnFunction(m_cursor, record, functionStore(), functionStore()->symbol()); } -float FunctionGraphController::displayBottomMarginRatio() { - return (curveView()->cursorView()->minimalSizeForOptimalDisplay().height() + 2 + estimatedBannerHeight()) / k_viewHeight; -} - -float FunctionGraphController::estimatedBannerHeight() const { - return BannerView::HeightGivenNumberOfLines(estimatedBannerNumberOfLines()); -} - InteractiveCurveViewRangeDelegate::Range FunctionGraphController::computeYRange(InteractiveCurveViewRange * interactiveCurveViewRange) { FunctionApp * myApp = static_cast(app()); float min = FLT_MAX; diff --git a/apps/shared/function_graph_controller.h b/apps/shared/function_graph_controller.h index f5cf39a4b..59d8f51b2 100644 --- a/apps/shared/function_graph_controller.h +++ b/apps/shared/function_graph_controller.h @@ -20,7 +20,6 @@ public: protected: float cursorTopMarginRatio() override { return 0.068f; } - float cursorBottomMarginRatio() override; void reloadBannerView() override; bool handleEnter() override; int indexFunctionSelectedByCursor() const { return *m_indexFunctionSelectedByCursor; } @@ -29,8 +28,6 @@ protected: virtual FunctionStore * functionStore() const; private: - constexpr static float k_viewHeight = 174.0f; // TODO Taken from Regresssion/graph_controller. Maybe we should compute and/or put in common ? - virtual FunctionGraphView * functionGraphView() = 0; virtual FunctionCurveParameterController * curveParameterController() = 0; @@ -38,12 +35,9 @@ private: /* When y auto is ticked, we use a display margin to be ensure that the user * can move the cursor along the curve without panning the window */ float displayTopMarginRatio() override { return 0.09f; } // cursorHeight/graphViewHeight - float displayBottomMarginRatio() override; // InteractiveCurveViewRangeDelegate InteractiveCurveViewRangeDelegate::Range computeYRange(InteractiveCurveViewRange * interactiveCurveViewRange) override; - float estimatedBannerHeight() const; - virtual int estimatedBannerNumberOfLines() const { return 1; } // InteractiveCurveViewController void initCursorParameters() override; diff --git a/apps/shared/interactive_curve_view_controller.cpp b/apps/shared/interactive_curve_view_controller.cpp index 9ed7e5a81..82de5ec6c 100644 --- a/apps/shared/interactive_curve_view_controller.cpp +++ b/apps/shared/interactive_curve_view_controller.cpp @@ -247,4 +247,16 @@ int InteractiveCurveViewController::closestCurveIndexVertically(bool goingUp, in return nextCurveIndex; } +float InteractiveCurveViewController::cursorBottomMarginRatio() { + return (curveView()->cursorView()->minimalSizeForOptimalDisplay().height()/2+estimatedBannerHeight())/k_viewHeight; +} + +float InteractiveCurveViewController::estimatedBannerHeight() const { + return BannerView::HeightGivenNumberOfLines(estimatedBannerNumberOfLines()); +} + +float InteractiveCurveViewController::displayBottomMarginRatio() { + return (curveView()->cursorView()->minimalSizeForOptimalDisplay().height() + 2 + estimatedBannerHeight()) / k_viewHeight; +} + } diff --git a/apps/shared/interactive_curve_view_controller.h b/apps/shared/interactive_curve_view_controller.h index 0d84460b4..7cabe64e6 100644 --- a/apps/shared/interactive_curve_view_controller.h +++ b/apps/shared/interactive_curve_view_controller.h @@ -46,12 +46,19 @@ protected: virtual bool suitableYValue(double y) const { return true; } virtual int numberOfCurves() const = 0; + // SimpleInteractiveCurveViewController + float cursorBottomMarginRatio() override; + OkView m_okView; private: + constexpr static float k_viewHeight = 174.0f; + float estimatedBannerHeight() const; + virtual int estimatedBannerNumberOfLines() const { return 1; } + // InteractiveCurveViewRangeDelegate float addMargin(float x, float range, bool isMin) override; virtual float displayTopMarginRatio() = 0; - virtual float displayBottomMarginRatio() = 0; + float displayBottomMarginRatio(); uint32_t * m_modelVersion; uint32_t * m_rangeVersion;