[interactive_curve_view_controller] Fix Cursor

Restore the permanence of the cursor between accesses to the graph
window.
The cursor used to be reset when the models had been modified. As there
is no longer a system in place to track these modifications, we manually
check if there is a curve beneath the cursor before reseting it.

Change-Id: I6f71fc17744b5bf1ee552c82126bb4a08b823629
This commit is contained in:
Gabriel Ozouf
2020-10-14 09:46:21 +02:00
committed by Émilie Feral
parent 16707aa518
commit 190568ea84
6 changed files with 33 additions and 1 deletions

View File

@@ -259,6 +259,21 @@ void GraphController::initCursorParameters() {
*m_selectedDotIndex = m_store->numberOfPairsOfSeries(*m_selectedSeriesIndex);
}
bool GraphController::isCursorHanging() {
if (m_store->seriesIsEmpty(*m_selectedSeriesIndex)) {
return true;
}
Coordinate2D<double> xy;
if (*m_selectedDotIndex == -1) {
xy = xyValues(*m_selectedSeriesIndex, m_cursor->t(), globalContext());
} else if (*m_selectedDotIndex == m_store->numberOfPairsOfSeries(*m_selectedSeriesIndex)) {
xy = Coordinate2D<double>(m_store->meanOfColumn(*m_selectedSeriesIndex, 0), m_store->meanOfColumn(*m_selectedSeriesIndex, 1));
} else {
xy = Coordinate2D<double>(m_store->get(*m_selectedSeriesIndex, 0, *m_selectedDotIndex), m_store->get(*m_selectedSeriesIndex, 1, *m_selectedDotIndex));
}
return xy.x1() != m_cursor->x() || xy.x2() != m_cursor->y();
}
bool GraphController::moveCursorVertically(int direction) {
Poincare::Context * context = globalContext();
double x = m_cursor->x();