mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare] Better collapsing of fractions
The user can now write intuitively 1/2 * 3/4
This commit is contained in:
committed by
EmilieNumworks
parent
95403c8a91
commit
05c479a6fc
@@ -59,6 +59,24 @@ bool CodePointLayoutNode::isCollapsable(int * numberOfOpenParenthesis, bool goin
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isMultiplicationCodePoint()) {
|
||||
/* We want '*' to be collapsable only if the following brother is not a
|
||||
* fraction, so that the user can write intuitively "1/2 * 3/4". */
|
||||
Layout thisRef = CodePointLayout(this);
|
||||
Layout parent = thisRef.parent();
|
||||
if (!parent.isUninitialized()) {
|
||||
int indexOfThis = parent.indexOfChild(thisRef);
|
||||
Layout brother;
|
||||
if (indexOfThis > 0 && goingLeft) {
|
||||
brother = parent.childAtIndex(indexOfThis-1);
|
||||
} else if (indexOfThis < parent.numberOfChildren() - 1 && !goingLeft) {
|
||||
brother = parent.childAtIndex(indexOfThis+1);
|
||||
}
|
||||
if (!brother.isUninitialized() && brother.type() == LayoutNode::Type::FractionLayout) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user