mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
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
63 lines
2.8 KiB
C++
63 lines
2.8 KiB
C++
#include "selectable_table_view.h"
|
|
|
|
namespace Calculation {
|
|
|
|
CalculationSelectableTableView::CalculationSelectableTableView(Responder * parentResponder, TableViewDataSource * dataSource,
|
|
SelectableTableViewDataSource * selectionDataSource, SelectableTableViewDelegate * delegate) :
|
|
::SelectableTableView(parentResponder, dataSource, selectionDataSource, delegate)
|
|
{
|
|
setVerticalCellOverlap(0);
|
|
setMargins(0);
|
|
setDecoratorType(ScrollView::Decorator::Type::None);
|
|
}
|
|
|
|
void CalculationSelectableTableView::scrollToCell(int i, int j) {
|
|
if (m_contentView.bounds().height() < bounds().height()) {
|
|
setTopMargin(bounds().height() - m_contentView.bounds().height());
|
|
} else {
|
|
setTopMargin(0);
|
|
}
|
|
::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));
|
|
}
|
|
}
|
|
|
|
void CalculationSelectableTableView::scrollToSubviewOfTypeOfCellAtLocation(HistoryViewCellDataSource::SubviewType subviewType, int i, int j) {
|
|
if (dataSource()->rowHeight(j) <= bounds().height()) {
|
|
return;
|
|
}
|
|
/* As we scroll, the selected calculation does not use the same history view
|
|
* cell, thus, we want to deselect the previous used history view cell. */
|
|
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) {
|
|
if (j == 0) {
|
|
contentOffsetY = 0;
|
|
} 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. */
|
|
cell->setHighlighted(true);
|
|
Container::activeApp()->setFirstResponder(cell);
|
|
}
|
|
|
|
|
|
}
|