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.
This commit is contained in:
Jacob Litewski 2024-04-10 19:09:37 -04:00
parent 6a7e70ad26
commit 3d2169b833

View file

@ -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) {