diff --git a/poincare/include/poincare/horizontal_layout_node.h b/poincare/include/poincare/horizontal_layout_node.h index 1e4824ebd..9e49465e4 100644 --- a/poincare/include/poincare/horizontal_layout_node.h +++ b/poincare/include/poincare/horizontal_layout_node.h @@ -75,6 +75,13 @@ public: addChildTreeAtIndex(l2, 1); } + HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3, LayoutRef l4) : LayoutReference() { + addChildTreeAtIndex(l1, 0); + addChildTreeAtIndex(l2, 1); + addChildTreeAtIndex(l3, 2); + addChildTreeAtIndex(l4, 3); + } + void addOrMergeChildAtIndex(LayoutRef l, int index, bool removeEmptyChildren, LayoutCursor * cursor = nullptr); void mergeChildrenAtIndex(HorizontalLayoutRef h, int index, bool removeEmptyChildren, LayoutCursor * cursor = nullptr); private: diff --git a/poincare/include/poincare/layout_cursor.h b/poincare/include/poincare/layout_cursor.h index 8bb911329..efb3d75d2 100644 --- a/poincare/include/poincare/layout_cursor.h +++ b/poincare/include/poincare/layout_cursor.h @@ -112,7 +112,7 @@ public: void addEmptyPowerLayout(); void addEmptySquareRootLayout() {} //TODO void addEmptySquarePowerLayout(); - void addEmptyTenPowerLayout() {} //TODO + void addEmptyTenPowerLayout(); void addFractionLayoutAndCollapseSiblings() {} //TODO void addXNTCharLayout(); void insertText(const char * text); diff --git a/poincare/src/layout_cursor.cpp b/poincare/src/layout_cursor.cpp index 7957eb7f5..9343797d3 100644 --- a/poincare/src/layout_cursor.cpp +++ b/poincare/src/layout_cursor.cpp @@ -90,6 +90,22 @@ void LayoutCursor::addEmptySquarePowerLayout() { privateAddEmptyPowerLayout(offsetLayout); } +void LayoutCursor::addEmptyTenPowerLayout() { + EmptyLayoutRef emptyLayout; + HorizontalLayoutRef sibling = HorizontalLayoutRef( + CharLayoutRef(Ion::Charset::MiddleDot), + CharLayoutRef('1'), + CharLayoutRef('0'), + 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::addXNTCharLayout() { m_layoutRef.addSibling(this, CharLayoutRef(m_layoutRef.XNTChar()), true); }