From 2508dd9c6ed951100ddc3857175a1dfa65828858 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 12 Jun 2014 07:35:49 -0700 Subject: [PATCH] Only scroll the grid to the active line if the row has actually changed Makes it so that undo/redo only scrolls to the active line if it's different in the two versions of the file. --- src/base_grid.cpp | 8 +++++--- src/base_grid.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/base_grid.cpp b/src/base_grid.cpp index b529642d1..3fa9b776a 100644 --- a/src/base_grid.cpp +++ b/src/base_grid.cpp @@ -237,11 +237,13 @@ void BaseGrid::UpdateMaps() { void BaseGrid::OnActiveLineChanged(AssDialogue *new_active) { if (new_active) { - int row = new_active->Row; - MakeRowVisible(row); - extendRow = row; + if (new_active->Row != active_row) + MakeRowVisible(new_active->Row); + extendRow = active_row = new_active->Row; Refresh(false); } + else + active_row = -1; } void BaseGrid::MakeRowVisible(int row) { diff --git a/src/base_grid.h b/src/base_grid.h index c8511504a..71d1c2f6a 100644 --- a/src/base_grid.h +++ b/src/base_grid.h @@ -55,6 +55,8 @@ class BaseGrid final : public wxWindow { /// First row that is visible at the current scroll position int yPos = 0; + int active_row = -1; + agi::Context *context; ///< Associated project context std::vector> columns;