mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
scroll zoom: use fractions of power of 2 to avoid desync between key and mouse zoom
This commit is contained in:
parent
34b2c15b8d
commit
13badb6088
2 changed files with 7 additions and 7 deletions
|
@ -647,7 +647,7 @@ void Plot::closeEvent(QCloseEvent *event) {
|
||||||
g_useOverlays = false;
|
g_useOverlays = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plot::Zoom(float factor, int refX) {
|
void Plot::Zoom(double factor, int refX) {
|
||||||
if (factor >= 1) { // Zoom in
|
if (factor >= 1) { // Zoom in
|
||||||
if (GraphPixelsPerPoint <= 25 * factor) {
|
if (GraphPixelsPerPoint <= 25 * factor) {
|
||||||
GraphPixelsPerPoint *= factor;
|
GraphPixelsPerPoint *= factor;
|
||||||
|
@ -710,9 +710,9 @@ void Plot::wheelEvent(QWheelEvent *event) {
|
||||||
// 120 => shift right 5%
|
// 120 => shift right 5%
|
||||||
// -120 => shift left 5%
|
// -120 => shift left 5%
|
||||||
const float move_offset = 0.05;
|
const float move_offset = 0.05;
|
||||||
// -120+shift => zoom in 10%
|
// -120+shift => zoom in (5 times = *2)
|
||||||
// 120+shift => zoom out 10%
|
// 120+shift => zoom out (5 times = /2)
|
||||||
const float zoom_offset = 0.1;
|
const double zoom_offset = 1.148698354997035; // 2**(1/5)
|
||||||
if (event->modifiers() & Qt::ShiftModifier) {
|
if (event->modifiers() & Qt::ShiftModifier) {
|
||||||
// event->position doesn't exist in QT5.12.8, both exist in 5.14.2 and event->x doesn't exist in 5.15.0
|
// event->position doesn't exist in QT5.12.8, both exist in 5.14.2 and event->x doesn't exist in 5.15.0
|
||||||
#if QT_VERSION >= 0x050d00
|
#if QT_VERSION >= 0x050d00
|
||||||
|
@ -730,9 +730,9 @@ void Plot::wheelEvent(QWheelEvent *event) {
|
||||||
float delta = event->delta();
|
float delta = event->delta();
|
||||||
#endif
|
#endif
|
||||||
if (delta < 0) {
|
if (delta < 0) {
|
||||||
Zoom(1.0 - (float)delta / (120 / zoom_offset), x);
|
Zoom(zoom_offset, x);
|
||||||
} else {
|
} else {
|
||||||
Zoom(1.0 / (1.0 + (float)delta / (120 / zoom_offset)), x);
|
Zoom(1.0 / zoom_offset, x);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if QT_VERSION >= 0x050d00
|
#if QT_VERSION >= 0x050d00
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Plot: public QWidget {
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
void Zoom(float factor, int refX);
|
void Zoom(double factor, int refX);
|
||||||
void Move(int offset);
|
void Move(int offset);
|
||||||
void Trim(void);
|
void Trim(void);
|
||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue