From 9cd50d8d9a843b9ecf2771ea3e3d6a8230a33660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 25 Jan 2018 13:49:35 +0100 Subject: [PATCH] [apps] Graph/Sequence: set different cursors for Sequence and Graph --- apps/graph/graph/graph_controller.cpp | 7 +++++++ apps/graph/graph/graph_controller.h | 6 ++++++ apps/regression/graph_controller.h | 2 ++ apps/sequence/graph/graph_controller.h | 5 +++++ apps/shared/function_graph_controller.cpp | 2 +- apps/shared/function_graph_controller.h | 1 + apps/shared/interactive_curve_view_controller.cpp | 1 - apps/shared/interactive_curve_view_controller.h | 1 - 8 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/graph/graph/graph_controller.cpp b/apps/graph/graph/graph_controller.cpp index 0a5056f53..e09421114 100644 --- a/apps/graph/graph/graph_controller.cpp +++ b/apps/graph/graph/graph_controller.cpp @@ -28,6 +28,7 @@ I18n::Message GraphController::emptyMessage() { void GraphController::viewWillAppear() { m_view.drawTangent(false); FunctionGraphController::viewWillAppear(); + selectFunctionWithCursor(indexFunctionSelectedByCursor()); // update the color of the cursor } bool GraphController::displayDerivativeInBanner() const { @@ -38,6 +39,12 @@ void GraphController::setDisplayDerivativeInBanner(bool displayDerivative) { m_displayDerivativeInBanner = displayDerivative; } +void GraphController::selectFunctionWithCursor(int functionIndex) { + FunctionGraphController::selectFunctionWithCursor(functionIndex); + CartesianFunction * f = m_functionStore->activeFunctionAtIndex(indexFunctionSelectedByCursor()); + m_cursorView.setColor(f->color()); +} + BannerView * GraphController::bannerView() { return &m_bannerView; } diff --git a/apps/graph/graph/graph_controller.h b/apps/graph/graph/graph_controller.h index 33b1a6ec0..bcb3c9d81 100644 --- a/apps/graph/graph/graph_controller.h +++ b/apps/graph/graph/graph_controller.h @@ -7,6 +7,7 @@ #include "curve_parameter_controller.h" #include "../../shared/function_graph_controller.h" #include "../../shared/curve_view_cursor.h" +#include "../../shared/round_cursor_view.h" #include "../../shared/interactive_curve_view_range.h" #include "../cartesian_function_store.h" @@ -20,6 +21,7 @@ public: bool displayDerivativeInBanner() const; void setDisplayDerivativeInBanner(bool displayDerivative); private: + void selectFunctionWithCursor(int functionIndex) override; BannerView * bannerView() override; void reloadBannerView() override; bool moveCursorHorizontally(int direction) override; @@ -27,7 +29,11 @@ private: Shared::InteractiveCurveViewRange * interactiveCurveViewRange() override; CartesianFunctionStore * functionStore() const override; GraphView * functionGraphView() override; + View * cursorView() override { + return &m_cursorView; + } CurveParameterController * curveParameterController() override; + Shared::RoundCursorView m_cursorView; BannerView m_bannerView; GraphView m_view; Shared::InteractiveCurveViewRange * m_graphRange; diff --git a/apps/regression/graph_controller.h b/apps/regression/graph_controller.h index 86308d699..cbd5d99d7 100644 --- a/apps/regression/graph_controller.h +++ b/apps/regression/graph_controller.h @@ -9,6 +9,7 @@ #include "prediction_parameter_controller.h" #include "../shared/interactive_curve_view_controller.h" #include "../shared/curve_view_cursor.h" +#include "../shared/cursor_view.h" namespace Regression { @@ -36,6 +37,7 @@ private: uint32_t modelVersion() override; uint32_t rangeVersion() override; bool isCursorVisible() override; + Shared::CursorView m_cursorView; BannerView m_bannerView; GraphView m_view; Store * m_store; diff --git a/apps/sequence/graph/graph_controller.h b/apps/sequence/graph/graph_controller.h index a5e70a587..0cafb0f07 100644 --- a/apps/sequence/graph/graph_controller.h +++ b/apps/sequence/graph/graph_controller.h @@ -7,6 +7,7 @@ #include "curve_view_range.h" #include "term_sum_controller.h" #include "../../shared/function_graph_controller.h" +#include "../../shared/cursor_view.h" #include "../sequence_store.h" namespace Sequence { @@ -24,7 +25,11 @@ private: CurveViewRange * interactiveCurveViewRange() override; SequenceStore * functionStore() const override; GraphView * functionGraphView() override; + View * cursorView() override { + return &m_cursorView; + } CurveParameterController * curveParameterController() override; + Shared::CursorView m_cursorView; BannerView m_bannerView; GraphView m_view; CurveViewRange * m_graphRange; diff --git a/apps/shared/function_graph_controller.cpp b/apps/shared/function_graph_controller.cpp index 2718886a3..362205430 100644 --- a/apps/shared/function_graph_controller.cpp +++ b/apps/shared/function_graph_controller.cpp @@ -28,7 +28,7 @@ ViewController * FunctionGraphController::initialisationParameterController() { } void FunctionGraphController::viewWillAppear() { - functionGraphView()->setCursorView(&m_cursorView); + functionGraphView()->setCursorView(cursorView()); functionGraphView()->setBannerView(bannerView()); functionGraphView()->setAreaHighlight(NAN,NAN); diff --git a/apps/shared/function_graph_controller.h b/apps/shared/function_graph_controller.h index 981c27ebd..11840d97e 100644 --- a/apps/shared/function_graph_controller.h +++ b/apps/shared/function_graph_controller.h @@ -42,6 +42,7 @@ private: uint32_t rangeVersion() override; bool isCursorVisible() override; virtual FunctionGraphView * functionGraphView() = 0; + virtual View * cursorView() = 0; virtual FunctionStore * functionStore() const = 0; virtual FunctionCurveParameterController * curveParameterController() = 0; InitialisationParameterController m_initialisationParameterController; diff --git a/apps/shared/interactive_curve_view_controller.cpp b/apps/shared/interactive_curve_view_controller.cpp index 11736713e..36de73321 100644 --- a/apps/shared/interactive_curve_view_controller.cpp +++ b/apps/shared/interactive_curve_view_controller.cpp @@ -10,7 +10,6 @@ namespace Shared { InteractiveCurveViewController::InteractiveCurveViewController(Responder * parentResponder, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * rangeVersion) : SimpleInteractiveCurveViewController(parentResponder, interactiveRange, curveView, cursor), ButtonRowDelegate(header, nullptr), - m_cursorView(), m_modelVersion(modelVersion), m_rangeVersion(rangeVersion), m_rangeParameterController(this, interactiveRange), diff --git a/apps/shared/interactive_curve_view_controller.h b/apps/shared/interactive_curve_view_controller.h index 69561f88a..5ba889899 100644 --- a/apps/shared/interactive_curve_view_controller.h +++ b/apps/shared/interactive_curve_view_controller.h @@ -38,7 +38,6 @@ protected: virtual uint32_t modelVersion() = 0; virtual uint32_t rangeVersion() = 0; virtual bool isCursorVisible() = 0; - CursorView m_cursorView; OkView m_okView; private: uint32_t * m_modelVersion;