mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 14:20:39 +01:00
[expression_editor] Base app for development, to remove later.
Change-Id: I1d5b59f67fd146d2e2917546a7d8b9419a0a7036
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
EPSILON_I18N_LANGUAGES ?= en fr es de pt
|
||||
EPSILON_APPS ?= calculation graph sequence settings statistics probability regression code
|
||||
EPSILON_APPS ?= expression_editor
|
||||
|
||||
include apps/shared/Makefile
|
||||
include apps/home/Makefile
|
||||
|
||||
18
apps/expression_editor/Makefile
Normal file
18
apps/expression_editor/Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
snapshots += ExpressionEditor::App::Snapshot
|
||||
snapshot_headers += apps/expression_editor/app.h
|
||||
|
||||
app_objs += $(addprefix apps/expression_editor/,\
|
||||
app.o\
|
||||
controller.o\
|
||||
expression_and_layout.o\
|
||||
)
|
||||
|
||||
i18n_files += $(addprefix apps/expression_editor/,\
|
||||
base.universal.i18n\
|
||||
)
|
||||
|
||||
tests += $(addprefix apps/expression_editor/test/,\
|
||||
dummy_test.cpp\
|
||||
)
|
||||
|
||||
test_objs += $(addprefix apps/expression_editor/, controller.o)
|
||||
29
apps/expression_editor/app.cpp
Normal file
29
apps/expression_editor/app.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "app.h"
|
||||
#include "../i18n.h"
|
||||
|
||||
namespace ExpressionEditor {
|
||||
|
||||
I18n::Message App::Descriptor::name() {
|
||||
return I18n::Message::ExpressionEditorApp;
|
||||
}
|
||||
|
||||
I18n::Message App::Descriptor::upperName() {
|
||||
return I18n::Message::ExpressionEditorAppCapital;
|
||||
}
|
||||
|
||||
App * App::Snapshot::unpack(Container * container) {
|
||||
return new App(container, this);
|
||||
}
|
||||
|
||||
App::Descriptor * App::Snapshot::descriptor() {
|
||||
static Descriptor descriptor;
|
||||
return &descriptor;
|
||||
}
|
||||
|
||||
App::App(Container * container, Snapshot * snapshot) :
|
||||
::App(container, snapshot, &m_controller),
|
||||
m_controller(&m_modalViewController, snapshot->expressionAndLayout())
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
35
apps/expression_editor/app.h
Normal file
35
apps/expression_editor/app.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef EXPRESSION_EDITOR_APP_H
|
||||
#define EXPRESSION_EDITOR_APP_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "controller.h"
|
||||
#include "expression_and_layout.h"
|
||||
|
||||
namespace ExpressionEditor {
|
||||
|
||||
/* TODO This app is used for creating ExpressionLayout edition. It should be
|
||||
* removed when the development is finished. */
|
||||
|
||||
class App : public ::App {
|
||||
public:
|
||||
class Descriptor : public ::App::Descriptor {
|
||||
public:
|
||||
I18n::Message name() override;
|
||||
I18n::Message upperName() override;
|
||||
};
|
||||
class Snapshot : public ::App::Snapshot, public SelectableTableViewDataSource {
|
||||
public:
|
||||
App * unpack(Container * container) override;
|
||||
Descriptor * descriptor() override;
|
||||
ExpressionAndLayout * expressionAndLayout() { return &m_expressionAndLayout; }
|
||||
private:
|
||||
ExpressionAndLayout m_expressionAndLayout;
|
||||
};
|
||||
private:
|
||||
App(Container * container, Snapshot * snapshot);
|
||||
Controller m_controller;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
2
apps/expression_editor/base.universal.i18n
Normal file
2
apps/expression_editor/base.universal.i18n
Normal file
@@ -0,0 +1,2 @@
|
||||
ExpressionEditorApp = "ExpressionEdit"
|
||||
ExpressionEditorAppCapital = "EXPRESSION EDITOR"
|
||||
34
apps/expression_editor/controller.cpp
Normal file
34
apps/expression_editor/controller.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "controller.h"
|
||||
|
||||
namespace ExpressionEditor {
|
||||
|
||||
Controller::ContentView::ContentView(ExpressionAndLayout * expressionAndLayout) :
|
||||
SolidColorView(KDColorWhite),
|
||||
m_expressionView()
|
||||
{
|
||||
m_expressionView.setExpression(expressionAndLayout->expressionLayout());
|
||||
}
|
||||
|
||||
void Controller::ContentView::layoutSubviews() {
|
||||
m_expressionView.setFrame(KDRect(
|
||||
k_margin,
|
||||
k_margin,
|
||||
bounds().width() - 2 * k_margin,
|
||||
bounds().height() - 2 * k_margin));
|
||||
}
|
||||
|
||||
KDSize Controller::ContentView::minimalSizeForOptimalDisplay() const {
|
||||
return m_expressionView.minimalSizeForOptimalDisplay();
|
||||
}
|
||||
|
||||
Controller::Controller(Responder * parentResponder, ExpressionAndLayout * expressionAndLayout) :
|
||||
ViewController(parentResponder),
|
||||
m_view(expressionAndLayout)
|
||||
{
|
||||
}
|
||||
|
||||
bool Controller::handleEvent(Ion::Events::Event event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
39
apps/expression_editor/controller.h
Normal file
39
apps/expression_editor/controller.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef EXPRESSION_EDITOR_CONTROLLER_H
|
||||
#define EXPRESSION_EDITOR_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include <poincare.h>
|
||||
#include "expression_and_layout.h"
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
namespace ExpressionEditor {
|
||||
|
||||
class Controller : public ViewController {
|
||||
public:
|
||||
Controller(Responder * parentResponder, ExpressionAndLayout * expressionAndLayout);
|
||||
View * view() override { return &m_view; }
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
|
||||
private:
|
||||
class ContentView : public SolidColorView {
|
||||
public:
|
||||
ContentView(ExpressionAndLayout * expressionAndLayout);
|
||||
int numberOfSubviews() const override { return 1; }
|
||||
View * subviewAtIndex(int index) override {
|
||||
assert(index == 0);
|
||||
return &m_expressionView;
|
||||
}
|
||||
void layoutSubviews() override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
private:
|
||||
constexpr static KDCoordinate k_margin = 10;
|
||||
ExpressionView m_expressionView;
|
||||
};
|
||||
ContentView m_view;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
51
apps/expression_editor/expression_and_layout.cpp
Normal file
51
apps/expression_editor/expression_and_layout.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "expression_and_layout.h"
|
||||
|
||||
namespace ExpressionEditor {
|
||||
|
||||
ExpressionAndLayout::ExpressionAndLayout() {
|
||||
//const char * expression = "2/3";
|
||||
//const char * expression = "1+2/(3+4)";
|
||||
//const char * expression = "1+2/3+5+8";
|
||||
//const char * expression = "[[1+5,2,3][4,5,6]]";
|
||||
//const char * expression = "1+2/(7+5/3/467777777)/3+8";
|
||||
//const char * expression = "1+2/7467777777";
|
||||
//const char * expression = "2385658/(7+5/46)";
|
||||
//const char * expression = "1+conj(100)+2";
|
||||
//const char * expression = "1+abs(100)+2";
|
||||
//const char * expression = "1+root(100,41)+2";
|
||||
//const char * expression = "ln(36)";
|
||||
//const char * expression = "1+floor(36)+2";
|
||||
//const char * expression = "ln(36)+root(542,52)+sum(12,3,4)+int(22,3,4)+conj(988)";
|
||||
//const char * expression = "2385658/(7/78+int(5/46*7/8,3,45))+sum(12,3,4)+(1111111)/(2/3+4/5)";
|
||||
//const char * expression = "2385658/(int(5/46*7/8,3,45))";
|
||||
//const char * expression = "1+binomial(6,88)+1";
|
||||
//const char * expression = "[[1+5,2,3][4,5,int(5/46+1,3,4)]]";
|
||||
//const char * expression = "2385658/(7/78+int(5/46*7/8,3,45))+sum(12,3,4)+[[1+5,2,3][4/2,5,6]]";
|
||||
//const char * expression = "1/2+[[1,2,3][4,5,6]]+1";
|
||||
//const char * expression = "1+(3+4)+1";
|
||||
//const char * expression = "1+product(23,46,123)+[[2,3][5,6]]+1/4";
|
||||
//const char * expression = "2385658/(7/78+int(5/46*7/8,3,45))+sum(12,3,4)+[[1+5,2,3][4/2,5,6]]";
|
||||
//const char * expression = "7/78+int(5/46*7/8,3,45)+sum(12,3,4)+[[1+5,2,3][4/2,5,6]]";
|
||||
//const char * expression = "1+conj(39)+abs(3)+root(6000,23)";
|
||||
//const char * expression = "1.5+3.4";
|
||||
//const char * expression = "abs(5)+int(5/46*7/8,3,4544444)+conj(4)+int(333,4,5)";
|
||||
//const char * expression = "conj(int(5/46*7/8,3,45))+conj(4)";
|
||||
//const char * expression = "abs(1+conj(conj(4))+(23)+conj(42))+abs(1+2)";
|
||||
const char * expression = "13+(23)";
|
||||
//const char * expression = "1+sum(12,3,4)+product(12,3,4)+2";
|
||||
|
||||
m_expression = Poincare::Expression::parse(expression);
|
||||
m_expressionLayout = m_expression->createLayout();
|
||||
}
|
||||
ExpressionAndLayout::~ExpressionAndLayout() {
|
||||
if (m_expressionLayout) {
|
||||
delete m_expressionLayout;
|
||||
m_expressionLayout = nullptr;
|
||||
}
|
||||
if (m_expression) {
|
||||
delete m_expression;
|
||||
m_expression = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
26
apps/expression_editor/expression_and_layout.h
Normal file
26
apps/expression_editor/expression_and_layout.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef EXPRESSION_EDITOR_EXPRESSION_AND_LAYOUT_H
|
||||
#define EXPRESSION_EDITOR_EXPRESSION_AND_LAYOUT_H
|
||||
|
||||
#include <poincare.h>
|
||||
|
||||
namespace ExpressionEditor {
|
||||
|
||||
class ExpressionAndLayout {
|
||||
public:
|
||||
ExpressionAndLayout();
|
||||
~ExpressionAndLayout();
|
||||
ExpressionAndLayout(const ExpressionAndLayout& other) = delete;
|
||||
ExpressionAndLayout(ExpressionAndLayout&& other) = delete;
|
||||
ExpressionAndLayout operator=(const ExpressionAndLayout& other) = delete;
|
||||
ExpressionAndLayout& operator=(ExpressionAndLayout&& other) = delete;
|
||||
|
||||
Poincare::Expression * expression() { return m_expression; }
|
||||
Poincare::ExpressionLayout * expressionLayout() { return m_expressionLayout; }
|
||||
private:
|
||||
Poincare::Expression * m_expression;
|
||||
Poincare::ExpressionLayout * m_expressionLayout;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
6
apps/expression_editor/test/dummy_test.cpp
Normal file
6
apps/expression_editor/test/dummy_test.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <quiz.h>
|
||||
#include <assert.h>
|
||||
|
||||
QUIZ_CASE() {
|
||||
assert(true);
|
||||
}
|
||||
Reference in New Issue
Block a user