From 7d0a1cd0b2b1ffbe20a29166992fd5aa97ec1b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 22 Jan 2020 09:36:13 +0100 Subject: [PATCH] [apps/calculation] HistoryViewCell: enable selecting the ellipsis --- apps/calculation/history_view_cell.cpp | 24 ++++++++++++++++++++---- apps/calculation/history_view_cell.h | 3 ++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/apps/calculation/history_view_cell.cpp b/apps/calculation/history_view_cell.cpp index 26e03f52d..05df03ae8 100644 --- a/apps/calculation/history_view_cell.cpp +++ b/apps/calculation/history_view_cell.cpp @@ -64,8 +64,11 @@ void HistoryViewCell::setHighlighted(bool highlight) { if (isHighlighted()) { if (m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Input) { m_inputView.setExpressionBackgroundColor(Palette::Select); - } else { + } else if (m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Output) { m_scrollableOutputView.evenOddCell()->setHighlighted(true); + } else { + assert(m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Ellipsis); + m_ellipsis.setHighlighted(true); } } } @@ -257,9 +260,22 @@ void HistoryViewCell::didBecomeFirstResponder() { bool HistoryViewCell::handleEvent(Ion::Events::Event event) { assert(m_dataSource); - if ((event == Ion::Events::Down && m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Input) || - (event == Ion::Events::Up && m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Output)) { - HistoryViewCellDataSource::SubviewType otherSubviewType = m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Input ? HistoryViewCellDataSource::SubviewType::Output : HistoryViewCellDataSource::SubviewType::Input; + HistoryViewCellDataSource::SubviewType type = m_dataSource->selectedSubviewType(); + if ((event == Ion::Events::Down && type == HistoryViewCellDataSource::SubviewType::Input) || + (event == Ion::Events::Up && type == HistoryViewCellDataSource::SubviewType::Output) || + (event == Ion::Events::Right && type != HistoryViewCellDataSource::SubviewType::Ellipsis) || + (event == Ion::Events::Left && type == HistoryViewCellDataSource::SubviewType::Ellipsis)) { + HistoryViewCellDataSource::SubviewType otherSubviewType; + if (event == Ion::Events::Down) { + otherSubviewType = HistoryViewCellDataSource::SubviewType::Output; + } else if (event == Ion::Events::Up) { + otherSubviewType = HistoryViewCellDataSource::SubviewType::Input; + } else if (event == Ion::Events::Right) { + otherSubviewType = HistoryViewCellDataSource::SubviewType::Ellipsis; + } else { + assert(event == Ion::Events::Left); + otherSubviewType = HistoryViewCellDataSource::SubviewType::Output; + } m_dataSource->setSelectedSubviewType(otherSubviewType); CalculationSelectableTableView * tableView = (CalculationSelectableTableView *)parentResponder(); tableView->scrollToSubviewOfTypeOfCellAtLocation(otherSubviewType, tableView->selectedColumn(), tableView->selectedRow()); diff --git a/apps/calculation/history_view_cell.h b/apps/calculation/history_view_cell.h index 69791b724..10bac7e49 100644 --- a/apps/calculation/history_view_cell.h +++ b/apps/calculation/history_view_cell.h @@ -13,7 +13,8 @@ class HistoryViewCellDataSource { public: enum class SubviewType { Input, - Output + Output, + Ellipsis }; HistoryViewCellDataSource(); void setSelectedSubviewType(SubviewType subviewType, int previousSelectedX = -1, int previousSelectedY = -1);