From 7715da8e3691f1dd273b0e3b97d260d83ddd533d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 25 Apr 2017 16:20:55 +0200 Subject: [PATCH] [apps/shared] In float parameter controllers, back has the same consequence as 'validate' Change-Id: Id45f824c50af2f6e47be5abd9115d98971a1e073 --- apps/probability/parameters_controller.cpp | 7 ------- apps/probability/parameters_controller.h | 2 -- apps/shared/float_parameter_controller.cpp | 5 ----- apps/shared/float_parameter_controller.h | 1 - apps/shared/go_to_parameter_controller.cpp | 10 ---------- apps/shared/go_to_parameter_controller.h | 3 --- apps/shared/interval_parameter_controller.cpp | 12 ------------ apps/shared/interval_parameter_controller.h | 3 --- apps/shared/range_parameter_controller.cpp | 17 ----------------- apps/shared/range_parameter_controller.h | 3 --- .../histogram_parameter_controller.cpp | 11 ----------- .../statistics/histogram_parameter_controller.h | 3 --- 12 files changed, 77 deletions(-) diff --git a/apps/probability/parameters_controller.cpp b/apps/probability/parameters_controller.cpp index c15405862..2399637fb 100644 --- a/apps/probability/parameters_controller.cpp +++ b/apps/probability/parameters_controller.cpp @@ -88,7 +88,6 @@ void ParametersController::setLaw(Law * law) { void ParametersController::viewWillAppear() { for (int i = 0; i < m_law->numberOfParameter(); i++) { - m_previousParameters[i] = parameterAtIndex(i); contentView()->parameterDefinitionAtIndex(i)->setMessage(m_law->parameterDefinitionAtIndex(i)); } contentView()->layoutSubviews(); @@ -133,12 +132,6 @@ void ParametersController::unloadView() { FloatParameterController::unloadView(); } -float ParametersController::previousParameterAtIndex(int index) { - assert(index >= 0); - assert(index < 2); - return m_previousParameters[index]; -} - float ParametersController::parameterAtIndex(int index) { return m_law->parameterValueAtIndex(index); } diff --git a/apps/probability/parameters_controller.h b/apps/probability/parameters_controller.h index 27f392ce2..727bf18e7 100644 --- a/apps/probability/parameters_controller.h +++ b/apps/probability/parameters_controller.h @@ -21,7 +21,6 @@ private: HighlightCell * reusableParameterCell(int index, int type) override; int reusableParameterCellCount(int type) override; void buttonAction() override; - float previousParameterAtIndex(int index) override; float parameterAtIndex(int index) override; bool setParameterAtIndex(int parameterIndex, float f) override; bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override; @@ -51,7 +50,6 @@ private: constexpr static int k_maxNumberOfCells = 2; char m_draftTextBuffer[MessageTableCellWithEditableText::k_bufferLength]; MessageTableCellWithEditableText * m_menuListCell[k_maxNumberOfCells]; - float m_previousParameters[k_maxNumberOfCells]; Law * m_law; CalculationController m_calculationController; }; diff --git a/apps/shared/float_parameter_controller.cpp b/apps/shared/float_parameter_controller.cpp index 53491d7ca..d874f5b92 100644 --- a/apps/shared/float_parameter_controller.cpp +++ b/apps/shared/float_parameter_controller.cpp @@ -46,11 +46,6 @@ void FloatParameterController::willExitResponderChain(Responder * nextFirstRespo bool FloatParameterController::handleEvent(Ion::Events::Event event) { if (event == Ion::Events::Back) { - for (int i = 0; i < numberOfRows()-1; i++) { - if (parameterAtIndex(i) != previousParameterAtIndex(i)) { - setParameterAtIndex(i, previousParameterAtIndex(i)); - } - } stackController()->pop(); return true; } diff --git a/apps/shared/float_parameter_controller.h b/apps/shared/float_parameter_controller.h index 5f848760e..450839e30 100644 --- a/apps/shared/float_parameter_controller.h +++ b/apps/shared/float_parameter_controller.h @@ -43,7 +43,6 @@ private: virtual int reusableParameterCellCount(int type) = 0; virtual HighlightCell * reusableParameterCell(int index, int type) = 0; TextFieldDelegateApp * textFieldDelegateApp() override; - virtual float previousParameterAtIndex(int index) = 0; virtual bool setParameterAtIndex(int parameterIndex, float f) = 0; ButtonWithSeparator * m_okButton; }; diff --git a/apps/shared/go_to_parameter_controller.cpp b/apps/shared/go_to_parameter_controller.cpp index 5aa009e4f..d0eacfd40 100644 --- a/apps/shared/go_to_parameter_controller.cpp +++ b/apps/shared/go_to_parameter_controller.cpp @@ -12,11 +12,6 @@ GoToParameterController::GoToParameterController(Responder * parentResponder, In { } -void GoToParameterController::viewWillAppear() { - m_previousParameter = parameterAtIndex(0); - FloatParameterController::viewWillAppear(); -} - int GoToParameterController::numberOfRows() { return 2; } @@ -28,11 +23,6 @@ void GoToParameterController::unloadView() { FloatParameterController::unloadView(); } -float GoToParameterController::previousParameterAtIndex(int index) { - assert(index == 0); - return m_previousParameter; -} - HighlightCell * GoToParameterController::reusableParameterCell(int index, int type) { assert(index == 0); return m_abscisseCell; diff --git a/apps/shared/go_to_parameter_controller.h b/apps/shared/go_to_parameter_controller.h index 9ed7067ad..d9f21d52f 100644 --- a/apps/shared/go_to_parameter_controller.h +++ b/apps/shared/go_to_parameter_controller.h @@ -11,7 +11,6 @@ namespace Shared { class GoToParameterController : public FloatParameterController { public: GoToParameterController(Responder * parentResponder, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, I18n::Message symbol); - void viewWillAppear() override; int numberOfRows() override; void unloadView() override; protected: @@ -21,11 +20,9 @@ private: void buttonAction() override; HighlightCell * reusableParameterCell(int index, int type) override; int reusableParameterCellCount(int type) override; - float previousParameterAtIndex(int index) override; View * createView() override; char m_draftTextBuffer[MessageTableCellWithEditableText::k_bufferLength]; MessageTableCellWithEditableText * m_abscisseCell; - float m_previousParameter; InteractiveCurveViewRange * m_graphRange; I18n::Message m_abscissaSymbol; }; diff --git a/apps/shared/interval_parameter_controller.cpp b/apps/shared/interval_parameter_controller.cpp index e9a4da662..f6c359372 100644 --- a/apps/shared/interval_parameter_controller.cpp +++ b/apps/shared/interval_parameter_controller.cpp @@ -13,13 +13,6 @@ const char * IntervalParameterController::title() { return I18n::translate(I18n::Message::IntervalSet); } -void IntervalParameterController::viewWillAppear() { - for (int i = 0; i < k_totalNumberOfCell; i++) { - m_previousParameters[i] = parameterAtIndex(i); - } - FloatParameterController::viewWillAppear(); -} - int IntervalParameterController::numberOfRows() { return k_totalNumberOfCell+1; } @@ -47,11 +40,6 @@ void IntervalParameterController::unloadView() { FloatParameterController::unloadView(); } -float IntervalParameterController::previousParameterAtIndex(int index) { - assert(index >= 0 && index < k_totalNumberOfCell); - return m_previousParameters[index]; -} - float IntervalParameterController::parameterAtIndex(int index) { GetterPointer getters[k_totalNumberOfCell] = {&Interval::start, &Interval::end, &Interval::step}; return (m_interval->*getters[index])(); diff --git a/apps/shared/interval_parameter_controller.h b/apps/shared/interval_parameter_controller.h index 1ca4d900a..0012cf93f 100644 --- a/apps/shared/interval_parameter_controller.h +++ b/apps/shared/interval_parameter_controller.h @@ -12,7 +12,6 @@ public: IntervalParameterController(Responder * parentResponder, Interval * interval); Interval * interval(); const char * title() override; - void viewWillAppear() override; void willDisplayCellForIndex(HighlightCell * cell, int index) override; int numberOfRows() override; void unloadView() override; @@ -23,12 +22,10 @@ protected: private: HighlightCell * reusableParameterCell(int index, int type) override; int reusableParameterCellCount(int type) override; - float previousParameterAtIndex(int index) override; float parameterAtIndex(int index) override; View * createView() override; char m_draftTextBuffer[MessageTableCellWithEditableText::k_bufferLength]; MessageTableCellWithEditableText * m_intervalCells[k_totalNumberOfCell]; - float m_previousParameters[k_totalNumberOfCell]; }; } diff --git a/apps/shared/range_parameter_controller.cpp b/apps/shared/range_parameter_controller.cpp index bc6b95e5d..75feb404a 100644 --- a/apps/shared/range_parameter_controller.cpp +++ b/apps/shared/range_parameter_controller.cpp @@ -17,15 +17,6 @@ const char * RangeParameterController::title() { return I18n::translate(I18n::Message::Axis); } -void RangeParameterController::viewWillAppear() { - for (int i = 0; i < k_numberOfTextCell; i++) { - int index = i > 2 ? i + 1 : i; - m_previousParameters[i] = parameterAtIndex(index); - } - m_previousSwitchState = m_interactiveRange->yAuto(); - FloatParameterController::viewWillAppear(); -} - int RangeParameterController::numberOfRows() { return k_numberOfTextCell+2; } @@ -96,17 +87,9 @@ bool RangeParameterController::handleEvent(Ion::Events::Event event) { selectableTableView()->reloadData(); return true; } - if (event == Ion::Events::Back) { - m_interactiveRange->setYAuto(m_previousSwitchState); - } return FloatParameterController::handleEvent(event); } -float RangeParameterController::previousParameterAtIndex(int parameterIndex) { - int index = parameterIndex > 2 ? parameterIndex - 1 : parameterIndex; - return m_previousParameters[index]; -} - float RangeParameterController::parameterAtIndex(int parameterIndex) { ParameterGetterPointer getters[k_numberOfTextCell] = {&InteractiveCurveViewRange::xMin, &InteractiveCurveViewRange::xMax, &InteractiveCurveViewRange::yMin, &InteractiveCurveViewRange::yMax}; diff --git a/apps/shared/range_parameter_controller.h b/apps/shared/range_parameter_controller.h index b885a06bf..fa909e2e4 100644 --- a/apps/shared/range_parameter_controller.h +++ b/apps/shared/range_parameter_controller.h @@ -11,7 +11,6 @@ class RangeParameterController : public FloatParameterController { public: RangeParameterController(Responder * parentResponder, InteractiveCurveViewRange * interactiveCurveViewRange); const char * title() override; - void viewWillAppear() override; int numberOfRows() override; int typeAtLocation(int i, int j) override; void willDisplayCellForIndex(HighlightCell * cell, int index) override; @@ -22,7 +21,6 @@ public: private: HighlightCell * reusableParameterCell(int index, int type) override; int reusableParameterCellCount(int type) override; - float previousParameterAtIndex(int index) override; float parameterAtIndex(int index) override; bool setParameterAtIndex(int parameterIndex, float f) override; View * createView() override; @@ -31,7 +29,6 @@ private: char m_draftTextBuffer[MessageTableCellWithEditableText::k_bufferLength]; MessageTableCellWithEditableText * m_rangeCells[k_numberOfTextCell]; MessageTableCellWithSwitch * m_yAutoCell; - float m_previousParameters[k_numberOfTextCell]; bool m_previousSwitchState; }; diff --git a/apps/statistics/histogram_parameter_controller.cpp b/apps/statistics/histogram_parameter_controller.cpp index 3f8b5acb7..85a1ac89f 100644 --- a/apps/statistics/histogram_parameter_controller.cpp +++ b/apps/statistics/histogram_parameter_controller.cpp @@ -16,13 +16,6 @@ const char * HistogramParameterController::title() { return I18n::translate(I18n::Message::HistogramSet); } -void HistogramParameterController::viewWillAppear() { - for (int i = 0; i < k_numberOfCells; i++) { - m_previousParameters[i] = parameterAtIndex(i); - } - FloatParameterController::viewWillAppear(); -} - int HistogramParameterController::numberOfRows() { return 1+k_numberOfCells; } @@ -54,10 +47,6 @@ float HistogramParameterController::parameterAtIndex(int index) { return m_store->firstDrawnBarAbscissa(); } -float HistogramParameterController::previousParameterAtIndex(int index) { - return m_previousParameters[index]; -} - bool HistogramParameterController::setParameterAtIndex(int parameterIndex, float f) { assert(parameterIndex >= 0 && parameterIndex < k_numberOfCells); if (parameterIndex == 0) { diff --git a/apps/statistics/histogram_parameter_controller.h b/apps/statistics/histogram_parameter_controller.h index e33a7ecfb..5cd5d3a1c 100644 --- a/apps/statistics/histogram_parameter_controller.h +++ b/apps/statistics/histogram_parameter_controller.h @@ -11,7 +11,6 @@ class HistogramParameterController : public Shared::FloatParameterController { public: HistogramParameterController(Responder * parentResponder, Store * store); const char * title() override; - void viewWillAppear() override; int numberOfRows() override; void willDisplayCellForIndex(HighlightCell * cell, int index) override; void unloadView() override; @@ -19,13 +18,11 @@ private: HighlightCell * reusableParameterCell(int index, int type) override; int reusableParameterCellCount(int type) override; float parameterAtIndex(int index) override; - float previousParameterAtIndex(int index) override; bool setParameterAtIndex(int parameterIndex, float f) override; View * createView() override; char m_draftTextBuffer[MessageTableCellWithEditableText::k_bufferLength]; constexpr static int k_numberOfCells = 2; MessageTableCellWithEditableText * m_cells[k_numberOfCells]; - float m_previousParameters[k_numberOfCells]; Store * m_store; };