[poincare] Fix all layouts: redefine baseline

Change-Id: Iff04bf9bee946050721fc095d1617586dc251d6b
This commit is contained in:
Émilie Feral
2017-11-22 14:38:08 +01:00
parent a536ef58cf
commit 7ae6241acd
6 changed files with 12 additions and 13 deletions

View File

@@ -9,8 +9,7 @@ ExpressionLayout(), m_numerator_layout(numerator_layout), m_denominator_layout(d
m_numerator_layout->setParent(this);
m_denominator_layout->setParent(this);
m_baseline = m_numerator_layout->size().height()
+ k_fractionLineMargin + k_fractionLineHeight
+ KDText::charSize().height()/2;
+ k_fractionLineMargin + k_fractionLineHeight;
}
FractionLayout::~FractionLayout() {

View File

@@ -16,7 +16,7 @@ GridLayout::GridLayout(ExpressionLayout ** entryLayouts, int numberOfRows, int n
m_entryLayouts[i] = entryLayouts[i];
m_entryLayouts[i]->setParent(this);
}
m_baseline = height()/2 + KDText::charSize().height()/2;
m_baseline = (height()+1)/2;
}
GridLayout::~GridLayout() {

View File

@@ -8,13 +8,13 @@ void ProductLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor,
KDSize upperBoundSize = m_upperBoundLayout->size();
KDSize lowerBoundSize = m_lowerBoundLayout->size();
ctx->fillRect(KDRect(p.x() + max(max(0, (upperBoundSize.width()-k_symbolWidth)/2), (lowerBoundSize.width()-k_symbolWidth)/2),
p.y() + max(upperBoundSize.height()+k_boundHeightMargin, m_argumentLayout->baseline()-k_symbolHeight),
p.y() + max(upperBoundSize.height()+k_boundHeightMargin, m_argumentLayout->baseline()-(k_symbolHeight+1)/2),
k_lineThickness, k_symbolHeight), expressionColor);
ctx->fillRect(KDRect(p.x() + max(max(0, (upperBoundSize.width()-k_symbolWidth)/2), (lowerBoundSize.width()-k_symbolWidth)/2),
p.y() + max(upperBoundSize.height()+k_boundHeightMargin, m_argumentLayout->baseline()-k_symbolHeight),
p.y() + max(upperBoundSize.height()+k_boundHeightMargin, m_argumentLayout->baseline()-(k_symbolHeight+1)/2),
k_symbolWidth, k_lineThickness), expressionColor);
ctx->fillRect(KDRect(p.x() + max(max(0, (upperBoundSize.width()-k_symbolWidth)/2), (lowerBoundSize.width()-k_symbolWidth)/2)+k_symbolWidth,
p.y() + max(upperBoundSize.height()+k_boundHeightMargin, m_argumentLayout->baseline()-k_symbolHeight),
p.y() + max(upperBoundSize.height()+k_boundHeightMargin, m_argumentLayout->baseline()-(k_symbolHeight+1)/2),
k_lineThickness, k_symbolHeight), expressionColor);
}

View File

@@ -13,7 +13,7 @@ SequenceLayout::SequenceLayout(ExpressionLayout * lowerBoundLayout, ExpressionLa
m_lowerBoundLayout->setParent(this);
m_upperBoundLayout->setParent(this);
m_argumentLayout->setParent(this);
m_baseline = max(m_upperBoundLayout->size().height()+k_boundHeightMargin+k_symbolHeight, m_argumentLayout->baseline());
m_baseline = max(m_upperBoundLayout->size().height()+k_boundHeightMargin+(k_symbolHeight+1)/2, m_argumentLayout->baseline());
}
SequenceLayout::~SequenceLayout() {
@@ -28,7 +28,7 @@ KDSize SequenceLayout::computeSize() {
KDSize upperBoundSize = m_upperBoundLayout->size();
return KDSize(
max(max(k_symbolWidth, lowerBoundSize.width()), upperBoundSize.width())+k_argumentWidthMargin+argumentSize.width(),
m_baseline + max(k_boundHeightMargin+lowerBoundSize.height(), argumentSize.height() - m_argumentLayout->baseline())
m_baseline + max(k_symbolHeight/2+k_boundHeightMargin+lowerBoundSize.height(), argumentSize.height() - m_argumentLayout->baseline())
);
}
@@ -52,10 +52,10 @@ KDPoint SequenceLayout::positionOfChild(ExpressionLayout * child) {
KDCoordinate y = 0;
if (child == m_lowerBoundLayout) {
x = max(max(0, (k_symbolWidth-lowerBoundSize.width())/2), (upperBoundSize.width()-lowerBoundSize.width())/2);
y = m_baseline + k_boundHeightMargin;
y = m_baseline + k_symbolHeight/2 + k_boundHeightMargin;
} else if (child == m_upperBoundLayout) {
x = max(max(0, (k_symbolWidth-upperBoundSize.width())/2), (lowerBoundSize.width()-upperBoundSize.width())/2);
y = m_baseline - k_symbolHeight- k_boundHeightMargin-upperBoundSize.height();
y = m_baseline - (k_symbolHeight+1)/2- k_boundHeightMargin-upperBoundSize.height();
} else if (child == m_argumentLayout) {
x = max(max(k_symbolWidth, lowerBoundSize.width()), upperBoundSize.width())+k_argumentWidthMargin;
y = m_baseline - m_argumentLayout->baseline();

View File

@@ -11,8 +11,8 @@ StringLayout::StringLayout(const char * string, size_t length, KDText::FontSize
m_string = new char[length+1];
memcpy(m_string, string, length);
m_string[length] = 0;
// Height of the font.
m_baseline = KDText::charSize(m_fontSize).height();
// Half height of the font.
m_baseline = (KDText::charSize(m_fontSize).height()+1)/2;
}
StringLayout::~StringLayout() {

View File

@@ -27,7 +27,7 @@ void SumLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDCo
KDSize lowerBoundSize = m_lowerBoundLayout->size();
KDColor workingBuffer[k_symbolWidth*k_symbolHeight];
KDRect symbolFrame(p.x() + max(max(0, (upperBoundSize.width()-k_symbolWidth)/2), (lowerBoundSize.width()-k_symbolWidth)/2),
p.y() + max(upperBoundSize.height()+k_boundHeightMargin, m_argumentLayout->baseline()-k_symbolHeight),
p.y() + max(upperBoundSize.height()+k_boundHeightMargin, m_argumentLayout->baseline()-(k_symbolHeight+1)/2),
k_symbolWidth, k_symbolHeight);
ctx->blendRectWithMask(symbolFrame, expressionColor, (const uint8_t *)symbolPixel, (KDColor *)workingBuffer);
}