mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-29 03:29:58 +02:00
[poincare] ExpressionLayoutArray was a method, it is now a class.
Change-Id: Iddde7ed9d8a8539193c6547a9e718865ff8e8cc7
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "math_toolbox.h"
|
||||
#include "./shared/toolbox_helpers.h"
|
||||
#include <poincare/expression_layout_array.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -17,9 +18,9 @@ const ToolboxMessageTree calculChildren[4] = {
|
||||
ToolboxMessageTree(I18n::Message::IntCommandWithArg, I18n::Message::Integral, I18n::Message::IntCommandWithArg, nullptr, 0,
|
||||
new IntegralLayout(
|
||||
new HorizontalLayout(
|
||||
const_cast<Poincare::ExpressionLayout**>(Poincare::ExpressionLayout::ExpressionLayoutArray2(
|
||||
Poincare::ExpressionLayoutArray(
|
||||
new EmptyVisibleLayout(),
|
||||
new StringLayout("dx",2))), 2, false),
|
||||
new StringLayout("dx",2)).array(), 2, false),
|
||||
new EmptyVisibleLayout(),
|
||||
new EmptyVisibleLayout(),
|
||||
false),
|
||||
@@ -27,10 +28,10 @@ const ToolboxMessageTree calculChildren[4] = {
|
||||
2),
|
||||
ToolboxMessageTree(I18n::Message::SumCommandWithArg, I18n::Message::Sum, I18n::Message::SumCommandWithArg, nullptr, 0,
|
||||
new SumLayout(
|
||||
new HorizontalLayout(const_cast<Poincare::ExpressionLayout**>(Poincare::ExpressionLayout::ExpressionLayoutArray2(
|
||||
new StringLayout("n=",2),
|
||||
new EmptyVisibleLayout())), 2, false),
|
||||
new EmptyVisibleLayout(),
|
||||
new HorizontalLayout(Poincare::ExpressionLayoutArray(
|
||||
new StringLayout("n=",2),
|
||||
new EmptyVisibleLayout()).array(), 2, false),
|
||||
new EmptyVisibleLayout(),
|
||||
false),
|
||||
const_cast<int *>(&pointedLayoutPathSum[0]),
|
||||
@@ -54,9 +55,9 @@ const ToolboxMessageTree probabilityChildren[2] = {
|
||||
ToolboxMessageTree(I18n::Message::BinomialCommandWithArg, I18n::Message::Combination, I18n::Message::BinomialCommandWithArg, nullptr, 0,
|
||||
new UneditableHorizontalTrioLayout(
|
||||
new ParenthesisLeftLayout(),
|
||||
new GridLayout(const_cast<Poincare::ExpressionLayout**>(Poincare::ExpressionLayout::ExpressionLayoutArray2(
|
||||
new GridLayout(Poincare::ExpressionLayoutArray(
|
||||
new EmptyVisibleLayout(),
|
||||
new EmptyVisibleLayout())),
|
||||
new EmptyVisibleLayout()).array(),
|
||||
2, 1, false),
|
||||
new ParenthesisRightLayout(), false, true),
|
||||
const_cast<int *>(&pointedLayoutPathBinomial[0]),
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <poincare/division_remainder.h>
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/expression_layout.h>
|
||||
#include <poincare/expression_layout_array.h>
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
#include <poincare/factorial.h>
|
||||
#include <poincare/floor.h>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define POINCARE_DYNAMIC_LAYOUT_HIERARCHY_H
|
||||
|
||||
#include <poincare/expression_layout.h>
|
||||
#include <poincare/expression_layout_array.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -10,7 +11,7 @@ public:
|
||||
DynamicLayoutHierarchy();
|
||||
DynamicLayoutHierarchy(const ExpressionLayout * const * operands, int numberOfOperands, bool cloneOperands = true);
|
||||
DynamicLayoutHierarchy(const ExpressionLayout * operand1, const ExpressionLayout * operand2, bool cloneOperands = true) :
|
||||
DynamicLayoutHierarchy(ExpressionLayoutArray2(operand1, operand2), 2, cloneOperands) {}
|
||||
DynamicLayoutHierarchy(ExpressionLayoutArray(operand1, operand2).array(), 2, cloneOperands) {}
|
||||
~DynamicLayoutHierarchy();
|
||||
DynamicLayoutHierarchy(const DynamicLayoutHierarchy & other) = delete;
|
||||
DynamicLayoutHierarchy(DynamicLayoutHierarchy && other) = delete;
|
||||
|
||||
@@ -21,8 +21,6 @@ public:
|
||||
/* Constructor & Destructor */
|
||||
ExpressionLayout();
|
||||
virtual ~ExpressionLayout() = default;
|
||||
static const ExpressionLayout * const * ExpressionLayoutArray2(const ExpressionLayout * e1, const ExpressionLayout * e2);
|
||||
static const ExpressionLayout * const * ExpressionLayoutArray3(const ExpressionLayout * e1, const ExpressionLayout * e2, const ExpressionLayout * e3);
|
||||
virtual ExpressionLayout * clone() const = 0;
|
||||
|
||||
/* Rendering */
|
||||
|
||||
20
poincare/include/poincare/expression_layout_array.h
Normal file
20
poincare/include/poincare/expression_layout_array.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef POINCARE_EXPRESSION_LAYOUT_ARRAY_H
|
||||
#define POINCARE_EXPRESSION_LAYOUT_ARRAY_H
|
||||
|
||||
#include <poincare/expression_layout.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class ExpressionLayoutArray {
|
||||
public:
|
||||
ExpressionLayoutArray(const ExpressionLayout * eL1 = nullptr, const ExpressionLayout * eL2 = nullptr, const ExpressionLayout * eL3 = nullptr) :
|
||||
m_data{eL1, eL2, eL3}
|
||||
{}
|
||||
const ExpressionLayout * const * array() { return const_cast<const ExpressionLayout * const *>(m_data); }
|
||||
private:
|
||||
const ExpressionLayout * m_data[3];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,21 +18,6 @@ ExpressionLayout::ExpressionLayout() :
|
||||
{
|
||||
}
|
||||
|
||||
const ExpressionLayout * const * ExpressionLayout::ExpressionLayoutArray2(const ExpressionLayout * e1, const ExpressionLayout * e2) {
|
||||
static const ExpressionLayout * result[2] = {nullptr, nullptr};
|
||||
result[0] = e1;
|
||||
result[1] = e2;
|
||||
return result;
|
||||
}
|
||||
|
||||
const ExpressionLayout * const * ExpressionLayout::ExpressionLayoutArray3(const ExpressionLayout * e1, const ExpressionLayout * e2, const ExpressionLayout * e3) {
|
||||
static const ExpressionLayout * result[3] = {nullptr, nullptr, nullptr};
|
||||
result[0] = e1;
|
||||
result[1] = e2;
|
||||
result[2] = e3;
|
||||
return result;
|
||||
}
|
||||
|
||||
KDPoint ExpressionLayout::origin() {
|
||||
if (m_parent == nullptr) {
|
||||
return absoluteOrigin();
|
||||
|
||||
@@ -9,7 +9,7 @@ extern "C" {
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
GridLayout::GridLayout(ExpressionLayout ** entryLayouts, int numberOfRows, int numberOfColumns, bool cloneOperands) :
|
||||
GridLayout::GridLayout(const ExpressionLayout * const * entryLayouts, int numberOfRows, int numberOfColumns, bool cloneOperands) :
|
||||
DynamicLayoutHierarchy(entryLayouts, numberOfRows*numberOfColumns, cloneOperands),
|
||||
m_numberOfRows(numberOfRows),
|
||||
m_numberOfColumns(numberOfColumns)
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Poincare {
|
||||
|
||||
class GridLayout : public DynamicLayoutHierarchy {
|
||||
public:
|
||||
GridLayout(ExpressionLayout ** entryLayouts, int numberOfRows, int numberOfColumns, bool cloneOperands);
|
||||
GridLayout(const ExpressionLayout * const * entryLayouts, int numberOfRows, int numberOfColumns, bool cloneOperands);
|
||||
ExpressionLayout * clone() const override;
|
||||
void backspaceAtCursor(ExpressionLayoutCursor * cursor) override;
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "parenthesis_layout.h"
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
#include "parenthesis_left_layout.h"
|
||||
#include "parenthesis_right_layout.h"
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
#include <poincare/expression_layout_array.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
@@ -14,7 +15,7 @@ ParenthesisLayout::ParenthesisLayout(ExpressionLayout * operand, bool cloneOpera
|
||||
{
|
||||
ExpressionLayout * leftParenthesis = new ParenthesisLeftLayout();
|
||||
ExpressionLayout * rightParenthesis = new ParenthesisRightLayout();
|
||||
build(ExpressionLayout::ExpressionLayoutArray3(leftParenthesis, operand, rightParenthesis), 3, cloneOperands);
|
||||
build(ExpressionLayoutArray(leftParenthesis, operand, rightParenthesis).array(), 3, cloneOperands);
|
||||
}
|
||||
|
||||
ExpressionLayout * ParenthesisLayout::clone() const {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "parenthesis_right_layout.h"
|
||||
#include "uneditable_horizontal_trio_layout.h"
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
#include <poincare/expression_layout_array.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -14,7 +15,7 @@ SequenceLayout::SequenceLayout(ExpressionLayout * lowerBound, ExpressionLayout *
|
||||
ParenthesisLeftLayout * parLeft = new ParenthesisLeftLayout();
|
||||
ParenthesisRightLayout * parRight = new ParenthesisRightLayout();
|
||||
UneditableHorizontalTrioLayout * horLayout = new UneditableHorizontalTrioLayout(parLeft, argument, parRight, cloneOperands, false);
|
||||
build(const_cast<Poincare::ExpressionLayout**>(Poincare::ExpressionLayout::ExpressionLayoutArray3(horLayout, lowerBound, upperBound)), 3, cloneOperands);
|
||||
build(ExpressionLayoutArray(horLayout, lowerBound, upperBound).array(), 3, cloneOperands);
|
||||
}
|
||||
|
||||
void SequenceLayout::backspaceAtCursor(ExpressionLayoutCursor * cursor) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <poincare/static_layout_hierarchy.h>
|
||||
#include <poincare/expression_layout_array.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
@@ -27,13 +28,13 @@ StaticLayoutHierarchy<1>::StaticLayoutHierarchy(const ExpressionLayout * e, bool
|
||||
|
||||
template<>
|
||||
StaticLayoutHierarchy<2>::StaticLayoutHierarchy(const ExpressionLayout * e1, const ExpressionLayout * e2, bool cloneChildren) :
|
||||
StaticLayoutHierarchy(ExpressionLayoutArray2(e1, e2), cloneChildren)
|
||||
StaticLayoutHierarchy(ExpressionLayoutArray(e1, e2).array(), cloneChildren)
|
||||
{
|
||||
}
|
||||
|
||||
template<>
|
||||
StaticLayoutHierarchy<3>::StaticLayoutHierarchy(const ExpressionLayout * e1, const ExpressionLayout * e2, const ExpressionLayout * e3, bool cloneChildren) :
|
||||
StaticLayoutHierarchy(ExpressionLayoutArray3(e1, e2, e3), cloneChildren)
|
||||
StaticLayoutHierarchy(ExpressionLayoutArray(e1, e2, e3).array(), cloneChildren)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user