[apps/graph] Use editable text menu list cell in float parameter

controller to enable editing parameter "inline"

Change-Id: Ibfb8134242ebdcdc8e17027f31196b94a537bd1b
This commit is contained in:
Émilie Feral
2016-12-05 11:27:48 +01:00
parent b0474c492c
commit 306d36ca69
6 changed files with 14 additions and 16 deletions

View File

@@ -59,22 +59,20 @@ void FloatParameterController::editParameter(const char * initialText) {
strlcpy(initialTextContent, textMenuListCell->accessoryText(), sizeof(initialTextContent));
}
int cursorLocation = strlen(initialTextContent) + cursorDelta;
EditableTextMenuListCell * cell = (EditableTextMenuListCell *)m_selectableTableView.cellAtLocation(0, activeCell());
cell->setParentResponder(&m_selectableTableView);
App * myApp = (App *)app();
InputViewController * inputController = myApp->inputViewController();
inputController->edit(this, initialTextContent, cursorLocation, this,
cell->editValue(myApp, initialTextContent, cursorLocation, this,
[](void * context, void * sender){
FloatParameterController * floatParameterController = (FloatParameterController *)context;
int activeCell = floatParameterController->activeCell();
TextMenuListCell * cell = (TextMenuListCell *)floatParameterController->reusableCell(activeCell);
InputViewController * myInputViewController = (InputViewController *)sender;
const char * textBody = myInputViewController->textBody();
EditableTextMenuListCell * cell = (EditableTextMenuListCell *)sender;
const char * textBody = cell->editedText();
AppsContainer * appsContainer = (AppsContainer *)floatParameterController->app()->container();
Context * globalContext = appsContainer->context();
float floatBody = Expression::parse(textBody)->approximate(*globalContext);
floatParameterController->setParameterAtIndex(activeCell, floatBody);
floatParameterController->willDisplayCellForIndex(cell, activeCell);
},
[](void * context, void * sender){
});
}

View File

@@ -21,7 +21,7 @@ private:
void setParameterAtIndex(int parameterIndex, float f) override;
constexpr static int k_numberOfTextCell = 4;
AxisInterval * m_axisInterval;
TextMenuListCell m_axisCells[k_numberOfTextCell];
EditableTextMenuListCell m_axisCells[k_numberOfTextCell];
SwitchMenuListCell m_yAutoCell;
GraphView * m_graphView;
};

View File

@@ -5,7 +5,7 @@ namespace Graph {
GoToParameterController::GoToParameterController(Responder * parentResponder, GraphView * graphView) :
FloatParameterController(parentResponder),
m_abscisseCell(TextMenuListCell((char*)"x")),
m_abscisseCell(EditableTextMenuListCell((char*)"x")),
m_graphView(graphView),
m_function(nullptr)
{

View File

@@ -18,7 +18,7 @@ public:
private:
float parameterAtIndex(int index) override;
void setParameterAtIndex(int parameterIndex, float f) override;
TextMenuListCell m_abscisseCell;
EditableTextMenuListCell m_abscisseCell;
GraphView * m_graphView;
Function * m_function;
};

View File

@@ -6,9 +6,9 @@ namespace Graph {
IntervalParameterController::IntervalParameterController(Responder * parentResponder, Interval * interval) :
FloatParameterController(parentResponder),
m_interval(interval),
m_intervalStartCell(TextMenuListCell((char*)"X Debut")),
m_intervalEndCell(TextMenuListCell((char*)"X Fin")),
m_intervalStepCell(TextMenuListCell((char*)"Pas"))
m_intervalStartCell(EditableTextMenuListCell((char*)"X Debut")),
m_intervalEndCell(EditableTextMenuListCell((char*)"X Fin")),
m_intervalStepCell(EditableTextMenuListCell((char*)"Pas"))
{
}

View File

@@ -20,9 +20,9 @@ private:
void setParameterAtIndex(int parameterIndex, float f) override;
constexpr static int k_totalNumberOfCell = 3;
Interval * m_interval;
TextMenuListCell m_intervalStartCell;
TextMenuListCell m_intervalEndCell;
TextMenuListCell m_intervalStepCell;
EditableTextMenuListCell m_intervalStartCell;
EditableTextMenuListCell m_intervalEndCell;
EditableTextMenuListCell m_intervalStepCell;
};
}