From b034f8e054f89695bb0ecd2f84c01ed66b7a8792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 27 May 2020 11:52:47 +0200 Subject: [PATCH] [apps/calculation] Fix history navigation When calculations span on two lines, better selection --- apps/calculation/history_controller.cpp | 8 +++++++- apps/calculation/history_view_cell.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/calculation/history_controller.cpp b/apps/calculation/history_controller.cpp index 5fca0aa98..251cc3a1f 100644 --- a/apps/calculation/history_controller.cpp +++ b/apps/calculation/history_controller.cpp @@ -169,8 +169,14 @@ void HistoryController::tableViewDidChangeSelection(SelectableTableView * t, int } else if (selectedRow() == -1) { setSelectedSubviewType(SubviewType::Input, false, previousSelectedCellX, previousSelectedCellY); } else { - setSelectedSubviewType(selectedSubviewType(), false, previousSelectedCellX, previousSelectedCellY); + HistoryViewCell * selectedCell = (HistoryViewCell *)(t->selectedCell()); + SubviewType nextSelectedSubviewType = selectedSubviewType(); + if (!selectedCell->displaysSingleLine()) { + nextSelectedSubviewType = previousSelectedCellY < selectedRow() ? SubviewType::Input : SubviewType::Output; + } + setSelectedSubviewType(nextSelectedSubviewType, false, previousSelectedCellX, previousSelectedCellY); } + // The selectedCell may change during setSelectedSubviewType HistoryViewCell * selectedCell = (HistoryViewCell *)(t->selectedCell()); if (selectedCell == nullptr) { return; diff --git a/apps/calculation/history_view_cell.h b/apps/calculation/history_view_cell.h index 2cca12b62..d50256fc8 100644 --- a/apps/calculation/history_view_cell.h +++ b/apps/calculation/history_view_cell.h @@ -42,6 +42,9 @@ public: void setHighlighted(bool highlight) override; void reloadSubviewHighlight(); void setDataSource(HistoryViewCellDataSource * dataSource) { m_dataSource = dataSource; } + bool displaysSingleLine() const { + return m_calculationSingleLine; + } Responder * responder() override { return this; }