From 6334e2f4353ca845488cb05040b2766e58e1f1d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 8 Jan 2018 16:09:57 +0100 Subject: [PATCH] [apps] Change MathToolbox's binomial coefficient layout. It now uses a Parenthesis layout. Change-Id: Ia83d7881a57bc91e41d125fef1e2a648d0278946 --- apps/math_toolbox.cpp | 8 +++----- poincare/src/layout/grid_layout.cpp | 4 ++++ poincare/src/layout/grid_layout.h | 6 ++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/math_toolbox.cpp b/apps/math_toolbox.cpp index 612e4324f..1597980ba 100644 --- a/apps/math_toolbox.cpp +++ b/apps/math_toolbox.cpp @@ -45,16 +45,14 @@ const ToolboxMessageTree complexChildren[5] = { const_cast(&pointedLayoutPathConj[0]), 1)}; -const int pointedLayoutPathBinomial[] = {1,0}; +const int pointedLayoutPathBinomial[] = {0, 0}; const ToolboxMessageTree probabilityChildren[2] = { ToolboxMessageTree(I18n::Message::BinomialCommandWithArg, I18n::Message::Combination, I18n::Message::BinomialCommandWithArg, nullptr, 0, - new HorizontalLayout( - new ParenthesisLeftLayout(), + new ParenthesisLayout( new GridLayout(Poincare::ExpressionLayoutArray( new EmptyVisibleLayout(), new EmptyVisibleLayout()).array(), - 2, 1, false), - new ParenthesisRightLayout(), false), + 2, 1, false)), const_cast(&pointedLayoutPathBinomial[0]), 2), ToolboxMessageTree(I18n::Message::PermuteCommandWithArg, I18n::Message::Permutation, I18n::Message::PermuteCommandWithArg)}; diff --git a/poincare/src/layout/grid_layout.cpp b/poincare/src/layout/grid_layout.cpp index 2d3152b09..5756d1c4c 100644 --- a/poincare/src/layout/grid_layout.cpp +++ b/poincare/src/layout/grid_layout.cpp @@ -138,6 +138,10 @@ bool GridLayout::moveDown(ExpressionLayoutCursor * cursor, ExpressionLayout * pr return ExpressionLayout::moveDown(cursor, previousLayout, previousPreviousLayout); } +void GridLayout::removeChildAtIndex(int index, bool deleteAfterRemoval) { + ExpressionLayout::removeChildAtIndex(index, deleteAfterRemoval); +} + int GridLayout::writeTextInBuffer(char * buffer, int bufferSize) const { const ExpressionLayout * editableParent = const_cast(this)->parent(); assert(editableParent != nullptr); diff --git a/poincare/src/layout/grid_layout.h b/poincare/src/layout/grid_layout.h index a00dcb65d..7d89e01e6 100644 --- a/poincare/src/layout/grid_layout.h +++ b/poincare/src/layout/grid_layout.h @@ -17,6 +17,12 @@ public: bool moveUp(ExpressionLayoutCursor * cursor, ExpressionLayout * previousLayout, ExpressionLayout * previousPreviousLayout) override; bool moveDown(ExpressionLayoutCursor * cursor, ExpressionLayout * previousLayout, ExpressionLayout * previousPreviousLayout) override; + + /* Dynamic layout */ + void removeChildAtIndex(int index, bool deleteAfterRemoval) override; + //TODO: is this ok? If we want to delete the grid's children, we have to make + //sure no to call this function. + /* Expression engine */ int writeTextInBuffer(char * buffer, int bufferSize) const override;