mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 22:30:30 +01:00
When moving a cursor in an EditableExpressionView, do not recompute the layout, unless specified otherwise (for instance when entering or exiting a MatrixLayout). Change-Id: Ic2471095d6f6a08014a79f1d9d8fb7d39a1a6864
74 lines
2.0 KiB
C++
74 lines
2.0 KiB
C++
#include "bracket_left_right_layout.h"
|
|
#include <poincare/expression_layout_cursor.h>
|
|
extern "C" {
|
|
#include <assert.h>
|
|
#include <stdlib.h>
|
|
}
|
|
|
|
namespace Poincare {
|
|
|
|
BracketLeftRightLayout::BracketLeftRightLayout() :
|
|
StaticLayoutHierarchy<0>(),
|
|
m_operandHeightComputed(false)
|
|
{
|
|
}
|
|
|
|
void BracketLeftRightLayout::invalidAllSizesPositionsAndBaselines() {
|
|
m_operandHeightComputed = false;
|
|
ExpressionLayout::invalidAllSizesPositionsAndBaselines();
|
|
}
|
|
|
|
bool BracketLeftRightLayout::moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
|
assert(cursor->pointedExpressionLayout() == this);
|
|
// Case: Right.
|
|
// Go Left.
|
|
if (cursor->position() == ExpressionLayoutCursor::Position::Right) {
|
|
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
|
return true;
|
|
}
|
|
assert(cursor->position() == ExpressionLayoutCursor::Position::Left);
|
|
// Case: Left.
|
|
// Ask the parent.
|
|
if (m_parent) {
|
|
return m_parent->moveLeft(cursor, shouldRecomputeLayout);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool BracketLeftRightLayout::moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
|
assert(cursor->pointedExpressionLayout() == this);
|
|
// Case: Left.
|
|
// Go Right.
|
|
if (cursor->position() == ExpressionLayoutCursor::Position::Left) {
|
|
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
|
return true;
|
|
}
|
|
assert(cursor->position() == ExpressionLayoutCursor::Position::Right);
|
|
// Case: Right.
|
|
// Ask the parent.
|
|
if (m_parent) {
|
|
return m_parent->moveRight(cursor, shouldRecomputeLayout);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
KDSize BracketLeftRightLayout::computeSize() {
|
|
return KDSize(k_externWidthMargin + k_lineThickness + k_widthMargin, operandHeight() + k_lineThickness);
|
|
}
|
|
|
|
KDCoordinate BracketLeftRightLayout::operandHeight() {
|
|
if (!m_operandHeightComputed) {
|
|
computeOperandHeight();
|
|
m_operandHeightComputed = true;
|
|
}
|
|
return m_operandHeight;
|
|
}
|
|
|
|
KDPoint BracketLeftRightLayout::positionOfChild(ExpressionLayout * child) {
|
|
assert(false);
|
|
return KDPointZero;
|
|
}
|
|
|
|
}
|