mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 08:47:28 +01:00
Compare commits
9 Commits
upsilon-de
...
upsilon-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51fd990c31 | ||
|
|
7af2b45f1d | ||
|
|
d95785ba42 | ||
|
|
d108b76a32 | ||
|
|
a3d3cbbfa5 | ||
|
|
3a41cbdc85 | ||
|
|
3ccfdf0365 | ||
|
|
6aad7d2279 | ||
|
|
5c1f192228 |
23
apps/geometry/Makefile
Normal file
23
apps/geometry/Makefile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
apps += Geometry::App
|
||||||
|
app_headers += apps/geometry/app.h
|
||||||
|
|
||||||
|
app_geometry_src = $(addprefix apps/geometry/,\
|
||||||
|
app.cpp \
|
||||||
|
list/figures_controller.cpp \
|
||||||
|
list/definition_type_controller.cpp \
|
||||||
|
list/figure_type_controller.cpp \
|
||||||
|
list/figure_parameters_controller.cpp \
|
||||||
|
list/objects_controller.cpp \
|
||||||
|
list/message_table_cell_with_selector.cpp \
|
||||||
|
figure_store.cpp \
|
||||||
|
graph/graph_controller.cpp \
|
||||||
|
graph/banner_view.cpp \
|
||||||
|
)
|
||||||
|
|
||||||
|
apps_src += $(app_geometry_src)
|
||||||
|
|
||||||
|
app_images += apps/geometry/geometry_icon.png
|
||||||
|
|
||||||
|
i18n_files += $(call i18n_with_universal_for,geometry/base)
|
||||||
|
|
||||||
|
$(eval $(call depends_on_image,apps/geometry/app.cpp,apps/geometry/geometry_icon.png))
|
||||||
48
apps/geometry/app.cpp
Normal file
48
apps/geometry/app.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#include "app.h"
|
||||||
|
#include "geometry_icon.h"
|
||||||
|
#include "apps/apps_container.h"
|
||||||
|
#include "apps/i18n.h"
|
||||||
|
|
||||||
|
namespace Geometry
|
||||||
|
{
|
||||||
|
|
||||||
|
I18n::Message App::Descriptor::name()
|
||||||
|
{
|
||||||
|
return I18n::Message::GeometryApp;
|
||||||
|
}
|
||||||
|
|
||||||
|
I18n::Message App::Descriptor::upperName()
|
||||||
|
{
|
||||||
|
return I18n::Message::GeometryAppCapital;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Image * App::Descriptor::icon()
|
||||||
|
{
|
||||||
|
return ImageStore::GeometryIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
App * App::Snapshot::unpack(Container * container)
|
||||||
|
{
|
||||||
|
return new (container->currentAppBuffer()) App(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
App::Descriptor * App::Snapshot::descriptor()
|
||||||
|
{
|
||||||
|
static Descriptor descriptor;
|
||||||
|
return &descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
App::App(Snapshot * snapshot) :
|
||||||
|
TextFieldDelegateApp(snapshot, &m_tabViewController),
|
||||||
|
m_figuresController(&m_stackViewController),
|
||||||
|
m_stackViewController(&m_tabViewController, &m_figuresController),
|
||||||
|
m_graphController(&m_graphAlternateEmptyViewController, this, &m_graphHeader, nullptr, nullptr, nullptr),
|
||||||
|
m_graphAlternateEmptyViewController(&m_graphHeader, &m_graphController, &m_graphController),
|
||||||
|
m_graphHeader(&m_graphStackViewController, &m_graphAlternateEmptyViewController, &m_graphController),
|
||||||
|
m_graphStackViewController(&m_tabViewController, &m_graphHeader),
|
||||||
|
m_otherViewController(&m_tabViewController),
|
||||||
|
m_tabViewController(&m_modalViewController, snapshot, &m_stackViewController, &m_graphAlternateEmptyViewController, &m_otherViewController)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
40
apps/geometry/app.h
Normal file
40
apps/geometry/app.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef GEOMETRY_H
|
||||||
|
#define GEOMETRY_H
|
||||||
|
|
||||||
|
#include <escher.h>
|
||||||
|
#include "list/figures_controller.h"
|
||||||
|
#include "graph/graph_controller.h"
|
||||||
|
#include "other/other_view_controller.h"
|
||||||
|
#include "../shared/text_field_delegate_app.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
class App : public Shared::TextFieldDelegateApp {
|
||||||
|
public:
|
||||||
|
class Descriptor : public ::App::Descriptor {
|
||||||
|
public:
|
||||||
|
I18n::Message name() override;
|
||||||
|
I18n::Message upperName() override;
|
||||||
|
const Image * icon() override;
|
||||||
|
};
|
||||||
|
class Snapshot : public ::App::Snapshot, public TabViewDataSource {
|
||||||
|
public:
|
||||||
|
App * unpack(Container * container) override;
|
||||||
|
Descriptor * descriptor() override;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
App(Snapshot * snapshot);
|
||||||
|
|
||||||
|
FiguresController m_figuresController;
|
||||||
|
StackViewController m_stackViewController;
|
||||||
|
GraphController m_graphController;
|
||||||
|
AlternateEmptyViewController m_graphAlternateEmptyViewController;
|
||||||
|
StackViewController m_graphStackViewController;
|
||||||
|
ButtonRowController m_graphHeader;
|
||||||
|
OtherViewController m_otherViewController;
|
||||||
|
TabViewController m_tabViewController;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
6
apps/geometry/base.de.i18n
Normal file
6
apps/geometry/base.de.i18n
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
GeometryApp = "Geometry"
|
||||||
|
GeometryAppCapital = "GEOMETRY"
|
||||||
|
AddFigure = "Ajouter une figure"
|
||||||
|
FigureType = "Type de figure"
|
||||||
|
DefinitionType = "Définition de la figure"
|
||||||
|
ParametersChoice = "Choix des paramètres"
|
||||||
6
apps/geometry/base.en.i18n
Normal file
6
apps/geometry/base.en.i18n
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
GeometryApp = "Geometry"
|
||||||
|
GeometryAppCapital = "GEOMETRY"
|
||||||
|
AddFigure = "Ajouter une figure"
|
||||||
|
FigureType = "Type de figure"
|
||||||
|
DefinitionType = "Définition de la figure"
|
||||||
|
ParametersChoice = "Choix des paramètres"
|
||||||
6
apps/geometry/base.es.i18n
Normal file
6
apps/geometry/base.es.i18n
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
GeometryApp = "Geometry"
|
||||||
|
GeometryAppCapital = "GEOMETRY"
|
||||||
|
AddFigure = "Ajouter une figure"
|
||||||
|
FigureType = "Type de figure"
|
||||||
|
DefinitionType = "Définition de la figure"
|
||||||
|
ParametersChoice = "Choix des paramètres"
|
||||||
6
apps/geometry/base.fr.i18n
Normal file
6
apps/geometry/base.fr.i18n
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
GeometryApp = "Geometry"
|
||||||
|
GeometryAppCapital = "GEOMETRY"
|
||||||
|
AddFigure = "Ajouter une figure"
|
||||||
|
FigureType = "Type de figure"
|
||||||
|
DefinitionType = "Définition de la figure"
|
||||||
|
ParametersChoice = "Choix des paramètres"
|
||||||
6
apps/geometry/base.hu.i18n
Normal file
6
apps/geometry/base.hu.i18n
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
GeometryApp = "Geometry"
|
||||||
|
GeometryAppCapital = "GEOMETRY"
|
||||||
|
AddFigure = "Ajouter une figure"
|
||||||
|
FigureType = "Type de figure"
|
||||||
|
DefinitionType = "Définition de la figure"
|
||||||
|
ParametersChoice = "Choix des paramètres"
|
||||||
6
apps/geometry/base.it.i18n
Normal file
6
apps/geometry/base.it.i18n
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
GeometryApp = "Geometry"
|
||||||
|
GeometryAppCapital = "GEOMETRY"
|
||||||
|
AddFigure = "Ajouter une figure"
|
||||||
|
FigureType = "Type de figure"
|
||||||
|
DefinitionType = "Définition de la figure"
|
||||||
|
ParametersChoice = "Choix des paramètres"
|
||||||
6
apps/geometry/base.nl.i18n
Normal file
6
apps/geometry/base.nl.i18n
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
GeometryApp = "Geometry"
|
||||||
|
GeometryAppCapital = "GEOMETRY"
|
||||||
|
AddFigure = "Ajouter une figure"
|
||||||
|
FigureType = "Type de figure"
|
||||||
|
DefinitionType = "Définition de la figure"
|
||||||
|
ParametersChoice = "Choix des paramètres"
|
||||||
6
apps/geometry/base.pt.i18n
Normal file
6
apps/geometry/base.pt.i18n
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
GeometryApp = "Geometry"
|
||||||
|
GeometryAppCapital = "GEOMETRY"
|
||||||
|
AddFigure = "Ajouter une figure"
|
||||||
|
FigureType = "Type de figure"
|
||||||
|
DefinitionType = "Définition de la figure"
|
||||||
|
ParametersChoice = "Choix des paramètres"
|
||||||
24
apps/geometry/base.universal.i18n
Normal file
24
apps/geometry/base.universal.i18n
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
FiguresTab = "Figures"
|
||||||
|
NoFigures = "Aucune figure à afficher"
|
||||||
|
OtherTab = "TODO"
|
||||||
|
Coordinates = "Coordonnées"
|
||||||
|
Middle = "Milieu"
|
||||||
|
VectorProject = "Projeté vectoriel"
|
||||||
|
OrthogonalProject = "Projeté orthogonal"
|
||||||
|
CartesianEquation = "Equation cartésienne"
|
||||||
|
LinearEquation = "Equation linéaire"
|
||||||
|
Points = "Points"
|
||||||
|
PointAndVector = "Point et vecteur"
|
||||||
|
Parallele = "Parallèle"
|
||||||
|
Perpendicular = "Perpendiculaire"
|
||||||
|
PointAndRadius = "Point et rayon"
|
||||||
|
Diameter = "Diamètre"
|
||||||
|
TwoPoints = "Deux points"
|
||||||
|
Segment = "Segment"
|
||||||
|
Angle = "Angle"
|
||||||
|
Area = "Surface"
|
||||||
|
Point = "Point"
|
||||||
|
Line = "Droite"
|
||||||
|
Circle = "Cercle"
|
||||||
|
Vector = "Vecteur"
|
||||||
|
Indicator = "Indicateur"
|
||||||
1
apps/geometry/figure_store.cpp
Normal file
1
apps/geometry/figure_store.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "figure_store.h"
|
||||||
14
apps/geometry/figure_store.h
Normal file
14
apps/geometry/figure_store.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef FIGURE__STORE__H
|
||||||
|
#define FIGURE__STORE__H
|
||||||
|
|
||||||
|
#include "../shared/expression_model_store.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
class FigureStore: Shared::ExpressionModelStore {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
27
apps/geometry/figures/figure.h
Normal file
27
apps/geometry/figures/figure.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef POINCARE_FIGURE_H
|
||||||
|
#define POINCARE_FIGURE_H
|
||||||
|
|
||||||
|
#include "figure_type.h"
|
||||||
|
|
||||||
|
using namespace Poincare;
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
class FigureNode : public TreeNode {
|
||||||
|
public:
|
||||||
|
virtual size_t size() const override = 0;
|
||||||
|
|
||||||
|
virtual int numberOfChildren() const override { return 0; }
|
||||||
|
|
||||||
|
virtual FigureType type() const = 0;
|
||||||
|
virtual FigureDefinitionType definitionType() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Figure : public TreeHandle {
|
||||||
|
public:
|
||||||
|
Figure(const FigureNode * node) : TreeHandle(node) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
24
apps/geometry/figures/figure_type.h
Normal file
24
apps/geometry/figures/figure_type.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef GEOMETRY_FIGURE_TYPE_H
|
||||||
|
#define GEOMETRY_FIGURE_TYPE_H
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
enum class FigureType {
|
||||||
|
None = 0, // Used to trigger assert in debug mode
|
||||||
|
Expression, // It's not a real figure type but we use it to build figures like points
|
||||||
|
|
||||||
|
Point,
|
||||||
|
|
||||||
|
Line,
|
||||||
|
Circle,
|
||||||
|
Vector,
|
||||||
|
Indicator
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class FigureDefinitionType {
|
||||||
|
PointByCoordinates
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
6
apps/geometry/figures/figures.h
Normal file
6
apps/geometry/figures/figures.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef FIGURES_H
|
||||||
|
#define FIGURES_H
|
||||||
|
|
||||||
|
#include "point_by_coordinates.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
1
apps/geometry/figures/point.cpp
Normal file
1
apps/geometry/figures/point.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "point.h"
|
||||||
18
apps/geometry/figures/point.h
Normal file
18
apps/geometry/figures/point.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef GEOMETRY_POINT_H
|
||||||
|
#define GEOMETRY_POINT_H
|
||||||
|
|
||||||
|
#include "figure.h"
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
class PointNode : public FigureNode {
|
||||||
|
virtual FigureType type() const override { return FigureType::Point; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class Point : public Figure {
|
||||||
|
public:
|
||||||
|
Point(const PointNode * n) : Figure(n) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
31
apps/geometry/figures/point_by_coordinates.h
Normal file
31
apps/geometry/figures/point_by_coordinates.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef POINT_BY_COORDINATES_H
|
||||||
|
#define POINT_BY_COORDINATES_H
|
||||||
|
|
||||||
|
#include <poincare/expression.h>
|
||||||
|
#include "point.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
class PointByCoordinatesNode : public PointNode {
|
||||||
|
public:
|
||||||
|
virtual size_t size() const override { return sizeof(PointByCoordinatesNode); }
|
||||||
|
virtual int numberOfChildren() const override { return 2; }
|
||||||
|
virtual FigureDefinitionType definitionType() const override { return FigureDefinitionType::PointByCoordinates; }
|
||||||
|
#if POINCARE_TREE_LOG
|
||||||
|
void logNodeName(std::ostream & stream) const override {
|
||||||
|
stream << "PointByCoordinates";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
class PointByCoordinates : public Figure {
|
||||||
|
public:
|
||||||
|
PointByCoordinates(const PointByCoordinatesNode * n) : Figure(n) {}
|
||||||
|
static PointByCoordinates Builder(Expression x, Expression y) { return TreeHandle::FixedArityBuilder<PointByCoordinates, PointByCoordinatesNode>({x, x}); }
|
||||||
|
static int numberOfParameters() { return 2; }
|
||||||
|
static FigureType parameterTypeAtIndex(int i) { return FigureType::Expression; }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
BIN
apps/geometry/geometry_icon.png
Normal file
BIN
apps/geometry/geometry_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
15
apps/geometry/graph/banner_view.cpp
Normal file
15
apps/geometry/graph/banner_view.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "banner_view.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
BannerView::BannerView(
|
||||||
|
Responder * parentResponder,
|
||||||
|
InputEventHandlerDelegate * inputEventHandlerDelegate,
|
||||||
|
TextFieldDelegate * textFieldDelegate
|
||||||
|
) :
|
||||||
|
Shared::XYBannerView(parentResponder, inputEventHandlerDelegate, textFieldDelegate)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
15
apps/geometry/graph/banner_view.h
Normal file
15
apps/geometry/graph/banner_view.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef GEOMETRY_BANNER_VIEW_H
|
||||||
|
#define GEOMETRY_BANNER_VIEW_H
|
||||||
|
|
||||||
|
#include "../../shared/xy_banner_view.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
class BannerView : public Shared::XYBannerView {
|
||||||
|
public:
|
||||||
|
BannerView(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, TextFieldDelegate * textFieldDelegate);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
11
apps/geometry/graph/graph_controller.cpp
Normal file
11
apps/geometry/graph/graph_controller.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "graph_controller.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
GraphController::GraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Shared::InteractiveCurveViewRange/*TODO -> Store*/ * store, Shared::CurveViewCursor * cursor, uint32_t * rangeVersion) :
|
||||||
|
InteractiveCurveViewController(parentResponder, inputEventHandlerDelegate, header, store, nullptr, cursor, rangeVersion)
|
||||||
|
{
|
||||||
|
/* WHEREIWAS: Now i must make the app launch again without crash, by replacing the multiples nullptr that I used... */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
33
apps/geometry/graph/graph_controller.h
Normal file
33
apps/geometry/graph/graph_controller.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef GRAPH_VIEW_CONTROLLER_H
|
||||||
|
#define GRAPH_VIEW_CONTROLLER_H
|
||||||
|
|
||||||
|
#include "../shared/interactive_curve_view_controller.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
class GraphController : public Shared::InteractiveCurveViewController {
|
||||||
|
public:
|
||||||
|
GraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Shared::InteractiveCurveViewRange * store, Shared::CurveViewCursor * cursor, uint32_t * rangeVersion);
|
||||||
|
|
||||||
|
virtual Shared::InteractiveCurveViewRange * interactiveCurveViewRange() override { return nullptr; } //TOIMPLEMENT
|
||||||
|
virtual Shared::CurveView * curveView() override { return nullptr; } //TOIMPLEMENT
|
||||||
|
virtual void reloadBannerView() override { } //TOIMPLEMENT
|
||||||
|
virtual bool handleEnter() override { return false; } //TOIMPLEMENT
|
||||||
|
virtual void initCursorParameters() override { } //TOIMPLEMENT
|
||||||
|
virtual bool moveCursorVertically(int direction) override { return false; } //TOIMPLEMENT
|
||||||
|
virtual uint32_t rangeVersion() override { return 0; } //TOIMPLEMENT
|
||||||
|
virtual bool cursorMatchesModel() override { return false; } //TOIMPLEMENT
|
||||||
|
virtual Poincare::Coordinate2D<double> xyValues(int curveIndex, double t, Poincare::Context * context) const override { return Poincare::Coordinate2D<double>(0, 0); } //TOIMPLEMENT
|
||||||
|
virtual bool closestCurveIndexIsSuitable(int newIndex, int currentIndex) const override { return false; }
|
||||||
|
virtual int selectedCurveIndex() const override { return 0; }
|
||||||
|
virtual int numberOfCurves() const override { return 0; }
|
||||||
|
|
||||||
|
/* AlternateEmptyViewDefaultDelegate */
|
||||||
|
virtual bool isEmpty() const override { return false; }
|
||||||
|
virtual I18n::Message emptyMessage() override { return I18n::Message::NoFigures; }
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
147
apps/geometry/list/definition_type_controller.cpp
Normal file
147
apps/geometry/list/definition_type_controller.cpp
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
#include "figure_type_controller.h"
|
||||||
|
#include "../figures/figures.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
static constexpr I18n::Message sPointDefinitionsMessages[] = {
|
||||||
|
I18n::Message::Coordinates,
|
||||||
|
I18n::Message::Middle,
|
||||||
|
I18n::Message::VectorProject,
|
||||||
|
I18n::Message::OrthogonalProject
|
||||||
|
};
|
||||||
|
static const uint8_t sPointDefinitionsMessagesCount = sizeof(sPointDefinitionsMessages) / sizeof(I18n::Message);
|
||||||
|
|
||||||
|
|
||||||
|
static constexpr I18n::Message sLineDefinitionMessages[] = {
|
||||||
|
I18n::Message::CartesianEquation,
|
||||||
|
I18n::Message::LinearEquation,
|
||||||
|
I18n::Message::Points,
|
||||||
|
I18n::Message::PointAndVector,
|
||||||
|
I18n::Message::Parallele,
|
||||||
|
I18n::Message::Perpendicular
|
||||||
|
};
|
||||||
|
static const uint8_t sLineDefinitionsMessagesCount = sizeof(sLineDefinitionMessages) / sizeof(I18n::Message);
|
||||||
|
|
||||||
|
|
||||||
|
static constexpr I18n::Message sCircleDefinitionsMessages[] = {
|
||||||
|
I18n::Message::PointAndRadius,
|
||||||
|
I18n::Message::Diameter,
|
||||||
|
I18n::Message::CartesianEquation,
|
||||||
|
};
|
||||||
|
static const uint8_t sCircleDefinitionsMessagesCount = sizeof(sCircleDefinitionsMessages) / sizeof(I18n::Message);
|
||||||
|
|
||||||
|
|
||||||
|
static constexpr I18n::Message sVectorDefinitionsMessages[] = {
|
||||||
|
I18n::Message::Coordinates,
|
||||||
|
I18n::Message::TwoPoints
|
||||||
|
};
|
||||||
|
static const uint8_t sVectorDefinitionsMessagesCount = sizeof(sVectorDefinitionsMessages) / sizeof(I18n::Message);
|
||||||
|
|
||||||
|
|
||||||
|
static constexpr I18n::Message sIndicatorDefinitionsMessages[] = {
|
||||||
|
I18n::Message::Segment,
|
||||||
|
I18n::Message::Angle,
|
||||||
|
I18n::Message::Area,
|
||||||
|
};
|
||||||
|
static const uint8_t sIndicatorDefinitionsMessagesCount = sizeof(sIndicatorDefinitionsMessages) / sizeof(I18n::Message);
|
||||||
|
|
||||||
|
|
||||||
|
DefinitionTypeController::DefinitionTypeController(Responder * parentResponder, FigureParametersController * parametersController):
|
||||||
|
ViewController(parentResponder),
|
||||||
|
m_lastSelectedRow(0),
|
||||||
|
m_selectableTableView(this),
|
||||||
|
m_messages(nullptr),
|
||||||
|
m_figureType(FigureType::None),
|
||||||
|
m_parametersController(parametersController)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < k_numberOfCells; i ++) {
|
||||||
|
m_cells[i].setMessageFont(KDFont::LargeFont);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefinitionTypeController::viewWillAppear() {
|
||||||
|
assert(m_figureType != FigureType::None && m_messages != nullptr);
|
||||||
|
selectRow(m_lastSelectedRow);
|
||||||
|
m_selectableTableView.reloadData(); // We reload the cell of the table view to update their message
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefinitionTypeController::didBecomeFirstResponder() {
|
||||||
|
//App::app()->snapshot()->setActivePage(App::Snapshot::Page::Distribution);
|
||||||
|
Container::activeApp()->setFirstResponder(&m_selectableTableView);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DefinitionTypeController::handleEvent(Ion::Events::Event event) {
|
||||||
|
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
|
||||||
|
m_lastSelectedRow = selectedRow();
|
||||||
|
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||||
|
m_parametersController->setParametersInfoFunctions(PointByCoordinates::numberOfParameters, PointByCoordinates::parameterTypeAtIndex);
|
||||||
|
stack->push(m_parametersController);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (event == Ion::Events::Back) {
|
||||||
|
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||||
|
stack->pop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HighlightCell * DefinitionTypeController::reusableCell(int index) {
|
||||||
|
assert(index >= 0);
|
||||||
|
assert(index < k_numberOfCells);
|
||||||
|
return &m_cells[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefinitionTypeController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||||
|
MessageTableCellWithChevron * myCell = (MessageTableCellWithChevron *)cell;
|
||||||
|
myCell->setMessage(m_messages[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int DefinitionTypeController::numberOfRows() const {
|
||||||
|
switch (m_figureType) {
|
||||||
|
case FigureType::Point:
|
||||||
|
return sPointDefinitionsMessagesCount;
|
||||||
|
break;
|
||||||
|
case FigureType::Line:
|
||||||
|
return sLineDefinitionsMessagesCount;
|
||||||
|
break;
|
||||||
|
case FigureType::Circle:
|
||||||
|
return sCircleDefinitionsMessagesCount;
|
||||||
|
break;
|
||||||
|
case FigureType::Vector:
|
||||||
|
return sVectorDefinitionsMessagesCount;
|
||||||
|
break;
|
||||||
|
case FigureType::Indicator:
|
||||||
|
return sIndicatorDefinitionsMessagesCount;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefinitionTypeController::setFigureType(FigureType figureType) {
|
||||||
|
m_figureType = figureType;
|
||||||
|
switch (m_figureType) {
|
||||||
|
case FigureType::Point:
|
||||||
|
m_messages = sPointDefinitionsMessages;
|
||||||
|
break;
|
||||||
|
case FigureType::Line:
|
||||||
|
m_messages = sLineDefinitionMessages;
|
||||||
|
break;
|
||||||
|
case FigureType::Circle:
|
||||||
|
m_messages = sCircleDefinitionsMessages;
|
||||||
|
break;
|
||||||
|
case FigureType::Vector:
|
||||||
|
m_messages = sVectorDefinitionsMessages;
|
||||||
|
break;
|
||||||
|
case FigureType::Indicator:
|
||||||
|
m_messages = sIndicatorDefinitionsMessages;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
53
apps/geometry/list/definition_type_controller.h
Normal file
53
apps/geometry/list/definition_type_controller.h
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#ifndef GEOMETRY_DEFINITION_TYPE_CONTROLLER_H
|
||||||
|
#define GEOMETRY_DEFINITION_TYPE_CONTROLLER_H
|
||||||
|
|
||||||
|
#include <escher.h>
|
||||||
|
#include "apps/i18n.h"
|
||||||
|
#include "../figures/figure_type.h"
|
||||||
|
#include "figure_parameters_controller.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
/**
|
||||||
|
* \brief DefinitionTypeController is a controller to choose how the figure is defined
|
||||||
|
*/
|
||||||
|
class DefinitionTypeController : public ViewController, public SimpleListViewDataSource, public SelectableTableViewDataSource {
|
||||||
|
public:
|
||||||
|
DefinitionTypeController(Responder * parentResponder, FigureParametersController * parametersController);
|
||||||
|
|
||||||
|
/* ViewController */
|
||||||
|
View * view() override { return &m_selectableTableView; }
|
||||||
|
// We want to avoid using half of the screen just for titles
|
||||||
|
virtual DisplayParameter displayParameter() override { return DisplayParameter::DoNotShowOwnTitle; }
|
||||||
|
const char * title() override { return I18n::translate(I18n::Message::DefinitionType); }
|
||||||
|
|
||||||
|
/* Responder */
|
||||||
|
bool handleEvent(Ion::Events::Event event) override;
|
||||||
|
|
||||||
|
/* ViewController */
|
||||||
|
void didBecomeFirstResponder() override;
|
||||||
|
void viewWillAppear() override;
|
||||||
|
TELEMETRY_ID("FigureType");
|
||||||
|
|
||||||
|
/* SelectableTableViewDataSource */
|
||||||
|
int numberOfRows() const override;
|
||||||
|
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||||
|
KDCoordinate cellHeight() override { return k_cellHeight; }
|
||||||
|
HighlightCell * reusableCell(int index) override;
|
||||||
|
int reusableCellCount() const override { return k_numberOfCells; }
|
||||||
|
|
||||||
|
/* Customs methods */
|
||||||
|
void setFigureType(FigureType type);
|
||||||
|
private:
|
||||||
|
constexpr static KDCoordinate k_cellHeight = Metric::ParameterCellHeight;
|
||||||
|
constexpr static int k_numberOfCells = 6;
|
||||||
|
int m_lastSelectedRow;
|
||||||
|
MessageTableCellWithChevron m_cells[k_numberOfCells];
|
||||||
|
SelectableTableView m_selectableTableView;
|
||||||
|
const I18n::Message * m_messages;
|
||||||
|
FigureType m_figureType;
|
||||||
|
FigureParametersController * m_parametersController;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
114
apps/geometry/list/figure_parameters_controller.cpp
Normal file
114
apps/geometry/list/figure_parameters_controller.cpp
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
#include "figure_parameters_controller.h"
|
||||||
|
#include "../app.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
FigureParametersController::FigureParametersController(Responder * parentResponder):
|
||||||
|
ViewController(parentResponder),
|
||||||
|
m_lastSelectedRow(0),
|
||||||
|
m_selectableTableView(this),
|
||||||
|
m_okButton(&m_selectableTableView, I18n::Message::Ok, Invocation([](void * context, void * sender) {
|
||||||
|
FigureParametersController * parameterController = (FigureParametersController *) context;
|
||||||
|
parameterController->returnToMenu();
|
||||||
|
return true;
|
||||||
|
}, this))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < k_choiceCells; i++) {
|
||||||
|
m_choicesCells[i].setParentResponder(&m_selectableTableView);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < k_textCells; i++) {
|
||||||
|
m_textCells[i].setParentResponder(&m_selectableTableView);
|
||||||
|
m_textCells[i].textField()->setDelegates(this, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FigureParametersController::setParametersInfoFunctions(NumberOfParametersFunction numberOfParametersFunction, TypeOfParametersAtIndexFunction typeOfParametersAtIndexFunction) {
|
||||||
|
m_numberOfParametersFunction = numberOfParametersFunction;
|
||||||
|
m_typeOfParametersAtIndexFunction = typeOfParametersAtIndexFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FigureParametersController::didBecomeFirstResponder() {
|
||||||
|
Container::activeApp()->setFirstResponder(&m_selectableTableView);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FigureParametersController::viewWillAppear() {
|
||||||
|
selectRow(m_lastSelectedRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FigureParametersController::returnToMenu() {
|
||||||
|
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||||
|
stack->pop();
|
||||||
|
stack->pop();
|
||||||
|
stack->pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ListViewDataSource */
|
||||||
|
int FigureParametersController::typeAtLocation(int i, int j) {
|
||||||
|
if (j == m_numberOfParametersFunction()) {
|
||||||
|
return 0; // It's equivalent to "None", so we can use it for button cell
|
||||||
|
}
|
||||||
|
return (int) m_typeOfParametersAtIndexFunction(j);
|
||||||
|
}
|
||||||
|
|
||||||
|
int FigureParametersController::reusableCellCount(int type) {
|
||||||
|
if (type == 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return type == (int) FigureType::Expression ? k_textCells: k_choiceCells;
|
||||||
|
}
|
||||||
|
|
||||||
|
HighlightCell * FigureParametersController::reusableCell(int index, int type) {
|
||||||
|
if (type == 0) {
|
||||||
|
return &m_okButton;
|
||||||
|
}
|
||||||
|
if (type == (int) FigureType::Expression) {
|
||||||
|
return &m_textCells[index];
|
||||||
|
}
|
||||||
|
return &m_choicesCells[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
int FigureParametersController::numberOfRows() const {
|
||||||
|
return m_numberOfParametersFunction() + 1;
|
||||||
|
}
|
||||||
|
KDCoordinate FigureParametersController::rowHeight(int j) {
|
||||||
|
if (j == numberOfRows()-1) {
|
||||||
|
return Metric::ParameterCellHeight+k_buttonMargin;
|
||||||
|
}
|
||||||
|
return Metric::ParameterCellHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
KDCoordinate FigureParametersController::cumulatedHeightFromIndex(int j) {
|
||||||
|
if (j == numberOfRows()) {
|
||||||
|
return j*Metric::ParameterCellHeight+k_buttonMargin;
|
||||||
|
}
|
||||||
|
return Metric::ParameterCellHeight*j;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FigureParametersController::indexFromCumulatedHeight(KDCoordinate offsetY) {
|
||||||
|
return (offsetY - 1) / Metric::ParameterCellHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FigureParametersController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FigureParametersController::textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) {
|
||||||
|
return (event == Ion::Events::Down && selectedRow() < numberOfRows()-1)
|
||||||
|
|| (event == Ion::Events::Up && selectedRow() > 0)
|
||||||
|
|| TextFieldDelegate::textFieldShouldFinishEditing(textField, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FigureParametersController::textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) {
|
||||||
|
m_selectableTableView.reloadCellAtLocation(0, selectedRow());
|
||||||
|
m_selectableTableView.reloadData();
|
||||||
|
textField->setText(text);
|
||||||
|
if (event == Ion::Events::EXE || event == Ion::Events::OK) {
|
||||||
|
m_selectableTableView.selectCellAtLocation(selectedColumn(), selectedRow() + 1);
|
||||||
|
} else {
|
||||||
|
m_selectableTableView.handleEvent(event);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
64
apps/geometry/list/figure_parameters_controller.h
Normal file
64
apps/geometry/list/figure_parameters_controller.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#ifndef GEOMETRY_FIGURE_PARAMETERS_CONTROLLER_H
|
||||||
|
#define GEOMETRY_FIGURE_PARAMETERS_CONTROLLER_H
|
||||||
|
|
||||||
|
#include <escher.h>
|
||||||
|
#include "apps/i18n.h"
|
||||||
|
#include "message_table_cell_with_selector.h"
|
||||||
|
#include "../figures/figure.h"
|
||||||
|
#include "../../shared/parameter_text_field_delegate.h"
|
||||||
|
#include "../../shared/input_event_handler_delegate.h"
|
||||||
|
#include "../../shared/button_with_separator.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
typedef int (*NumberOfParametersFunction)();
|
||||||
|
typedef FigureType (*TypeOfParametersAtIndexFunction)(int);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Controller returning the parameter choosen by the user to define the figure
|
||||||
|
*/
|
||||||
|
class FigureParametersController : public ViewController, public ListViewDataSource, public SelectableTableViewDataSource, public Shared::ParameterTextFieldDelegate, public Shared::InputEventHandlerDelegate {
|
||||||
|
public:
|
||||||
|
FigureParametersController(Responder * parentResponder);
|
||||||
|
void setParametersInfoFunctions(NumberOfParametersFunction numberOfParametersFunction, TypeOfParametersAtIndexFunction typeOfParametersAtIndexFunction);
|
||||||
|
void returnToMenu();
|
||||||
|
/* ViewController */
|
||||||
|
const char * title() override { return I18n::translate(I18n::Message::ParametersChoice); }
|
||||||
|
// We want to avoid using half of the screen just for titles
|
||||||
|
virtual DisplayParameter displayParameter() override { return DisplayParameter::DoNotShowOwnTitle; }
|
||||||
|
View * view() override { return &m_selectableTableView; };
|
||||||
|
|
||||||
|
/* Responder */
|
||||||
|
void didBecomeFirstResponder() override;
|
||||||
|
void viewWillAppear() override;
|
||||||
|
|
||||||
|
/* ListViewDataSource */
|
||||||
|
int typeAtLocation(int i, int j) override;
|
||||||
|
int reusableCellCount(int type) override; // TO IMPLEMENT
|
||||||
|
HighlightCell * reusableCell(int index, int type) override;
|
||||||
|
int numberOfRows() const override;
|
||||||
|
KDCoordinate rowHeight(int j) override;
|
||||||
|
KDCoordinate cumulatedHeightFromIndex(int j) override;
|
||||||
|
int indexFromCumulatedHeight(KDCoordinate offsetY) override;
|
||||||
|
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||||
|
|
||||||
|
/* InputEventHandlerDelegate */
|
||||||
|
bool textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) override;
|
||||||
|
bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SelectableTableView m_selectableTableView;
|
||||||
|
constexpr static int k_textCells = 2;
|
||||||
|
constexpr static int k_choiceCells = 3;
|
||||||
|
constexpr static int k_buttonMargin = 6;
|
||||||
|
int m_lastSelectedRow;
|
||||||
|
MessageTableCellWithEditableText m_textCells[k_textCells];
|
||||||
|
MessageTableCellWithSelector m_choicesCells[k_choiceCells];
|
||||||
|
ButtonWithSeparator m_okButton;
|
||||||
|
NumberOfParametersFunction m_numberOfParametersFunction;
|
||||||
|
TypeOfParametersAtIndexFunction m_typeOfParametersAtIndexFunction;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
70
apps/geometry/list/figure_type_controller.cpp
Normal file
70
apps/geometry/list/figure_type_controller.cpp
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#include "figure_type_controller.h"
|
||||||
|
#include "apps/i18n.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
static FigureType sTypes[] = {
|
||||||
|
FigureType::Point,
|
||||||
|
FigureType::Line,
|
||||||
|
FigureType::Circle,
|
||||||
|
FigureType::Vector,
|
||||||
|
FigureType::Indicator
|
||||||
|
};
|
||||||
|
|
||||||
|
static I18n::Message sMessages[] = {
|
||||||
|
I18n::Message::Point,
|
||||||
|
I18n::Message::Line,
|
||||||
|
I18n::Message::Circle,
|
||||||
|
I18n::Message::Vector,
|
||||||
|
I18n::Message::Indicator
|
||||||
|
};
|
||||||
|
|
||||||
|
FigureTypeController::FigureTypeController(Responder * parentResponder, DefinitionTypeController * definitionTypeController) :
|
||||||
|
ViewController(parentResponder),
|
||||||
|
m_lastSelectedRow(0),
|
||||||
|
m_selectableTableView(this),
|
||||||
|
m_definitionTypeController(definitionTypeController),
|
||||||
|
m_messages(sMessages)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < k_numberOfCells; i ++) {
|
||||||
|
m_cells[i].setMessageFont(KDFont::LargeFont);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FigureTypeController::viewWillAppear() {
|
||||||
|
selectRow(m_lastSelectedRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FigureTypeController::didBecomeFirstResponder() {
|
||||||
|
//App::app()->snapshot()->setActivePage(App::Snapshot::Page::Distribution);
|
||||||
|
Container::activeApp()->setFirstResponder(&m_selectableTableView);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FigureTypeController::handleEvent(Ion::Events::Event event) {
|
||||||
|
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
|
||||||
|
m_lastSelectedRow = selectedRow();
|
||||||
|
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||||
|
m_definitionTypeController->setFigureType(sTypes[selectedRow()]);
|
||||||
|
stack->push(m_definitionTypeController);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (event == Ion::Events::Back ) {
|
||||||
|
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||||
|
stack->pop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HighlightCell * FigureTypeController::reusableCell(int index) {
|
||||||
|
assert(index >= 0);
|
||||||
|
assert(index < k_numberOfCells);
|
||||||
|
return &m_cells[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void FigureTypeController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||||
|
MessageTableCellWithChevron * myCell = (MessageTableCellWithChevron *)cell;
|
||||||
|
myCell->setMessage(m_messages[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
49
apps/geometry/list/figure_type_controller.h
Normal file
49
apps/geometry/list/figure_type_controller.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#ifndef GEOMETRY_FIGURE_TYPE_CONTROLLER_H
|
||||||
|
#define GEOMETRY_FIGURE_TYPE_CONTROLLER_H
|
||||||
|
|
||||||
|
#include <escher.h>
|
||||||
|
#include "definition_type_controller.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
/**
|
||||||
|
* \brief FigureTypeController is a controller that is used to select the type of
|
||||||
|
* figure to be created.
|
||||||
|
*/
|
||||||
|
class FigureTypeController : public ViewController, public SimpleListViewDataSource, public SelectableTableViewDataSource {
|
||||||
|
public:
|
||||||
|
FigureTypeController(Responder * parentResponder, DefinitionTypeController * definitionController);
|
||||||
|
|
||||||
|
/* ViewController */
|
||||||
|
View * view() override { return &m_selectableTableView; }
|
||||||
|
// We want to avoid using half of the screen just for titles
|
||||||
|
virtual DisplayParameter displayParameter() override { return DisplayParameter::DoNotShowOwnTitle; }
|
||||||
|
const char * title() override { return I18n::translate(I18n::Message::FigureType); }
|
||||||
|
|
||||||
|
/* Responder */
|
||||||
|
bool handleEvent(Ion::Events::Event event) override;
|
||||||
|
void didBecomeFirstResponder() override;
|
||||||
|
|
||||||
|
/* ViewController */
|
||||||
|
void viewWillAppear() override;
|
||||||
|
TELEMETRY_ID("FigureType");
|
||||||
|
|
||||||
|
/* TableViewDataSource */
|
||||||
|
int numberOfRows() const override { return k_numberOfRows; }
|
||||||
|
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||||
|
KDCoordinate cellHeight() override { return k_cellHeight; }
|
||||||
|
HighlightCell * reusableCell(int index) override;
|
||||||
|
int reusableCellCount() const override { return k_numberOfCells; }
|
||||||
|
private:
|
||||||
|
constexpr static KDCoordinate k_cellHeight = Metric::ParameterCellHeight;
|
||||||
|
constexpr static int k_numberOfCells = 5;
|
||||||
|
constexpr static int k_numberOfRows = 5;
|
||||||
|
int m_lastSelectedRow;
|
||||||
|
MessageTableCellWithChevron m_cells[k_numberOfCells];
|
||||||
|
SelectableTableView m_selectableTableView;
|
||||||
|
DefinitionTypeController * m_definitionTypeController;
|
||||||
|
I18n::Message * m_messages;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
77
apps/geometry/list/figures_controller.cpp
Normal file
77
apps/geometry/list/figures_controller.cpp
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#include "figures_controller.h"
|
||||||
|
#include "definition_type_controller.h"
|
||||||
|
#include <apps/i18n.h>
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
FiguresController::FiguresController(Responder * parentResponder):
|
||||||
|
ViewController(parentResponder),
|
||||||
|
m_selectableTableView(this, this, this, this),
|
||||||
|
m_addFigureCell(),
|
||||||
|
m_emptyCell(),
|
||||||
|
m_figureTypeController(this, &m_definitionTypeController),
|
||||||
|
m_definitionTypeController(&m_figureTypeController, &m_parametersController),
|
||||||
|
m_parametersController(&m_definitionTypeController)
|
||||||
|
{
|
||||||
|
m_addFigureCell.setMessage(I18n::Message::AddFigure);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FiguresController::handleEvent(Ion::Events::Event event) {
|
||||||
|
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||||
|
if (isAddFigureRow(selectedRow())) {
|
||||||
|
StackViewController * stack = static_cast<StackViewController *>(parentResponder());
|
||||||
|
stack->push(&m_figureTypeController);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (event == Ion::Events::Up && selectedRow() == 0) {
|
||||||
|
m_selectableTableView.deselectTable();
|
||||||
|
assert(selectedRow() == -1);
|
||||||
|
Container::activeApp()->setFirstResponder(parentResponder()->parentResponder());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FiguresController::didBecomeFirstResponder() {
|
||||||
|
Container::activeApp()->setFirstResponder(&m_selectableTableView);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HighlightCell * FiguresController::reusableCell(int index, int type) {
|
||||||
|
assert(index >= 0);
|
||||||
|
if (type == 2) {
|
||||||
|
return &m_emptyCell;
|
||||||
|
}
|
||||||
|
return &m_addFigureCell;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FiguresController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
|
||||||
|
if (i == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EvenOddCell * myCell = (EvenOddCell *)cell;
|
||||||
|
myCell->setEven(j%2 == 0);
|
||||||
|
myCell->setHighlighted(i == selectedColumn() && j == selectedRow());
|
||||||
|
myCell->reloadCell();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FiguresController::isAddFigureRow(int j) {
|
||||||
|
return j == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FiguresController::reusableCellCount(int type) {
|
||||||
|
if (type > 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FiguresController::typeAtLocation(int i, int j) {
|
||||||
|
if (isAddFigureRow(j)) {
|
||||||
|
return i + 2;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
47
apps/geometry/list/figures_controller.h
Normal file
47
apps/geometry/list/figures_controller.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#ifndef FIGURES_CONTROLLER_H
|
||||||
|
#define FIGURES_CONTROLLER_H
|
||||||
|
|
||||||
|
#include <escher.h>
|
||||||
|
#include "figure_type_controller.h"
|
||||||
|
|
||||||
|
namespace Geometry
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* \brief FiguresController is a controller to show the list of the figures
|
||||||
|
*/
|
||||||
|
class FiguresController : public ViewController, public SelectableTableViewDataSource, public SelectableTableViewDelegate, public TableViewDataSource {
|
||||||
|
public:
|
||||||
|
FiguresController(Responder * parentResponder);
|
||||||
|
|
||||||
|
/* ViewController */
|
||||||
|
View * view() override { return &m_selectableTableView; }
|
||||||
|
const char * title() override { return I18n::translate(I18n::Message::FiguresTab); }
|
||||||
|
virtual DisplayParameter displayParameter() override { return DisplayParameter::DoNotShowOwnTitle; }
|
||||||
|
/* Responder */
|
||||||
|
bool handleEvent(Ion::Events::Event event) override; // TO IMPLEMENT
|
||||||
|
void didBecomeFirstResponder() override;
|
||||||
|
|
||||||
|
/* TableView */
|
||||||
|
int numberOfRows() const override { return 1; } // TO IMPLEMENT
|
||||||
|
int numberOfColumns() const override { return 2; } // TO IMPLEMENT
|
||||||
|
KDCoordinate columnWidth(int i) { return i == 0 ? 50 : 150; } // TO IMPLEMENT
|
||||||
|
KDCoordinate rowHeight(int j) { return 50; } // TO IMPLEMENT
|
||||||
|
HighlightCell * reusableCell(int index, int type); // TO IMPLEMENT
|
||||||
|
void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; // TO IMPLEMENT
|
||||||
|
int reusableCellCount(int type);
|
||||||
|
int typeAtLocation(int i, int j); // TO IMPLEMENT
|
||||||
|
|
||||||
|
private:
|
||||||
|
/* Customs methods */
|
||||||
|
bool isAddFigureRow(int j); // TO IMPLEMENT
|
||||||
|
|
||||||
|
SelectableTableView m_selectableTableView;
|
||||||
|
EvenOddMessageTextCell m_addFigureCell;
|
||||||
|
EvenOddCell m_emptyCell;
|
||||||
|
FigureTypeController m_figureTypeController;
|
||||||
|
DefinitionTypeController m_definitionTypeController;
|
||||||
|
FigureParametersController m_parametersController;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
24
apps/geometry/list/message_table_cell_with_selector.cpp
Normal file
24
apps/geometry/list/message_table_cell_with_selector.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include "message_table_cell_with_selector.h"
|
||||||
|
#include <escher/container.h>
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
MessageTableCellWithSelector::MessageTableCellWithSelector(ToolboxMessageTree * root, const KDFont * font) :
|
||||||
|
Responder(nullptr),
|
||||||
|
MessageTableCell((I18n::Message)0, font),
|
||||||
|
m_objectsRoot(root),
|
||||||
|
m_selectedMessage(nullptr),
|
||||||
|
m_toolbox(this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MessageTableCellWithSelector::handleEvent(Ion::Events::Event event) {
|
||||||
|
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||||
|
Container::activeApp()->displayModalViewController(&m_toolbox, 0.f, 0.f, Metric::PopUpTopMargin, Metric::PopUpLeftMargin, 0, Metric::PopUpRightMargin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
26
apps/geometry/list/message_table_cell_with_selector.h
Normal file
26
apps/geometry/list/message_table_cell_with_selector.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef ESHER_MESSAGE_TABLE_CELL_WITH_OBJECT_SELECTOR_H_
|
||||||
|
#define ESHER_MESSAGE_TABLE_CELL_WITH_OBJECT_SELECTOR_H_
|
||||||
|
|
||||||
|
#include <escher/message_table_cell_with_buffer.h>
|
||||||
|
#include <escher/toolbox_message_tree.h>
|
||||||
|
#include "objects_controller.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
class MessageTableCellWithSelector : public Responder, public MessageTableCell {
|
||||||
|
public:
|
||||||
|
MessageTableCellWithSelector(ToolboxMessageTree * root = nullptr, const KDFont * font = KDFont::SmallFont);
|
||||||
|
ToolboxMessageTree * getSelectedMessage() const { return m_selectedMessage; };
|
||||||
|
bool handleEvent(Ion::Events::Event event);
|
||||||
|
Responder * responder() override {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
ToolboxMessageTree * m_objectsRoot;
|
||||||
|
ToolboxMessageTree * m_selectedMessage;
|
||||||
|
ObjectsController m_toolbox;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
35
apps/geometry/list/objects_controller.cpp
Normal file
35
apps/geometry/list/objects_controller.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "objects_controller.h"
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
ObjectsController::ObjectsController(Responder * responder) :
|
||||||
|
NestedMenuController(this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObjectsController::numberOfRows() const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObjectsController::reusableCellCount(int type) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObjectsController::typeAtLocation(int i, int j) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ObjectsController::selectLeaf(int type) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HighlightCell * ObjectsController::leafCellAtIndex(int index) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
HighlightCell * ObjectsController::nodeCellAtIndex(int index) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
21
apps/geometry/list/objects_controller.h
Normal file
21
apps/geometry/list/objects_controller.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef GEOMETRY_OBJECTS_CONTROLLER_H
|
||||||
|
#define GEOMETRY_OBJECTS_CONTROLLER_H
|
||||||
|
|
||||||
|
#include <escher/nested_menu_controller.h>
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
class ObjectsController : public NestedMenuController {
|
||||||
|
public:
|
||||||
|
ObjectsController(Responder * parentResponder);
|
||||||
|
virtual int numberOfRows() const override;
|
||||||
|
virtual int reusableCellCount(int type) override;
|
||||||
|
virtual int typeAtLocation(int i, int j) override;
|
||||||
|
virtual bool selectLeaf(int selectedRow) override;
|
||||||
|
virtual HighlightCell * leafCellAtIndex(int index) override;
|
||||||
|
virtual HighlightCell * nodeCellAtIndex(int index) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
16
apps/geometry/other/other_view_controller.h
Normal file
16
apps/geometry/other/other_view_controller.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef OTHER_VIEW_CONTROLLER_H
|
||||||
|
#define OTHER_VIEW_CONTROLLER_H
|
||||||
|
|
||||||
|
namespace Geometry {
|
||||||
|
|
||||||
|
class OtherViewController : public ViewController {
|
||||||
|
public:
|
||||||
|
OtherViewController(Responder * parentResponder):
|
||||||
|
ViewController(parentResponder) {}
|
||||||
|
View * view() override { return nullptr; }
|
||||||
|
const char * title() override { return I18n::translate(I18n::Message::OtherTab); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
Default,calculation,rpn,graph,code,statistics,probability,solver,atomic,sequence,regression,reader,settings
|
Default,geometry,calculation,rpn,graph,code,statistics,probability,solver,atomic,sequence,regression,reader,settings
|
||||||
HidePython,calculation,rpn,graph,code,statistics,probability,solver,atomic,sequence,regression,reader,settings
|
HidePython,geometry,calculation,rpn,graph,code,statistics,probability,solver,atomic,sequence,regression,reader,settings
|
||||||
|
|||||||
|
@@ -15,7 +15,8 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
|||||||
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
|
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
|
||||||
#ifdef HAS_CODE
|
#ifdef HAS_CODE
|
||||||
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
|
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
|
||||||
#endif SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren),
|
#endif
|
||||||
|
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren),
|
||||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
|
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
|
||||||
|
|
||||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);
|
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ EPSILON_VERSION ?= 15.5.0
|
|||||||
OMEGA_VERSION ?= 1.22.1
|
OMEGA_VERSION ?= 1.22.1
|
||||||
# OMEGA_USERNAME ?= N/A
|
# OMEGA_USERNAME ?= N/A
|
||||||
OMEGA_STATE ?= public
|
OMEGA_STATE ?= public
|
||||||
EPSILON_APPS ?= calculation rpn graph code statistics probability solver atomic sequence regression reader settings external
|
EPSILON_APPS ?= geometry calculation rpn graph code statistics probability solver atomic sequence regression reader settings external
|
||||||
SUBMODULES_APPS = atomic rpn
|
SUBMODULES_APPS = atomic rpn
|
||||||
EPSILON_I18N ?= en fr nl pt it de es hu
|
EPSILON_I18N ?= en fr nl pt it de es hu
|
||||||
EPSILON_COUNTRIES ?= WW CA DE ES FR GB IT NL PT US
|
EPSILON_COUNTRIES ?= WW CA DE ES FR GB IT NL PT US
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public:
|
|||||||
virtual void scrollToCell(int i, int j);
|
virtual void scrollToCell(int i, int j);
|
||||||
HighlightCell * cellAtLocation(int i, int j);
|
HighlightCell * cellAtLocation(int i, int j);
|
||||||
void reloadCellAtLocation(int i, int j);
|
void reloadCellAtLocation(int i, int j);
|
||||||
|
void reloadVisibleCells();
|
||||||
protected:
|
protected:
|
||||||
#if ESCHER_VIEW_LOGGING
|
#if ESCHER_VIEW_LOGGING
|
||||||
const char * className() const override;
|
const char * className() const override;
|
||||||
@@ -34,6 +35,7 @@ protected:
|
|||||||
void setHorizontalCellOverlap(KDCoordinate o) { m_horizontalCellOverlap = o; }
|
void setHorizontalCellOverlap(KDCoordinate o) { m_horizontalCellOverlap = o; }
|
||||||
void setVerticalCellOverlap(KDCoordinate o) { m_verticalCellOverlap = o; }
|
void setVerticalCellOverlap(KDCoordinate o) { m_verticalCellOverlap = o; }
|
||||||
|
|
||||||
|
void reloadVisibleCells();
|
||||||
void reloadCellAtLocation(int i, int j);
|
void reloadCellAtLocation(int i, int j);
|
||||||
HighlightCell * cellAtLocation(int i, int j);
|
HighlightCell * cellAtLocation(int i, int j);
|
||||||
TableViewDataSource * dataSource();
|
TableViewDataSource * dataSource();
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
#include <poincare/tree_handle.h>
|
#include <poincare/tree_handle.h>
|
||||||
#include <poincare_nodes.h>
|
#include <poincare_nodes.h>
|
||||||
|
#include <apps/geometry/figures/figures.h>
|
||||||
#include <poincare_layouts.h>
|
#include <poincare_layouts.h>
|
||||||
#include <poincare/ghost.h>
|
#include <poincare/ghost.h>
|
||||||
|
|
||||||
|
using namespace Geometry;
|
||||||
|
|
||||||
namespace Poincare {
|
namespace Poincare {
|
||||||
|
|
||||||
/* Clone */
|
/* Clone */
|
||||||
@@ -377,4 +380,7 @@ template VectorNorm TreeHandle::FixedArityBuilder<VectorNorm, VectorNormNode>(co
|
|||||||
template VectorNormLayout TreeHandle::FixedArityBuilder<VectorNormLayout, VectorNormLayoutNode>(const Tuple &);
|
template VectorNormLayout TreeHandle::FixedArityBuilder<VectorNormLayout, VectorNormLayoutNode>(const Tuple &);
|
||||||
template MatrixLayout TreeHandle::NAryBuilder<MatrixLayout, MatrixLayoutNode>(const Tuple &);
|
template MatrixLayout TreeHandle::NAryBuilder<MatrixLayout, MatrixLayoutNode>(const Tuple &);
|
||||||
|
|
||||||
|
// Geometry templates
|
||||||
|
template PointByCoordinates TreeHandle::FixedArityBuilder<PointByCoordinates, PointByCoordinatesNode>(const Tuple &);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
"apps/calculation/calculation_icon.png" : "apps/calculation_icon.png",
|
"apps/calculation/calculation_icon.png" : "apps/calculation_icon.png",
|
||||||
"apps/code/code_icon.png" : "apps/code_icon.png",
|
"apps/code/code_icon.png" : "apps/code_icon.png",
|
||||||
"apps/external/external_icon.png" : "apps/external_icon.png",
|
"apps/external/external_icon.png" : "apps/external_icon.png",
|
||||||
|
"apps/geometry/geometry_icon.png" : "apps/geometry_icon.png",
|
||||||
"apps/graph/graph_icon.png" : "apps/graph_icon.png",
|
"apps/graph/graph_icon.png" : "apps/graph_icon.png",
|
||||||
"apps/probability/probability_icon.png" : "apps/probability_icon.png",
|
"apps/probability/probability_icon.png" : "apps/probability_icon.png",
|
||||||
"apps/regression/regression_icon.png" : "apps/regression_icon.png",
|
"apps/regression/regression_icon.png" : "apps/regression_icon.png",
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user