mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[escher][apps] SelectableTableViewDelegate: add
tableViewDidChangeSelectionAndDidScroll method and implement it for Calculation::HistoryController This fixes the following bug: In the calculation application, input 1, OK, 1/2/3/4/5/6/7/8, OK, up, up, left, down, up. The selection failed.
This commit is contained in:
@@ -40,7 +40,7 @@ void HistoryController::reload() {
|
||||
if (numberOfRows() > 0) {
|
||||
m_selectableTableView.scrollToCell(0, numberOfRows()-1);
|
||||
// Force to reload last added cell (hide the burger and exact output if necessary)
|
||||
tableViewDidChangeSelection(&m_selectableTableView, 0, numberOfRows()-1);
|
||||
tableViewDidChangeSelectionAndDidScroll(&m_selectableTableView, 0, numberOfRows()-1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
|
||||
return true;
|
||||
}
|
||||
m_selectableTableView.selectCellAtLocation(0, focusRow > 0 ? focusRow - 1 : 0);
|
||||
tableViewDidChangeSelection(&m_selectableTableView, 0, (subviewType == SubviewType::Input) ? selectedRow() : -1);
|
||||
tableViewDidChangeSelectionAndDidScroll(&m_selectableTableView, 0, (subviewType == SubviewType::Input) ? selectedRow() : -1);
|
||||
m_selectableTableView.scrollToCell(0, selectedRow());
|
||||
return true;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ Shared::ExpiringPointer<Calculation> HistoryController::calculationAtIndex(int i
|
||||
return m_calculationStore->calculationAtIndex(storeIndex(i));
|
||||
}
|
||||
|
||||
void HistoryController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
|
||||
void HistoryController::tableViewDidChangeSelectionAndDidScroll(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
|
||||
if (withinTemporarySelection || previousSelectedCellY == selectedRow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) override;
|
||||
void tableViewDidChangeSelectionAndDidScroll(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) override;
|
||||
private:
|
||||
int storeIndex(int i) { return numberOfRows() - i - 1; }
|
||||
Shared::ExpiringPointer<Calculation> calculationAtIndex(int i);
|
||||
|
||||
@@ -285,7 +285,7 @@ void ConsoleController::willDisplayCellAtLocation(HighlightCell * cell, int i, i
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
|
||||
void ConsoleController::tableViewDidChangeSelectionAndDidScroll(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
|
||||
if (withinTemporarySelection) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override;
|
||||
|
||||
// SelectableTableViewDelegate
|
||||
void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) override;
|
||||
void tableViewDidChangeSelectionAndDidScroll(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) override;
|
||||
|
||||
// TextFieldDelegate
|
||||
bool textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) override;
|
||||
|
||||
@@ -140,7 +140,21 @@ int Controller::numberOfIcons() const {
|
||||
}
|
||||
|
||||
void Controller::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
|
||||
AppsContainer * container = AppsContainer::sharedAppsContainer();
|
||||
if (withinTemporarySelection) {
|
||||
return;
|
||||
}
|
||||
/* To prevent the selectable table view to select cells that are unvisible,
|
||||
* we reselect the previous selected cell as soon as the selected cell is
|
||||
* unvisible. This trick does not create an endless loop as we ensure not to
|
||||
* stay on a unvisible cell and to initialize the first cell on a visible one
|
||||
* (so the previous one is always visible). */
|
||||
int appIndex = (t->selectedColumn()+t->selectedRow()*k_numberOfColumns)+1;
|
||||
if (appIndex >= AppsContainer::sharedAppsContainer()->numberOfApps()) {
|
||||
t->selectCellAtLocation(previousSelectedCellX, previousSelectedCellY);
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::tableViewDidChangeSelectionAndDidScroll(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
|
||||
if (withinTemporarySelection) {
|
||||
return;
|
||||
}
|
||||
@@ -153,16 +167,7 @@ void Controller::tableViewDidChangeSelection(SelectableTableView * t, int previo
|
||||
* background complete redrawing but the code is a bit
|
||||
* clumsy. */
|
||||
if (t->selectedRow() == numberOfRows()-1) {
|
||||
m_view.reloadBottomRow(this, container->numberOfApps()-1, k_numberOfColumns);
|
||||
}
|
||||
/* To prevent the selectable table view to select cells that are unvisible,
|
||||
* we reselect the previous selected cell as soon as the selected cell is
|
||||
* unvisible. This trick does not create an endless loop as we ensure not to
|
||||
* stay on a unvisible cell and to initialize the first cell on a visible one
|
||||
* (so the previous one is always visible). */
|
||||
int appIndex = (t->selectedColumn()+t->selectedRow()*k_numberOfColumns)+1;
|
||||
if (appIndex >= container->numberOfApps()) {
|
||||
t->selectCellAtLocation(previousSelectedCellX, previousSelectedCellY);
|
||||
m_view.reloadBottomRow(this, AppsContainer::sharedAppsContainer()->numberOfApps()-1, k_numberOfColumns);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
int reusableCellCount() const override;
|
||||
void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override;
|
||||
void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) override;
|
||||
void tableViewDidChangeSelectionAndDidScroll(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) override;
|
||||
private:
|
||||
int numberOfIcons() const;
|
||||
SelectableTableViewDataSource * selectionDataSource() const;
|
||||
|
||||
@@ -87,7 +87,7 @@ bool ListParameterController::textFieldDidFinishEditing(TextField * textField, c
|
||||
return true;
|
||||
}
|
||||
|
||||
void ListParameterController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
|
||||
void ListParameterController::tableViewDidChangeSelectionAndDidScroll(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
|
||||
if (withinTemporarySelection || (previousSelectedCellX == t->selectedColumn() && previousSelectedCellY == t->selectedRow())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
bool textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) override;
|
||||
bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override;
|
||||
void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) override;
|
||||
void tableViewDidChangeSelectionAndDidScroll(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) override;
|
||||
|
||||
// ListViewDataSource
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
* the previous selected cell. We might implement different course of action
|
||||
* when the selection change is 'real' or within temporary selection. */
|
||||
virtual void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) {}
|
||||
virtual void tableViewDidChangeSelectionAndDidScroll(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -102,6 +102,10 @@ bool SelectableTableView::selectCellAtLocation(int i, int j, bool setFirstRespon
|
||||
scrollToCell(selectedColumn(), selectedRow());
|
||||
}
|
||||
|
||||
if (m_delegate) {
|
||||
m_delegate->tableViewDidChangeSelectionAndDidScroll(this, previousX, previousY, withinTemporarySelection);
|
||||
}
|
||||
|
||||
HighlightCell * cell = selectedCell();
|
||||
if (cell) {
|
||||
// Update first responder
|
||||
|
||||
Reference in New Issue
Block a user