mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-28 10:09:53 +01:00
[apps/calculation] Calculation::height has two types of margin arguments
One for the margin between layouts and on top / at the bottom of the cell, the other for the margin surrounding each layout.
This commit is contained in:
committed by
EmilieNumworks
parent
78cac6ddae
commit
11c39b6206
@@ -8,7 +8,7 @@ namespace Shared {
|
||||
|
||||
AbstractScrollableMultipleExpressionsView::ContentCell::ContentCell() :
|
||||
m_rightExpressionView(),
|
||||
m_approximateSign(KDFont::LargeFont, I18n::Message::AlmostEqual, 0.5f, 0.5f, Palette::GreyVeryDark),
|
||||
m_approximateSign(k_font, k_defaultApproximateMessage, 0.5f, 0.5f, Palette::GreyVeryDark),
|
||||
m_centeredExpressionView(),
|
||||
m_selectedSubviewPosition(SubviewPosition::Center),
|
||||
m_displayCenter(true)
|
||||
@@ -66,13 +66,13 @@ KDSize AbstractScrollableMultipleExpressionsView::ContentCell::minimalSizeForOpt
|
||||
KDSize leftSize = KDSizeZero;
|
||||
if (leftExpressionView() && !leftExpressionView()->layout().isUninitialized()) {
|
||||
leftSize = leftExpressionView()->minimalSizeForOptimalDisplay();
|
||||
width += leftSize.width() + Metric::CommonLargeMargin;
|
||||
width += leftSize.width() + k_horizontalMargin;
|
||||
}
|
||||
|
||||
KDSize centerSize = KDSizeZero;
|
||||
if (displayCenter()) {
|
||||
centerSize = m_centeredExpressionView.minimalSizeForOptimalDisplay();
|
||||
width += centerSize.width() + 2 * Metric::CommonLargeMargin + m_approximateSign.minimalSizeForOptimalDisplay().width();
|
||||
width += centerSize.width() + 2 * k_horizontalMargin + m_approximateSign.minimalSizeForOptimalDisplay().width();
|
||||
}
|
||||
|
||||
KDSize rightSize = m_rightExpressionView.minimalSizeForOptimalDisplay();
|
||||
@@ -156,6 +156,10 @@ View * AbstractScrollableMultipleExpressionsView::ContentCell::subviewAtIndex(in
|
||||
return views[index - leftIsVisible];
|
||||
}
|
||||
|
||||
KDCoordinate AbstractScrollableMultipleExpressionsView::ContentCell::StandardApproximateViewAndMarginsSize() {
|
||||
return 2 * k_horizontalMargin + k_font->stringSize(I18n::translate(k_defaultApproximateMessage)).width(); //TODO LEA
|
||||
}
|
||||
|
||||
void AbstractScrollableMultipleExpressionsView::ContentCell::layoutSubviews(bool force) {
|
||||
// Subviews sizes
|
||||
KDSize leftSize = leftExpressionView() ? leftExpressionView()->minimalSizeForOptimalDisplay() : KDSizeZero;
|
||||
@@ -172,16 +176,16 @@ void AbstractScrollableMultipleExpressionsView::ContentCell::layoutSubviews(bool
|
||||
KDCoordinate currentWidth = 0;
|
||||
if (leftExpressionView()) {
|
||||
leftExpressionView()->setFrame(KDRect(currentWidth, viewBaseline - leftBaseline, leftSize), force);
|
||||
currentWidth += leftSize.width() + Metric::CommonLargeMargin;
|
||||
currentWidth += leftSize.width() + k_horizontalMargin;
|
||||
}
|
||||
|
||||
// Layout center expression
|
||||
if (displayCenter()) {
|
||||
KDSize approximateSignSize = m_approximateSign.minimalSizeForOptimalDisplay();
|
||||
m_centeredExpressionView.setFrame(KDRect(currentWidth, viewBaseline - centerBaseline, centerSize), force);
|
||||
currentWidth += Metric::CommonLargeMargin + centerSize.width();
|
||||
currentWidth += k_horizontalMargin + centerSize.width();
|
||||
m_approximateSign.setFrame(KDRect(currentWidth, viewBaseline - approximateSignSize.height()/2, approximateSignSize), force);
|
||||
currentWidth += Metric::CommonLargeMargin + approximateSignSize.width();
|
||||
currentWidth += k_horizontalMargin + approximateSignSize.width();
|
||||
}
|
||||
|
||||
// Layout right expression
|
||||
@@ -243,8 +247,8 @@ bool AbstractScrollableMultipleExpressionsView::handleEvent(Ion::Events::Event e
|
||||
if (contentCell()->displayCenter()) {
|
||||
KDCoordinate centerExpressionWidth = contentCell()->centeredExpressionView()->minimalSizeForOptimalDisplay().width();
|
||||
KDCoordinate signWidth = contentCell()->approximateSign()->minimalSizeForOptimalDisplay().width();
|
||||
centeredExpressionIsVisibleOnTheLeft = leftWidth + Metric::CommonLargeMargin + centerExpressionWidth - contentOffset().x() > 0;
|
||||
centeredExpressionIsVisibleOnTheRight = minimalSizeForOptimalDisplay().width() - rightExpressionWidth - signWidth - centerExpressionWidth - 2*Metric::CommonLargeMargin - contentOffset().x() < bounds().width();
|
||||
centeredExpressionIsVisibleOnTheLeft = leftWidth + ContentCell::k_horizontalMargin + centerExpressionWidth - contentOffset().x() > 0;
|
||||
centeredExpressionIsVisibleOnTheRight = minimalSizeForOptimalDisplay().width() - rightExpressionWidth - signWidth - centerExpressionWidth - 2 * ContentCell::k_horizontalMargin - contentOffset().x() < bounds().width();
|
||||
}
|
||||
// Select center
|
||||
if ((event == Ion::Events::Left && selectedSubviewPosition() == SubviewPosition::Right && centeredExpressionIsVisibleOnTheLeft) ||
|
||||
|
||||
Reference in New Issue
Block a user