From 2cb895666509e758f87b5947c2264298be789cb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Fri, 19 Jan 2018 16:18:55 +0100 Subject: [PATCH] [apps/math_toolbox] Remove the pointedPath from ToolboxMessageTree. Change-Id: I2deb6564321da13ea27975216aa949b68298533c --- apps/math_toolbox.cpp | 10 ++-------- escher/include/escher/toolbox_message_tree.h | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/apps/math_toolbox.cpp b/apps/math_toolbox.cpp index 3910a60c0..6a82fc083 100644 --- a/apps/math_toolbox.cpp +++ b/apps/math_toolbox.cpp @@ -73,7 +73,6 @@ const ToolboxMessageTree predictionChildren[3] = { ToolboxMessageTree(I18n::Message::PredictionCommandWithArg, I18n::Message::Prediction, I18n::Message::PredictionCommandWithArg), ToolboxMessageTree(I18n::Message::ConfidenceCommandWithArg, I18n::Message::Confidence, I18n::Message::ConfidenceCommandWithArg)}; -const int pointedLayoutPathLog[] = {3,0}; #if LIST_ARE_DEFINED const ToolboxMessageTree menu[12] = { #elif MATRICES_ARE_DEFINED @@ -83,7 +82,7 @@ const ToolboxMessageTree menu[10] = { #endif ToolboxMessageTree(I18n::Message::AbsCommandWithArg, I18n::Message::AbsoluteValue, I18n::Message::AbsCommandWithArg), ToolboxMessageTree(I18n::Message::RootCommandWithArg, I18n::Message::NthRoot, I18n::Message::RootCommandWithArg), - ToolboxMessageTree(I18n::Message::LogCommandWithArg, I18n::Message::BasedLogarithm, I18n::Message::LogCommandWithArg, nullptr, 0, const_cast(&pointedLayoutPathLog[0]), 2), + ToolboxMessageTree(I18n::Message::LogCommandWithArg, I18n::Message::BasedLogarithm, I18n::Message::LogCommandWithArg), ToolboxMessageTree(I18n::Message::Calculation, I18n::Message::Default, I18n::Message::Default, calculChildren, 4), ToolboxMessageTree(I18n::Message::ComplexNumber, I18n::Message::Default, I18n::Message::Default, complexChildren, 5), ToolboxMessageTree(I18n::Message::Probability, I18n::Message::Default, I18n::Message::Default, probabilityChildren, 2), @@ -131,12 +130,7 @@ void MathToolbox::actionForEditableExpressionView(void * sender, ToolboxMessageT ExpressionLayout * resultLayout = resultExpression->createLayout(); // Find the pointed layout. ExpressionLayout * pointedLayout = resultLayout; - if (messageTree->pointedPath() != nullptr) { - for (int i = 0; i < messageTree->pointedPathLength(); i++) { - assert(messageTree->pointedPath()[i] < pointedLayout->numberOfChildren()); - pointedLayout = pointedLayout->editableChild(messageTree->pointedPath()[i]); - } - } else if (resultLayout->isHorizontal()) { + if (resultLayout->isHorizontal()) { // If the layout is horizontal, pick the first open parenthesis. for (int i = 0; i < resultLayout->numberOfChildren(); i++) { if (resultLayout->editableChild(i)->isLeftParenthesis()) { diff --git a/escher/include/escher/toolbox_message_tree.h b/escher/include/escher/toolbox_message_tree.h index 062271417..48d027403 100644 --- a/escher/include/escher/toolbox_message_tree.h +++ b/escher/include/escher/toolbox_message_tree.h @@ -6,26 +6,20 @@ class ToolboxMessageTree : public MessageTree { public: - constexpr ToolboxMessageTree(I18n::Message label = (I18n::Message)0, I18n::Message text = (I18n::Message)0, I18n::Message insertedText = (I18n::Message)0, const ToolboxMessageTree * children = nullptr, int numberOfChildren = 0, int * pointedLayoutPath = nullptr, int pointedLayoutPathLength = 0) : + constexpr ToolboxMessageTree(I18n::Message label = (I18n::Message)0, I18n::Message text = (I18n::Message)0, I18n::Message insertedText = (I18n::Message)0, const ToolboxMessageTree * children = nullptr, int numberOfChildren = 0) : MessageTree(label, numberOfChildren), m_children(children), m_text(text), - m_insertedText(insertedText), - m_pointedLayoutPath(pointedLayoutPath), - m_pointedLayoutPathLength(pointedLayoutPathLength) + m_insertedText(insertedText) { }; const MessageTree * children(int index) const override { return &m_children[index]; } I18n::Message text() const { return m_text; } I18n::Message insertedText() const { return m_insertedText; } - int * pointedPath() const { return m_pointedLayoutPath; } - int pointedPathLength() const { return m_pointedLayoutPathLength; } private: const ToolboxMessageTree * m_children; I18n::Message m_text; I18n::Message m_insertedText; - int * m_pointedLayoutPath; - int m_pointedLayoutPathLength; }; #endif