[poincare] LayoutCursor::addEmptyExponentialLayout

This commit is contained in:
Léa Saviot
2018-07-13 10:53:18 +02:00
parent 4eb5b4355a
commit 2bb5c3d831
3 changed files with 17 additions and 1 deletions

View File

@@ -107,7 +107,7 @@ public:
}
/* Layout modification */
void addEmptyExponentialLayout() {} //TODO
void addEmptyExponentialLayout();
void addEmptyMatrixLayout() {} //TODO
void addEmptyPowerLayout();
void addEmptySquareRootLayout() {} //TODO

View File

@@ -91,6 +91,10 @@ public:
assert(isDefined());
return node()->hasSibling(t.node());
}
bool hasAncestor(TreeReference<TreeNode> t, bool includeSelf) const {
assert(isDefined());
return node()->hasAncestor(t.node(), includeSelf);
}
int numberOfChildren() const {
assert(isDefined());
return node()->numberOfChildren();

View File

@@ -65,6 +65,18 @@ void LayoutCursor::moveUnder(bool * shouldRecomputeLayout) {
/* Layout modification */
void LayoutCursor::addEmptyExponentialLayout() {
EmptyLayoutRef emptyLayout;
HorizontalLayoutRef sibling = HorizontalLayoutRef(
CharLayoutRef(Ion::Charset::Exponential),
VerticalOffsetLayoutRef(emptyLayout, VerticalOffsetLayoutNode::Type::Superscript));
LayoutRef rootRef = m_layoutRef.root();
m_layoutRef.addSibling(this, sibling, false);
if (emptyLayout.hasAncestor(rootRef, false) && !emptyLayout.isAllocationFailure()) {
m_layoutRef = emptyLayout;
}
}
void LayoutCursor::addEmptyPowerLayout() {
VerticalOffsetLayoutRef offsetLayout = VerticalOffsetLayoutRef(EmptyLayoutRef(), VerticalOffsetLayoutNode::Type::Superscript);
privateAddEmptyPowerLayout(offsetLayout);