[poincare] Change names: LayoutReference-->Layout

This commit is contained in:
Émilie Feral
2018-09-18 16:28:39 +02:00
parent f5298650a7
commit 365b145cf3
277 changed files with 1654 additions and 1671 deletions

View File

@@ -42,14 +42,14 @@ void Calculation::setContent(const char * c, Context * context, Expression ansEx
KDCoordinate Calculation::height(Context * context) {
if (m_height < 0) {
LayoutReference inputLayout = createInputLayout();
Layout inputLayout = createInputLayout();
KDCoordinate inputHeight = inputLayout.layoutSize().height();
LayoutReference approximateLayout = createApproximateOutputLayout(context);
Layout approximateLayout = createApproximateOutputLayout(context);
KDCoordinate approximateOutputHeight = approximateLayout.layoutSize().height();
if (shouldOnlyDisplayApproximateOutput(context)) {
m_height = inputHeight+approximateOutputHeight;
} else {
LayoutReference exactLayout = createExactOutputLayout(context);
Layout exactLayout = createExactOutputLayout(context);
KDCoordinate exactOutputHeight = exactLayout.layoutSize().height();
KDCoordinate outputHeight = max(exactLayout.baseline(), approximateLayout.baseline()) + max(exactOutputHeight-exactLayout.baseline(), approximateOutputHeight-approximateLayout.baseline());
m_height = inputHeight + outputHeight;
@@ -77,7 +77,7 @@ Expression Calculation::input() {
return m_input;
}
LayoutReference Calculation::createInputLayout() {
Layout Calculation::createInputLayout() {
return input().createLayout(Preferences::PrintFloatMode::Decimal, PrintFloat::k_numberOfStoredSignificantDigits);
}
@@ -118,7 +118,7 @@ Expression Calculation::exactOutput(Context * context) {
return m_exactOutput;
}
LayoutReference Calculation::createExactOutputLayout(Context * context) {
Layout Calculation::createExactOutputLayout(Context * context) {
return PoincareHelpers::CreateLayout(exactOutput(context));
}
@@ -132,7 +132,7 @@ Expression Calculation::approximateOutput(Context * context) {
return m_approximateOutput;
}
LayoutReference Calculation::createApproximateOutputLayout(Context * context) {
Layout Calculation::createApproximateOutputLayout(Context * context) {
return PoincareHelpers::CreateLayout(approximateOutput(context));
}

View File

@@ -24,11 +24,11 @@ public:
const char * exactOutputText();
const char * approximateOutputText();
Poincare::Expression input();
Poincare::LayoutReference createInputLayout();
Poincare::Layout createInputLayout();
Poincare::Expression approximateOutput(Poincare::Context * context);
Poincare::Expression exactOutput(Poincare::Context * context);
Poincare::LayoutReference createExactOutputLayout(Poincare::Context * context);
Poincare::LayoutReference createApproximateOutputLayout(Poincare::Context * context);
Poincare::Layout createExactOutputLayout(Poincare::Context * context);
Poincare::Layout createApproximateOutputLayout(Poincare::Context * context);
bool isEmpty();
void tidy();
bool shouldOnlyDisplayApproximateOutput(Poincare::Context * context);

View File

@@ -99,7 +99,7 @@ bool EditExpressionController::layoutFieldDidReceiveEvent(::LayoutField * layout
return expressionFieldDelegateApp()->layoutFieldDidReceiveEvent(layoutField, event);
}
bool EditExpressionController::layoutFieldDidFinishEditing(::LayoutField * layoutField, LayoutReference layoutR, Ion::Events::Event event) {
bool EditExpressionController::layoutFieldDidFinishEditing(::LayoutField * layoutField, Layout layoutR, Ion::Events::Event event) {
return inputViewDidFinishEditing(nullptr, layoutR);
}
@@ -149,7 +149,7 @@ bool EditExpressionController::inputViewDidReceiveEvent(Ion::Events::Event event
}
bool EditExpressionController::inputViewDidFinishEditing(const char * text, LayoutReference layoutR) {
bool EditExpressionController::inputViewDidFinishEditing(const char * text, Layout layoutR) {
App * calculationApp = (App *)app();
if (layoutR.isUninitialized()) {
assert(text);

View File

@@ -2,7 +2,7 @@
#define CALCULATION_EDIT_EXPRESSION_CONTROLLER_H
#include <escher.h>
#include <poincare/layout_reference.h>
#include <poincare/layout.h>
#include "expression_field.h"
#include "../shared/text_field_delegate.h"
#include "../shared/layout_field_delegate.h"
@@ -29,7 +29,7 @@ public:
/* LayoutFieldDelegate */
bool layoutFieldDidReceiveEvent(::LayoutField * layoutField, Ion::Events::Event event) override;
bool layoutFieldDidFinishEditing(::LayoutField * layoutField, Poincare::LayoutReference layoutR, Ion::Events::Event event) override;
bool layoutFieldDidFinishEditing(::LayoutField * layoutField, Poincare::Layout layoutR, Ion::Events::Event event) override;
bool layoutFieldDidAbortEditing(::LayoutField * layoutField) override;
void layoutFieldDidChangeSize(::LayoutField * layoutField) override;
@@ -52,7 +52,7 @@ private:
};
void reloadView();
bool inputViewDidReceiveEvent(Ion::Events::Event event);
bool inputViewDidFinishEditing(const char * text, Poincare::LayoutReference layoutR);
bool inputViewDidFinishEditing(const char * text, Poincare::Layout layoutR);
bool inputViewDidAbortEditing(const char * text);
Shared::TextFieldDelegateApp * textFieldDelegateApp() override;
Shared::ExpressionFieldDelegateApp * expressionFieldDelegateApp() override;

View File

@@ -42,11 +42,11 @@ void HistoryViewCell::setHighlighted(bool highlight) {
reloadScroll();
}
Poincare::LayoutReference HistoryViewCell::layoutRef() const {
Poincare::Layout HistoryViewCell::layout() const {
if (m_selectedSubviewType == SubviewType::Input) {
return m_inputLayout;
} else {
return m_scrollableOutputView.layoutRef();
return m_scrollableOutputView.layout();
}
}
@@ -95,13 +95,13 @@ void HistoryViewCell::layoutSubviews() {
void HistoryViewCell::setCalculation(Calculation * calculation) {
m_inputLayout = calculation->createInputLayout();
m_inputView.setLayoutReference(m_inputLayout);
m_inputView.setLayout(m_inputLayout);
App * calculationApp = (App *)app();
/* Both output expressions have to be updated at the same time. Otherwise,
* when updating one layout, if the second one still points to a deleted
* layout, calling to layoutSubviews() would fail. */
if (!m_exactOutputLayout.isUninitialized()) {
m_exactOutputLayout = Poincare::LayoutReference();
m_exactOutputLayout = Poincare::Layout();
}
if (!calculation->shouldOnlyDisplayApproximateOutput(calculationApp->localContext())) {
m_exactOutputLayout = calculation->createExactOutputLayout(calculationApp->localContext());

View File

@@ -22,7 +22,7 @@ public:
Responder * responder() override {
return this;
}
Poincare::LayoutReference layoutRef() const override;
Poincare::Layout layout() const override;
KDColor backgroundColor() const override;
void setCalculation(Calculation * calculation);
int numberOfSubviews() const override;
@@ -36,9 +36,9 @@ public:
Shared::ScrollableExactApproximateExpressionsView * outputView();
private:
constexpr static KDCoordinate k_resultWidth = 80;
Poincare::LayoutReference m_inputLayout;
Poincare::LayoutReference m_exactOutputLayout;
Poincare::LayoutReference m_approximateOutputLayout;
Poincare::Layout m_inputLayout;
Poincare::Layout m_exactOutputLayout;
Poincare::Layout m_approximateOutputLayout;
ScrollableExpressionView m_inputView;
Shared::ScrollableExactApproximateExpressionsView m_scrollableOutputView;
SubviewType m_selectedSubviewType;

View File

@@ -10,8 +10,8 @@ ScrollableExpressionView::ScrollableExpressionView(Responder * parentResponder)
{
}
void ScrollableExpressionView::setLayoutReference(LayoutReference layoutRef) {
m_expressionView.setLayoutReference(layoutRef);
void ScrollableExpressionView::setLayout(Layout layout) {
m_expressionView.setLayout(layout);
layoutSubviews();
}

View File

@@ -8,7 +8,7 @@ namespace Calculation {
class ScrollableExpressionView : public ScrollableView, public ScrollViewDataSource {
public:
ScrollableExpressionView(Responder * parentResponder);
void setLayoutReference(Poincare::LayoutReference layoutRef);
void setLayout(Poincare::Layout layout);
void setBackgroundColor(KDColor backgroundColor) override;
KDSize minimalSizeForOptimalDisplay() const override;
private:

View File

@@ -36,7 +36,7 @@ double IntegralGraphController::cursorNextStep(double x, int direction) {
return (direction > 0 ? x + m_graphRange->xGridUnit()/k_numberOfCursorStepsInGradUnit : x - m_graphRange->xGridUnit()/k_numberOfCursorStepsInGradUnit);
}
LayoutReference IntegralGraphController::createFunctionLayout(const char * functionName) {
Layout IntegralGraphController::createFunctionLayout(const char * functionName) {
char buffer[7] = "0(x)dx";
buffer[0] = functionName[0];
return LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small);

View File

@@ -14,7 +14,7 @@ public:
private:
I18n::Message legendMessageAtStep(Step step) override;
double cursorNextStep(double position, int direction) override;
Poincare::LayoutReference createFunctionLayout(const char * functionName) override;
Poincare::Layout createFunctionLayout(const char * functionName) override;
};
}

View File

@@ -25,7 +25,7 @@ CalculationController::CalculationController(Responder * parentResponder, Button
m_hideableCell(),
m_store(store)
{
m_r2Layout = HorizontalLayoutReference(CharLayoutReference('r', KDText::FontSize::Small), VerticalOffsetLayoutReference(CharLayoutReference('2', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Superscript));
m_r2Layout = HorizontalLayout(CharLayout('r', KDText::FontSize::Small), VerticalOffsetLayout(CharLayout('2', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Superscript));
m_selectableTableView.setVerticalCellOverlap(0);
m_selectableTableView.setBackgroundColor(Palette::WallScreenDark);
m_selectableTableView.setMargins(k_margin, k_scrollBarMargin, k_scrollBarMargin, k_margin);
@@ -125,7 +125,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
int numberRows = numberOfRows();
if (shouldDisplayRAndR2 && j == numberRows-1) {
EvenOddExpressionCell * myCell = (EvenOddExpressionCell *)cell;
myCell->setLayoutReference(m_r2Layout);
myCell->setLayout(m_r2Layout);
return;
}
MarginEvenOddMessageTextCell * myCell = (MarginEvenOddMessageTextCell *)cell;

View File

@@ -69,7 +69,7 @@ private:
SelectableTableView * selectableTableView() override { return &m_selectableTableView; }
bool hasLinearRegression() const;
int maxNumberOfCoefficients() const;
Poincare::LayoutReference m_r2Layout;
Poincare::Layout m_r2Layout;
SelectableTableView m_selectableTableView;
Shared::MarginEvenOddMessageTextCell m_titleCells[k_maxNumberOfDisplayableRows];
EvenOddExpressionCell m_r2TitleCell;

View File

@@ -116,7 +116,7 @@ int GraphOptionsController::typeAtLocation(int i, int j) {
void GraphOptionsController::willDisplayCellForIndex(HighlightCell * cell, int index) {
if (index == numberOfRows() - 1) {
m_changeRegressionCell.setLayoutReference(static_cast<Store *>(m_store)->modelForSeries(m_graphController->selectedSeriesIndex())->layout());
m_changeRegressionCell.setLayout(static_cast<Store *>(m_store)->modelForSeries(m_graphController->selectedSeriesIndex())->layout());
return;
}
assert(index >=0 && index < k_numberOfParameterCells);

View File

@@ -8,32 +8,32 @@ using namespace Shared;
namespace Regression {
LayoutReference CubicModel::layout() {
Layout CubicModel::layout() {
if (m_layout.isUninitialized()) {
const LayoutReference layoutChildren[] = {
CharLayoutReference('a', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
VerticalOffsetLayoutReference(
CharLayoutReference('3', KDText::FontSize::Small),
const Layout layoutChildren[] = {
CharLayout('a', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
VerticalOffsetLayout(
CharLayout('3', KDText::FontSize::Small),
VerticalOffsetLayoutNode::Type::Superscript
),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('b', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
VerticalOffsetLayoutReference(
CharLayoutReference('2', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('b', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
VerticalOffsetLayout(
CharLayout('2', KDText::FontSize::Small),
VerticalOffsetLayoutNode::Type::Superscript
),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('c', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('d', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('c', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('d', KDText::FontSize::Small),
};
m_layout = HorizontalLayoutReference(layoutChildren, 15);
m_layout = HorizontalLayout(layoutChildren, 15);
}
return m_layout;
}

View File

@@ -8,7 +8,7 @@ namespace Regression {
class CubicModel : public Model {
public:
using Model::Model;
Poincare::LayoutReference layout() override;
Poincare::Layout layout() override;
Poincare::Expression simplifiedExpression(double * modelCoefficients, Poincare::Context * context) override;
I18n::Message formulaMessage() const override { return I18n::Message::CubicRegressionFormula; }
double evaluate(double * modelCoefficients, double x) const override;

View File

@@ -6,22 +6,22 @@ using namespace Poincare;
namespace Regression {
LayoutReference ExponentialModel::layout() {
Layout ExponentialModel::layout() {
if (m_layout.isUninitialized()) {
const LayoutReference layoutChildren[] = {
CharLayoutReference('a', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('e', KDText::FontSize::Small),
VerticalOffsetLayoutReference(
HorizontalLayoutReference(
CharLayoutReference('b', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small)
const Layout layoutChildren[] = {
CharLayout('a', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('e', KDText::FontSize::Small),
VerticalOffsetLayout(
HorizontalLayout(
CharLayout('b', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small)
),
VerticalOffsetLayoutNode::Type::Superscript
)
};
m_layout = HorizontalLayoutReference(layoutChildren, 4);
m_layout = HorizontalLayout(layoutChildren, 4);
}
return m_layout;
}

View File

@@ -8,7 +8,7 @@ namespace Regression {
class ExponentialModel : public Model {
public:
using Model::Model;
Poincare::LayoutReference layout() override;
Poincare::Layout layout() override;
I18n::Message formulaMessage() const override { return I18n::Message::ExponentialRegressionFormula; }
double evaluate(double * modelCoefficients, double x) const override;
double levelSet(double * modelCoefficients, double xMin, double step, double xMax, double y, Poincare::Context * context) override;

View File

@@ -7,16 +7,16 @@ using namespace Poincare;
namespace Regression {
LayoutReference LinearModel::layout() {
Layout LinearModel::layout() {
if (m_layout.isUninitialized()) {
const LayoutReference layoutChildren[] = {
CharLayoutReference('a', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('b', KDText::FontSize::Small),
const Layout layoutChildren[] = {
CharLayout('a', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('b', KDText::FontSize::Small),
};
m_layout = HorizontalLayoutReference(layoutChildren, 5);
m_layout = HorizontalLayout(layoutChildren, 5);
}
return m_layout;
}

View File

@@ -8,7 +8,7 @@ namespace Regression {
class LinearModel : public Model {
public:
using Model::Model;
Poincare::LayoutReference layout() override;
Poincare::Layout layout() override;
I18n::Message formulaMessage() const override { return I18n::Message::LinearRegressionFormula; }
double evaluate(double * modelCoefficients, double x) const override;
double levelSet(double * modelCoefficients, double xMin, double step, double xMax, double y, Poincare::Context * context) override;

View File

@@ -7,20 +7,20 @@ using namespace Poincare;
namespace Regression {
LayoutReference LogarithmicModel::layout() {
Layout LogarithmicModel::layout() {
if (m_layout.isUninitialized()) {
const LayoutReference layoutChildren[] = {
CharLayoutReference('a', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('l', KDText::FontSize::Small),
CharLayoutReference('n', KDText::FontSize::Small),
CharLayoutReference('(', KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
CharLayoutReference(')', KDText::FontSize::Small),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('b', KDText::FontSize::Small)
const Layout layoutChildren[] = {
CharLayout('a', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('l', KDText::FontSize::Small),
CharLayout('n', KDText::FontSize::Small),
CharLayout('(', KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
CharLayout(')', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('b', KDText::FontSize::Small)
};
m_layout = HorizontalLayoutReference(layoutChildren, 9);
m_layout = HorizontalLayout(layoutChildren, 9);
}
return m_layout;
}

View File

@@ -8,7 +8,7 @@ namespace Regression {
class LogarithmicModel : public Model {
public:
using Model::Model;
Poincare::LayoutReference layout() override;
Poincare::Layout layout() override;
I18n::Message formulaMessage() const override { return I18n::Message::LogarithmicRegressionFormula; }
double evaluate(double * modelCoefficients, double x) const override;
double levelSet(double * modelCoefficients, double xMin, double step, double xMax, double y, Poincare::Context * context) override;

View File

@@ -6,28 +6,28 @@ using namespace Poincare;
namespace Regression {
LayoutReference LogisticModel::layout() {
Layout LogisticModel::layout() {
if (m_layout.isUninitialized()) {
const LayoutReference exponentLayoutChildren[] = {
CharLayoutReference('-', KDText::FontSize::Small),
CharLayoutReference('b', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small)
const Layout exponentLayoutChildren[] = {
CharLayout('-', KDText::FontSize::Small),
CharLayout('b', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small)
};
const LayoutReference layoutChildren[] = {
CharLayoutReference('1', KDText::FontSize::Small),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('a', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('e', KDText::FontSize::Small),
VerticalOffsetLayoutReference(
HorizontalLayoutReference(exponentLayoutChildren, 4),
const Layout layoutChildren[] = {
CharLayout('1', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('a', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('e', KDText::FontSize::Small),
VerticalOffsetLayout(
HorizontalLayout(exponentLayoutChildren, 4),
VerticalOffsetLayoutNode::Type::Superscript
)
};
m_layout = FractionLayoutReference(
CharLayoutReference('c', KDText::FontSize::Small),
HorizontalLayoutReference(layoutChildren, 6)
m_layout = FractionLayout(
CharLayout('c', KDText::FontSize::Small),
HorizontalLayout(layoutChildren, 6)
);
}
return m_layout;

View File

@@ -8,7 +8,7 @@ namespace Regression {
class LogisticModel : public Model {
public:
using Model::Model;
Poincare::LayoutReference layout() override;
Poincare::Layout layout() override;
I18n::Message formulaMessage() const override { return I18n::Message::LogisticRegressionFormula; }
double evaluate(double * modelCoefficients, double x) const override;
double levelSet(double * modelCoefficients, double xMin, double step, double xMax, double y, Poincare::Context * context) override;

View File

@@ -12,7 +12,7 @@ using namespace Shared;
namespace Regression {
void Model::tidy() {
m_layout = LayoutReference();
m_layout = Layout();
}
double Model::levelSet(double * modelCoefficients, double xMin, double step, double xMax, double y, Poincare::Context * context) {

View File

@@ -25,7 +25,7 @@ public:
static constexpr int k_numberOfModels = 9;
static constexpr int k_maxNumberOfCoefficients = 5; // This has to verify: k_maxNumberOfCoefficients < Matrix::k_maxNumberOfCoefficients
virtual ~Model() = default;
virtual Poincare::LayoutReference layout() = 0;
virtual Poincare::Layout layout() = 0;
// Reinitialize m_layout to empty the pool
void tidy();
// simplifiedExpression is overrided only by Models that override levelSet
@@ -39,7 +39,7 @@ public:
protected:
// Fit
virtual bool dataSuitableForFit(Store * store, int series) const;
Poincare::LayoutReference m_layout;
Poincare::Layout m_layout;
private:
// Model attributes
virtual double partialDerivate(double * modelCoefficients, int derivateCoefficientIndex, double x) const = 0;

View File

@@ -7,18 +7,18 @@ using namespace Poincare;
namespace Regression {
LayoutReference PowerModel::layout() {
Layout PowerModel::layout() {
if (m_layout.isUninitialized()) {
const LayoutReference layoutChildren[] = {
CharLayoutReference('a', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
VerticalOffsetLayoutReference(
CharLayoutReference('b', KDText::FontSize::Small),
const Layout layoutChildren[] = {
CharLayout('a', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
VerticalOffsetLayout(
CharLayout('b', KDText::FontSize::Small),
VerticalOffsetLayoutNode::Type::Superscript
),
};
m_layout = HorizontalLayoutReference(layoutChildren, 4);
m_layout = HorizontalLayout(layoutChildren, 4);
}
return m_layout;
}

View File

@@ -8,7 +8,7 @@ namespace Regression {
class PowerModel : public Model {
public:
using Model::Model;
Poincare::LayoutReference layout() override;
Poincare::Layout layout() override;
I18n::Message formulaMessage() const override { return I18n::Message::PowerRegressionFormula; }
double evaluate(double * modelCoefficients, double x) const override;
double levelSet(double * modelCoefficients, double xMin, double step, double xMax, double y, Poincare::Context * context) override;

View File

@@ -8,24 +8,24 @@ using namespace Shared;
namespace Regression {
LayoutReference QuadraticModel::layout() {
Layout QuadraticModel::layout() {
if (m_layout.isUninitialized()) {
const LayoutReference layoutChildren[] = {
CharLayoutReference('a', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
VerticalOffsetLayoutReference(
CharLayoutReference('2', KDText::FontSize::Small),
const Layout layoutChildren[] = {
CharLayout('a', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
VerticalOffsetLayout(
CharLayout('2', KDText::FontSize::Small),
VerticalOffsetLayoutNode::Type::Superscript
),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('b', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('c', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('b', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('c', KDText::FontSize::Small),
};
m_layout = HorizontalLayoutReference(layoutChildren, 10);
m_layout = HorizontalLayout(layoutChildren, 10);
}
return m_layout;
}

View File

@@ -8,7 +8,7 @@ namespace Regression {
class QuadraticModel : public Model {
public:
using Model::Model;
Poincare::LayoutReference layout() override;
Poincare::Layout layout() override;
Poincare::Expression simplifiedExpression(double * modelCoefficients, Poincare::Context * context) override;
I18n::Message formulaMessage() const override { return I18n::Message::QuadraticRegressionFormula; }
double evaluate(double * modelCoefficients, double x) const override;

View File

@@ -8,40 +8,40 @@ using namespace Shared;
namespace Regression {
LayoutReference QuarticModel::layout() {
Layout QuarticModel::layout() {
if (m_layout.isUninitialized()) {
const LayoutReference layoutChildren[] = {
CharLayoutReference('a', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
VerticalOffsetLayoutReference(
CharLayoutReference('4', KDText::FontSize::Small),
const Layout layoutChildren[] = {
CharLayout('a', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
VerticalOffsetLayout(
CharLayout('4', KDText::FontSize::Small),
VerticalOffsetLayoutNode::Type::Superscript
),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('b', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
VerticalOffsetLayoutReference(
CharLayoutReference('3', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('b', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
VerticalOffsetLayout(
CharLayout('3', KDText::FontSize::Small),
VerticalOffsetLayoutNode::Type::Superscript
),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('c', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
VerticalOffsetLayoutReference(
CharLayoutReference('2', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('c', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
VerticalOffsetLayout(
CharLayout('2', KDText::FontSize::Small),
VerticalOffsetLayoutNode::Type::Superscript
),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('d', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('e', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('d', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('e', KDText::FontSize::Small),
};
m_layout = HorizontalLayoutReference(layoutChildren, 20);
m_layout = HorizontalLayout(layoutChildren, 20);
}
return m_layout;
}

View File

@@ -8,7 +8,7 @@ namespace Regression {
class QuarticModel : public Model {
public:
using Model::Model;
Poincare::LayoutReference layout() override;
Poincare::Layout layout() override;
Poincare::Expression simplifiedExpression(double * modelCoefficients, Poincare::Context * context) override;
I18n::Message formulaMessage() const override { return I18n::Message::QuarticRegressionFormula; }
double evaluate(double * modelCoefficients, double x) const override;

View File

@@ -9,25 +9,25 @@ using namespace Shared;
namespace Regression {
LayoutReference TrigonometricModel::layout() {
Layout TrigonometricModel::layout() {
if (m_layout.isUninitialized()) {
const LayoutReference layoutChildren[] = {
CharLayoutReference('a', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('s', KDText::FontSize::Small),
CharLayoutReference('i', KDText::FontSize::Small),
CharLayoutReference('n', KDText::FontSize::Small),
CharLayoutReference('(', KDText::FontSize::Small),
CharLayoutReference('b', KDText::FontSize::Small),
CharLayoutReference(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayoutReference('X', KDText::FontSize::Small),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('c', KDText::FontSize::Small),
CharLayoutReference(')', KDText::FontSize::Small),
CharLayoutReference('+', KDText::FontSize::Small),
CharLayoutReference('d', KDText::FontSize::Small)
const Layout layoutChildren[] = {
CharLayout('a', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('s', KDText::FontSize::Small),
CharLayout('i', KDText::FontSize::Small),
CharLayout('n', KDText::FontSize::Small),
CharLayout('(', KDText::FontSize::Small),
CharLayout('b', KDText::FontSize::Small),
CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small),
CharLayout('X', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('c', KDText::FontSize::Small),
CharLayout(')', KDText::FontSize::Small),
CharLayout('+', KDText::FontSize::Small),
CharLayout('d', KDText::FontSize::Small)
};
m_layout = HorizontalLayoutReference(layoutChildren, 14);
m_layout = HorizontalLayout(layoutChildren, 14);
}
return m_layout;
}

View File

@@ -8,7 +8,7 @@ namespace Regression {
class TrigonometricModel : public Model {
public:
using Model::Model;
Poincare::LayoutReference layout() override;
Poincare::Layout layout() override;
Poincare::Expression simplifiedExpression(double * modelCoefficients, Poincare::Context * context) override;
I18n::Message formulaMessage() const override { return I18n::Message::TrigonometricRegressionFormula; }
double evaluate(double * modelCoefficients, double x) const override;

View File

@@ -85,7 +85,7 @@ void RegressionController::willDisplayCellAtLocation(HighlightCell * cell, int i
I18n::Message messages[k_numberOfRows] = {I18n::Message::Linear, I18n::Message::Quadratic, I18n::Message::Cubic, I18n::Message::Quartic, I18n::Message::Logarithmic, I18n::Message::Exponential, I18n::Message::Power, I18n::Message::Trigonometrical, I18n::Message::Logistic};
MessageTableCellWithExpression * castedCell = static_cast<MessageTableCellWithExpression *>(cell);
castedCell->setMessage(messages[j]);
castedCell->setLayoutReference(m_store->regressionModel((Model::Type) j)->layout());
castedCell->setLayout(m_store->regressionModel((Model::Type) j)->layout());
}
}

View File

@@ -76,7 +76,7 @@ int StoreParameterController::typeAtLocation(int i, int j) {
void StoreParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) {
if (index == numberOfRows() -1) {
m_changeRegressionCell.setLayoutReference(static_cast<Store *>(m_store)->modelForSeries(m_series)->layout());
m_changeRegressionCell.setLayout(static_cast<Store *>(m_store)->modelForSeries(m_series)->layout());
}
Shared::StoreParameterController::willDisplayCellForIndex(cell, index);
}

View File

@@ -46,11 +46,11 @@ double TermSumController::cursorNextStep(double x, int direction) {
return std::round(m_cursor->x()+delta);
}
LayoutReference TermSumController::createFunctionLayout(const char * functionName) {
return HorizontalLayoutReference(
CharLayoutReference(functionName[0], KDText::FontSize::Small),
VerticalOffsetLayoutReference(
CharLayoutReference('n', KDText::FontSize::Small),
Layout TermSumController::createFunctionLayout(const char * functionName) {
return HorizontalLayout(
CharLayout(functionName[0], KDText::FontSize::Small),
VerticalOffsetLayout(
CharLayout('n', KDText::FontSize::Small),
VerticalOffsetLayoutNode::Type::Subscript
)
);

View File

@@ -16,7 +16,7 @@ private:
bool moveCursorHorizontallyToPosition(double position) override;
I18n::Message legendMessageAtStep(Step step) override;
double cursorNextStep(double position, int direction) override;
Poincare::LayoutReference createFunctionLayout(const char * functionName) override;
Poincare::Layout createFunctionLayout(const char * functionName) override;
};
}

View File

@@ -62,7 +62,7 @@ KDCoordinate ListController::expressionRowHeight(int j) {
}
Sequence * sequence = m_sequenceStore->modelAtIndex(modelIndexForRow(j));
KDCoordinate defaultHeight = 2*k_expressionCellVerticalMargin + (sequence->type() == Sequence::Type::Explicit ? Metric::StoreRowHeight : k_emptySubRowHeight);
LayoutReference layout = sequence->layoutRef();
Layout layout = sequence->layout();
if (sequenceDefinitionForRow(j) == 1) {
layout = sequence->firstInitialConditionLayout();
}
@@ -204,13 +204,13 @@ void ListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int
FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell;
Sequence * sequence = m_sequenceStore->modelAtIndex(modelIndexForRow(j));
if (sequenceDefinitionForRow(j) == 0) {
myCell->setLayoutReference(sequence->layoutRef());
myCell->setLayout(sequence->layout());
}
if (sequenceDefinitionForRow(j) == 1) {
myCell->setLayoutReference(sequence->firstInitialConditionLayout());
myCell->setLayout(sequence->firstInitialConditionLayout());
}
if (sequenceDefinitionForRow(j) == 2) {
myCell->setLayoutReference(sequence->secondInitialConditionLayout());
myCell->setLayout(sequence->secondInitialConditionLayout());
}
bool active = sequence->isActive();
KDColor textColor = active ? KDColorBlack : Palette::GreyDark;

View File

@@ -104,7 +104,7 @@ void ListParameterController::willDisplayCellForIndex(HighlightCell * cell, int
cell->setHighlighted(index == selectedRow()); // See FIXME in SelectableTableView::reloadData()
Shared::ListParameterController::willDisplayCellForIndex(cell, index);
if (cell == &m_typeCell && m_sequence != nullptr) {
m_typeCell.setLayoutReference(m_sequence->definitionName());
m_typeCell.setLayout(m_sequence->definitionName());
}
if (cell == &m_initialRankCell && m_sequence != nullptr) {
MessageTableCellWithEditableText * myCell = (MessageTableCellWithEditableText *) cell;

View File

@@ -43,7 +43,7 @@ HighlightCell * SequenceToolbox::reusableCell(int index, int type) {
void SequenceToolbox::willDisplayCellForIndex(HighlightCell * cell, int index) {
if (typeAtLocation(0, index) == 2) {
static_cast<ExpressionTableCell *>(cell)->setLayoutReference(m_addedCellLayout[index]);
static_cast<ExpressionTableCell *>(cell)->setLayout(m_addedCellLayout[index]);
return;
}
MathToolbox::willDisplayCellForIndex(cell, mathToolboxIndex(index));
@@ -73,20 +73,20 @@ void SequenceToolbox::buildExtraCellsLayouts(const char * sequenceName, int recu
const char * otherSequenceName = SequenceStore::k_sequenceNames[1-sequenceIndex];
for (int j = 0; j < recurrenceDepth; j++) {
const char * indice = j == 0 ? "n" : "n+1";
m_addedCellLayout[j] = HorizontalLayoutReference(
CharLayoutReference(sequenceName[0], KDText::FontSize::Large),
VerticalOffsetLayoutReference(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
m_addedCellLayout[j] = HorizontalLayout(
CharLayout(sequenceName[0], KDText::FontSize::Large),
VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
);
m_addedCellLayout[j+recurrenceDepth] = HorizontalLayoutReference(
CharLayoutReference(otherSequenceName[0], KDText::FontSize::Large),
VerticalOffsetLayoutReference(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
m_addedCellLayout[j+recurrenceDepth] = HorizontalLayout(
CharLayout(otherSequenceName[0], KDText::FontSize::Large),
VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
);
}
if (recurrenceDepth < 2) {
const char * indice = recurrenceDepth == 0 ? "n" : (recurrenceDepth == 1 ? "n+1" : "n+2");
m_addedCellLayout[2*recurrenceDepth] = HorizontalLayoutReference(
CharLayoutReference(otherSequenceName[0], KDText::FontSize::Large),
VerticalOffsetLayoutReference(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
m_addedCellLayout[2*recurrenceDepth] = HorizontalLayout(
CharLayout(otherSequenceName[0], KDText::FontSize::Large),
VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
);
}
}

View File

@@ -18,7 +18,7 @@ private:
bool selectAddedCell(int selectedRow);
int mathToolboxIndex(int index);
ExpressionTableCell m_addedCells[k_maxNumberOfDisplayedRows];
Poincare::LayoutReference m_addedCellLayout[k_maxNumberOfDisplayedRows];
Poincare::Layout m_addedCellLayout[k_maxNumberOfDisplayedRows];
int m_numberOfAddedCells;
};

View File

@@ -113,12 +113,12 @@ void TypeParameterController::willDisplayCellAtLocation(HighlightCell * cell, in
size = KDText::FontSize::Small;
}
const char * subscripts[3] = {"n", "n+1", "n+2"};
m_layouts[j] = HorizontalLayoutReference(
CharLayoutReference(nextName[0], size),
VerticalOffsetLayoutReference(LayoutHelper::String(subscripts[j], strlen(subscripts[j]), size), VerticalOffsetLayoutNode::Type::Subscript)
m_layouts[j] = HorizontalLayout(
CharLayout(nextName[0], size),
VerticalOffsetLayout(LayoutHelper::String(subscripts[j], strlen(subscripts[j]), size), VerticalOffsetLayoutNode::Type::Subscript)
);
ExpressionTableCellWithPointer * myCell = (ExpressionTableCellWithPointer *)cell;
myCell->setLayoutReference(m_layouts[j]);
myCell->setLayout(m_layouts[j]);
}
void TypeParameterController::setSequence(Sequence * sequence) {

View File

@@ -31,7 +31,7 @@ private:
ExpressionTableCellWithPointer m_expliciteCell;
ExpressionTableCellWithPointer m_singleRecurrenceCell;
ExpressionTableCellWithPointer m_doubleRecurenceCell;
Poincare::LayoutReference m_layouts[k_totalNumberOfCell];
Poincare::Layout m_layouts[k_totalNumberOfCell];
SelectableTableView m_selectableTableView;
SequenceStore * m_sequenceStore;
Sequence * m_sequence;

View File

@@ -86,8 +86,8 @@ void Sequence::setType(Type type) {
void Sequence::setInitialRank(int rank) {
m_initialRank = rank;
m_firstInitialConditionName = LayoutReference();
m_secondInitialConditionName = LayoutReference();
m_firstInitialConditionName = Layout();
m_secondInitialConditionName = Layout();
}
Poincare::Expression Sequence::firstInitialConditionExpression(Context * context) const {
@@ -104,7 +104,7 @@ Poincare::Expression Sequence::secondInitialConditionExpression(Context * contex
return m_secondInitialConditionExpression;
}
Poincare::LayoutReference Sequence::firstInitialConditionLayout() {
Poincare::Layout Sequence::firstInitialConditionLayout() {
if (m_firstInitialConditionLayout.isUninitialized()) {
Expression nonSimplifedExpression = Expression::parse(m_firstInitialConditionText);
if (!nonSimplifedExpression.isUninitialized()) {
@@ -114,7 +114,7 @@ Poincare::LayoutReference Sequence::firstInitialConditionLayout() {
return m_firstInitialConditionLayout;
}
Poincare::LayoutReference Sequence::secondInitialConditionLayout() {
Poincare::Layout Sequence::secondInitialConditionLayout() {
if (m_secondInitialConditionLayout.isUninitialized()) {
Expression nonSimplifedExpression = Expression::parse(m_secondInitialConditionText);
if (!nonSimplifedExpression.isUninitialized()) {
@@ -127,13 +127,13 @@ Poincare::LayoutReference Sequence::secondInitialConditionLayout() {
void Sequence::setFirstInitialConditionContent(const char * c) {
strlcpy(m_firstInitialConditionText, c, sizeof(m_firstInitialConditionText));
m_firstInitialConditionExpression = Expression();
m_firstInitialConditionLayout = LayoutReference();
m_firstInitialConditionLayout = Layout();
}
void Sequence::setSecondInitialConditionContent(const char * c) {
strlcpy(m_secondInitialConditionText, c, sizeof(m_secondInitialConditionText));
m_secondInitialConditionExpression = Expression();
m_secondInitialConditionLayout = LayoutReference();
m_secondInitialConditionLayout = Layout();
}
char Sequence::symbol() const {
@@ -144,65 +144,65 @@ int Sequence::numberOfElements() {
return (int)m_type + 1;
}
Poincare::LayoutReference Sequence::nameLayout() {
Poincare::Layout Sequence::nameLayout() {
if (m_nameLayout.isUninitialized()) {
m_nameLayout = HorizontalLayoutReference(
CharLayoutReference(name()[0], KDText::FontSize::Small),
VerticalOffsetLayoutReference(CharLayoutReference('n', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Subscript)
m_nameLayout = HorizontalLayout(
CharLayout(name()[0], KDText::FontSize::Small),
VerticalOffsetLayout(CharLayout('n', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Subscript)
);
}
return m_nameLayout;
}
Poincare::LayoutReference Sequence::definitionName() {
Poincare::Layout Sequence::definitionName() {
if (m_definitionName.isUninitialized()) {
if (m_type == Type::Explicit) {
m_definitionName = HorizontalLayoutReference(
CharLayoutReference(name()[0], KDText::FontSize::Large),
VerticalOffsetLayoutReference(LayoutHelper::String("n", 1, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
m_definitionName = HorizontalLayout(
CharLayout(name()[0], KDText::FontSize::Large),
VerticalOffsetLayout(LayoutHelper::String("n", 1, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
);
}
if (m_type == Type::SingleRecurrence) {
m_definitionName = HorizontalLayoutReference(
CharLayoutReference(name()[0], KDText::FontSize::Large),
VerticalOffsetLayoutReference(LayoutHelper::String("n+1", 3, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
m_definitionName = HorizontalLayout(
CharLayout(name()[0], KDText::FontSize::Large),
VerticalOffsetLayout(LayoutHelper::String("n+1", 3, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
);
}
if (m_type == Type::DoubleRecurrence) {
m_definitionName = HorizontalLayoutReference(
CharLayoutReference(name()[0], KDText::FontSize::Large),
VerticalOffsetLayoutReference(LayoutHelper::String("n+2", 3, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
m_definitionName = HorizontalLayout(
CharLayout(name()[0], KDText::FontSize::Large),
VerticalOffsetLayout(LayoutHelper::String("n+2", 3, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript)
);
}
}
return m_definitionName;
}
Poincare::LayoutReference Sequence::firstInitialConditionName() {
Poincare::Layout Sequence::firstInitialConditionName() {
char buffer[k_initialRankNumberOfDigits+1];
Integer(m_initialRank).serialize(buffer, k_initialRankNumberOfDigits+1);
if (m_firstInitialConditionName.isUninitialized()
&& (m_type == Type::SingleRecurrence
|| m_type == Type::DoubleRecurrence))
{
LayoutReference indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large);
m_firstInitialConditionName = HorizontalLayoutReference(
CharLayoutReference(name()[0], KDText::FontSize::Large),
VerticalOffsetLayoutReference(indexLayout, VerticalOffsetLayoutNode::Type::Subscript)
Layout indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large);
m_firstInitialConditionName = HorizontalLayout(
CharLayout(name()[0], KDText::FontSize::Large),
VerticalOffsetLayout(indexLayout, VerticalOffsetLayoutNode::Type::Subscript)
);
}
return m_firstInitialConditionName;
}
Poincare::LayoutReference Sequence::secondInitialConditionName() {
Poincare::Layout Sequence::secondInitialConditionName() {
char buffer[k_initialRankNumberOfDigits+1];
Integer(m_initialRank+1).serialize(buffer, k_initialRankNumberOfDigits+1);
if (m_secondInitialConditionName.isUninitialized()) {
if (m_type == Type::DoubleRecurrence) {
LayoutReference indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large);
m_secondInitialConditionName = HorizontalLayoutReference(
CharLayoutReference(name()[0], KDText::FontSize::Large),
VerticalOffsetLayoutReference(indexLayout, VerticalOffsetLayoutNode::Type::Subscript)
Layout indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large);
m_secondInitialConditionName = HorizontalLayout(
CharLayout(name()[0], KDText::FontSize::Large),
VerticalOffsetLayout(indexLayout, VerticalOffsetLayoutNode::Type::Subscript)
);
}
}
@@ -310,14 +310,14 @@ double Sequence::sumBetweenBounds(double start, double end, Context * context) c
void Sequence::tidy() {
Function::tidy();
m_firstInitialConditionLayout = LayoutReference();
m_secondInitialConditionLayout = LayoutReference();
m_firstInitialConditionLayout = Layout();
m_secondInitialConditionLayout = Layout();
m_firstInitialConditionExpression = Expression();
m_secondInitialConditionExpression = Expression();
m_nameLayout = LayoutReference();
m_definitionName = LayoutReference();
m_firstInitialConditionName = LayoutReference();
m_secondInitialConditionName = LayoutReference();
m_nameLayout = Layout();
m_definitionName = Layout();
m_firstInitialConditionName = Layout();
m_secondInitialConditionName = Layout();
}
template double Sequence::templatedApproximateAtAbscissa<double>(double, SequenceContext*) const;

View File

@@ -24,8 +24,8 @@ public:
const char * secondInitialConditionText();
Poincare::Expression firstInitialConditionExpression(Poincare::Context * context) const;
Poincare::Expression secondInitialConditionExpression(Poincare::Context * context) const;
Poincare::LayoutReference firstInitialConditionLayout();
Poincare::LayoutReference secondInitialConditionLayout();
Poincare::Layout firstInitialConditionLayout();
Poincare::Layout secondInitialConditionLayout();
/* WARNING: after calling setType, setContent, setFirstInitialConditionContent
* or setSecondInitialConditionContent, the sequence context needs to
* invalidate the cache because the sequences evaluations might have changed. */
@@ -34,10 +34,10 @@ public:
void setFirstInitialConditionContent(const char * c);
void setSecondInitialConditionContent(const char * c);
int numberOfElements();
Poincare::LayoutReference nameLayout();
Poincare::LayoutReference definitionName();
Poincare::LayoutReference firstInitialConditionName();
Poincare::LayoutReference secondInitialConditionName();
Poincare::Layout nameLayout();
Poincare::Layout definitionName();
Poincare::Layout firstInitialConditionName();
Poincare::Layout secondInitialConditionName();
bool isDefined() override;
bool isEmpty() override;
float evaluateAtAbscissa(float x, Poincare::Context * context) const override {
@@ -61,12 +61,12 @@ private:
char m_secondInitialConditionText[TextField::maxBufferSize()];
mutable Poincare::Expression m_firstInitialConditionExpression;
mutable Poincare::Expression m_secondInitialConditionExpression;
Poincare::LayoutReference m_firstInitialConditionLayout;
Poincare::LayoutReference m_secondInitialConditionLayout;
Poincare::LayoutReference m_nameLayout;
Poincare::LayoutReference m_definitionName;
Poincare::LayoutReference m_firstInitialConditionName;
Poincare::LayoutReference m_secondInitialConditionName;
Poincare::Layout m_firstInitialConditionLayout;
Poincare::Layout m_secondInitialConditionLayout;
Poincare::Layout m_nameLayout;
Poincare::Layout m_definitionName;
Poincare::Layout m_firstInitialConditionName;
Poincare::Layout m_secondInitialConditionName;
int m_initialRank;
};

View File

@@ -12,8 +12,8 @@ SequenceTitleCell::SequenceTitleCell() :
{
}
void SequenceTitleCell::setLayout(Poincare::LayoutReference layout) {
m_titleTextView.setLayoutReference(layout);
void SequenceTitleCell::setLayout(Poincare::Layout layout) {
m_titleTextView.setLayout(layout);
}
void SequenceTitleCell::setHighlighted(bool highlight) {

View File

@@ -8,12 +8,12 @@ namespace Sequence {
class SequenceTitleCell : public Shared::FunctionTitleCell {
public:
SequenceTitleCell();
void setLayout(Poincare::LayoutReference layout);
void setLayout(Poincare::Layout layout);
void setEven(bool even) override;
void setHighlighted(bool highlight) override;
void setColor(KDColor color) override;
Poincare::LayoutReference layoutRef() const override {
return m_titleTextView.layoutRef();
Poincare::Layout layout() const override {
return m_titleTextView.layout();
}
private:
int numberOfSubviews() const override;

View File

@@ -7,17 +7,17 @@ using namespace Poincare;
namespace Settings {
namespace Helpers {
LayoutReference CartesianComplexFormat(KDText::FontSize fontSize) {
Layout CartesianComplexFormat(KDText::FontSize fontSize) {
const char text[] = {'a','+', Ion::Charset::IComplex, 'b', ' '};
return LayoutHelper::String(text, sizeof(text), fontSize);
}
LayoutReference PolarComplexFormat(KDText::FontSize fontSize) {
Layout PolarComplexFormat(KDText::FontSize fontSize) {
const char base[] = {'r', Ion::Charset::Exponential};
const char superscript[] = {Ion::Charset::IComplex, Ion::Charset::SmallTheta, ' '};
return HorizontalLayoutReference(
return HorizontalLayout(
LayoutHelper::String(base, sizeof(base), fontSize),
VerticalOffsetLayoutReference(LayoutHelper::String(superscript, sizeof(superscript), fontSize), VerticalOffsetLayoutNode::Type::Superscript)
VerticalOffsetLayout(LayoutHelper::String(superscript, sizeof(superscript), fontSize), VerticalOffsetLayoutNode::Type::Superscript)
);
}

View File

@@ -6,8 +6,8 @@
namespace Settings {
namespace Helpers {
Poincare::LayoutReference CartesianComplexFormat(KDText::FontSize fontSize);
Poincare::LayoutReference PolarComplexFormat(KDText::FontSize fontSize);
Poincare::Layout CartesianComplexFormat(KDText::FontSize fontSize);
Poincare::Layout PolarComplexFormat(KDText::FontSize fontSize);
}
}

View File

@@ -172,7 +172,7 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) {
m_complexFormatLayout = Helpers::PolarComplexFormat(KDText::FontSize::Small);
}
MessageTableCellWithChevronAndExpression * myExpCell = (MessageTableCellWithChevronAndExpression *)cell;
myExpCell->setLayoutReference(m_complexFormatLayout);
myExpCell->setLayout(m_complexFormatLayout);
return;
}
if (index == 4) {

View File

@@ -35,7 +35,7 @@ private:
MessageTableCellWithChevronAndMessage m_cells[k_numberOfSimpleChevronCells];
MessageTableCellWithChevronAndExpression m_complexFormatCell;
MessageTableCellWithGauge m_brightnessCell;
Poincare::LayoutReference m_complexFormatLayout;
Poincare::Layout m_complexFormatLayout;
SelectableTableView m_selectableTableView;
MessageTree * m_messageTreeModel;
SubController m_subController;

View File

@@ -27,7 +27,7 @@ SubController::SubController(Responder * parentResponder) :
m_complexFormatLayout[0] = Helpers::CartesianComplexFormat(KDText::FontSize::Large);
m_complexFormatLayout[1] = Helpers::PolarComplexFormat(KDText::FontSize::Large);
for (int i = 0; i < 2; i++) {
m_complexFormatCells[i].setLayoutReference(m_complexFormatLayout[i]);
m_complexFormatCells[i].setLayout(m_complexFormatLayout[i]);
}
m_editableCell.setMessage(I18n::Message::SignificantFigures);
m_editableCell.setMessageFontSize(KDText::FontSize::Large);

View File

@@ -38,7 +38,7 @@ private:
constexpr static int k_totalNumberOfCell = (Ion::Display::Height-2*k_topBottomMargin-Metric::TitleBarHeight-Metric::StackTitleHeight)/Metric::ParameterCellHeight;
MessageTableCellWithBuffer m_cells[k_totalNumberOfCell];
ExpressionTableCell m_complexFormatCells[2];
Poincare::LayoutReference m_complexFormatLayout[2];
Poincare::Layout m_complexFormatLayout[2];
MessageTableCellWithEditableText m_editableCell;
char m_draftTextBuffer[MessageTableCellWithEditableText::k_bufferLength];
SelectableTableView m_selectableTableView;

View File

@@ -11,7 +11,7 @@ namespace Shared {
ExpressionModel::ExpressionModel() :
m_text{0},
m_expression(),
m_layoutRef()
m_layout()
{
}
@@ -26,12 +26,12 @@ Poincare::Expression ExpressionModel::expression(Poincare::Context * context) co
return m_expression;
}
LayoutReference ExpressionModel::layoutRef() {
if (m_layoutRef.isUninitialized()) {
Layout ExpressionModel::layout() {
if (m_layout.isUninitialized()) {
Expression nonSimplifiedExpression = Expression::parse(m_text);
m_layoutRef = PoincareHelpers::CreateLayout(nonSimplifiedExpression);
m_layout = PoincareHelpers::CreateLayout(nonSimplifiedExpression);
}
return m_layoutRef;
return m_layout;
}
bool ExpressionModel::isDefined() {
@@ -47,12 +47,12 @@ void ExpressionModel::setContent(const char * c) {
/* We cannot call tidy here because tidy is a virtual function and does not
* do the same thing for all children class. And here we want to delete only
* the m_layout and m_expression. */
m_layoutRef = LayoutReference();
m_layout = Layout();
m_expression = Expression();
}
void ExpressionModel::tidy() {
m_layoutRef = LayoutReference();
m_layout = Layout();
m_expression = Expression();
}

View File

@@ -12,7 +12,7 @@ public:
ExpressionModel();
const char * text() const;
Poincare::Expression expression(Poincare::Context * context) const;
Poincare::LayoutReference layoutRef();
Poincare::Layout layout();
/* Here, isDefined is the exact contrary of isEmpty. However, for Sequence
* inheriting from ExpressionModel, isEmpty and isDefined have not exactly
* opposite meaning. For instance, u(n+1)=u(n) & u(0) = ... is not empty and
@@ -30,7 +30,7 @@ private:
static_assert((k_dataLengthInBytes & 0x3) == 0, "The expression model data size is not a multiple of 4 bytes (cannot compute crc)"); // Assert that dataLengthInBytes is a multiple of 4
char m_text[k_expressionBufferSize];
mutable Poincare::Expression m_expression;
mutable Poincare::LayoutReference m_layoutRef;
mutable Poincare::Layout m_layout;
};
}

View File

@@ -23,17 +23,17 @@ KDCoordinate ExpressionModelListController::expressionRowHeight(int j) {
return Metric::StoreRowHeight;
}
ExpressionModel * m = modelStore()->modelAtIndex(j);
if (m->layoutRef().isUninitialized()) {
if (m->layout().isUninitialized()) {
return Metric::StoreRowHeight;
}
KDCoordinate modelSize = m->layoutRef().layoutSize().height();
KDCoordinate modelSize = m->layout().layoutSize().height();
return modelSize + Metric::StoreRowHeight - KDText::charSize().height();
}
void ExpressionModelListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) {
EvenOddExpressionCell * myCell = (EvenOddExpressionCell *)cell;
ExpressionModel * m = modelStore()->modelAtIndex(j);
myCell->setLayoutReference(m->layoutRef());
myCell->setLayout(m->layout());
}
/* Responder */

View File

@@ -12,7 +12,7 @@ bool LayoutFieldDelegate::layoutFieldDidReceiveEvent(LayoutField * layoutField,
return expressionFieldDelegateApp()->layoutFieldDidReceiveEvent(layoutField, event);
}
bool LayoutFieldDelegate::layoutFieldDidFinishEditing(LayoutField * layoutField, LayoutReference layoutR, Ion::Events::Event event) {
bool LayoutFieldDelegate::layoutFieldDidFinishEditing(LayoutField * layoutField, Layout layoutR, Ion::Events::Event event) {
return expressionFieldDelegateApp()->layoutFieldDidFinishEditing(layoutField, layoutR, event);
}

View File

@@ -10,7 +10,7 @@ class LayoutFieldDelegate : public ::LayoutFieldDelegate {
public:
bool layoutFieldShouldFinishEditing(LayoutField * layoutField, Ion::Events::Event event) override;
bool layoutFieldDidReceiveEvent(LayoutField * layoutField, Ion::Events::Event event) override;
bool layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::LayoutReference layoutR, Ion::Events::Event event) override;
bool layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::Layout layoutR, Ion::Events::Event event) override;
bool layoutFieldDidAbortEditing(LayoutField * layoutField) override;
void layoutFieldDidChangeSize(LayoutField * layoutField) override;
Toolbox * toolboxForLayoutField(LayoutField * layoutField) override;

View File

@@ -7,7 +7,7 @@ namespace Shared {
namespace PoincareHelpers {
inline Poincare::LayoutReference CreateLayout(const Poincare::Expression e) {
inline Poincare::Layout CreateLayout(const Poincare::Expression e) {
return e.createLayout(Poincare::Preferences::sharedPreferences()->displayMode(), Poincare::Preferences::sharedPreferences()->numberOfSignificantDigits());
}

View File

@@ -9,7 +9,7 @@ namespace Shared {
class ScrollableExactApproximateExpressionsCell : public ::EvenOddCell, public Responder {
public:
ScrollableExactApproximateExpressionsCell(Responder * parentResponder = nullptr);
void setLayouts(Poincare::LayoutReference approximateLayout, Poincare::LayoutReference exactLayout) {
void setLayouts(Poincare::Layout approximateLayout, Poincare::Layout exactLayout) {
return m_view.setLayouts(approximateLayout, exactLayout);
}
void setEqualMessage(I18n::Message equalSignMessage) {
@@ -22,7 +22,7 @@ public:
Responder * responder() override {
return this;
}
Poincare::LayoutReference layoutRef() const override { return m_view.layoutRef(); }
Poincare::Layout layout() const override { return m_view.layout(); }
void didBecomeFirstResponder() override;
constexpr static KDCoordinate k_margin = 5;
private:

View File

@@ -49,8 +49,8 @@ KDSize ScrollableExactApproximateExpressionsView::ContentCell::minimalSizeForOpt
return approximateExpressionSize;
}
KDSize exactExpressionSize = m_exactExpressionView.minimalSizeForOptimalDisplay();
KDCoordinate exactBaseline = m_exactExpressionView.layoutRef().baseline();
KDCoordinate approximateBaseline = m_approximateExpressionView.layoutRef().baseline();
KDCoordinate exactBaseline = m_exactExpressionView.layout().baseline();
KDCoordinate approximateBaseline = m_approximateExpressionView.layout().baseline();
KDCoordinate height = max(exactBaseline, approximateBaseline) + max(exactExpressionSize.height()-exactBaseline, approximateExpressionSize.height()-approximateBaseline);
KDSize approximateSignSize = m_approximateSign.minimalSizeForOptimalDisplay();
return KDSize(exactExpressionSize.width()+approximateSignSize.width()+approximateExpressionSize.width()+2*k_digitHorizontalMargin, height);
@@ -61,16 +61,16 @@ void ScrollableExactApproximateExpressionsView::ContentCell::setSelectedSubviewT
setHighlighted(isHighlighted());
}
Poincare::LayoutReference ScrollableExactApproximateExpressionsView::ContentCell::layoutRef() const {
Poincare::Layout ScrollableExactApproximateExpressionsView::ContentCell::layout() const {
if (m_selectedSubviewType == SubviewType::ExactOutput) {
return m_exactExpressionView.layoutRef();
return m_exactExpressionView.layout();
} else {
return m_approximateExpressionView.layoutRef();
return m_approximateExpressionView.layout();
}
}
int ScrollableExactApproximateExpressionsView::ContentCell::numberOfSubviews() const {
if (m_exactExpressionView.layoutRef().isUninitialized()) {
if (m_exactExpressionView.layout().isUninitialized()) {
return 1;
}
return 3;
@@ -88,8 +88,8 @@ void ScrollableExactApproximateExpressionsView::ContentCell::layoutSubviews() {
m_approximateExpressionView.setFrame(KDRect(0, 0, approximateExpressionSize.width(), height));
return;
}
KDCoordinate exactBaseline = m_exactExpressionView.layoutRef().baseline();
KDCoordinate approximateBaseline = m_approximateExpressionView.layoutRef().baseline();
KDCoordinate exactBaseline = m_exactExpressionView.layout().baseline();
KDCoordinate approximateBaseline = m_approximateExpressionView.layout().baseline();
KDCoordinate baseline = max(exactBaseline, approximateBaseline);
KDSize exactExpressionSize = m_exactExpressionView.minimalSizeForOptimalDisplay();
KDSize approximateSignSize = m_approximateSign.minimalSizeForOptimalDisplay();
@@ -104,9 +104,9 @@ ScrollableExactApproximateExpressionsView::ScrollableExactApproximateExpressions
{
}
void ScrollableExactApproximateExpressionsView::setLayouts(Poincare::LayoutReference approximateLayout, Poincare::LayoutReference exactLayout) {
m_contentCell.approximateExpressionView()->setLayoutReference(approximateLayout);
m_contentCell.exactExpressionView()->setLayoutReference(exactLayout);
void ScrollableExactApproximateExpressionsView::setLayouts(Poincare::Layout approximateLayout, Poincare::Layout exactLayout) {
m_contentCell.approximateExpressionView()->setLayout(approximateLayout);
m_contentCell.exactExpressionView()->setLayout(exactLayout);
m_contentCell.layoutSubviews();
}
@@ -115,7 +115,7 @@ void ScrollableExactApproximateExpressionsView::setEqualMessage(I18n::Message eq
}
void ScrollableExactApproximateExpressionsView::didBecomeFirstResponder() {
if (m_contentCell.exactExpressionView()->layoutRef().isUninitialized()) {
if (m_contentCell.exactExpressionView()->layout().isUninitialized()) {
setSelectedSubviewType(SubviewType::ApproximativeOutput);
} else {
setSelectedSubviewType(SubviewType::ExactOutput);
@@ -123,7 +123,7 @@ void ScrollableExactApproximateExpressionsView::didBecomeFirstResponder() {
}
bool ScrollableExactApproximateExpressionsView::handleEvent(Ion::Events::Event event) {
if (m_contentCell.exactExpressionView()->layoutRef().isUninitialized()) {
if (m_contentCell.exactExpressionView()->layout().isUninitialized()) {
return ScrollableView::handleEvent(event);
}
bool rightExpressionIsVisible = minimalSizeForOptimalDisplay().width() - m_contentCell.approximateExpressionView()->minimalSizeForOptimalDisplay().width() - m_manualScrollingOffset.x() < bounds().width()

View File

@@ -15,7 +15,7 @@ public:
::EvenOddCell * evenOddCell() {
return &m_contentCell;
}
void setLayouts(Poincare::LayoutReference approximatelayout, Poincare::LayoutReference exactLayout);
void setLayouts(Poincare::Layout approximatelayout, Poincare::Layout exactLayout);
void setEqualMessage(I18n::Message equalSignMessage);
SubviewType selectedSubviewType() {
return m_contentCell.selectedSubviewType();
@@ -26,8 +26,8 @@ public:
void didBecomeFirstResponder() override;
bool handleEvent(Ion::Events::Event event) override;
KDSize minimalSizeForOptimalDisplay() const override;
Poincare::LayoutReference layoutRef() const {
return m_contentCell.layoutRef();
Poincare::Layout layout() const {
return m_contentCell.layout();
}
private:
class ContentCell : public ::EvenOddCell {
@@ -52,7 +52,7 @@ private:
void setSelectedSubviewType(SubviewType subviewType);
void layoutSubviews() override;
int numberOfSubviews() const override;
Poincare::LayoutReference layoutRef() const override;
Poincare::Layout layout() const override;
private:
View * subviewAtIndex(int index) override;
constexpr static KDCoordinate k_digitHorizontalMargin = 10;

View File

@@ -202,7 +202,7 @@ bool SumGraphController::handleEnter() {
SumGraphController::LegendView::LegendView(SumGraphController * controller, char sumSymbol) :
m_sum(0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
m_sumLayoutReference(),
m_sumLayout(),
m_legend(KDText::FontSize::Small, I18n::Message::Default, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
m_editableZone(controller, m_draftText, m_draftText, TextField::maxBufferSize(), controller, false, KDText::FontSize::Small, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
m_sumSymbol(sumSymbol)
@@ -229,37 +229,37 @@ void SumGraphController::LegendView::setEditableZone(double d) {
m_editableZone.setText(buffer);
}
void SumGraphController::LegendView::setSumSymbol(Step step, double start, double end, double result, LayoutReference functionLayout) {
void SumGraphController::LegendView::setSumSymbol(Step step, double start, double end, double result, Layout functionLayout) {
assert(step == Step::Result || functionLayout.isUninitialized());
const char sigma[] = {' ', m_sumSymbol};
if (step == Step::FirstParameter) {
m_sumLayoutReference = LayoutHelper::String(sigma, sizeof(sigma));
m_sumLayout = LayoutHelper::String(sigma, sizeof(sigma));
} else if (step == Step::SecondParameter) {
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits)];
PrintFloat::convertFloatToText<double>(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
m_sumLayoutReference = CondensedSumLayoutReference(
m_sumLayout = CondensedSumLayout(
LayoutHelper::String(sigma, sizeof(sigma)),
LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small),
EmptyLayoutReference(EmptyLayoutNode::Color::Yellow, false, KDText::FontSize::Small, false));
EmptyLayout(EmptyLayoutNode::Color::Yellow, false, KDText::FontSize::Small, false));
} else {
m_sumLayoutReference = LayoutHelper::String(sigma, sizeof(sigma));
m_sumLayout = LayoutHelper::String(sigma, sizeof(sigma));
char buffer[2+PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
PrintFloat::convertFloatToText<double>(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
LayoutReference start = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small);
Layout start = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small);
PrintFloat::convertFloatToText<double>(end, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
LayoutReference end = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small);
m_sumLayoutReference = CondensedSumLayoutReference(
Layout end = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small);
m_sumLayout = CondensedSumLayout(
LayoutHelper::String(sigma, sizeof(sigma)),
start,
end);
strlcpy(buffer, "= ", 3);
PoincareHelpers::ConvertFloatToText<double>(result, buffer+2, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
m_sumLayoutReference = HorizontalLayoutReference(
m_sumLayoutReference,
m_sumLayout = HorizontalLayout(
m_sumLayout,
functionLayout,
LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small));
}
m_sum.setLayoutReference(m_sumLayoutReference);
m_sum.setLayout(m_sumLayout);
if (step == Step::Result) {
m_sum.setAlignment(0.5f, 0.5f);
} else {

View File

@@ -39,7 +39,7 @@ private:
constexpr static float k_cursorBottomMarginRatio = 0.28f; // (cursorHeight/2+bannerHeigh)/graphViewHeight
virtual I18n::Message legendMessageAtStep(Step step) = 0;
virtual double cursorNextStep(double position, int direction) = 0;
virtual Poincare::LayoutReference createFunctionLayout(const char * functionName) = 0;
virtual Poincare::Layout createFunctionLayout(const char * functionName) = 0;
Shared::InteractiveCurveViewRange * interactiveCurveViewRange() override { return m_graphRange; }
Shared::CurveView * curveView() override { return m_graphView; }
TextFieldDelegateApp * textFieldDelegateApp() override {
@@ -58,7 +58,7 @@ private:
void drawRect(KDContext * ctx, KDRect rect) const override;
void setLegendMessage(I18n::Message message, Step step);
void setEditableZone(double d);
void setSumSymbol(Step step, double start = NAN, double end = NAN, double result = NAN, Poincare::LayoutReference sequenceName = Poincare::LayoutReference());
void setSumSymbol(Step step, double start = NAN, double end = NAN, double result = NAN, Poincare::Layout sequenceName = Poincare::Layout());
private:
constexpr static KDCoordinate k_legendHeight = 35;
constexpr static KDCoordinate k_editableZoneWidth = 12*KDText::charSize(KDText::FontSize::Small).width();
@@ -70,7 +70,7 @@ private:
void layoutSubviews() override;
void layoutSubviews(Step step);
ExpressionView m_sum;
Poincare::LayoutReference m_sumLayoutReference;
Poincare::Layout m_sumLayout;
MessageTextView m_legend;
TextField m_editableZone;
char m_draftText[TextField::maxBufferSize()];

View File

@@ -24,7 +24,7 @@ EquationModelsParameterController::EquationModelsParameterController(Responder *
for (int i = 0; i < k_numberOfExpressionCells; i++) {
Poincare::Expression e = Expression::parse(k_models[i+1]);
m_layouts[i] = e.createLayout(Poincare::Preferences::PrintFloatMode::Decimal, Constant::ShortNumberOfSignificantDigits);
m_modelCells[i].setLayoutReference(m_layouts[i]);
m_modelCells[i].setLayout(m_layouts[i]);
}
}

View File

@@ -32,7 +32,7 @@ private:
constexpr static int k_numberOfExpressionCells = k_numberOfModels-1;
MessageTableCell m_emptyModelCell;
ExpressionTableCell m_modelCells[k_numberOfExpressionCells];
Poincare::LayoutReference m_layouts[k_numberOfExpressionCells];
Poincare::Layout m_layouts[k_numberOfExpressionCells];
SelectableTableView m_selectableTableView;
EquationStore * m_equationStore;
ListController * m_listController;

View File

@@ -29,7 +29,7 @@ void EquationStore::tidy() {
tidySolution();
}
Poincare::LayoutReference EquationStore::exactSolutionLayoutAtIndex(int i, bool exactLayout) {
Poincare::Layout EquationStore::exactSolutionLayoutAtIndex(int i, bool exactLayout) {
assert(m_type != Type::Monovariable && i >= 0 && (i < m_numberOfSolutions || (i == m_numberOfSolutions && m_type == Type::PolynomialMonovariable)));
if (exactLayout) {
return m_exactSolutionExactLayouts[i];
@@ -311,8 +311,8 @@ EquationStore::Error EquationStore::oneDimensialPolynomialSolve(Expression exact
void EquationStore::tidySolution() {
for (int i = 0; i < k_maxNumberOfExactSolutions; i++) {
m_exactSolutionExactLayouts[i] = LayoutReference();
m_exactSolutionApproximateLayouts[i] = LayoutReference();
m_exactSolutionExactLayouts[i] = Layout();
m_exactSolutionApproximateLayouts[i] = Layout();
}
}

View File

@@ -45,7 +45,7 @@ public:
* Layout and an approximate layout. For example, 'sqrt(2)' and '1.414213'.
* The boolean exactLayout indicates if we want the exact layout or the
* approximate one. */
Poincare::LayoutReference exactSolutionLayoutAtIndex(int i, bool exactLayout);
Poincare::Layout exactSolutionLayoutAtIndex(int i, bool exactLayout);
/* Exact layout and approximate layout of an exact solution can be:
* - identical: for instance, 5 and 5
* - equal: for instance 1/2 and 0.5
@@ -86,8 +86,8 @@ private:
Type m_type;
char m_variables[Poincare::Expression::k_maxNumberOfVariables+1];
int m_numberOfSolutions;
Poincare::LayoutReference m_exactSolutionExactLayouts[k_maxNumberOfApproximateSolutions];
Poincare::LayoutReference m_exactSolutionApproximateLayouts[k_maxNumberOfExactSolutions];
Poincare::Layout m_exactSolutionExactLayouts[k_maxNumberOfApproximateSolutions];
Poincare::Layout m_exactSolutionApproximateLayouts[k_maxNumberOfExactSolutions];
bool m_exactSolutionIdentity[k_maxNumberOfExactSolutions];
bool m_exactSolutionEquality[k_maxNumberOfExactSolutions];
double m_intervalApproximateSolutions[2];

View File

@@ -161,7 +161,7 @@ bool ListController::textFieldDidFinishEditing(TextField * textField, const char
return true;
}
bool ListController::layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::LayoutReference layout, Ion::Events::Event event) {
bool ListController::layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::Layout layout, Ion::Events::Event event) {
reloadButtonMessage();
return true;
}

View File

@@ -42,7 +42,7 @@ public:
bool textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) override;
bool layoutFieldDidReceiveEvent(LayoutField * layoutField, Ion::Events::Event event) override;
bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override;
bool layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::LayoutReference layout, Ion::Events::Event event) override;
bool layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::Layout layout, Ion::Events::Event event) override;
/* Specific to Solver */
void resolveEquations();
private:

View File

@@ -66,9 +66,9 @@ SolutionsController::SolutionsController(Responder * parentResponder, EquationSt
m_delta2Layout(),
m_contentView(this)
{
m_delta2Layout = HorizontalLayoutReference(VerticalOffsetLayoutReference(CharLayoutReference('2', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Superscript), LayoutHelper::String("-4ac", 4, KDText::FontSize::Small));
m_delta2Layout = HorizontalLayout(VerticalOffsetLayout(CharLayout('2', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Superscript), LayoutHelper::String("-4ac", 4, KDText::FontSize::Small));
char deltaB[] = {Ion::Charset::CapitalDelta, '=', 'b'};
static_cast<HorizontalLayoutReference&>(m_delta2Layout).addOrMergeChildAtIndex(LayoutHelper::String(deltaB, 3, KDText::FontSize::Small), 0, false);
static_cast<HorizontalLayout&>(m_delta2Layout).addOrMergeChildAtIndex(LayoutHelper::String(deltaB, 3, KDText::FontSize::Small), 0, false);
for (int i = 0; i < EquationStore::k_maxNumberOfExactSolutions; i++) {
m_exactValueCells[i].setParentResponder(m_contentView.selectableTableView());
}
@@ -145,7 +145,7 @@ void SolutionsController::willDisplayCellAtLocation(HighlightCell * cell, int i,
if (i == 0) {
if (m_equationStore->type() == EquationStore::Type::PolynomialMonovariable && j == m_equationStore->numberOfSolutions()) {
EvenOddExpressionCell * deltaCell = static_cast<EvenOddExpressionCell *>(cell);
deltaCell->setLayoutReference(m_delta2Layout);
deltaCell->setLayout(m_delta2Layout);
} else {
EvenOddBufferTextCell * symbolCell = static_cast<EvenOddBufferTextCell *>(cell);
symbolCell->setFontSize(KDText::FontSize::Large);
@@ -171,7 +171,7 @@ void SolutionsController::willDisplayCellAtLocation(HighlightCell * cell, int i,
valueCell->setText(bufferValue);
} else {
Shared::ScrollableExactApproximateExpressionsCell * valueCell = static_cast<ScrollableExactApproximateExpressionsCell *>(cell);
Poincare::LayoutReference exactLayout = m_equationStore->exactSolutionLayoutsAtIndexAreIdentical(j) ? Poincare::LayoutReference() : m_equationStore->exactSolutionLayoutAtIndex(j, true);
Poincare::Layout exactLayout = m_equationStore->exactSolutionLayoutsAtIndexAreIdentical(j) ? Poincare::Layout() : m_equationStore->exactSolutionLayoutAtIndex(j, true);
valueCell->setLayouts(m_equationStore->exactSolutionLayoutAtIndex(j, false), exactLayout);
if (!exactLayout.isUninitialized()) {
valueCell->setEqualMessage(m_equationStore->exactSolutionLayoutsAtIndexAreEqual(j) ? I18n::Message::Equal : I18n::Message::AlmostEqual);
@@ -194,8 +194,8 @@ KDCoordinate SolutionsController::rowHeight(int j) {
if (m_equationStore->type() == EquationStore::Type::Monovariable) {
return k_defaultCellHeight;
}
Poincare::LayoutReference exactLayout = m_equationStore->exactSolutionLayoutAtIndex(j, true);
Poincare::LayoutReference approximateLayout = m_equationStore->exactSolutionLayoutAtIndex(j, false);
Poincare::Layout exactLayout = m_equationStore->exactSolutionLayoutAtIndex(j, true);
Poincare::Layout approximateLayout = m_equationStore->exactSolutionLayoutAtIndex(j, false);
KDCoordinate exactLayoutHeight = exactLayout.layoutSize().height();
KDCoordinate approximateLayoutHeight = approximateLayout.layoutSize().height();
KDCoordinate layoutHeight = max(exactLayout.baseline(), approximateLayout.baseline()) + max(exactLayoutHeight-exactLayout.baseline(), approximateLayoutHeight-approximateLayout.baseline());

View File

@@ -58,7 +58,7 @@ private:
EquationStore * m_equationStore;
EvenOddBufferTextCell m_symbolCells[EquationStore::k_maxNumberOfSolutions];
EvenOddExpressionCell m_deltaCell;
Poincare::LayoutReference m_delta2Layout;
Poincare::Layout m_delta2Layout;
Shared::ScrollableExactApproximateExpressionsCell m_exactValueCells[EquationStore::k_maxNumberOfExactSolutions];
EvenOddBufferTextCell m_approximateValueCells[EquationStore::k_maxNumberOfApproximateSolutions];
ContentView m_contentView;

View File

@@ -150,16 +150,16 @@ void VariableBoxController::ContentViewController::willDisplayCellForIndex(Highl
if (!evaluation.isUninitialized()) {
/* TODO: implement list contexts */
// TODO: handle matrix and scalar!
LayoutReference layoutR = layoutRefForIndex(index);
Layout layoutR = layoutForIndex(index);
const Matrix matrixEvaluation = static_cast<const Matrix&>(evaluation);
myCell->setLayoutReference(layoutR);
myCell->setLayout(layoutR);
char buffer[2*PrintFloat::bufferSizeForFloatsWithPrecision(2)+1];
int numberOfChars = PrintFloat::convertFloatToText<float>(matrixEvaluation.numberOfRows(), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(2), 2, Preferences::PrintFloatMode::Decimal);
buffer[numberOfChars++] = 'x';
PrintFloat::convertFloatToText<float>(matrixEvaluation.numberOfColumns(), buffer+numberOfChars, PrintFloat::bufferSizeForFloatsWithPrecision(2), 2, Preferences::PrintFloatMode::Decimal);
myCell->setSubtitle(buffer);
} else {
myCell->setLayoutReference(LayoutReference());
myCell->setLayout(Layout());
myCell->setSubtitle(I18n::translate(I18n::Message::Empty));
}
}
@@ -168,7 +168,7 @@ KDCoordinate VariableBoxController::ContentViewController::rowHeight(int index)
if (m_currentPage == Page::RootMenu || m_currentPage == Page::Scalar) {
return Metric::ToolboxRowHeight;
}
LayoutReference layoutR = layoutRefForIndex(index);
Layout layoutR = layoutForIndex(index);
if (!layoutR.isUninitialized()) {
return max(layoutR.layoutSize().height()+k_leafMargin, Metric::ToolboxRowHeight);
}
@@ -198,7 +198,7 @@ void VariableBoxController::ContentViewController::viewDidDisappear() {
m_selectableTableView.deselectTable();
// Tidy the layouts used to display the VariableBoxController to clean TreePool
for (int i = 0; i < k_maxNumberOfDisplayedRows; i++) {
m_leafCells[i].setLayoutReference(LayoutReference());
m_leafCells[i].setLayout(Layout());
}
ViewController::viewDidDisappear();
}
@@ -258,17 +258,17 @@ const Expression VariableBoxController::ContentViewController::expressionForInde
return Expression();
}
LayoutReference VariableBoxController::ContentViewController::layoutRefForIndex(int index) {
Layout VariableBoxController::ContentViewController::layoutForIndex(int index) {
if (m_currentPage == Page::Matrix) {
const Symbol symbol = Symbol::matrixSymbol('0'+(char)index);
return m_context->layoutForSymbol(symbol, Constant::ShortNumberOfSignificantDigits);
}
#if LIST_VARIABLES
if (m_currentPage == Page::List) {
return LayoutReference();
return Layout();
}
#endif
return LayoutReference();
return Layout();
}
VariableBoxController::VariableBoxController(GlobalContext * context) :

View File

@@ -53,7 +53,7 @@ private:
void putLabelAtIndexInBuffer(int index, char * buffer);
I18n::Message nodeLabelAtIndex(int index);
const Poincare::Expression expressionForIndex(int index);
Poincare::LayoutReference layoutRefForIndex(int index);
Poincare::Layout layoutForIndex(int index);
Poincare::GlobalContext * m_context;
Responder * m_sender;
int m_firstSelectedRow;

View File

@@ -76,8 +76,8 @@ void VariableBoxLeafCell::setSubtitle(const char * text) {
layoutSubviews();
}
void VariableBoxLeafCell::setLayoutReference(LayoutReference layoutRef) {
m_expressionView.setLayoutReference(layoutRef);
void VariableBoxLeafCell::setLayout(Layout layout) {
m_expressionView.setLayout(layout);
}
void VariableBoxLeafCell::drawRect(KDContext * ctx, KDRect rect) const {

View File

@@ -11,7 +11,7 @@ public:
void reloadCell() override;
void setLabel(const char * text);
void setSubtitle(const char * text);
void setLayoutReference(Poincare::LayoutReference layoutRef);
void setLayout(Poincare::Layout layout);
void drawRect(KDContext * ctx, KDRect rect) const override;
const char * text() const override {
return m_labelView.text();

View File

@@ -8,7 +8,7 @@ class Clipboard {
public:
static Clipboard * sharedClipboard();
void store(const char * storedText);
void store(Poincare::LayoutReference layoutR);
void store(Poincare::Layout layoutR);
const char * storedText();
void reset();
private:

View File

@@ -10,14 +10,14 @@ public:
KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite);
void setEven(bool even) override;
void setHighlighted(bool highlight) override;
void setLayoutReference(Poincare::LayoutReference layoutRef);
void setLayout(Poincare::Layout layout);
void setBackgroundColor(KDColor backgroundColor);
void setTextColor(KDColor textColor);
KDSize minimalSizeForOptimalDisplay() const override;
void setAlignment(float horizontalAlignment, float verticalAlignment) { m_expressionView.setAlignment(horizontalAlignment, verticalAlignment); }
void setLeftMargin(KDCoordinate margin);
void setRightMargin(KDCoordinate margin);
Poincare::LayoutReference layoutRef() const override { return m_expressionView.layoutRef(); }
Poincare::Layout layout() const override { return m_expressionView.layout(); }
void drawRect(KDContext * ctx, KDRect rect) const override;
protected:
int numberOfSubviews() const override;

View File

@@ -5,7 +5,7 @@
#include <escher/layout_field_delegate.h>
#include <escher/text_field.h>
#include <escher/text_field_delegate.h>
#include <poincare/layout_reference.h>
#include <poincare/layout.h>
class ExpressionField : public Responder, public View {
public:

View File

@@ -9,8 +9,8 @@ public:
ExpressionTableCell(Layout layout = Layout::Horizontal);
View * labelView() const override;
void setHighlighted(bool highlight) override;
void setLayoutReference(Poincare::LayoutReference layoutR);
Poincare::LayoutReference layoutRef() const override { return m_labelExpressionView.layoutRef(); }
void setLayout(Poincare::Layout layoutR);
Poincare::Layout layout() const override { return m_labelExpressionView.layout(); }
private:
ExpressionView m_labelExpressionView;
};

View File

@@ -3,7 +3,7 @@
#include <escher/view.h>
#include <kandinsky/color.h>
#include <poincare/layout_reference.h>
#include <poincare/layout.h>
/* This class does not handle the expression layout as the size of the layout is
* needed to compute the size of table cells hosting the expression. As the size
@@ -15,8 +15,8 @@ class ExpressionView : public View {
public:
ExpressionView(float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f,
KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite);
Poincare::LayoutReference layoutRef() const { return m_layoutRef; }
void setLayoutReference(Poincare::LayoutReference layoutRef);
Poincare::Layout layout() const { return m_layout; }
void setLayout(Poincare::Layout layout);
void drawRect(KDContext * ctx, KDRect rect) const override;
void setBackgroundColor(KDColor backgroundColor);
void setTextColor(KDColor textColor);
@@ -32,7 +32,7 @@ private:
* layout is always possessed by a controller which only gives a pointer to
* the expression view (without cloning it). The named controller is then
* responsible for freeing the expression layout when required. */
mutable Poincare::LayoutReference m_layoutRef; // TODO find better way to have minimalSizeForOptimalDisplay const
mutable Poincare::Layout m_layout; // TODO find better way to have minimalSizeForOptimalDisplay const
float m_horizontalAlignment;
float m_verticalAlignment;
KDColor m_textColor;

View File

@@ -4,7 +4,7 @@
#include <escher/view.h>
#include <escher/responder.h>
#include <poincare.h>
#include <poincare/layout_reference.h>
#include <poincare/layout.h>
class HighlightCell : public View {
public:
@@ -18,8 +18,8 @@ public:
virtual const char * text() const {
return nullptr;
}
virtual Poincare::LayoutReference layoutRef() const {
return Poincare::LayoutReference();
virtual Poincare::Layout layout() const {
return Poincare::Layout();
}
protected:
bool m_highlighted;

View File

@@ -29,7 +29,7 @@ public:
/* LayoutFieldDelegate */
bool layoutFieldShouldFinishEditing(LayoutField * layoutField, Ion::Events::Event event) override;
bool layoutFieldDidReceiveEvent(LayoutField * layoutField, Ion::Events::Event event) override;
bool layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::LayoutReference layoutR, Ion::Events::Event event) override;
bool layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::Layout layoutR, Ion::Events::Event event) override;
bool layoutFieldDidAbortEditing(LayoutField * layoutField) override;
void layoutFieldDidChangeSize(LayoutField * layoutField) override;
Toolbox * toolboxForLayoutField(LayoutField * layoutField) override;

View File

@@ -7,7 +7,7 @@
#include <escher/text_cursor_view.h>
#include <escher/text_field.h>
#include <kandinsky/point.h>
#include <poincare/layout_reference.h>
#include <poincare/layout.h>
#include <poincare/layout_cursor.h>
class LayoutField : public ScrollableView, public ScrollViewDataSource {
@@ -25,10 +25,10 @@ public:
scrollToBaselinedRect(m_contentView.cursorRect(), m_contentView.cursor()->baseline());
}
void reload();
bool hasText() const { return layoutRef().hasText(); }
int serialize(char * buffer, int bufferLength) { return layoutRef().serialize(buffer, bufferLength); }
Poincare::LayoutReference layoutRef() const { return m_contentView.expressionView()->layoutRef(); }
char XNTChar() { return m_contentView.cursor()->layoutReference().XNTChar(); }
bool hasText() const { return layout().hasText(); }
int serialize(char * buffer, int bufferLength) { return layout().serialize(buffer, bufferLength); }
Poincare::Layout layout() const { return m_contentView.expressionView()->layout(); }
char XNTChar() { return m_contentView.cursor()->layouterence().XNTChar(); }
// ScrollableView
void setBackgroundColor(KDColor c) override {
@@ -59,9 +59,9 @@ protected:
private:
constexpr static int k_maxNumberOfLayouts = 152;
static_assert(k_maxNumberOfLayouts == TextField::maxBufferSize(), "Maximal number of layouts in a layout field should be equal to max number of char in text field");
void scrollRightOfLayout(Poincare::LayoutReference layoutR);
void scrollRightOfLayout(Poincare::Layout layoutR);
void scrollToBaselinedRect(KDRect rect, KDCoordinate baseline);
void insertLayoutAtCursor(Poincare::LayoutReference layoutR, Poincare::LayoutReference pointedLayoutReference, bool forceCursorRightOfLayout = false);
void insertLayoutAtCursor(Poincare::Layout layoutR, Poincare::Layout pointedLayout, bool forceCursorRightOfLayout = false);
class ContentView : public View {
public:

View File

@@ -10,7 +10,7 @@ class LayoutFieldDelegate {
public:
virtual bool layoutFieldShouldFinishEditing(LayoutField * layoutField, Ion::Events::Event event) = 0;
virtual bool layoutFieldDidReceiveEvent(LayoutField * layoutField, Ion::Events::Event event) = 0;
virtual bool layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::LayoutReference layoutR, Ion::Events::Event event) { return false; }
virtual bool layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::Layout layoutR, Ion::Events::Event event) { return false; }
virtual bool layoutFieldDidAbortEditing(LayoutField * layoutField) { return false; }
virtual void layoutFieldDidChangeSize(LayoutField * layoutField) {}
virtual Toolbox * toolboxForLayoutField(LayoutField * layoutField) = 0;

View File

@@ -9,7 +9,7 @@ public:
MessageTableCellWithChevronAndExpression(I18n::Message message = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small);
View * subAccessoryView() const override;
void setHighlighted(bool highlight) override;
void setLayoutReference(Poincare::LayoutReference layoutR);
void setLayout(Poincare::Layout layoutR);
private:
ExpressionView m_subtitleView;
};

View File

@@ -9,7 +9,7 @@ public:
MessageTableCellWithExpression(I18n::Message message = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small);
View * accessoryView() const override;
void setHighlighted(bool highlight) override;
void setLayoutReference(Poincare::LayoutReference layout);
void setLayout(Poincare::Layout layout);
private:
ExpressionView m_subtitleView;
};

View File

@@ -10,7 +10,7 @@ void Clipboard::store(const char * storedText) {
strlcpy(m_textBuffer, storedText, TextField::maxBufferSize());
}
void Clipboard::store(Poincare::LayoutReference layoutR) {
void Clipboard::store(Poincare::Layout layoutR) {
layoutR.serialize(m_textBuffer, TextField::maxBufferSize());
}

View File

@@ -23,8 +23,8 @@ void EvenOddExpressionCell::setEven(bool even) {
m_expressionView.setBackgroundColor(backgroundColor());
}
void EvenOddExpressionCell::setLayoutReference(LayoutReference layoutR) {
m_expressionView.setLayoutReference(layoutR);
void EvenOddExpressionCell::setLayout(Layout layoutR) {
m_expressionView.setLayout(layoutR);
}
void EvenOddExpressionCell::setBackgroundColor(KDColor backgroundColor) {

View File

@@ -18,7 +18,7 @@ void ExpressionTableCell::setHighlighted(bool highlight) {
m_labelExpressionView.setBackgroundColor(backgroundColor);
}
void ExpressionTableCell::setLayoutReference(Poincare::LayoutReference layoutR) {
m_labelExpressionView.setLayoutReference(layoutR);
void ExpressionTableCell::setLayout(Poincare::Layout layoutR) {
m_labelExpressionView.setLayout(layoutR);
layoutSubviews();
}

View File

@@ -3,7 +3,7 @@ using namespace Poincare;
ExpressionView::ExpressionView(float horizontalAlignment, float verticalAlignment,
KDColor textColor, KDColor backgroundColor) :
m_layoutRef(),
m_layout(),
m_horizontalAlignment(horizontalAlignment),
m_verticalAlignment(verticalAlignment),
m_textColor(textColor),
@@ -12,8 +12,8 @@ ExpressionView::ExpressionView(float horizontalAlignment, float verticalAlignmen
{
}
void ExpressionView::setLayoutReference(LayoutReference layoutR) {
m_layoutRef = layoutR;
void ExpressionView::setLayout(Layout layoutR) {
m_layout = layoutR;
markRectAsDirty(bounds());
}
@@ -38,19 +38,19 @@ void ExpressionView::setAlignment(float horizontalAlignment, float verticalAlign
}
int ExpressionView::numberOfLayouts() const {
return m_layoutRef.numberOfDescendants(true);
return m_layout.numberOfDescendants(true);
}
KDSize ExpressionView::minimalSizeForOptimalDisplay() const {
if (m_layoutRef.isUninitialized()) {
if (m_layout.isUninitialized()) {
return KDSizeZero;
}
KDSize expressionSize = m_layoutRef.layoutSize();
KDSize expressionSize = m_layout.layoutSize();
return KDSize(expressionSize.width() + 2*m_horizontalMargin, expressionSize.height());
}
KDPoint ExpressionView::drawingOrigin() const {
KDSize expressionSize = m_layoutRef.layoutSize();
KDSize expressionSize = m_layout.layoutSize();
return KDPoint(m_horizontalMargin + m_horizontalAlignment*(m_frame.width() - 2*m_horizontalMargin - expressionSize.width()), max(0, (m_frame.height() - expressionSize.height())/2));
}
@@ -60,7 +60,7 @@ KDPoint ExpressionView::absoluteDrawingOrigin() const {
void ExpressionView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(rect, m_backgroundColor);
if (!m_layoutRef.isUninitialized()) {
m_layoutRef.draw(ctx, drawingOrigin(), m_textColor, m_backgroundColor);
if (!m_layout.isUninitialized()) {
m_layout.draw(ctx, drawingOrigin(), m_textColor, m_backgroundColor);
}
}

View File

@@ -76,7 +76,7 @@ bool InputViewController::layoutFieldDidReceiveEvent(LayoutField * layoutField,
return m_layoutFieldDelegate->layoutFieldDidReceiveEvent(layoutField, event);
}
bool InputViewController::layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::LayoutReference layoutR, Ion::Events::Event event) {
bool InputViewController::layoutFieldDidFinishEditing(LayoutField * layoutField, Poincare::Layout layoutR, Ion::Events::Event event) {
inputViewDidFinishEditing();
m_layoutFieldDelegate->layoutFieldDidFinishEditing(layoutField, layoutR, event);
return true;

View File

@@ -25,9 +25,9 @@ void LayoutField::ContentView::setEditing(bool isEditing) {
}
void LayoutField::ContentView::clearLayout() {
HorizontalLayoutReference h;
m_expressionView.setLayoutReference(h);
m_cursor.setLayoutReference(h);
HorizontalLayout h;
m_expressionView.setLayout(h);
m_cursor.setLayout(h);
}
KDSize LayoutField::ContentView::minimalSizeForOptimalDisplay() const {
@@ -52,11 +52,11 @@ void LayoutField::ContentView::layoutCursorSubview() {
return;
}
KDPoint expressionViewOrigin = m_expressionView.absoluteDrawingOrigin();
LayoutReference pointedLayoutR = m_cursor.layoutReference();
Layout pointedLayoutR = m_cursor.layouterence();
LayoutCursor::Position cursorPosition = m_cursor.position();
LayoutCursor eqCursor = pointedLayoutR.equivalentCursor(&m_cursor);
if (eqCursor.isDefined() && pointedLayoutR.hasChild(eqCursor.layoutReference())) {
pointedLayoutR = eqCursor.layoutReference();
if (eqCursor.isDefined() && pointedLayoutR.hasChild(eqCursor.layouterence())) {
pointedLayoutR = eqCursor.layouterence();
cursorPosition = eqCursor.position();
}
KDPoint cursoredExpressionViewOrigin = pointedLayoutR.absoluteOrigin();
@@ -70,7 +70,7 @@ void LayoutField::ContentView::layoutCursorSubview() {
void LayoutField::reload() {
KDSize previousSize = minimalSizeForOptimalDisplay();
layoutRef().invalidAllSizesPositionsAndBaselines();
layout().invalidAllSizesPositionsAndBaselines();
KDSize newSize = minimalSizeForOptimalDisplay();
if (m_delegate && previousSize.height() != newSize.height()) {
m_delegate->layoutFieldDidChangeSize(this);
@@ -114,30 +114,30 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool
if (resultExpression.isUninitialized()) {
m_contentView.cursor()->insertText(text);
} else {
LayoutReference resultLayoutReference = resultExpression.createLayout(Poincare::Preferences::sharedPreferences()->displayMode(), Poincare::PrintFloat::k_numberOfStoredSignificantDigits);
if (currentNumberOfLayouts + resultLayoutReference.numberOfDescendants(true) >= k_maxNumberOfLayouts) {
Layout resultLayout = resultExpression.createLayout(Poincare::Preferences::sharedPreferences()->displayMode(), Poincare::PrintFloat::k_numberOfStoredSignificantDigits);
if (currentNumberOfLayouts + resultLayout.numberOfDescendants(true) >= k_maxNumberOfLayouts) {
return true;
}
// Find the pointed layout.
LayoutReference pointedLayoutReference;
Layout pointedLayout;
if (strcmp(text, I18n::translate(I18n::Message::RandomCommandWithArg)) == 0) {
/* Special case: if the text is "random()", the cursor should not be set
* inside the parentheses. */
pointedLayoutReference = resultLayoutReference;
} else if (resultLayoutReference.isHorizontal()) {
pointedLayout = resultLayout;
} else if (resultLayout.isHorizontal()) {
/* If the layout is horizontal, pick the first open parenthesis. For now,
* all horizontal layouts in MathToolbox have parentheses. */
for (int i = 0; i < resultLayoutReference.numberOfChildren(); i++) {
LayoutReference l = resultLayoutReference.childAtIndex(i);
for (int i = 0; i < resultLayout.numberOfChildren(); i++) {
Layout l = resultLayout.childAtIndex(i);
if (l.isLeftParenthesis()) {
pointedLayoutReference = l;
pointedLayout = l;
break;
}
}
}
/* Insert the layout. If pointedLayout is uninitialized, the cursor will
* be on the right of the inserted layout. */
insertLayoutAtCursor(resultLayoutReference, pointedLayoutReference, forceCursorRightOfText);
insertLayoutAtCursor(resultLayout, pointedLayout, forceCursorRightOfText);
}
}
return true;
@@ -185,14 +185,14 @@ bool LayoutField::privateHandleEvent(Ion::Events::Event event) {
}
if (isEditing() && m_delegate->layoutFieldShouldFinishEditing(this, event)) { //TODO use class method?
setEditing(false);
if (m_delegate->layoutFieldDidFinishEditing(this, layoutRef(), event)) {
if (m_delegate->layoutFieldDidFinishEditing(this, layout(), event)) {
clearLayout();
}
return true;
}
if ((event == Ion::Events::OK || event == Ion::Events::EXE) && !isEditing()) {
setEditing(true);
m_contentView.cursor()->setLayoutReference(layoutRef());
m_contentView.cursor()->setLayout(layout());
m_contentView.cursor()->setPosition(LayoutCursor::Position::Right);
return true;
}
@@ -235,16 +235,16 @@ bool LayoutField::privateHandleMoveEvent(Ion::Events::Event event, bool * should
result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::MoveDirection::Down, shouldRecomputeLayout);
} else if (event == Ion::Events::ShiftLeft) {
*shouldRecomputeLayout = true;
if (m_contentView.cursor()->layoutReference().removeGreySquaresFromAllMatrixAncestors()) {
if (m_contentView.cursor()->layouterence().removeGreySquaresFromAllMatrixAncestors()) {
*shouldRecomputeLayout = true;
}
result.setLayoutReference(layoutRef());
result.setLayout(layout());
result.setPosition(LayoutCursor::Position::Left);
} else if (event == Ion::Events::ShiftRight) {
if (m_contentView.cursor()->layoutReference().removeGreySquaresFromAllMatrixAncestors()) {
if (m_contentView.cursor()->layouterence().removeGreySquaresFromAllMatrixAncestors()) {
*shouldRecomputeLayout = true;
}
result.setLayoutReference(layoutRef());
result.setLayout(layout());
result.setPosition(LayoutCursor::Position::Right);
}
if (result.isDefined()) {
@@ -254,7 +254,7 @@ bool LayoutField::privateHandleMoveEvent(Ion::Events::Event event, bool * should
return false;
}
void LayoutField::scrollRightOfLayout(LayoutReference layoutR) {
void LayoutField::scrollRightOfLayout(Layout layoutR) {
KDRect layoutRect(layoutR.absoluteOrigin().translatedBy(m_contentView.expressionView()->drawingOrigin()), layoutR.layoutSize());
scrollToBaselinedRect(layoutRect, layoutR.baseline());
}
@@ -269,7 +269,7 @@ void LayoutField::scrollToBaselinedRect(KDRect rect, KDCoordinate baseline) {
scrollToContentRect(balancedRect, true);
}
void LayoutField::insertLayoutAtCursor(LayoutReference layoutR, LayoutReference pointedLayoutR, bool forceCursorRightOfLayout) {
void LayoutField::insertLayoutAtCursor(Layout layoutR, Layout pointedLayoutR, bool forceCursorRightOfLayout) {
if (layoutR.isUninitialized()) {
return;
}
@@ -278,7 +278,7 @@ void LayoutField::insertLayoutAtCursor(LayoutReference layoutR, LayoutReference
m_contentView.cursor()->showEmptyLayoutIfNeeded();
bool layoutWillBeMerged = layoutR.isHorizontal();
LayoutReference lastMergedLayoutChild = layoutWillBeMerged ? layoutR.childAtIndex(layoutR.numberOfChildren()-1) : LayoutReference();
Layout lastMergedLayoutChild = layoutWillBeMerged ? layoutR.childAtIndex(layoutR.numberOfChildren()-1) : Layout();
// Add the layout
m_contentView.cursor()->addLayoutAndMoveCursor(layoutR);
@@ -287,19 +287,19 @@ void LayoutField::insertLayoutAtCursor(LayoutReference layoutR, LayoutReference
if(!forceCursorRightOfLayout) {
if (!pointedLayoutR.isUninitialized() && (!layoutWillBeMerged || pointedLayoutR != layoutR)) {
// Make sure the layout was inserted (its parent is not uninitialized)
m_contentView.cursor()->setLayoutReference(pointedLayoutR);
m_contentView.cursor()->setLayout(pointedLayoutR);
m_contentView.cursor()->setPosition(LayoutCursor::Position::Right);
} else if (!layoutWillBeMerged) {
m_contentView.cursor()->setLayoutReference(layoutR.layoutToPointWhenInserting());
m_contentView.cursor()->setLayout(layoutR.layoutToPointWhenInserting());
m_contentView.cursor()->setPosition(LayoutCursor::Position::Right);
}
} else if (!layoutWillBeMerged) {
m_contentView.cursor()->setLayoutReference(layoutR);
m_contentView.cursor()->setLayout(layoutR);
m_contentView.cursor()->setPosition(LayoutCursor::Position::Right);
}
// Handle matrices
m_contentView.cursor()->layoutReference().addGreySquaresToAllMatrixAncestors();
m_contentView.cursor()->layouterence().addGreySquaresToAllMatrixAncestors();
// Handle empty layouts
m_contentView.cursor()->hideEmptyLayoutIfNeeded();

View File

@@ -17,8 +17,8 @@ void MessageTableCellWithChevronAndExpression::setHighlighted(bool highlight) {
m_subtitleView.setBackgroundColor(backgroundColor);
}
void MessageTableCellWithChevronAndExpression::setLayoutReference(Poincare::LayoutReference layoutR) {
m_subtitleView.setLayoutReference(layoutR);
void MessageTableCellWithChevronAndExpression::setLayout(Poincare::Layout layoutR) {
m_subtitleView.setLayout(layoutR);
reloadCell();
layoutSubviews();
}

View File

@@ -17,8 +17,8 @@ void MessageTableCellWithExpression::setHighlighted(bool highlight) {
m_subtitleView.setBackgroundColor(backgroundColor);
}
void MessageTableCellWithExpression::setLayoutReference(Poincare::LayoutReference layout) {
m_subtitleView.setLayoutReference(layout);
void MessageTableCellWithExpression::setLayout(Poincare::Layout layout) {
m_subtitleView.setLayout(layout);
reloadCell();
layoutSubviews();
}

View File

@@ -128,7 +128,7 @@ bool SelectableTableView::handleEvent(Ion::Events::Event event) {
Clipboard::sharedClipboard()->store(text);
return true;
}
Poincare::LayoutReference layoutR = cell->layoutRef();
Poincare::Layout layoutR = cell->layout();
if (!layoutR.isUninitialized()) {
Clipboard::sharedClipboard()->store(layoutR);
return true;

View File

@@ -17,7 +17,7 @@ objs += $(addprefix poincare/src/,\
integral_layout.o\
layout_cursor.o\
layout.o\
layout_reference.o\
layout_node.o\
left_parenthesis_layout.o\
left_square_bracket_layout.o\
matrix_layout.o\

View File

@@ -17,7 +17,6 @@
#include <poincare/integral_layout.h>
#include <poincare/layout_cursor.h>
#include <poincare/layout.h>
#include <poincare/layout_reference.h>
#include <poincare/left_parenthesis_layout.h>
#include <poincare/left_square_bracket_layout.h>
#include <poincare/matrix_layout.h>

View File

@@ -34,7 +34,7 @@ public:
}
// Layout
LayoutReference createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
Layout createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "abs");
}

View File

@@ -30,10 +30,10 @@ private:
bool renderBottomBar() const override { return false; }
};
class AbsoluteValueLayoutReference : public LayoutReference {
class AbsoluteValueLayout : public Layout {
public:
explicit AbsoluteValueLayoutReference(LayoutReference l) :
LayoutReference(TreePool::sharedPool()->createTreeNode<AbsoluteValueLayoutNode>())
explicit AbsoluteValueLayout(Layout l) :
Layout(TreePool::sharedPool()->createTreeNode<AbsoluteValueLayoutNode>())
{
replaceChildAtIndexInPlace(0, l);
}

Some files were not shown because too many files have changed in this diff Show More