mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-28 01:59:59 +01:00
[poincare] Remove outdated layouts, such as StringLayout.
Change-Id: I351113cd9a14a1c48896ac9f56153a8513d36a16
This commit is contained in:
@@ -84,7 +84,6 @@ objs += $(addprefix poincare/src/,\
|
||||
|
||||
objs += $(addprefix poincare/src/layout/,\
|
||||
absolute_value_layout.o\
|
||||
baseline_relative_layout.o\
|
||||
bracket_layout.o\
|
||||
bracket_left_layout.o\
|
||||
bracket_left_right_layout.o\
|
||||
@@ -94,8 +93,6 @@ objs += $(addprefix poincare/src/layout/,\
|
||||
condensed_sum_layout.o\
|
||||
conjugate_layout.o\
|
||||
dynamic_layout_hierarchy.o\
|
||||
editable_baseline_relative_layout.o\
|
||||
editable_string_layout.o\
|
||||
empty_layout.o\
|
||||
empty_visible_layout.o\
|
||||
expression_layout.o\
|
||||
@@ -112,11 +109,7 @@ objs += $(addprefix poincare/src/layout/,\
|
||||
product_layout.o\
|
||||
sequence_layout.o\
|
||||
static_layout_hierarchy.o\
|
||||
string_layout.o\
|
||||
sum_layout.o\
|
||||
uneditable_horizontal_trio_layout.o\
|
||||
uneditable_parenthesis_left_layout.o\
|
||||
uneditable_parenthesis_right_layout.o\
|
||||
vertical_offset_layout.o\
|
||||
)
|
||||
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
#include "baseline_relative_layout.h"
|
||||
#include "empty_visible_layout.h"
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
BaselineRelativeLayout::BaselineRelativeLayout(ExpressionLayout * base, ExpressionLayout * indice, Type type, bool cloneOperands) :
|
||||
StaticLayoutHierarchy(base, indice, cloneOperands),
|
||||
m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
ExpressionLayout * BaselineRelativeLayout::clone() const {
|
||||
BaselineRelativeLayout * layout = new BaselineRelativeLayout(const_cast<BaselineRelativeLayout *>(this)->baseLayout(), const_cast<BaselineRelativeLayout *>(this)->indiceLayout(), m_type, true);
|
||||
return layout;
|
||||
}
|
||||
|
||||
void BaselineRelativeLayout::backspaceAtCursor(ExpressionLayoutCursor * cursor) {
|
||||
if (cursor->pointedExpressionLayout() == indiceLayout()
|
||||
|| (cursor->pointedExpressionLayout() == this
|
||||
&& cursor->position() == ExpressionLayoutCursor::Position::Right))
|
||||
{
|
||||
ExpressionLayout * previousParent = m_parent;
|
||||
int indexInParent = previousParent->indexOfChild(this);
|
||||
replaceWith(new EmptyVisibleLayout(), true);
|
||||
if (indexInParent == 0) {
|
||||
cursor->setPointedExpressionLayout(previousParent);
|
||||
return;
|
||||
}
|
||||
cursor->setPointedExpressionLayout(previousParent->editableChild(indexInParent - 1));
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return;
|
||||
}
|
||||
ExpressionLayout::backspaceAtCursor(cursor);
|
||||
}
|
||||
|
||||
bool BaselineRelativeLayout::moveLeft(ExpressionLayoutCursor * cursor) {
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Case: Right.
|
||||
// Go Left.
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Right) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
return true;
|
||||
}
|
||||
// Case: Left.
|
||||
// Ask the parent.
|
||||
assert(cursor->position() == ExpressionLayoutCursor::Position::Left);
|
||||
if (m_parent) {
|
||||
return m_parent->moveLeft(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BaselineRelativeLayout::moveRight(ExpressionLayoutCursor * cursor) {
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Case: Left.
|
||||
// Go Right.
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Left) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return true;
|
||||
}
|
||||
// Case: Right.
|
||||
// Ask the parent.
|
||||
assert(cursor->position() == ExpressionLayoutCursor::Position::Right);
|
||||
if (m_parent) {
|
||||
return m_parent->moveRight(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int BaselineRelativeLayout::writeTextInBuffer(char * buffer, int bufferSize) const {
|
||||
if (m_type == Type::Subscript) {
|
||||
if (bufferSize == 0) {
|
||||
return -1;
|
||||
}
|
||||
buffer[bufferSize-1] = 0;
|
||||
if (bufferSize == 1) {
|
||||
return 0;
|
||||
}
|
||||
int numberOfChars = LayoutEngine::writeInfixExpressionLayoutTextInBuffer(this, buffer, bufferSize, "_{");
|
||||
if (numberOfChars < bufferSize - 1) {
|
||||
//FIXME what if the buffer is not big enough?
|
||||
buffer[numberOfChars++] = '}';
|
||||
buffer[numberOfChars] = 0;
|
||||
}
|
||||
return numberOfChars;
|
||||
}
|
||||
assert(m_type == Type::Superscript);
|
||||
return LayoutEngine::writeInfixExpressionLayoutTextInBuffer(this, buffer, bufferSize, "^");
|
||||
}
|
||||
|
||||
ExpressionLayout * BaselineRelativeLayout::baseLayout() {
|
||||
return editableChild(0);
|
||||
}
|
||||
|
||||
ExpressionLayout * BaselineRelativeLayout::indiceLayout() {
|
||||
return editableChild(1);
|
||||
}
|
||||
|
||||
void BaselineRelativeLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
|
||||
// There is nothing to draw for a subscript/superscript, only the position of the children matters
|
||||
}
|
||||
|
||||
KDSize BaselineRelativeLayout::computeSize() {
|
||||
KDSize baseSize = baseLayout()->size();
|
||||
KDSize indiceSize = indiceLayout()->size();
|
||||
return KDSize(baseSize.width() + indiceSize.width(), baseSize.height() + indiceSize.height() - k_indiceHeight);
|
||||
}
|
||||
|
||||
void BaselineRelativeLayout::computeBaseline() {
|
||||
m_baseline = m_type == Type::Subscript ? baseLayout()->baseline() :
|
||||
indiceLayout()->size().height() + baseLayout()->baseline() - k_indiceHeight;
|
||||
m_baselined = true;
|
||||
}
|
||||
|
||||
KDPoint BaselineRelativeLayout::positionOfChild(ExpressionLayout * child) {
|
||||
KDCoordinate x = 0;
|
||||
KDCoordinate y = 0;
|
||||
if (child == baseLayout() && m_type == Type::Superscript) {
|
||||
x = 0;
|
||||
y = indiceLayout()->size().height() - k_indiceHeight;
|
||||
}
|
||||
if (child == indiceLayout()) {
|
||||
x = baseLayout()->size().width();
|
||||
y = m_type == Type::Superscript ? 0 : baseLayout()->size().height() - k_indiceHeight;
|
||||
}
|
||||
return KDPoint(x,y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef POINCARE_BASELINE_RELATIVE_LAYOUT_H
|
||||
#define POINCARE_BASELINE_RELATIVE_LAYOUT_H
|
||||
|
||||
#include <poincare/static_layout_hierarchy.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class BaselineRelativeLayout : public StaticLayoutHierarchy<2> {
|
||||
public:
|
||||
enum class Type {
|
||||
Subscript,
|
||||
Superscript
|
||||
};
|
||||
BaselineRelativeLayout(ExpressionLayout * base, ExpressionLayout * indice, Type type, bool cloneOperands);
|
||||
ExpressionLayout * clone() const override;
|
||||
void backspaceAtCursor(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor) override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize) const override;
|
||||
protected:
|
||||
ExpressionLayout * baseLayout();
|
||||
ExpressionLayout * indiceLayout();
|
||||
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
|
||||
KDSize computeSize() override;
|
||||
void computeBaseline() override;
|
||||
KDPoint positionOfChild(ExpressionLayout * child) override;
|
||||
Type m_type;
|
||||
private:
|
||||
constexpr static KDCoordinate k_indiceHeight = 5;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,244 +0,0 @@
|
||||
#include "editable_baseline_relative_layout.h"
|
||||
#include "empty_visible_layout.h"
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
ExpressionLayout * EditableBaselineRelativeLayout::clone() const {
|
||||
EditableBaselineRelativeLayout * layout = new EditableBaselineRelativeLayout(const_cast<EditableBaselineRelativeLayout *>(this)->baseLayout(), const_cast<EditableBaselineRelativeLayout *>(this)->indiceLayout(), m_type, true);
|
||||
return layout;
|
||||
}
|
||||
|
||||
void EditableBaselineRelativeLayout::backspaceAtCursor(ExpressionLayoutCursor * cursor) {
|
||||
if (cursor->pointedExpressionLayout() == indiceLayout()) {
|
||||
if (m_type == Type::Superscript) {
|
||||
assert(cursor->position() == ExpressionLayoutCursor::Position::Left);
|
||||
ExpressionLayout * base = baseLayout();
|
||||
ExpressionLayout * pointedLayout = base;
|
||||
if (base->isHorizontal()) {
|
||||
pointedLayout = base->editableChild(base->numberOfChildren()-1);
|
||||
}
|
||||
if (indiceLayout()->isEmpty()) {
|
||||
if (baseLayout()->isEmpty()) {
|
||||
// Case: Empty base and indice.
|
||||
// Replace with an empty layout.
|
||||
int indexInParent = m_parent->indexOfChild(this);
|
||||
if (indexInParent == 0) {
|
||||
pointedLayout = m_parent;
|
||||
replaceWith(base, true);
|
||||
cursor->setPointedExpressionLayout(pointedLayout);
|
||||
return;
|
||||
}
|
||||
pointedLayout = m_parent->editableChild(indexInParent - 1);
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
replaceWith(base, true);
|
||||
cursor->setPointedExpressionLayout(pointedLayout);
|
||||
return;
|
||||
}
|
||||
// Case: Empty indice only.
|
||||
// Replace with the base.
|
||||
replaceWith(base, true);
|
||||
cursor->setPointedExpressionLayout(pointedLayout);
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return;
|
||||
}
|
||||
// Case: Non-empty indice.
|
||||
// Move to the base.
|
||||
cursor->setPointedExpressionLayout(pointedLayout);
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return;
|
||||
}
|
||||
assert(m_type == Type::Subscript);
|
||||
ExpressionLayout * previousParent = m_parent;
|
||||
int indexInParent = previousParent->indexOfChild(this);
|
||||
replaceWith(new EmptyVisibleLayout(), true);
|
||||
if (indexInParent == 0) {
|
||||
cursor->setPointedExpressionLayout(previousParent);
|
||||
return;
|
||||
}
|
||||
cursor->setPointedExpressionLayout(previousParent->editableChild(indexInParent - 1));
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return;
|
||||
}
|
||||
ExpressionLayout::backspaceAtCursor(cursor);
|
||||
}
|
||||
|
||||
bool EditableBaselineRelativeLayout::moveLeft(ExpressionLayoutCursor * cursor) {
|
||||
// Case: Left of the indice.
|
||||
// Go from the indice to the base.
|
||||
if (indiceLayout()
|
||||
&& cursor->pointedExpressionLayout() == indiceLayout()
|
||||
&& cursor->position() == ExpressionLayoutCursor::Position::Left)
|
||||
{
|
||||
assert(baseLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(baseLayout());
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return true;
|
||||
}
|
||||
// Case: Left of the base.
|
||||
// Ask the parent.
|
||||
if (baseLayout()
|
||||
&& cursor->pointedExpressionLayout() == baseLayout()
|
||||
&& cursor->position() == ExpressionLayoutCursor::Position::Left)
|
||||
{
|
||||
cursor->setPointedExpressionLayout(this);
|
||||
if (m_parent) {
|
||||
return m_parent->moveLeft(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Case: Right.
|
||||
// Go to the indice.
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Right) {
|
||||
assert(indiceLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(indiceLayout());
|
||||
return true;
|
||||
}
|
||||
// Case: Left.
|
||||
// Ask the parent.
|
||||
assert(cursor->position() == ExpressionLayoutCursor::Position::Left);
|
||||
if (m_parent) {
|
||||
return m_parent->moveLeft(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditableBaselineRelativeLayout::moveRight(ExpressionLayoutCursor * cursor) {
|
||||
// Case: Right of the base.
|
||||
// Go from the base to the indice.
|
||||
if (baseLayout()
|
||||
&& cursor->pointedExpressionLayout() == baseLayout()
|
||||
&& cursor->position() == ExpressionLayoutCursor::Position::Right)
|
||||
{
|
||||
assert(indiceLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(indiceLayout());
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
return true;
|
||||
}
|
||||
// Case: Right of the indice.
|
||||
// Go Right.
|
||||
if (indiceLayout()
|
||||
&& cursor->pointedExpressionLayout() == indiceLayout()
|
||||
&& cursor->position() == ExpressionLayoutCursor::Position::Right)
|
||||
{
|
||||
cursor->setPointedExpressionLayout(this);
|
||||
return true;
|
||||
}
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Case: Left.
|
||||
// Go to the base and move Right.
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Left) {
|
||||
assert(baseLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(baseLayout());
|
||||
return baseLayout()->moveRight(cursor);
|
||||
}
|
||||
// Case: Right.
|
||||
// Ask the parent.
|
||||
assert(cursor->position() == ExpressionLayoutCursor::Position::Right);
|
||||
cursor->setPointedExpressionLayout(this);
|
||||
if (m_parent) {
|
||||
return m_parent->moveRight(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditableBaselineRelativeLayout::moveUp(ExpressionLayoutCursor * cursor, ExpressionLayout * previousLayout, ExpressionLayout * previousPreviousLayout) {
|
||||
// If the baseline is a superscript:
|
||||
if (m_type == BaselineRelativeLayout::Type::Superscript) {
|
||||
// If the cursor is Right of the base layout, move it to the indice.
|
||||
if (baseLayout()
|
||||
&& previousLayout == baseLayout()
|
||||
&& cursor->positionIsEquivalentTo(baseLayout(), ExpressionLayoutCursor::Position::Right))
|
||||
{
|
||||
assert(indiceLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(indiceLayout());
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
cursor->setPositionInside(0);
|
||||
return true;
|
||||
}
|
||||
// If the cursor is Right, move it to the indice.
|
||||
if (cursor->positionIsEquivalentTo(this, ExpressionLayoutCursor::Position::Right)) {
|
||||
assert(indiceLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(indiceLayout());
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
cursor->setPositionInside(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// If the baseline is a subscript:
|
||||
if (m_type == BaselineRelativeLayout::Type::Subscript
|
||||
&& indiceLayout()
|
||||
&& previousLayout == indiceLayout())
|
||||
{
|
||||
// If the cursor is Left of the indice layout, move it to the base.
|
||||
if (cursor->positionIsEquivalentTo(indiceLayout(), ExpressionLayoutCursor::Position::Left)) {
|
||||
assert(baseLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(baseLayout());
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
cursor->setPositionInside(0);
|
||||
return true;
|
||||
}
|
||||
// If the cursor is Right of the indice layout, move it Right.
|
||||
if (cursor->positionIsEquivalentTo(indiceLayout(), ExpressionLayoutCursor::Position::Right)) {
|
||||
cursor->setPointedExpressionLayout(this);
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
cursor->setPositionInside(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return ExpressionLayout::moveUp(cursor, previousLayout, previousPreviousLayout);
|
||||
}
|
||||
|
||||
bool EditableBaselineRelativeLayout::moveDown(ExpressionLayoutCursor * cursor, ExpressionLayout * previousLayout, ExpressionLayout * previousPreviousLayout) {
|
||||
// If the baseline is a subscript:
|
||||
if (m_type == BaselineRelativeLayout::Type::Subscript) {
|
||||
// If the cursor is Right of the base layout, move it to the indice.
|
||||
if (baseLayout()
|
||||
&& previousLayout == baseLayout()
|
||||
&& cursor->positionIsEquivalentTo(baseLayout(), ExpressionLayoutCursor::Position::Right))
|
||||
{
|
||||
assert(indiceLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(indiceLayout());
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
cursor->setPositionInside(0);
|
||||
return true;
|
||||
}
|
||||
// If the cursor is Right, move it to the indice.
|
||||
if (cursor->positionIsEquivalentTo(this, ExpressionLayoutCursor::Position::Right)) {
|
||||
assert(indiceLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(indiceLayout());
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
cursor->setPositionInside(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// If the baseline is a superscript:
|
||||
if (m_type == BaselineRelativeLayout::Type::Superscript
|
||||
&& indiceLayout()
|
||||
&& previousLayout == indiceLayout())
|
||||
{
|
||||
// If the cursor is Left of the indice layout, move it to the base.
|
||||
if (cursor->positionIsEquivalentTo(indiceLayout(), ExpressionLayoutCursor::Position::Left)) {
|
||||
assert(indiceLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(baseLayout());
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
cursor->setPositionInside(0);
|
||||
return true;
|
||||
}
|
||||
// If the cursor is Right of the indice layout, move it Right.
|
||||
if (cursor->positionIsEquivalentTo(indiceLayout(), ExpressionLayoutCursor::Position::Right)) {
|
||||
assert(indiceLayout() != nullptr);
|
||||
cursor->setPointedExpressionLayout(this);
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
cursor->setPositionInside(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return ExpressionLayout::moveDown(cursor, previousLayout, previousPreviousLayout);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef POINCARE_EDITABLE_BASELINE_RELATIVE_LAYOUT_H
|
||||
#define POINCARE_EDITABLE_BASELINE_RELATIVE_LAYOUT_H
|
||||
|
||||
#include "baseline_relative_layout.h"
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class EditableBaselineRelativeLayout : public BaselineRelativeLayout {
|
||||
public:
|
||||
using BaselineRelativeLayout::BaselineRelativeLayout;
|
||||
ExpressionLayout * clone() const override;
|
||||
void backspaceAtCursor(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, ExpressionLayout * previousLayout, ExpressionLayout * previousPreviousLayout) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, ExpressionLayout * previousLayout, ExpressionLayout * previousPreviousLayout) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,122 +0,0 @@
|
||||
#include "editable_string_layout.h"
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
ExpressionLayout * EditableStringLayout::clone() const {
|
||||
EditableStringLayout * layout = new EditableStringLayout(m_string, strlen(m_string), m_fontSize);
|
||||
return layout;
|
||||
}
|
||||
|
||||
bool EditableStringLayout::moveLeft(ExpressionLayoutCursor * cursor) {
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Case: Right.
|
||||
// Go before the last char.
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Right) {
|
||||
size_t stringLength = strlen(m_string);
|
||||
if (stringLength > 1) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Inside);
|
||||
cursor->setPositionInside(stringLength - 1);
|
||||
return true;
|
||||
}
|
||||
if (stringLength == 1) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
return true;
|
||||
}
|
||||
assert(stringLength == 0);
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
if (m_parent) {
|
||||
return m_parent->moveLeft(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Case: Inside.
|
||||
// Go one char left.
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Inside) {
|
||||
int cursorIndex = cursor->positionInside();
|
||||
assert(cursorIndex > 0 && cursorIndex < strlen(m_string));
|
||||
if (cursorIndex == 1) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
return true;
|
||||
}
|
||||
cursor->setPositionInside(cursorIndex - 1);
|
||||
return true;
|
||||
}
|
||||
// Case: Left.
|
||||
// Ask the parent.
|
||||
if (m_parent) {
|
||||
return m_parent->moveLeft(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditableStringLayout::moveRight(ExpressionLayoutCursor * cursor) {
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Case: Left.
|
||||
// Go after the first char.
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Left) {
|
||||
size_t stringLength = strlen(m_string);
|
||||
if (stringLength > 1) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Inside);
|
||||
cursor->setPositionInside(1);
|
||||
return true;
|
||||
}
|
||||
if (stringLength == 1) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return true;
|
||||
}
|
||||
assert(stringLength == 0);
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
if (m_parent) {
|
||||
return m_parent->moveRight(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Case: Inside.
|
||||
// Go one char right.
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Inside) {
|
||||
int cursorIndex = cursor->positionInside();
|
||||
assert(cursorIndex > 0 && cursorIndex < strlen(m_string));
|
||||
if (cursorIndex == strlen(m_string)-1) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return true;
|
||||
}
|
||||
cursor->setPositionInside(cursorIndex + 1);
|
||||
return true;
|
||||
}
|
||||
// Case: Right.
|
||||
// Ask the parent.
|
||||
if (m_parent) {
|
||||
return m_parent->moveRight(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditableStringLayout::moveCursorInsideAtDirection (
|
||||
VerticalDirection direction,
|
||||
ExpressionLayoutCursor * cursor,
|
||||
ExpressionLayout ** childResult,
|
||||
void * resultPosition,
|
||||
int * resultPositionInside,
|
||||
int * resultScore)
|
||||
{
|
||||
ExpressionLayout::moveCursorInsideAtDirection(direction, cursor, childResult, resultPosition, resultPositionInside, resultScore);
|
||||
ExpressionLayoutCursor::Position * castedResultPosition = static_cast<ExpressionLayoutCursor::Position *>(resultPosition);
|
||||
// Check the distance to Inside cursors.
|
||||
size_t stringLength = strlen(m_string);
|
||||
int currentDistance = 0;
|
||||
KDPoint cursorMiddleLeft = cursor->middleLeftPoint();
|
||||
for (int i = 1; i < stringLength; i++) {
|
||||
currentDistance = cursor->middleLeftPointOfCursor(this, ExpressionLayoutCursor::Position::Inside, i).squareDistanceTo(cursorMiddleLeft);
|
||||
if (currentDistance < *resultScore) {
|
||||
*childResult = this;
|
||||
*castedResultPosition = ExpressionLayoutCursor::Position::Inside;
|
||||
*resultPositionInside = i;
|
||||
*resultScore = currentDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef POINCARE_EDITABLE_STRING_LAYOUT_H
|
||||
#define POINCARE_EDITABLE_STRING_LAYOUT_H
|
||||
|
||||
#include "string_layout.h"
|
||||
#include <string.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class EditableStringLayout : public StringLayout {
|
||||
public:
|
||||
using StringLayout::StringLayout;
|
||||
ExpressionLayout * clone() const override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor) override;
|
||||
private:
|
||||
void moveCursorInsideAtDirection (
|
||||
VerticalDirection direction,
|
||||
ExpressionLayoutCursor * cursor,
|
||||
ExpressionLayout ** childResult,
|
||||
void * resultPosition,
|
||||
int * resultPositionInside,
|
||||
int * resultScore) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,121 +0,0 @@
|
||||
#include "string_layout.h"
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
StringLayout::StringLayout(const char * string, size_t length, KDText::FontSize fontSize) :
|
||||
StaticLayoutHierarchy<0>(),
|
||||
m_fontSize(fontSize)
|
||||
{
|
||||
m_string = new char[length+1];
|
||||
memcpy(m_string, string, length);
|
||||
m_string[length] = 0;
|
||||
}
|
||||
|
||||
StringLayout::~StringLayout() {
|
||||
delete[] m_string;
|
||||
}
|
||||
|
||||
ExpressionLayout * StringLayout::clone() const {
|
||||
StringLayout * layout = new StringLayout(m_string, strlen(m_string), m_fontSize);
|
||||
return layout;
|
||||
}
|
||||
|
||||
void StringLayout::backspaceAtCursor(ExpressionLayoutCursor * cursor) {
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Right) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
return;
|
||||
}
|
||||
assert(cursor->position() == ExpressionLayoutCursor::Position::Left);
|
||||
m_parent->backspaceAtCursor(cursor);
|
||||
}
|
||||
|
||||
bool StringLayout::moveLeft(ExpressionLayoutCursor * cursor) {
|
||||
// A StringLayout is not editable, and the cursor cannot go inside it.
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Case: Right.
|
||||
// If there is a Left brother, go Right of it. Else go Left of the
|
||||
// grandparent. We need to do this to avoid adding text left or right of a
|
||||
// string layout, for instance left of "n=" in a Sum layout.
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Right) {
|
||||
int indexOfThis = m_parent->indexOfChild(this);
|
||||
if (indexOfThis > 0) {
|
||||
cursor->setPointedExpressionLayout(m_parent->editableChild(indexOfThis-1));
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return true;
|
||||
}
|
||||
cursor->setPointedExpressionLayout(m_parent);
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
return true;
|
||||
}
|
||||
// Case: Left.
|
||||
// Ask the parent.
|
||||
if (m_parent) {
|
||||
return m_parent->moveLeft(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StringLayout::moveRight(ExpressionLayoutCursor * cursor) {
|
||||
// A StringLayout is not editable, and the cursor cannot go inside it.
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
assert(m_parent != nullptr);
|
||||
// Case: Left.
|
||||
// If there is a Right brother, go Left of it. Else go Right of the
|
||||
// grandparent. We need to do this to avoid adding text left or right of a
|
||||
// string layout, for instance right of "dx" in an integral layout.
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Left) {
|
||||
int indexOfThis = m_parent->indexOfChild(this);
|
||||
if (m_parent->editableChild(indexOfThis+1) != nullptr) {
|
||||
cursor->setPointedExpressionLayout(m_parent->editableChild(indexOfThis+1));
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
return true;
|
||||
}
|
||||
if (m_parent->parent()) {
|
||||
cursor->setPointedExpressionLayout(const_cast<ExpressionLayout *>(m_parent->parent()));
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Case: Right.
|
||||
// Ask the parent.
|
||||
return m_parent->moveRight(cursor);
|
||||
}
|
||||
|
||||
int StringLayout::writeTextInBuffer(char * buffer, int bufferSize) const {
|
||||
if (bufferSize == 0) {
|
||||
return -1;
|
||||
}
|
||||
buffer[bufferSize-1] = 0;
|
||||
int numberOfChar = strlcpy(buffer, m_string, bufferSize);
|
||||
if (numberOfChar >= bufferSize-1) {
|
||||
return bufferSize-1;
|
||||
}
|
||||
|
||||
buffer[numberOfChar] = 0;
|
||||
return numberOfChar;
|
||||
}
|
||||
|
||||
void StringLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
|
||||
ctx->drawString(m_string, p, m_fontSize, expressionColor, backgroundColor);
|
||||
}
|
||||
|
||||
KDPoint StringLayout::positionOfChild(ExpressionLayout * child) {
|
||||
assert(false); // We should never be here
|
||||
return KDPointZero;
|
||||
}
|
||||
|
||||
KDSize StringLayout::computeSize() {
|
||||
return KDText::stringSize(m_string, m_fontSize);
|
||||
}
|
||||
|
||||
void StringLayout::computeBaseline() {
|
||||
// Half height of the font.
|
||||
m_baseline = (KDText::charSize(m_fontSize).height()+1)/2;
|
||||
m_baselined = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
#ifndef POINCARE_STRING_LAYOUT_H
|
||||
#define POINCARE_STRING_LAYOUT_H
|
||||
|
||||
#include <poincare/static_layout_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class StringLayout : public StaticLayoutHierarchy<0> {
|
||||
public:
|
||||
StringLayout(const char * string, size_t length, KDText::FontSize fontSize = KDText::FontSize::Large);
|
||||
~StringLayout();
|
||||
StringLayout(const StringLayout& other) = delete;
|
||||
StringLayout(StringLayout&& other) = delete;
|
||||
StringLayout& operator=(const StringLayout& other) = delete;
|
||||
StringLayout& operator=(StringLayout&& other) = delete;
|
||||
ExpressionLayout * clone() const override;
|
||||
void backspaceAtCursor(ExpressionLayoutCursor * cursor) override;
|
||||
|
||||
char * text() { return m_string; }
|
||||
KDText::FontSize fontSize() { return m_fontSize; }
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor) override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize) const override;
|
||||
protected:
|
||||
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
|
||||
KDPoint positionOfChild(ExpressionLayout * child) override;
|
||||
KDSize computeSize() override;
|
||||
void computeBaseline() override;
|
||||
char * m_string;
|
||||
KDText::FontSize m_fontSize;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,193 +0,0 @@
|
||||
#include "uneditable_horizontal_trio_layout.h"
|
||||
#include "empty_visible_layout.h"
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
UneditableHorizontalTrioLayout::UneditableHorizontalTrioLayout(ExpressionLayout * left, ExpressionLayout * central, ExpressionLayout * right, bool cloneOperands, bool cursorAllowedLeftAndRight) :
|
||||
StaticLayoutHierarchy(left, central, right, cloneOperands),
|
||||
m_cursorCanBeLeftOrRight(cursorAllowedLeftAndRight)
|
||||
{
|
||||
}
|
||||
|
||||
ExpressionLayout * UneditableHorizontalTrioLayout::clone() const {
|
||||
UneditableHorizontalTrioLayout * layout = new UneditableHorizontalTrioLayout(
|
||||
const_cast<UneditableHorizontalTrioLayout *>(this)->leftLayout(),
|
||||
const_cast<UneditableHorizontalTrioLayout *>(this)->centerLayout(),
|
||||
const_cast<UneditableHorizontalTrioLayout *>(this)->rightLayout(),
|
||||
true, m_cursorCanBeLeftOrRight);
|
||||
return layout;
|
||||
}
|
||||
|
||||
void UneditableHorizontalTrioLayout::backspaceAtCursor(ExpressionLayoutCursor * cursor) {
|
||||
// Case: Left of the center layout (for sequence layouts).
|
||||
if (cursor->pointedExpressionLayout() == centerLayout()
|
||||
&& cursor->position() == ExpressionLayoutCursor::Position::Left)
|
||||
{
|
||||
ExpressionLayout * grandParent = const_cast<ExpressionLayout *>(m_parent->parent());
|
||||
assert(grandParent != nullptr);
|
||||
ExpressionLayout * parent = m_parent;
|
||||
int indexInGrandParent = grandParent->indexOfChild(parent);
|
||||
parent->replaceWith(centerLayout(), true);
|
||||
// Place the cursor on the right of the left brother of the integral if
|
||||
// there is one.
|
||||
if (indexInGrandParent > 0) {
|
||||
cursor->setPointedExpressionLayout(grandParent->editableChild(indexInGrandParent - 1));
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return;
|
||||
}
|
||||
// Else place the cursor on the Left of the parent.
|
||||
cursor->setPointedExpressionLayout(grandParent);
|
||||
return;
|
||||
}
|
||||
// Case: Right.
|
||||
// Move to the argument.
|
||||
if (cursor->pointedExpressionLayout() == this
|
||||
&& cursor->position() == ExpressionLayoutCursor::Position::Right)
|
||||
{
|
||||
// Go Right of the center layout's last child if it has one, else go Right
|
||||
// of the center layout.
|
||||
if (centerLayout()->numberOfChildren() > 1) {
|
||||
cursor->setPointedExpressionLayout(centerLayout()->editableChild(centerLayout()->numberOfChildren()-1));
|
||||
return;
|
||||
}
|
||||
cursor->setPointedExpressionLayout(centerLayout());
|
||||
return;
|
||||
}
|
||||
ExpressionLayout::backspaceAtCursor(cursor);
|
||||
}
|
||||
|
||||
bool UneditableHorizontalTrioLayout::moveLeft(ExpressionLayoutCursor * cursor) {
|
||||
if (cursor->pointedExpressionLayout() == centerLayout()) {
|
||||
// Case: Center layout.
|
||||
// Go Left.
|
||||
assert(cursor->position() == ExpressionLayoutCursor::Position::Left);
|
||||
cursor->setPointedExpressionLayout(this);
|
||||
if (m_cursorCanBeLeftOrRight) {
|
||||
return true;
|
||||
}
|
||||
if (m_parent) {
|
||||
return m_parent->moveLeft(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Right) {
|
||||
// Case: Right.
|
||||
// Go Right of the center layout's last child if it has one, else go Right
|
||||
// of the center layout.
|
||||
if (centerLayout()->numberOfChildren() > 1) {
|
||||
cursor->setPointedExpressionLayout(centerLayout()->editableChild(centerLayout()->numberOfChildren()-1));
|
||||
return true;
|
||||
}
|
||||
cursor->setPointedExpressionLayout(centerLayout());
|
||||
return true;
|
||||
}
|
||||
assert(cursor->position() == ExpressionLayoutCursor::Position::Left);
|
||||
// Case: Left.
|
||||
// Ask the parent.
|
||||
if (m_parent) {
|
||||
return m_parent->moveLeft(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UneditableHorizontalTrioLayout::moveRight(ExpressionLayoutCursor * cursor) {
|
||||
if (cursor->pointedExpressionLayout() == centerLayout()) {
|
||||
// Case: Center layout.
|
||||
// Go Right.
|
||||
assert(cursor->position() == ExpressionLayoutCursor::Position::Right);
|
||||
cursor->setPointedExpressionLayout(this);
|
||||
if (m_cursorCanBeLeftOrRight) {
|
||||
return true;
|
||||
}
|
||||
if (m_parent) {
|
||||
return m_parent->moveRight(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
if (cursor->position() == ExpressionLayoutCursor::Position::Left) {
|
||||
// Case: Left.
|
||||
// Go Left of the center layout's first child if it has one, else go Left of
|
||||
// the center layout.
|
||||
ExpressionLayout * grandChild = centerLayout()->editableChild(0);
|
||||
if (grandChild != nullptr) {
|
||||
cursor->setPointedExpressionLayout(grandChild);
|
||||
return true;
|
||||
}
|
||||
cursor->setPointedExpressionLayout(centerLayout());
|
||||
return true;
|
||||
}
|
||||
assert(cursor->position() == ExpressionLayoutCursor::Position::Right);
|
||||
// Case: Right.
|
||||
// Ask the parent.
|
||||
if (m_parent) {
|
||||
return m_parent->moveRight(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UneditableHorizontalTrioLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
|
||||
}
|
||||
|
||||
KDSize UneditableHorizontalTrioLayout::computeSize() {
|
||||
// TODO: This code is duplicated from horizontal_layout.cpp.
|
||||
KDCoordinate totalWidth = 0;
|
||||
int i = 0;
|
||||
KDCoordinate max_under_baseline = 0;
|
||||
KDCoordinate max_above_baseline = 0;
|
||||
while (ExpressionLayout * c = editableChild(i++)) {
|
||||
KDSize childSize = c->size();
|
||||
totalWidth += childSize.width();
|
||||
if (childSize.height() - c->baseline() > max_under_baseline) {
|
||||
max_under_baseline = childSize.height() - c->baseline() ;
|
||||
}
|
||||
if (c->baseline() > max_above_baseline) {
|
||||
max_above_baseline = c->baseline();
|
||||
}
|
||||
}
|
||||
return KDSize(totalWidth, max_under_baseline + max_above_baseline);
|
||||
}
|
||||
|
||||
void UneditableHorizontalTrioLayout::computeBaseline() {
|
||||
// TODO: This code is duplicated from horizontal_layout.cpp.
|
||||
m_baseline = 0;
|
||||
for (int i = 0; i < numberOfChildren(); i++) {
|
||||
if (editableChild(i)->baseline() > m_baseline) {
|
||||
m_baseline = editableChild(i)->baseline();
|
||||
}
|
||||
}
|
||||
m_baselined = true;
|
||||
}
|
||||
|
||||
KDPoint UneditableHorizontalTrioLayout::positionOfChild(ExpressionLayout * child) {
|
||||
// TODO: This code is duplicated from horizontal_layout.cpp.
|
||||
KDCoordinate x = 0;
|
||||
KDCoordinate y = 0;
|
||||
int index = indexOfChild(child);
|
||||
if (index > 0) {
|
||||
ExpressionLayout * previousChild = editableChild(index-1);
|
||||
assert(previousChild != nullptr);
|
||||
x = previousChild->origin().x() + previousChild->size().width();
|
||||
}
|
||||
y = baseline() - child->baseline();
|
||||
return KDPoint(x, y);
|
||||
}
|
||||
|
||||
ExpressionLayout * UneditableHorizontalTrioLayout::leftLayout() {
|
||||
return editableChild(0);
|
||||
}
|
||||
|
||||
ExpressionLayout * UneditableHorizontalTrioLayout::centerLayout() {
|
||||
return editableChild(1);
|
||||
}
|
||||
|
||||
ExpressionLayout * UneditableHorizontalTrioLayout::rightLayout() {
|
||||
return editableChild(2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#ifndef POINCARE_UNEDITABLE_HORIZONTAL_TRIO_LAYOUT_H
|
||||
#define POINCARE_UNEDITABLE_HORIZONTAL_TRIO_LAYOUT_H
|
||||
|
||||
#include <poincare/static_layout_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
/* UneditableHorizontalTrioLayout has 3 children: a left and a right layout
|
||||
* (usually parentheses or brackets), and a central layout.
|
||||
* The cursor can only be:
|
||||
* - Left or Right of the UneditableHorizontalTrioLayout,
|
||||
* - Left or Right of the central layout if it is not an horizontal layout,
|
||||
* - Inside the central layout if it is an horizontal layout.
|
||||
* This way, the lateral children of an UneditableHorizontalTrioLayout cannot be
|
||||
* edited, and it it will always have only 3 children.
|
||||
* This layout can be used to create binomial coefficient layouts, matrix
|
||||
* layouts or the argument of sum and product layouts. */
|
||||
|
||||
class UneditableHorizontalTrioLayout : public StaticLayoutHierarchy<3> {
|
||||
public:
|
||||
UneditableHorizontalTrioLayout(ExpressionLayout * left, ExpressionLayout * central, ExpressionLayout * right, bool cloneOperands, bool cursorAllowedLeftAndRight);
|
||||
ExpressionLayout * clone() const override;
|
||||
void backspaceAtCursor(ExpressionLayoutCursor * cursor) override;
|
||||
|
||||
/* Navigation */
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor) override;
|
||||
|
||||
/* Expression Engine */
|
||||
int writeTextInBuffer(char * buffer, int bufferSize) const override {
|
||||
return LayoutEngine::writeInfixExpressionLayoutTextInBuffer(this, buffer, bufferSize, "");
|
||||
}
|
||||
protected:
|
||||
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
|
||||
KDSize computeSize() override;
|
||||
void computeBaseline() override;
|
||||
KDPoint positionOfChild(ExpressionLayout * child) override;
|
||||
private:
|
||||
ExpressionLayout * leftLayout();
|
||||
ExpressionLayout * centerLayout();
|
||||
ExpressionLayout * rightLayout();
|
||||
bool m_cursorCanBeLeftOrRight;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
#include "uneditable_parenthesis_left_layout.h"
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
ExpressionLayout * UneditableParenthesisLeftLayout::clone() const {
|
||||
return new UneditableParenthesisLeftLayout();
|
||||
}
|
||||
|
||||
bool UneditableParenthesisLeftLayout::moveLeft(ExpressionLayoutCursor * cursor) {
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Ask the parent.
|
||||
if (m_parent) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
return m_parent->moveLeft(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UneditableParenthesisLeftLayout::moveRight(ExpressionLayoutCursor * cursor) {
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Ask the parent.
|
||||
if (m_parent) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return m_parent->moveRight(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef POINCARE_UNEDITABLE_PARENTHESIS_LEFT_LAYOUT_H
|
||||
#define POINCARE_UNEDITABLE_PARENTHESIS_LEFT_LAYOUT_H
|
||||
|
||||
#include <poincare/src/layout/parenthesis_left_layout.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class UneditableParenthesisLeftLayout : public ParenthesisLeftLayout {
|
||||
public:
|
||||
using ParenthesisLeftLayout::ParenthesisLeftLayout;
|
||||
ExpressionLayout * clone() const override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
#include "uneditable_parenthesis_right_layout.h"
|
||||
#include <poincare/expression_layout_cursor.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
ExpressionLayout * UneditableParenthesisRightLayout::clone() const {
|
||||
return new UneditableParenthesisRightLayout();
|
||||
}
|
||||
|
||||
bool UneditableParenthesisRightLayout::moveLeft(ExpressionLayoutCursor * cursor) {
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Ask the parent.
|
||||
if (m_parent) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
return m_parent->moveLeft(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UneditableParenthesisRightLayout::moveRight(ExpressionLayoutCursor * cursor) {
|
||||
assert(cursor->pointedExpressionLayout() == this);
|
||||
// Ask the parent.
|
||||
if (m_parent) {
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
return m_parent->moveRight(cursor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef POINCARE_UNEDITABLE_PARENTHESIS_RIGHT_LAYOUT_H
|
||||
#define POINCARE_UNEDITABLE_PARENTHESIS_RIGHT_LAYOUT_H
|
||||
|
||||
#include <poincare/src/layout/parenthesis_right_layout.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class UneditableParenthesisRightLayout : public ParenthesisRightLayout {
|
||||
public:
|
||||
using ParenthesisRightLayout::ParenthesisRightLayout;
|
||||
ExpressionLayout * clone() const override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user