[apps/shared] Factorize go to parameter controllers in parent class

(used in regression, graph, sequence)

Change-Id: I5e54bca17f9de7b21aeb705ea87818b064662904
This commit is contained in:
Émilie Feral
2017-03-30 16:08:40 +02:00
parent 4968ffff49
commit e76cab75c1
10 changed files with 92 additions and 114 deletions

View File

@@ -6,17 +6,12 @@ namespace Shared {
GoToParameterController::GoToParameterController(Responder * parentResponder, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor, I18n::Message symbol) :
FloatParameterController(parentResponder),
m_abscisseCell(MessageTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, symbol)),
m_graphRange(graphRange),
m_cursor(cursor),
m_function(nullptr)
m_abscisseCell(MessageTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, symbol)),
m_graphRange(graphRange)
{
}
const char * GoToParameterController::title() {
return I18n::translate(I18n::Message::Goto);
}
void GoToParameterController::viewWillAppear() {
m_previousParameter = parameterAtIndex(0);
FloatParameterController::viewWillAppear();
@@ -31,23 +26,6 @@ float GoToParameterController::previousParameterAtIndex(int index) {
return m_previousParameter;
}
float GoToParameterController::parameterAtIndex(int index) {
assert(index == 0);
return m_cursor->x();
}
bool GoToParameterController::setParameterAtIndex(int parameterIndex, float f) {
assert(parameterIndex == 0);
TextFieldDelegateApp * myApp = (TextFieldDelegateApp *)app();
float y = m_function->evaluateAtAbscissa(f, myApp->localContext());
if (fabsf(f) > k_maxDisplayableFloat || fabsf(y) > k_maxDisplayableFloat) {
app()->displayWarning(I18n::Message::ForbiddenValue);
return false;
}
m_cursor->moveTo(f, y);
return true;
}
HighlightCell * GoToParameterController::reusableParameterCell(int index, int type) {
assert(index == 0);
return &m_abscisseCell;
@@ -57,10 +35,6 @@ int GoToParameterController::reusableParameterCellCount(int type) {
return 1;
}
void GoToParameterController::setFunction(Function * function) {
m_function = function;
}
void GoToParameterController::buttonAction() {
m_graphRange->centerAxisAround(CurveViewRange::Axis::X, m_cursor->x());
m_graphRange->centerAxisAround(CurveViewRange::Axis::Y, m_cursor->y());