From 7d753ae2d82592e09e04e4ecf11df976a2d187fd Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Wed, 7 Jun 2023 18:42:50 +0200 Subject: Debug and improve focus and scrollbars code --- src/CGEditor.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/CGEditor.cpp') diff --git a/src/CGEditor.cpp b/src/CGEditor.cpp index cf405db..1cdb012 100644 --- a/src/CGEditor.cpp +++ b/src/CGEditor.cpp @@ -8,6 +8,7 @@ CGEditor::CGEditor() { MT = new MoveTable(&status); MA = new Margin(&status); ME = new Menu(&status); + TF=nullptr; // Default Standard NagTable: https://en.wikipedia.org/wiki/Numeric_Annotation_Glyphs status.NagTable[0]=""; status.NagTable[1]="!"; @@ -81,6 +82,14 @@ void CGEditor::Draw() { MA->Refresh(); MT->Refresh(); MA->DrawMargin(MT->GetVariationsMarging()); + // Check if we need to focus on a specific move: + if(TF!=nullptr){ + double X,Y; + MT->GetMoveXY(TF,X,Y); + SBH->Focus(X+status.MoveWidth); + SBV->Focus(Y+status.MoveHeight); + TF=nullptr; + } SBV->Refresh(); SBH->Refresh(); ME->Refresh(); @@ -181,9 +190,6 @@ std::uint8_t CGEditor::GetNAGId(const std::string& symbol) const{ } void CGEditor::FocusOnMove(CMI::HalfMove* move){ - double X,Y; - MT->GetMoveXY(move,X,Y); - SBH->Focus(X+status.MoveWidth); - SBV->Focus(Y+status.MoveHeight); + TF=move; } } // namespace cgeditor -- cgit v1.2.3