[shared] ScrollableExactApproximateExpressionsView: change the selected

output only when one of the two layout is uninitialized. Otherwise, the
parent cell decides of which of right or left output should be selected.
This commit is contained in:
Émilie Feral
2019-04-23 11:15:17 +02:00
parent a3f669fb08
commit 06a8382ff4
3 changed files with 11 additions and 1 deletions

View File

@@ -133,6 +133,14 @@ void HistoryViewCell::setCalculation(Calculation * calculation, bool isSelected)
m_scrollableOutputView.setLayouts(rightOutputLayout, leftOutputLayout);
I18n::Message equalMessage = calculation->exactAndApproximateDisplayedOutputsAreEqual(calculationApp->localContext()) == Calculation::EqualSign::Equal ? I18n::Message::Equal : I18n::Message::AlmostEqual;
m_scrollableOutputView.setEqualMessage(equalMessage);
// Select the right output according to the calculation display output
if (display == Calculation::DisplayOutput::ApproximateOnly || (display == Calculation::DisplayOutput::ExactAndApproximateToggle && isSelected)) {
m_scrollableOutputView.setSelectedSubviewPosition(Shared::ScrollableExactApproximateExpressionsView::SubviewPosition::Right);
} else {
assert(display == Calculation::DisplayOutput::ExactOnly || display == Calculation::DisplayOutput::ExactAndApproximate || (display == Calculation::DisplayOutput::ExactAndApproximateToggle && !isSelected));
m_scrollableOutputView.setSelectedSubviewPosition(Shared::ScrollableExactApproximateExpressionsView::SubviewPosition::Left);
}
}
void HistoryViewCell::didBecomeFirstResponder() {

View File

@@ -30,6 +30,7 @@ void ScrollableExactApproximateExpressionsCell::reloadScroll() {
}
void ScrollableExactApproximateExpressionsCell::didBecomeFirstResponder() {
m_view.setSelectedSubviewPosition(ScrollableExactApproximateExpressionsView::SubviewPosition::Left);
app()->setFirstResponder(&m_view);
}

View File

@@ -126,7 +126,8 @@ void ScrollableExactApproximateExpressionsView::setEqualMessage(I18n::Message eq
void ScrollableExactApproximateExpressionsView::didBecomeFirstResponder() {
if (m_contentCell.leftExpressionView()->layout().isUninitialized()) {
setSelectedSubviewPosition(SubviewPosition::Right);
} else {
}
if (m_contentCell.rightExpressionView()->layout().isUninitialized()) {
setSelectedSubviewPosition(SubviewPosition::Left);
}
}