[apps/calculation] When EditExpressionController becomes the first

responder, scroll to the bottom of the table (and not the last cell).
Indeed, the last cell might be to big to be displayed and scroll to it
might scroll to its top.

This fixes the following bug: input 1/2/3/4/5/6/7/8, OK, up, down. We
did not scroll to the bottom of the table.
This commit is contained in:
Émilie Feral
2020-06-26 16:06:36 +02:00
parent 1da2f23914
commit 457fa6a925
4 changed files with 16 additions and 10 deletions

View File

@@ -12,6 +12,12 @@ CalculationSelectableTableView::CalculationSelectableTableView(Responder * paren
setDecoratorType(ScrollView::Decorator::Type::None);
}
void CalculationSelectableTableView::scrollToBottom() {
KDCoordinate contentOffsetX = contentOffset().x();
KDCoordinate contentOffsetY = dataSource()->cumulatedHeightFromIndex(dataSource()->numberOfRows()) - maxContentHeightDisplayableWithoutScrolling();
setContentOffset(KDPoint(contentOffsetX, contentOffsetY));
}
void CalculationSelectableTableView::scrollToCell(int i, int j) {
if (m_contentView.bounds().height() < bounds().height()) {
setTopMargin(bounds().height() - m_contentView.bounds().height());
@@ -21,9 +27,8 @@ void CalculationSelectableTableView::scrollToCell(int i, int j) {
::SelectableTableView::scrollToCell(i, j);
ScrollView::layoutSubviews();
if (m_contentView.bounds().height() - contentOffset().y() < bounds().height()) {
KDCoordinate contentOffsetX = contentOffset().x();
KDCoordinate contentOffsetY = dataSource()->cumulatedHeightFromIndex(dataSource()->numberOfRows()) - maxContentHeightDisplayableWithoutScrolling();
setContentOffset(KDPoint(contentOffsetX, contentOffsetY));
// Avoid empty space at the end of the table
scrollToBottom();
}
}