[poincare] More beautiful separation of exponential and root indexes

Exponent Layout (VerticalOffsetLayout of Superscript type) now add a
margin to their layout only when they are next to a layout that has an
upper left index.

Change-Id: I670e8aefc7c6bcace8f61bbe4a4b6cea0936d96c
This commit is contained in:
Léa Saviot
2018-04-17 17:29:56 +02:00
parent a1c0dae369
commit 021d98da7c
3 changed files with 8 additions and 1 deletions

View File

@@ -125,6 +125,7 @@ public:
virtual bool isRightBracket() const { return false; }
virtual bool isEmpty() const { return false; }
virtual bool isMatrix() const { return false; }
virtual bool hasUpperLeftIndex() const { return false; }
virtual char XNTChar() const;
protected:

View File

@@ -26,6 +26,7 @@ public:
/* Expression Engine */
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
bool hasUpperLeftIndex() const override { return numberOfChildren() > 1; }
protected:
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
KDSize computeSize() override;

View File

@@ -246,7 +246,12 @@ KDSize VerticalOffsetLayout::computeSize() {
KDSize indiceSize = indiceLayout()->size();
KDCoordinate width = indiceSize.width();
if (m_type == Type::Superscript) {
width += 5;
assert(m_parent != nullptr);
assert(m_parent->isHorizontal());
int indexInParent = m_parent->indexOfChild(this);
if (indexInParent < m_parent-> numberOfChildren() - 1 && m_parent->editableChild(indexInParent + 1)->hasUpperLeftIndex()) {
width += 5;
}
}
KDCoordinate height = 0;
if (m_type == Type::Subscript) {