mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-22 15:20:39 +01:00
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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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\
|
||||
|
||||
@@ -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>
|
||||
|
||||
17
escher/include/escher/invocation.h
Normal file
17
escher/include/escher/invocation.h
Normal 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
11
escher/src/invocation.cpp
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user