[apps/calculation] Fixed tall calculation scroll

When displaying a calculation taller than the screen, the output could
be displayed above the screen.
  - type 1/2/3/4/5/6/7/8/9 (the main fraction between the 1 and 2)
  - press UP to select the output
==> The output is still offscreen.

Change-Id: Ic3ed7664ae693d22486f8b2f9f3a8f2324c3d7c9
This commit is contained in:
Gabriel Ozouf
2020-06-25 17:50:34 +02:00
parent 363bf4a620
commit 123d5f9076
2 changed files with 8 additions and 2 deletions

View File

@@ -35,6 +35,8 @@ void CalculationSelectableTableView::scrollToSubviewOfTypeOfCellAtLocation(Histo
unhighlightSelectedCell();
/* Main part of the scroll */
HistoryViewCell * cell = (HistoryViewCell *)(selectedCell());
assert(cell);
KDCoordinate contentOffsetX = contentOffset().x();
KDCoordinate contentOffsetY = dataSource()->cumulatedHeightFromIndex(j+1) - maxContentHeightDisplayableWithoutScrolling();
if (subviewType == HistoryViewCellDataSource::SubviewType::Input) {
@@ -43,12 +45,15 @@ void CalculationSelectableTableView::scrollToSubviewOfTypeOfCellAtLocation(Histo
} else {
contentOffsetY = dataSource()->cumulatedHeightFromIndex(j);
}
} else if (cell->displaysSingleLine() && dataSource()->rowHeight(j) > maxContentHeightDisplayableWithoutScrolling()) {
/* If we cannot display the full calculation, we display the output as
* close as possible to the top of the screen without drawing empty space
* between the history and the input field. */
contentOffsetY = dataSource()->cumulatedHeightFromIndex(j) + std::min(dataSource()->rowHeight(j) - maxContentHeightDisplayableWithoutScrolling(), cell->inputView()->layout().baseline() - cell->outputView()->baseline());
}
setContentOffset(KDPoint(contentOffsetX, contentOffsetY));
/* For the same reason, we have to rehighlight the new history view cell and
* reselect the first responder. */
HistoryViewCell * cell = (HistoryViewCell *)(selectedCell());
assert(cell);
cell->setHighlighted(true);
Container::activeApp()->setFirstResponder(cell);
}