diff --git a/apps/sequence/graph/term_sum_controller.cpp b/apps/sequence/graph/term_sum_controller.cpp index a58b17f91..65fa6e669 100644 --- a/apps/sequence/graph/term_sum_controller.cpp +++ b/apps/sequence/graph/term_sum_controller.cpp @@ -15,12 +15,11 @@ using namespace Poincare; namespace Sequence { TermSumController::TermSumController(Responder * parentResponder, GraphView * graphView, CurveViewRange * graphRange, CurveViewCursor * cursor) : - ViewController(parentResponder), + SimpleInteractiveCurveViewController(parentResponder, graphRange, graphView, cursor), m_graphView(graphView), m_legendView(), m_graphRange(graphRange), m_sequence(nullptr), - m_cursor(cursor), m_cursorView(), m_bufferCursorPosition(0), m_step(0), @@ -33,10 +32,6 @@ const char * TermSumController::title() { return I18n::translate(I18n::Message::TermSum); } -View * TermSumController::view() { - return m_graphView; -} - void TermSumController::viewWillAppear() { m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio); m_graphView->setVerticalCursor(true); @@ -57,6 +52,9 @@ void TermSumController::viewWillAppear() { } bool TermSumController::handleEvent(Ion::Events::Event event) { + if (event == Ion::Events::Plus || event == Ion::Events::Minus) { + return handleZoom(event); + } if (m_step > 1 && event != Ion::Events::OK && event != Ion::Events::EXE && event != Ion::Events::Back) { return false; } @@ -163,6 +161,14 @@ void TermSumController::setSequence(Sequence * sequence) { m_sequence = sequence; } +CurveView * TermSumController::curveView() { + return m_graphView; +} + +InteractiveCurveViewRange * TermSumController::interactiveCurveViewRange() { + return m_graphRange; +} + /* Legend View */ TermSumController::LegendView::LegendView() : diff --git a/apps/sequence/graph/term_sum_controller.h b/apps/sequence/graph/term_sum_controller.h index 78a9cfe72..f55e067bf 100644 --- a/apps/sequence/graph/term_sum_controller.h +++ b/apps/sequence/graph/term_sum_controller.h @@ -6,14 +6,14 @@ #include "curve_view_range.h" #include "vertical_cursor_view.h" #include "../../shared/curve_view_cursor.h" +#include "../../shared/simple_interactive_curve_view_controller.h" namespace Sequence { -class TermSumController : public ViewController { +class TermSumController : public Shared::SimpleInteractiveCurveViewController { public: TermSumController(Responder * parentResponder, GraphView * graphView, CurveViewRange * graphRange, Shared::CurveViewCursor * cursor); const char * title() override; - View * view() override; void viewWillAppear() override; bool handleEvent(Ion::Events::Event event) override; bool moveCursorHorizontallyToPosition(int position); @@ -23,6 +23,8 @@ private: constexpr static float k_cursorRightMarginRatio = 0.04f; // (cursorWidth/2)/graphViewWidth constexpr static float k_cursorBottomMarginRatio = 0.28f; // (cursorHeight/2+bannerHeigh)/graphViewHeight constexpr static float k_cursorLeftMarginRatio = 0.04f; // (cursorWidth/2)/graphViewWidth + Shared::InteractiveCurveViewRange * interactiveCurveViewRange() override; + Shared::CurveView * curveView() override; class LegendView : public View { public: LegendView(); @@ -50,7 +52,6 @@ private: LegendView m_legendView; CurveViewRange * m_graphRange; Sequence * m_sequence; - Shared::CurveViewCursor * m_cursor; VerticalCursorView m_cursorView; /* The user can move the cursor to an abscissa n by typing the right digits. * To be able to go to abscissa represented by more than one digit, we record