[poincare] Fix parentheses on first child of a multiplication

They are not needed if the child is not an addition or a subtraction
This commit is contained in:
Léa Saviot
2018-11-12 14:22:56 +01:00
committed by Émilie Feral
parent 7038048d12
commit 5421874358

View File

@@ -68,11 +68,16 @@ Expression MultiplicationNode::setSign(Sign s, Context & context, Preferences::A
}
bool MultiplicationNode::childNeedsParenthesis(const TreeNode * child) const {
if (static_cast<const ExpressionNode *>(child)->isNumber() && static_cast<const ExpressionNode *>(child)->sign() == Sign::Negative) {
if ((static_cast<const ExpressionNode *>(child)->isNumber() && static_cast<const ExpressionNode *>(child)->sign() == Sign::Negative)
|| static_cast<const ExpressionNode *>(child)->type() == ExpressionNode::Type::Opposite)
{
if (child == childAtIndex(0)) {
return false;
}
return true;
}
Type types[] = {Type::Subtraction, Type::Opposite, Type::Addition};
return static_cast<const ExpressionNode *>(child)->isOfType(types, 3);
Type types[] = {Type::Subtraction, Type::Addition};
return static_cast<const ExpressionNode *>(child)->isOfType(types, 2);
}
Layout MultiplicationNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {