[apps/sequence] Specialize sequence go to parameter controller to round

the given abscissa and forbid negative values

Change-Id: Iaae39e575c0e2de4993a558e234717a839905872
This commit is contained in:
Émilie Feral
2017-03-30 16:36:52 +02:00
parent e76cab75c1
commit 5facbfb8ac
11 changed files with 57 additions and 12 deletions

View File

@@ -6,7 +6,8 @@ using namespace Shared;
namespace Graph {
CurveParameterController::CurveParameterController(InteractiveCurveViewRange * graphRange, BannerView * bannerView, CurveViewCursor * cursor) :
FunctionCurveParameterController(graphRange, cursor, I18n::Message::X),
FunctionCurveParameterController(graphRange, cursor),
m_goToParameterController(FunctionGoToParameterController(this, graphRange, cursor, I18n::Message::X)),
m_bannerView(bannerView),
m_calculationCell(MessageTableCellWithChevron(I18n::Message::Compute)),
m_derivativeCell(MessageTableCellWithSwitch(I18n::Message::DerivateNumber))
@@ -59,4 +60,8 @@ int CurveParameterController::reusableCellCount() {
return k_totalNumberOfCells;
}
FunctionGoToParameterController * CurveParameterController::goToParameterController() {
return &m_goToParameterController;
}
}

View File

@@ -16,6 +16,8 @@ public:
int reusableCellCount() override;
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
private:
Shared::FunctionGoToParameterController * goToParameterController() override;
Shared::FunctionGoToParameterController m_goToParameterController;
BannerView * m_bannerView;
constexpr static int k_totalNumberOfCells = 3;
MessageTableCellWithChevron m_calculationCell;

View File

@@ -3,6 +3,7 @@ app_objs += $(addprefix apps/sequence/,\
graph/banner_view.o\
graph/curve_parameter_controller.o\
graph/curve_view_range.o\
graph/go_to_parameter_controller.o\
graph/graph_controller.o\
graph/graph_view.o\
graph/term_sum_controller.o\

View File

@@ -7,7 +7,8 @@ using namespace Shared;
namespace Sequence {
CurveParameterController::CurveParameterController(GraphController * graphController, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor) :
FunctionCurveParameterController(graphRange, cursor, I18n::Message::N),
FunctionCurveParameterController(graphRange, cursor),
m_goToParameterController(GoToParameterController(this, graphRange, cursor, I18n::Message::N)),
m_sumCell(MessageTableCell(I18n::Message::TermSum)),
m_graphController(graphController)
{
@@ -51,4 +52,8 @@ int CurveParameterController::reusableCellCount() {
return k_totalNumberOfCells;
}
GoToParameterController * CurveParameterController::goToParameterController() {
return &m_goToParameterController;
}
}

View File

@@ -3,6 +3,7 @@
#include <escher.h>
#include "../../shared/function_curve_parameter_controller.h"
#include "go_to_parameter_controller.h"
namespace Sequence {
@@ -18,6 +19,8 @@ public:
int reusableCellCount() override;
private:
constexpr static int k_totalNumberOfCells = 2;
GoToParameterController * goToParameterController() override;
GoToParameterController m_goToParameterController;
MessageTableCell m_sumCell;
GraphController * m_graphController;
};

View File

@@ -0,0 +1,13 @@
#include "go_to_parameter_controller.h"
#include "../app.h"
#include <assert.h>
namespace Sequence {
bool GoToParameterController::setParameterAtIndex(int parameterIndex, float f) {
assert(parameterIndex == 0);
return Shared::FunctionGoToParameterController::setParameterAtIndex(parameterIndex, roundf(f));
}
}

View File

@@ -0,0 +1,18 @@
#ifndef SEQUENCE_GO_TO_PARAMETER_CONTROLLER_H
#define SEQUENCE_GO_TO_PARAMETER_CONTROLLER_H
#include "../../shared/function_go_to_parameter_controller.h"
namespace Sequence {
class GoToParameterController : public Shared::FunctionGoToParameterController {
public:
using Shared::FunctionGoToParameterController::FunctionGoToParameterController;
private:
bool setParameterAtIndex(int parameterIndex, float f) override;
};
}
#endif

View File

@@ -3,12 +3,11 @@
namespace Shared {
FunctionCurveParameterController::FunctionCurveParameterController(InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, I18n::Message symbol) :
FunctionCurveParameterController::FunctionCurveParameterController(InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor) :
ViewController(nullptr),
m_goToCell(MessageTableCellWithChevron(I18n::Message::Goto)),
m_selectableTableView(SelectableTableView(this, this, 0, 1, Metric::CommonTopMargin, Metric::CommonRightMargin,
Metric::CommonBottomMargin, Metric::CommonLeftMargin)),
m_goToParameterController(FunctionGoToParameterController(this, graphRange, cursor, symbol)),
m_function(nullptr)
{
}
@@ -26,9 +25,9 @@ bool FunctionCurveParameterController::handleGotoSelection() {
if (m_function == nullptr) {
return false;
}
m_goToParameterController.setFunction(m_function);
goToParameterController()->setFunction(m_function);
StackViewController * stack = (StackViewController *)parentResponder();
stack->push(&m_goToParameterController);
stack->push(goToParameterController());
return true;
}

View File

@@ -11,7 +11,7 @@ namespace Shared {
class FunctionCurveParameterController : public ViewController, public SimpleListViewDataSource {
public:
FunctionCurveParameterController(InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, I18n::Message symbol);
FunctionCurveParameterController(InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor);
View * view() override;
void didBecomeFirstResponder() override;
KDCoordinate cellHeight() override;
@@ -21,7 +21,7 @@ protected:
MessageTableCellWithChevron m_goToCell;
SelectableTableView m_selectableTableView;
private:
FunctionGoToParameterController m_goToParameterController;
virtual FunctionGoToParameterController * goToParameterController() = 0;
Function * m_function;
};

View File

@@ -2,8 +2,6 @@
#include "text_field_delegate_app.h"
#include <assert.h>
using namespace Poincare;
namespace Shared {
FunctionGoToParameterController::FunctionGoToParameterController(Responder * parentResponder, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, I18n::Message symbol) :

View File

@@ -11,10 +11,11 @@ public:
FunctionGoToParameterController(Responder * parentResponder, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, I18n::Message symbol);
const char * title() override;
void setFunction(Function * function);
private:
float parameterAtIndex(int index) override;
protected:
bool setParameterAtIndex(int parameterIndex, float f) override;
Function * m_function;
private:
float parameterAtIndex(int index) override;
};
}