From 3d2169b83376f84533277bb0d03f9f1212d613bf Mon Sep 17 00:00:00 2001 From: Jacob Litewski Date: Wed, 10 Apr 2024 19:09:37 -0400 Subject: [PATCH] Cursor A graph scrolling implementation If Cursor A goes off the screen, it will reposition the window to place the cursor in the middle of it. --- client/src/proxguiqt.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index 23ba3f332..760257bcd 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -1260,33 +1260,55 @@ void Plot::keyPressEvent(QKeyEvent *event) { RepaintGraphWindow(); break; - case Qt::Key_BracketLeft: + case Qt::Key_BracketLeft: { if(event->modifiers() & Qt::ControlModifier) { CursorAPos -= 5; } else { CursorAPos -= 1; } + if((CursorAPos >= g_GraphStop) || (CursorAPos <= g_GraphStart)) { + uint32_t halfway = PageWidth / 2; + + if((CursorAPos - halfway) > g_GraphTraceLen) { + g_GraphStart = 0; + } else { + g_GraphStart = CursorAPos - halfway; + } + } + if(CursorAPos < g_GraphStart) { CursorAPos = g_GraphStart; } RepaintGraphWindow(); break; + } - case Qt::Key_BracketRight: + case Qt::Key_BracketRight: { if(event->modifiers() & Qt::ControlModifier) { CursorAPos += 5; } else { CursorAPos += 1; } + if((CursorAPos >= g_GraphStop) || (CursorAPos <= g_GraphStart)) { + uint32_t halfway = PageWidth / 2; + + if((CursorAPos + halfway) >= g_GraphTraceLen) { + g_GraphStart = g_GraphTraceLen - halfway; + } else { + g_GraphStart = CursorAPos - halfway; + } + } + if(CursorAPos >= g_GraphTraceLen) { CursorAPos = g_GraphTraceLen; } RepaintGraphWindow(); break; + } case Qt::Key_BraceLeft: if(event->modifiers() & Qt::ControlModifier) {