From 74ca9a73b72946d34debcf2cf4493e60a7b96ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Fri, 10 Aug 2018 11:57:18 +0200 Subject: [PATCH] [poincarE] Fraction, Grid and Horizontal layouts --- poincare/Makefile | 3 +++ poincare/include/poincare/horizontal_layout_node.h | 6 +++--- poincare/include/poincare/layout_reference.h | 2 ++ poincare/src/fraction_layout_node.cpp | 2 ++ poincare/src/grid_layout_node.cpp | 4 ++-- poincare/src/horizontal_layout_node.cpp | 4 +++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/poincare/Makefile b/poincare/Makefile index db5a1edaf..1aebe503e 100644 --- a/poincare/Makefile +++ b/poincare/Makefile @@ -13,6 +13,9 @@ objs += $(addprefix poincare/src/,\ conjugate_layout_node.o\ empty_layout_node.o\ floor_layout_node.o\ + fraction_layout_node.o\ + grid_layout_node.o\ + horizontal_layout_node.o\ matrix_layout_node.o\ ) diff --git a/poincare/include/poincare/horizontal_layout_node.h b/poincare/include/poincare/horizontal_layout_node.h index 27541664a..7434624bb 100644 --- a/poincare/include/poincare/horizontal_layout_node.h +++ b/poincare/include/poincare/horizontal_layout_node.h @@ -1,9 +1,9 @@ #ifndef POINCARE_HORIZONTAL_LAYOUT_NODE_H #define POINCARE_HORIZONTAL_LAYOUT_NODE_H -#include "layout_reference.h" -#include "layout_node.h" -#include "layout_cursor.h" +#include +#include +#include namespace Poincare { diff --git a/poincare/include/poincare/layout_reference.h b/poincare/include/poincare/layout_reference.h index 971080b99..54a4eb180 100644 --- a/poincare/include/poincare/layout_reference.h +++ b/poincare/include/poincare/layout_reference.h @@ -9,6 +9,8 @@ namespace Poincare { class LayoutCursor; class LayoutReference : public TreeByReference { + friend class GridLayoutNode; + friend class HorizontalLayoutNode; friend class LayoutCursor; public: using TreeByReference::operator==; diff --git a/poincare/src/fraction_layout_node.cpp b/poincare/src/fraction_layout_node.cpp index 9ff32359a..faddb623e 100644 --- a/poincare/src/fraction_layout_node.cpp +++ b/poincare/src/fraction_layout_node.cpp @@ -1,7 +1,9 @@ #include +#include #include #include #include +#include #include #include #include diff --git a/poincare/src/grid_layout_node.cpp b/poincare/src/grid_layout_node.cpp index 369dd2ec8..5574492b4 100644 --- a/poincare/src/grid_layout_node.cpp +++ b/poincare/src/grid_layout_node.cpp @@ -130,7 +130,7 @@ void GridLayoutNode::deleteRowAtIndex(int index) { assert(index >= 0 && index < m_numberOfRows); LayoutRef thisRef = LayoutRef(this); for (int i = 0; i < m_numberOfColumns; i++) { - thisRef.removeTreeChildAtIndex(index * m_numberOfColumns); + thisRef.removeChildAtIndexInPlace(index * m_numberOfColumns); } m_numberOfRows--; } @@ -139,7 +139,7 @@ void GridLayoutNode::deleteColumnAtIndex(int index) { assert(index >= 0 && index < m_numberOfColumns); LayoutRef thisRef = LayoutRef(this); for (int i = (m_numberOfRows - 1) * m_numberOfColumns + index; i > -1; i-= m_numberOfColumns) { - thisRef.removeTreeChildAtIndex(i); + thisRef.removeChildAtIndexInPlace(i); } m_numberOfColumns--; } diff --git a/poincare/src/horizontal_layout_node.cpp b/poincare/src/horizontal_layout_node.cpp index c1bfea47f..310ee2bf3 100644 --- a/poincare/src/horizontal_layout_node.cpp +++ b/poincare/src/horizontal_layout_node.cpp @@ -1,6 +1,8 @@ #include +#include #include #include +#include namespace Poincare { @@ -238,7 +240,7 @@ bool HorizontalLayoutNode::willRemoveChild(LayoutNode * l, LayoutCursor * cursor assert(childAtIndex(0) == l); LayoutNode * p = parent(); if (p != nullptr) { - LayoutRef(p).removeChild(this, cursor); + LayoutRef(p).removeChild(HorizontalLayoutRef(this), cursor); // WARNING: Do not call "this" afterwards return false; }