For Qt, added mouse wheel scrolling logic to all custom QWidgets (Debugger Assembly Viewer, Trace Log Viewer, Hex Editor, and RAM Search Viewer)
This commit is contained in:
parent
43f87541b6
commit
c5cdd77fb1
|
@ -3407,7 +3407,7 @@ void QAsmView::wheelEvent(QWheelEvent *event)
|
|||
{
|
||||
|
||||
QPoint numPixels = event->pixelDelta();
|
||||
QPoint numDegrees = event->angleDelta() / 8;
|
||||
QPoint numDegrees = event->angleDelta();
|
||||
|
||||
if (!numPixels.isNull())
|
||||
{
|
||||
|
@ -3419,7 +3419,7 @@ void QAsmView::wheelEvent(QWheelEvent *event)
|
|||
//QPoint numSteps = numDegrees / 15;
|
||||
//printf("numSteps: (%i,%i) \n", numSteps.x(), numSteps.y() );
|
||||
//printf("numDegrees: (%i,%i) %i\n", numDegrees.x(), numDegrees.y(), pxLineSpacing );
|
||||
wheelPixelCounter += (pxLineSpacing * numDegrees.y()) / 15;
|
||||
wheelPixelCounter += (pxLineSpacing * numDegrees.y()) / (15*8);
|
||||
}
|
||||
//printf("Wheel Event: %i\n", wheelPixelCounter);
|
||||
|
||||
|
|
|
@ -1225,6 +1225,8 @@ QHexEdit::QHexEdit(QWidget *parent)
|
|||
frzRamMode = 0;
|
||||
frzIdx = 0;
|
||||
|
||||
wheelPixelCounter = 0;
|
||||
|
||||
highLightColor[ 0].setRgb( 0x00, 0x00, 0x00 );
|
||||
highLightColor[ 1].setRgb( 0x35, 0x40, 0x00 );
|
||||
highLightColor[ 2].setRgb( 0x18, 0x52, 0x18 );
|
||||
|
@ -1777,6 +1779,54 @@ void QHexEdit::mousePressEvent(QMouseEvent * event)
|
|||
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void QHexEdit::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
|
||||
QPoint numPixels = event->pixelDelta();
|
||||
QPoint numDegrees = event->angleDelta();
|
||||
|
||||
if (!numPixels.isNull())
|
||||
{
|
||||
wheelPixelCounter += numPixels.y();
|
||||
//printf("numPixels: (%i,%i) \n", numPixels.x(), numPixels.y() );
|
||||
}
|
||||
else if (!numDegrees.isNull())
|
||||
{
|
||||
//QPoint numSteps = numDegrees / 15;
|
||||
//printf("numSteps: (%i,%i) \n", numSteps.x(), numSteps.y() );
|
||||
//printf("numDegrees: (%i,%i) %i\n", numDegrees.x(), numDegrees.y(), pxLineSpacing );
|
||||
wheelPixelCounter += (pxLineSpacing * numDegrees.y()) / (15*8);
|
||||
}
|
||||
//printf("Wheel Event: %i\n", wheelPixelCounter);
|
||||
|
||||
if ( wheelPixelCounter >= pxLineSpacing )
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
if ( lineOffset > maxLineOffset )
|
||||
{
|
||||
lineOffset = maxLineOffset;
|
||||
}
|
||||
vbar->setValue( lineOffset );
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
else if ( wheelPixelCounter <= -pxLineSpacing )
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
if ( lineOffset < 0 )
|
||||
{
|
||||
lineOffset = 0;
|
||||
}
|
||||
vbar->setValue( lineOffset );
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void QHexEdit::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QAction *act;
|
||||
|
|
|
@ -130,6 +130,7 @@ class QHexEdit : public QWidget
|
|||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *event);
|
||||
void mousePressEvent(QMouseEvent * event);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
|
@ -185,6 +186,7 @@ class QHexEdit : public QWidget
|
|||
int frzRamVal;
|
||||
int frzRamMode;
|
||||
int frzIdx;
|
||||
int wheelPixelCounter;
|
||||
|
||||
bool cursorBlink;
|
||||
bool reverseVideo;
|
||||
|
|
|
@ -1507,6 +1507,8 @@ QRamSearchView::QRamSearchView(QWidget *parent)
|
|||
selAddr = -1;
|
||||
selLine = -1;
|
||||
|
||||
wheelPixelCounter = 0;
|
||||
|
||||
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
@ -1663,6 +1665,54 @@ void QRamSearchView::mousePressEvent(QMouseEvent * event)
|
|||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void QRamSearchView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
|
||||
QPoint numPixels = event->pixelDelta();
|
||||
QPoint numDegrees = event->angleDelta();
|
||||
|
||||
if (!numPixels.isNull())
|
||||
{
|
||||
wheelPixelCounter += numPixels.y();
|
||||
//printf("numPixels: (%i,%i) \n", numPixels.x(), numPixels.y() );
|
||||
}
|
||||
else if (!numDegrees.isNull())
|
||||
{
|
||||
//QPoint numSteps = numDegrees / 15;
|
||||
//printf("numSteps: (%i,%i) \n", numSteps.x(), numSteps.y() );
|
||||
//printf("numDegrees: (%i,%i) %i\n", numDegrees.x(), numDegrees.y(), pxLineSpacing );
|
||||
wheelPixelCounter += (pxLineSpacing * numDegrees.y()) / (15*8);
|
||||
}
|
||||
//printf("Wheel Event: %i\n", wheelPixelCounter);
|
||||
|
||||
if ( wheelPixelCounter >= pxLineSpacing )
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
if ( lineOffset > maxLineOffset )
|
||||
{
|
||||
lineOffset = maxLineOffset;
|
||||
}
|
||||
vbar->setValue( lineOffset );
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
else if ( wheelPixelCounter <= -pxLineSpacing )
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
if ( lineOffset < 0 )
|
||||
{
|
||||
lineOffset = 0;
|
||||
}
|
||||
vbar->setValue( lineOffset );
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void QRamSearchView::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
int i,x,y,row,nrow;
|
||||
|
|
|
@ -36,6 +36,7 @@ class QRamSearchView : public QWidget
|
|||
//void keyReleaseEvent(QKeyEvent *event);
|
||||
void mousePressEvent(QMouseEvent * event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
int convPixToLine( QPoint p );
|
||||
void calcFontData(void);
|
||||
|
@ -59,6 +60,7 @@ class QRamSearchView : public QWidget
|
|||
int viewHeight;
|
||||
int selAddr;
|
||||
int selLine;
|
||||
int wheelPixelCounter;
|
||||
};
|
||||
|
||||
class RamSearchDialog_t : public QDialog
|
||||
|
|
|
@ -1094,6 +1094,8 @@ QTraceLogView::QTraceLogView(QWidget *parent)
|
|||
|
||||
vbar = NULL;
|
||||
hbar = NULL;
|
||||
|
||||
wheelPixelCounter = 0;
|
||||
}
|
||||
//----------------------------------------------------
|
||||
QTraceLogView::~QTraceLogView(void)
|
||||
|
@ -1124,6 +1126,57 @@ void QTraceLogView::setScrollBars( QScrollBar *h, QScrollBar *v )
|
|||
hbar = h; vbar = v;
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void QTraceLogView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
int lineOffset;
|
||||
|
||||
QPoint numPixels = event->pixelDelta();
|
||||
QPoint numDegrees = event->angleDelta();
|
||||
|
||||
lineOffset = vbar->value();
|
||||
|
||||
if (!numPixels.isNull())
|
||||
{
|
||||
wheelPixelCounter += numPixels.y();
|
||||
//printf("numPixels: (%i,%i) \n", numPixels.x(), numPixels.y() );
|
||||
}
|
||||
else if (!numDegrees.isNull())
|
||||
{
|
||||
//QPoint numSteps = numDegrees / 15;
|
||||
//printf("numSteps: (%i,%i) \n", numSteps.x(), numSteps.y() );
|
||||
//printf("numDegrees: (%i,%i) %i\n", numDegrees.x(), numDegrees.y(), pxLineSpacing );
|
||||
wheelPixelCounter += (pxLineSpacing * numDegrees.y()) / (15*8);
|
||||
}
|
||||
//printf("Wheel Event: %i\n", wheelPixelCounter);
|
||||
|
||||
if ( wheelPixelCounter >= pxLineSpacing )
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
if ( lineOffset > recBufMax )
|
||||
{
|
||||
lineOffset = recBufMax;
|
||||
}
|
||||
vbar->setValue( lineOffset );
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
else if ( wheelPixelCounter <= -pxLineSpacing )
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
if ( lineOffset < 0 )
|
||||
{
|
||||
lineOffset = 0;
|
||||
}
|
||||
vbar->setValue( lineOffset );
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void QTraceLogView::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
viewWidth = event->size().width();
|
||||
|
|
|
@ -62,6 +62,7 @@ class QTraceLogView : public QWidget
|
|||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
void calcFontData(void);
|
||||
|
||||
|
@ -80,6 +81,7 @@ class QTraceLogView : public QWidget
|
|||
int viewLines;
|
||||
int viewWidth;
|
||||
int viewHeight;
|
||||
int wheelPixelCounter;
|
||||
};
|
||||
|
||||
class TraceLoggerDialog_t : public QDialog
|
||||
|
|
Loading…
Reference in New Issue