[poincare] Fix CharLayout: avoid adding multiplication sign between Sto

and another expression
This commit is contained in:
Émilie Feral
2018-05-24 14:37:39 +02:00
committed by EmilieNumworks
parent 386ebc5bfc
commit d11967f41a
3 changed files with 11 additions and 1 deletions

View File

@@ -107,7 +107,7 @@ public:
* inserted in the numerator (or denominator)? For instance, 1+2|3-4 should
* become 1+ 2/3 - 4 when pressing "Divide": a CharLayout is collapsable if
* its char is not +, -, or *. */
bool canBeOmittedMultiplicationLeftFactor() const;
virtual bool canBeOmittedMultiplicationLeftFactor() const;
virtual bool canBeOmittedMultiplicationRightFactor() const;
/* canBeOmittedMultiplicationLeftFactor and RightFactor return true if the
* layout, next to another layout, might be the factor of a multiplication

View File

@@ -51,6 +51,7 @@ bool CharLayout::isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) co
|| m_char == '*'
|| m_char == Ion::Charset::MultiplicationSign
|| m_char == Ion::Charset::MiddleDot
|| m_char == Ion::Charset::Sto
|| m_char == ','))
{
return false;
@@ -58,6 +59,13 @@ bool CharLayout::isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) co
return true;
}
bool CharLayout::canBeOmittedMultiplicationLeftFactor() const {
return m_char != Ion::Charset::Sto;
}
bool CharLayout::canBeOmittedMultiplicationRightFactor() const {
return m_char != Ion::Charset::Sto;
}
void CharLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
char string[2] = {m_char, 0};
ctx->drawString(string, p, m_fontSize, expressionColor, backgroundColor);

View File

@@ -28,6 +28,8 @@ public:
// Other
bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const override;
bool canBeOmittedMultiplicationLeftFactor() const override;
bool canBeOmittedMultiplicationRightFactor() const override;
protected:
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
KDPoint positionOfChild(ExpressionLayout * child) override {