Merge changes I7c8e976e,I7a8fd170,Idbcdff57

* changes:
  [apps/graph/list] clean the list controller (handle parameter controller)
  [apps/graph] Add a name attribute to functions
  [escher] define class invocation
This commit is contained in:
Romain Goyet
2016-09-19 09:56:55 +02:00
committed by Gerrit
8 changed files with 44 additions and 3 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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});

View File

@@ -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;

View File

@@ -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\

View File

@@ -3,6 +3,7 @@
#include <escher/app.h>
#include <escher/container.h>
#include <escher/invocation.h>
#include <escher/responder.h>
#include <escher/scroll_view.h>
#include <escher/scroll_view_indicator.h>

View File

@@ -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

11
escher/src/invocation.cpp Normal file
View File

@@ -0,0 +1,11 @@
#include <escher/invocation.h>
Invocation::Invocation(Action a, void * c) :
m_action(a),
m_context(c)
{
}
void Invocation::perform(void * sender) {
(*m_action)(m_context, sender);
}