diff --git a/apps/Makefile b/apps/Makefile index dc3b1492c..e06078311 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -8,6 +8,7 @@ app_objs += $(addprefix apps/,\ apps_container.o\ constant.o\ expression_text_field_delegate.o\ + float_parameter_controller.o\ main.o\ node.o\ node_list_view_controller.o\ diff --git a/apps/graph/float_parameter_controller.cpp b/apps/float_parameter_controller.cpp similarity index 93% rename from apps/graph/float_parameter_controller.cpp rename to apps/float_parameter_controller.cpp index 4c44937d8..2cd0a1c41 100644 --- a/apps/graph/float_parameter_controller.cpp +++ b/apps/float_parameter_controller.cpp @@ -1,11 +1,8 @@ #include "float_parameter_controller.h" -#include "app.h" -#include "../constant.h" -#include "../apps_container.h" +#include "constant.h" +#include "apps_container.h" #include -namespace Graph { - FloatParameterController::FloatParameterController(Responder * parentResponder) : ViewController(parentResponder), m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, @@ -61,8 +58,7 @@ void FloatParameterController::editParameter(const char * initialText) { int cursorLocation = strlen(initialTextContent) + cursorDelta; EditableTextMenuListCell * cell = (EditableTextMenuListCell *)m_selectableTableView.cellAtLocation(0, activeCell()); cell->setParentResponder(&m_selectableTableView); - App * myApp = (App *)app(); - cell->editValue(myApp, initialTextContent, cursorLocation, this, + cell->editValue(textFieldDelegate(), initialTextContent, cursorLocation, this, [](void * context, void * sender){ FloatParameterController * floatParameterController = (FloatParameterController *)context; int activeCell = floatParameterController->activeCell(); @@ -79,5 +75,3 @@ void FloatParameterController::editParameter(const char * initialText) { KDCoordinate FloatParameterController::cellHeight() { return 35; } - -} diff --git a/apps/graph/float_parameter_controller.h b/apps/float_parameter_controller.h similarity index 80% rename from apps/graph/float_parameter_controller.h rename to apps/float_parameter_controller.h index c831af656..2c2cf4922 100644 --- a/apps/graph/float_parameter_controller.h +++ b/apps/float_parameter_controller.h @@ -1,9 +1,8 @@ -#ifndef GRAPH_FLOAT_PARAMETER_CONTROLLER_H -#define GRAPH_FLOAT_PARAMETER_CONTROLLER_H +#ifndef APPS_FLOAT_PARAMETER_CONTROLLER_H +#define APPS_FLOAT_PARAMETER_CONTROLLER_H #include - -namespace Graph { +#include "expression_text_field_delegate.h" /* This controller edits float parameter of any model (given through * parameterAtIndex and setParameterAtIndex). */ @@ -13,7 +12,7 @@ public: FloatParameterController(Responder * parentResponder); int activeCell(); void editParameter(const char * initialText = nullptr); - + virtual ExpressionTextFieldDelegate * textFieldDelegate() = 0; View * view() override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override; @@ -27,6 +26,4 @@ private: }; -} - #endif diff --git a/apps/graph/Makefile b/apps/graph/Makefile index fcd12e08c..44f6d9344 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -1,7 +1,6 @@ app_objs += $(addprefix apps/graph/,\ app.o\ evaluate_context.o\ - float_parameter_controller.o\ function.o\ function_store.o\ function_title_cell.o\ diff --git a/apps/graph/graph/axis_parameter_controller.cpp b/apps/graph/graph/axis_parameter_controller.cpp index 4af5147ef..97be87422 100644 --- a/apps/graph/graph/axis_parameter_controller.cpp +++ b/apps/graph/graph/axis_parameter_controller.cpp @@ -16,6 +16,11 @@ AxisParameterController::AxisParameterController(Responder * parentResponder, Ax } +ExpressionTextFieldDelegate * AxisParameterController::textFieldDelegate() { + ExpressionTextFieldDelegate * myApp = (ExpressionTextFieldDelegate *)app(); + return myApp; +} + const char * AxisParameterController::title() const { return "Axes"; } diff --git a/apps/graph/graph/axis_parameter_controller.h b/apps/graph/graph/axis_parameter_controller.h index 46d9ee723..f5d2125bf 100644 --- a/apps/graph/graph/axis_parameter_controller.h +++ b/apps/graph/graph/axis_parameter_controller.h @@ -4,12 +4,13 @@ #include #include "axis_interval.h" #include "graph_view.h" -#include "../float_parameter_controller.h" +#include "../../float_parameter_controller.h" namespace Graph { class AxisParameterController : public FloatParameterController { public: AxisParameterController(Responder * parentResponder, AxisInterval * axisInterval, GraphView * graphView); + ExpressionTextFieldDelegate * textFieldDelegate() override; const char * title() const override; int numberOfRows() override; TableViewCell * reusableCell(int index) override; diff --git a/apps/graph/graph/goto_parameter_controller.cpp b/apps/graph/graph/goto_parameter_controller.cpp index ee8598d38..edf281143 100644 --- a/apps/graph/graph/goto_parameter_controller.cpp +++ b/apps/graph/graph/goto_parameter_controller.cpp @@ -11,6 +11,11 @@ GoToParameterController::GoToParameterController(Responder * parentResponder, Gr { } +ExpressionTextFieldDelegate * GoToParameterController::textFieldDelegate() { + ExpressionTextFieldDelegate * myApp = (ExpressionTextFieldDelegate *)app(); + return myApp; +} + const char * GoToParameterController::title() const { return "Aller a"; } diff --git a/apps/graph/graph/goto_parameter_controller.h b/apps/graph/graph/goto_parameter_controller.h index ebc681f68..c62efc60f 100644 --- a/apps/graph/graph/goto_parameter_controller.h +++ b/apps/graph/graph/goto_parameter_controller.h @@ -4,12 +4,13 @@ #include #include "axis_interval.h" #include "graph_view.h" -#include "../float_parameter_controller.h" +#include "../../float_parameter_controller.h" namespace Graph { class GoToParameterController : public FloatParameterController { public: GoToParameterController(Responder * parentResponder, GraphView * graphView); + ExpressionTextFieldDelegate * textFieldDelegate() override; const char * title() const override; int numberOfRows() override; TableViewCell * reusableCell(int index) override; diff --git a/apps/graph/values/interval_parameter_controller.cpp b/apps/graph/values/interval_parameter_controller.cpp index b62aeb1fd..bebccfd2c 100644 --- a/apps/graph/values/interval_parameter_controller.cpp +++ b/apps/graph/values/interval_parameter_controller.cpp @@ -12,6 +12,11 @@ IntervalParameterController::IntervalParameterController(Responder * parentRespo { } +ExpressionTextFieldDelegate * IntervalParameterController::textFieldDelegate() { + ExpressionTextFieldDelegate * myApp = (ExpressionTextFieldDelegate *)app(); + return myApp; +} + const char * IntervalParameterController::title() const { return "Regler l'intervalle"; } diff --git a/apps/graph/values/interval_parameter_controller.h b/apps/graph/values/interval_parameter_controller.h index 657181ab5..eb2f301d8 100644 --- a/apps/graph/values/interval_parameter_controller.h +++ b/apps/graph/values/interval_parameter_controller.h @@ -3,13 +3,14 @@ #include #include "interval.h" -#include "../float_parameter_controller.h" +#include "../../float_parameter_controller.h" namespace Graph { class IntervalParameterController : public FloatParameterController { public: IntervalParameterController(Responder * parentResponder, Interval * interval); + ExpressionTextFieldDelegate * textFieldDelegate() override; Interval * interval(); const char * title() const override; int numberOfRows() override;