From e70eb49bf99f50a63b52918a711666e72ca51d18 Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Thu, 17 Sep 2020 22:59:56 -0400 Subject: [PATCH] Added logic for ASM view horizontal scroll. Set debugger bookmark buttons to insensitive until code can be added. --- src/drivers/Qt/ConsoleDebugger.cpp | 46 +++++++++++++++++++++++------- src/drivers/Qt/ConsoleDebugger.h | 3 ++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/drivers/Qt/ConsoleDebugger.cpp b/src/drivers/Qt/ConsoleDebugger.cpp index 75f16137..ee4cca05 100644 --- a/src/drivers/Qt/ConsoleDebugger.cpp +++ b/src/drivers/Qt/ConsoleDebugger.cpp @@ -383,12 +383,15 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent) button = new QPushButton( tr("Add") ); vbox->addWidget( button ); + button->setEnabled(false); // TODO button = new QPushButton( tr("Delete") ); vbox->addWidget( button ); + button->setEnabled(false); // TODO button = new QPushButton( tr("Name") ); vbox->addWidget( button ); + button->setEnabled(false); // TODO hbox->addWidget( bmTree ); hbox->addLayout( vbox ); @@ -467,7 +470,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent) periodicTimer = new QTimer( this ); connect( periodicTimer, &QTimer::timeout, this, &ConsoleDebugger::updatePeriodic ); - //connect( hbar, SIGNAL(valueChanged(int)), this, SLOT(hbarChanged(int)) ); + connect( hbar, SIGNAL(valueChanged(int)), this, SLOT(hbarChanged(int)) ); connect( vbar, SIGNAL(valueChanged(int)), this, SLOT(vbarChanged(int)) ); bpListUpdate( false ); @@ -1813,7 +1816,9 @@ void QAsmView::updateAssemblyView(void) asmEntry.push_back(a); } - setMinimumWidth( maxLineLen * pxCharWidth ); + pxLineWidth = maxLineLen * pxCharWidth; + + setMinimumWidth( pxLineWidth ); vbar->setMaximum( asmEntry.size() ); } @@ -2132,6 +2137,12 @@ void ConsoleDebugger::breakPointNotify( int bpNum ) windowUpdateReq = true; } //---------------------------------------------------------------------------- +void ConsoleDebugger::hbarChanged(int value) +{ + //printf("HBar Changed: %i\n", value); + asmView->setXScroll( value ); +} +//---------------------------------------------------------------------------- void ConsoleDebugger::vbarChanged(int value) { //printf("VBar Changed: %i\n", value); @@ -2475,6 +2486,7 @@ QAsmView::QAsmView(QWidget *parent) symbolicDebugEnable = true; registerNameEnable = true; maxLineLen = 0; + pxLineWidth = 0; lineOffset = 0; maxLineOffset = 0; ctxMenuAddr = -1; @@ -2501,6 +2513,18 @@ void QAsmView::setLine(int lineNum) lineOffset = lineNum; } //---------------------------------------------------------------------------- +void QAsmView::setXScroll(int value) +{ + if ( viewWidth >= pxLineWidth ) + { + pxLineXScroll = 0; + } + else + { + pxLineXScroll = (int)(0.010f * (float)value * (float)(pxLineWidth - viewWidth) ); + } +} +//---------------------------------------------------------------------------- void QAsmView::scrollToPC(void) { if ( asmPC != NULL ) @@ -2573,14 +2597,14 @@ void QAsmView::resizeEvent(QResizeEvent *event) maxLineOffset = 0; // mb.numLines() - viewLines + 1; - //if ( viewWidth >= pxLineWidth ) - //{ - // pxLineXScroll = 0; - //} - //else - //{ - // pxLineXScroll = (int)(0.010f * (float)hbar->value() * (float)(pxLineWidth - viewWidth) ); - //} + if ( viewWidth >= pxLineWidth ) + { + pxLineXScroll = 0; + } + else + { + pxLineXScroll = (int)(0.010f * (float)hbar->value() * (float)(pxLineWidth - viewWidth) ); + } } //---------------------------------------------------------------------------- @@ -2775,7 +2799,7 @@ void QAsmView::paintEvent(QPaintEvent *event) for (row=0; row < nrow; row++) { - x=0; + x = -pxLineXScroll; l = lineOffset + row; painter.setPen( this->palette().color(QPalette::WindowText)); diff --git a/src/drivers/Qt/ConsoleDebugger.h b/src/drivers/Qt/ConsoleDebugger.h index 07e28f0f..3661e5ac 100644 --- a/src/drivers/Qt/ConsoleDebugger.h +++ b/src/drivers/Qt/ConsoleDebugger.h @@ -72,6 +72,7 @@ class QAsmView : public QWidget void asmClear(void); int getAsmLineFromAddr(int addr); void setLine(int lineNum); + void setXScroll(int value); void scrollToPC(void); void setDisplayROMoffsets( bool value ); void setSymbolDebugEnable( bool value ); @@ -107,6 +108,7 @@ class QAsmView : public QWidget int viewHeight; int lineOffset; int maxLineOffset; + int pxLineWidth; int pxLineXScroll; int cursorPosX; int cursorPosY; @@ -199,6 +201,7 @@ class ConsoleDebugger : public QDialog void asmViewCtxMenuAddSym(void); private slots: void updatePeriodic(void); + void hbarChanged(int value); void vbarChanged(int value); void debugRunCB(void); void debugStepIntoCB(void);