From c633fbda4d7651d5f6cbd0f4947db5671a6d4c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 16 Sep 2016 17:08:41 +0200 Subject: [PATCH 1/3] [escher] define class invocation Change-Id: Idbcdff574aa9b79864d26a13448a5b6c896f65f4 --- escher/Makefile | 1 + escher/include/escher.h | 1 + escher/include/escher/invocation.h | 17 +++++++++++++++++ escher/src/invocation.cpp | 11 +++++++++++ 4 files changed, 30 insertions(+) create mode 100644 escher/include/escher/invocation.h create mode 100644 escher/src/invocation.cpp diff --git a/escher/Makefile b/escher/Makefile index c40d4efc0..5ee7fc651 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -4,6 +4,7 @@ objs += $(addprefix escher/src/,\ app.o\ childless_view.o\ container.o\ + invocation.o\ responder.o\ scroll_view.o\ scroll_view_indicator.o\ diff --git a/escher/include/escher.h b/escher/include/escher.h index 2c0849c35..d539f6cb0 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/escher/include/escher/invocation.h b/escher/include/escher/invocation.h new file mode 100644 index 000000000..434ac6fc7 --- /dev/null +++ b/escher/include/escher/invocation.h @@ -0,0 +1,17 @@ +#ifndef ESCHER_INVOCATION_H +#define ESCHER_INVOCATION_H + +class Invocation { +public: + typedef void (*Action)(void * context, void * sender); + Invocation(Action a, void * c); + + void perform(void * sender); + +private: + Action m_action; + void * m_context; +}; + +#endif + diff --git a/escher/src/invocation.cpp b/escher/src/invocation.cpp new file mode 100644 index 000000000..8b7140796 --- /dev/null +++ b/escher/src/invocation.cpp @@ -0,0 +1,11 @@ +#include + +Invocation::Invocation(Action a, void * c) : + m_action(a), + m_context(c) +{ +} + +void Invocation::perform(void * sender) { + (*m_action)(m_context, sender); +} From 082a3883cdce6ca5ed5e83921344f7af6382ef6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 16 Sep 2016 17:23:45 +0200 Subject: [PATCH 2/3] [apps/graph] Add a name attribute to functions Change-Id: I7a8fd1701b026b27d1dfcfc87fc92398c494e7fd --- apps/graph/function.cpp | 5 +++++ apps/graph/function.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/apps/graph/function.cpp b/apps/graph/function.cpp index 4e23cb7c5..227d0818f 100644 --- a/apps/graph/function.cpp +++ b/apps/graph/function.cpp @@ -10,6 +10,7 @@ Graph::Function::Function() : Graph::Function::Function(const char * text, KDColor color) : m_text(text), // FIXME: Copy !! m_color(color), + m_name("f(x)"), m_expression(nullptr), m_layout(nullptr) { @@ -29,6 +30,10 @@ const char * Graph::Function::text() { return m_text; } +const char * Graph::Function::name() { + return m_name; +} + Expression * Graph::Function::expression() { if (m_expression == nullptr) { m_expression = Expression::parse(m_text); diff --git a/apps/graph/function.h b/apps/graph/function.h index 764516858..3021f129a 100644 --- a/apps/graph/function.h +++ b/apps/graph/function.h @@ -12,11 +12,13 @@ public: Function(const char * text, KDColor m_color); ~Function(); // Delete expression and layout, if needed const char * text(); + const char * name(); KDColor color() const { return m_color; } Expression * expression(); ExpressionLayout * layout(); private: const char * m_text; + const char * m_name; KDColor m_color; Expression * m_expression; ExpressionLayout * m_layout; From 844d6f848e55c0201fdd8c9b7929f407bf57f3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 16 Sep 2016 17:27:06 +0200 Subject: [PATCH 3/3] [apps/graph/list] clean the list controller (handle parameter controller) Change-Id: I7c8e976ebcceb7071e0f57348af4b07203d35adb --- apps/graph/list/list_controller.cpp | 9 ++++++--- apps/graph/list/list_controller.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/graph/list/list_controller.cpp b/apps/graph/list/list_controller.cpp index bc078eca0..3409cd701 100644 --- a/apps/graph/list/list_controller.cpp +++ b/apps/graph/list/list_controller.cpp @@ -37,6 +37,12 @@ void ListController::setActiveCell(int index) { app()->setFirstResponder(cell); } +void ListController::configureFunction(Graph::Function * function) { + // Add call to function + StackViewController * stack = ((StackViewController *)parentResponder()); + stack->push(&m_parameterController); +} + bool ListController::handleEvent(Ion::Events::Event event) { switch (event) { case Ion::Events::Event::DOWN_ARROW: @@ -49,9 +55,6 @@ bool ListController::handleEvent(Ion::Events::Event event) { app()->setFirstResponder(tabController()); } return true; - case Ion::Events::Event::ENTER: - ((StackViewController *) parentResponder())->push(&m_parameterController); - return true; case Ion::Events::Event::PLUS: m_manualScrolling += 10; m_tableView.setContentOffset({0, m_manualScrolling}); diff --git a/apps/graph/list/list_controller.h b/apps/graph/list/list_controller.h index 646169805..93c4d9b02 100644 --- a/apps/graph/list/list_controller.h +++ b/apps/graph/list/list_controller.h @@ -21,6 +21,7 @@ public: KDCoordinate cellHeight() override; View * reusableCell(int index) override; int reusableCellCount() override; + void configureFunction(Graph::Function * function); private: Responder * tabController() const; constexpr static int k_totalNumberOfModels = 20;