mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-25 16:50:50 +01:00
[apps/calculation] Calculation on 2 lines if does not fit when expanded
Scenario: 1+1+1+1+1+1+1+10.5 fits on one line when not expanded, but when the exact result is displayed not -> we thus always display it on two lines
This commit is contained in:
committed by
EmilieNumworks
parent
feee0a673c
commit
5535145b51
@@ -55,37 +55,11 @@ void AbstractScrollableMultipleExpressionsView::ContentCell::reloadTextColor() {
|
||||
}
|
||||
|
||||
KDSize AbstractScrollableMultipleExpressionsView::ContentCell::minimalSizeForOptimalDisplay() const {
|
||||
KDCoordinate width = 0;
|
||||
return privateMinimalSizeForOptimalDisplay(false);
|
||||
}
|
||||
|
||||
// Compute baselines
|
||||
KDCoordinate leftBaseline = 0;
|
||||
KDCoordinate centerBaseline = 0;
|
||||
KDCoordinate rightBaseline = 0;
|
||||
KDCoordinate viewBaseline = baseline(&leftBaseline, ¢erBaseline, &rightBaseline);
|
||||
|
||||
KDSize leftSize = KDSizeZero;
|
||||
if (leftExpressionView() && !leftExpressionView()->layout().isUninitialized()) {
|
||||
leftSize = leftExpressionView()->minimalSizeForOptimalDisplay();
|
||||
width += leftSize.width() + AbstractScrollableMultipleExpressionsView::k_horizontalMargin;
|
||||
}
|
||||
|
||||
KDSize centerSize = KDSizeZero;
|
||||
if (displayCenter()) {
|
||||
centerSize = m_centeredExpressionView.minimalSizeForOptimalDisplay();
|
||||
width += centerSize.width() + 2 * AbstractScrollableMultipleExpressionsView::k_horizontalMargin + m_approximateSign.minimalSizeForOptimalDisplay().width();
|
||||
}
|
||||
|
||||
KDSize rightSize = m_rightExpressionView.minimalSizeForOptimalDisplay();
|
||||
width += rightSize.width();
|
||||
|
||||
KDCoordinate height = viewBaseline
|
||||
+ std::max(
|
||||
std::max(
|
||||
centerSize.height() - centerBaseline,
|
||||
rightSize.height() - rightBaseline),
|
||||
leftSize.height() - leftBaseline);
|
||||
|
||||
return KDSize(width, height);
|
||||
KDSize AbstractScrollableMultipleExpressionsView::ContentCell::minimalSizeForOptimalDisplayFullSize() const {
|
||||
return privateMinimalSizeForOptimalDisplay(true);
|
||||
}
|
||||
|
||||
void AbstractScrollableMultipleExpressionsView::ContentCell::setSelectedSubviewPosition(AbstractScrollableMultipleExpressionsView::SubviewPosition subviewPosition) {
|
||||
@@ -147,6 +121,40 @@ KDCoordinate AbstractScrollableMultipleExpressionsView::ContentCell::baseline(KD
|
||||
return std::max(std::max(leftViewBaseline, centerViewBaseline), rightViewBaseline);
|
||||
}
|
||||
|
||||
KDSize AbstractScrollableMultipleExpressionsView::ContentCell::privateMinimalSizeForOptimalDisplay(bool forceFullDisplay) const {
|
||||
KDCoordinate width = 0;
|
||||
|
||||
// Compute baselines
|
||||
KDCoordinate leftBaseline = 0;
|
||||
KDCoordinate centerBaseline = 0;
|
||||
KDCoordinate rightBaseline = 0;
|
||||
KDCoordinate viewBaseline = baseline(&leftBaseline, ¢erBaseline, &rightBaseline);
|
||||
|
||||
KDSize leftSize = KDSizeZero;
|
||||
if (leftExpressionView() && !leftExpressionView()->layout().isUninitialized()) {
|
||||
leftSize = leftExpressionView()->minimalSizeForOptimalDisplay();
|
||||
width += leftSize.width() + AbstractScrollableMultipleExpressionsView::k_horizontalMargin;
|
||||
}
|
||||
|
||||
KDSize centerSize = KDSizeZero;
|
||||
if (displayCenter() || (forceFullDisplay && !m_centeredExpressionView.layout().isUninitialized())) {
|
||||
centerSize = m_centeredExpressionView.minimalSizeForOptimalDisplay();
|
||||
width += centerSize.width() + 2 * AbstractScrollableMultipleExpressionsView::k_horizontalMargin + m_approximateSign.minimalSizeForOptimalDisplay().width();
|
||||
}
|
||||
|
||||
KDSize rightSize = m_rightExpressionView.minimalSizeForOptimalDisplay();
|
||||
width += rightSize.width();
|
||||
|
||||
KDCoordinate height = viewBaseline
|
||||
+ std::max(
|
||||
std::max(
|
||||
centerSize.height() - centerBaseline,
|
||||
rightSize.height() - rightBaseline),
|
||||
leftSize.height() - leftBaseline);
|
||||
|
||||
return KDSize(width, height);
|
||||
}
|
||||
|
||||
View * AbstractScrollableMultipleExpressionsView::ContentCell::subviewAtIndex(int index) {
|
||||
bool leftIsVisible = leftExpressionView() != nullptr;
|
||||
if (leftIsVisible && index == 0) {
|
||||
|
||||
Reference in New Issue
Block a user