Custom vertical scroll wheel event modifications for robustness.
This commit is contained in:
parent
71977ef15d
commit
309f417c6d
|
@ -4814,6 +4814,7 @@ QAsmView::QAsmView(QWidget *parent)
|
|||
|
||||
cursorLineAddr = -1;
|
||||
wheelPixelCounter = 0;
|
||||
wheelAngleCounter = 0;
|
||||
|
||||
//setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
@ -5899,6 +5900,7 @@ void QAsmView::mousePressEvent(QMouseEvent * event)
|
|||
//----------------------------------------------------------------------------
|
||||
void QAsmView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
int zDelta = 0;
|
||||
|
||||
QPoint numPixels = event->pixelDelta();
|
||||
QPoint numDegrees = event->angleDelta();
|
||||
|
@ -5907,42 +5909,59 @@ void QAsmView::wheelEvent(QWheelEvent *event)
|
|||
{
|
||||
wheelPixelCounter -= numPixels.y();
|
||||
//printf("numPixels: (%i,%i) \n", numPixels.x(), numPixels.y() );
|
||||
|
||||
if ( wheelPixelCounter >= pxLineSpacing )
|
||||
{
|
||||
zDelta = (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
else if ( wheelPixelCounter <= -pxLineSpacing )
|
||||
{
|
||||
zDelta = (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
}
|
||||
else if (!numDegrees.isNull())
|
||||
{
|
||||
int stepDeg = 120;
|
||||
//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);
|
||||
wheelAngleCounter -= numDegrees.y();
|
||||
|
||||
if ( wheelAngleCounter <= stepDeg )
|
||||
{
|
||||
zDelta = wheelAngleCounter / stepDeg;
|
||||
|
||||
wheelAngleCounter = wheelAngleCounter % stepDeg;
|
||||
}
|
||||
else if ( wheelAngleCounter >= stepDeg )
|
||||
{
|
||||
zDelta = wheelAngleCounter / stepDeg;
|
||||
|
||||
wheelAngleCounter = wheelAngleCounter % stepDeg;
|
||||
}
|
||||
}
|
||||
//printf("Wheel Event: %i\n", wheelPixelCounter);
|
||||
|
||||
if ( wheelPixelCounter >= pxLineSpacing )
|
||||
if ( zDelta != 0 )
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
if ( lineOffset > maxLineOffset )
|
||||
{
|
||||
lineOffset = maxLineOffset;
|
||||
}
|
||||
vbar->setValue( lineOffset );
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
else if ( wheelPixelCounter <= -pxLineSpacing )
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
lineOffset += zDelta;
|
||||
|
||||
if ( lineOffset < 0 )
|
||||
{
|
||||
lineOffset = 0;
|
||||
}
|
||||
else if ( lineOffset > maxLineOffset )
|
||||
{
|
||||
lineOffset = maxLineOffset;
|
||||
}
|
||||
vbar->setValue( lineOffset );
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
|
||||
event->accept();
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void QAsmView::contextMenuEvent(QContextMenuEvent *event)
|
||||
|
|
|
@ -247,6 +247,7 @@ class QAsmView : public QWidget
|
|||
int txtHlgtEndLine;
|
||||
|
||||
int wheelPixelCounter;
|
||||
int wheelAngleCounter;
|
||||
|
||||
dbg_asm_entry_t *asmPC;
|
||||
std::vector <dbg_asm_entry_t*> asmEntry;
|
||||
|
|
|
@ -1963,6 +1963,7 @@ QHexEdit::QHexEdit(QWidget *parent)
|
|||
frzIdx = 0;
|
||||
|
||||
wheelPixelCounter = 0;
|
||||
wheelAngleCounter = 0;
|
||||
|
||||
highLightColor[ 0].setRgb( 0x00, 0x00, 0x00 );
|
||||
highLightColor[ 1].setRgb( 0x35, 0x40, 0x00 );
|
||||
|
@ -2931,6 +2932,7 @@ void QHexEdit::mouseReleaseEvent(QMouseEvent * event)
|
|||
//----------------------------------------------------------------------------
|
||||
void QHexEdit::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
int zDelta = 0;
|
||||
|
||||
QPoint numPixels = event->pixelDelta();
|
||||
QPoint numDegrees = event->angleDelta();
|
||||
|
@ -2939,42 +2941,58 @@ void QHexEdit::wheelEvent(QWheelEvent *event)
|
|||
{
|
||||
wheelPixelCounter -= numPixels.y();
|
||||
//printf("numPixels: (%i,%i) \n", numPixels.x(), numPixels.y() );
|
||||
if ( wheelPixelCounter >= pxLineSpacing )
|
||||
{
|
||||
zDelta = (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
else if ( wheelPixelCounter <= -pxLineSpacing )
|
||||
{
|
||||
zDelta = (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
}
|
||||
else if (!numDegrees.isNull())
|
||||
{
|
||||
int stepDeg = 120;
|
||||
//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);
|
||||
wheelAngleCounter -= numDegrees.y();
|
||||
|
||||
if ( wheelAngleCounter <= stepDeg )
|
||||
{
|
||||
zDelta = wheelAngleCounter / stepDeg;
|
||||
|
||||
wheelAngleCounter = wheelAngleCounter % stepDeg;
|
||||
}
|
||||
else if ( wheelAngleCounter >= stepDeg )
|
||||
{
|
||||
zDelta = wheelAngleCounter / stepDeg;
|
||||
|
||||
wheelAngleCounter = wheelAngleCounter % stepDeg;
|
||||
}
|
||||
}
|
||||
//printf("Wheel Event: %i\n", wheelPixelCounter);
|
||||
|
||||
if ( wheelPixelCounter >= pxLineSpacing )
|
||||
if ( zDelta != 0 )
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
if ( lineOffset > maxLineOffset )
|
||||
{
|
||||
lineOffset = maxLineOffset;
|
||||
}
|
||||
vbar->setValue( lineOffset );
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
else if ( wheelPixelCounter <= -pxLineSpacing )
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
lineOffset += zDelta;
|
||||
|
||||
if ( lineOffset < 0 )
|
||||
{
|
||||
lineOffset = 0;
|
||||
}
|
||||
else if ( lineOffset > maxLineOffset )
|
||||
{
|
||||
lineOffset = maxLineOffset;
|
||||
}
|
||||
vbar->setValue( lineOffset );
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
|
||||
event->accept();
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void QHexEdit::contextMenuEvent(QContextMenuEvent *event)
|
||||
|
|
|
@ -226,6 +226,7 @@ class QHexEdit : public QWidget
|
|||
int frzRamMode;
|
||||
int frzIdx;
|
||||
int wheelPixelCounter;
|
||||
int wheelAngleCounter;
|
||||
int txtHlgtAnchorChar;
|
||||
int txtHlgtAnchorLine;
|
||||
int txtHlgtStartChar;
|
||||
|
|
|
@ -1614,6 +1614,7 @@ QRamSearchView::QRamSearchView(QWidget *parent)
|
|||
selLine = -1;
|
||||
|
||||
wheelPixelCounter = 0;
|
||||
wheelAngleCounter = 0;
|
||||
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
@ -1772,6 +1773,7 @@ void QRamSearchView::mousePressEvent(QMouseEvent *event)
|
|||
//----------------------------------------------------------------------------
|
||||
void QRamSearchView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
int zDelta = 0;
|
||||
|
||||
QPoint numPixels = event->pixelDelta();
|
||||
QPoint numDegrees = event->angleDelta();
|
||||
|
@ -1780,39 +1782,56 @@ void QRamSearchView::wheelEvent(QWheelEvent *event)
|
|||
{
|
||||
wheelPixelCounter -= numPixels.y();
|
||||
//printf("numPixels: (%i,%i) \n", numPixels.x(), numPixels.y() );
|
||||
|
||||
if ( wheelPixelCounter >= pxLineSpacing )
|
||||
{
|
||||
zDelta = (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
else if ( wheelPixelCounter <= -pxLineSpacing )
|
||||
{
|
||||
zDelta = (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
}
|
||||
else if (!numDegrees.isNull())
|
||||
{
|
||||
int stepDeg = 120;
|
||||
//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);
|
||||
wheelAngleCounter -= numDegrees.y();
|
||||
|
||||
if ( wheelAngleCounter <= stepDeg )
|
||||
{
|
||||
zDelta = wheelAngleCounter / stepDeg;
|
||||
|
||||
wheelAngleCounter = wheelAngleCounter % stepDeg;
|
||||
}
|
||||
else if ( wheelAngleCounter >= stepDeg )
|
||||
{
|
||||
zDelta = wheelAngleCounter / stepDeg;
|
||||
|
||||
wheelAngleCounter = wheelAngleCounter % stepDeg;
|
||||
}
|
||||
}
|
||||
//printf("Wheel Event: %i\n", wheelPixelCounter);
|
||||
|
||||
if (wheelPixelCounter >= pxLineSpacing)
|
||||
if (zDelta != 0)
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
|
||||
if (lineOffset > maxLineOffset)
|
||||
{
|
||||
lineOffset = maxLineOffset;
|
||||
}
|
||||
vbar->setValue(lineOffset);
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
else if (wheelPixelCounter <= -pxLineSpacing)
|
||||
{
|
||||
lineOffset += (wheelPixelCounter / pxLineSpacing);
|
||||
lineOffset += zDelta;
|
||||
|
||||
if (lineOffset < 0)
|
||||
{
|
||||
lineOffset = 0;
|
||||
}
|
||||
else if (lineOffset > maxLineOffset)
|
||||
{
|
||||
lineOffset = maxLineOffset;
|
||||
}
|
||||
vbar->setValue(lineOffset);
|
||||
|
||||
wheelPixelCounter = wheelPixelCounter % pxLineSpacing;
|
||||
}
|
||||
|
||||
event->accept();
|
||||
|
|
|
@ -29,7 +29,7 @@ class QRamSearchView : public QWidget
|
|||
|
||||
void setScrollBars( QScrollBar *hbar, QScrollBar *vbar );
|
||||
|
||||
int getSelAddr(void){ return selAddr; }
|
||||
int getSelAddr(void){ return selAddr; }
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
@ -58,9 +58,10 @@ class QRamSearchView : public QWidget
|
|||
int viewLines;
|
||||
int viewWidth;
|
||||
int viewHeight;
|
||||
int selAddr;
|
||||
int selLine;
|
||||
int selAddr;
|
||||
int selLine;
|
||||
int wheelPixelCounter;
|
||||
int wheelAngleCounter;
|
||||
};
|
||||
|
||||
class RamSearchDialog_t : public QDialog
|
||||
|
|
Loading…
Reference in New Issue