summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
diff options
context:
space:
mode:
authorspycrab <spycrab@users.noreply.github.com>2018-08-19 13:29:52 +0200
committerspycrab <spycrab@users.noreply.github.com>2018-08-19 22:36:04 +0200
commit5b992f138bd7bbf07693b012c567a593b87236d8 (patch)
treef5c97c4d633448e6309782cc39dcce2de2426128 /Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
parent12a5fd80bde3c1f5557ea647ebb127d37e74040d (diff)
Qt/Debugger: Improve scrolling
Reduces the scrolling speed for both keyboard and mouse scrolling so users are able to navigate the code and memory view line by line
Diffstat (limited to 'Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp')
-rw-r--r--Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
index d9c6cbaf49..a1ab5ee3a1 100644
--- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
+++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
@@ -29,6 +29,10 @@
#include "DolphinQt/Resources.h"
#include "DolphinQt/Settings.h"
+// "Most mouse types work in steps of 15 degrees, in which case the delta value is a multiple of
+// 120; i.e., 120 units * 1/8 = 15 degrees." (http://doc.qt.io/qt-5/qwheelevent.html#angleDelta)
+constexpr double SCROLL_FRACTION_DEGREES = 15.;
+
constexpr size_t VALID_BRANCH_LENGTH = 10;
CodeViewWidget::CodeViewWidget()
@@ -484,11 +488,11 @@ void CodeViewWidget::keyPressEvent(QKeyEvent* event)
switch (event->key())
{
case Qt::Key_Up:
- m_address -= 3 * sizeof(u32);
+ m_address -= sizeof(u32);
Update();
return;
case Qt::Key_Down:
- m_address += 3 * sizeof(u32);
+ m_address += sizeof(u32);
Update();
return;
case Qt::Key_PageUp:
@@ -507,9 +511,13 @@ void CodeViewWidget::keyPressEvent(QKeyEvent* event)
void CodeViewWidget::wheelEvent(QWheelEvent* event)
{
- int delta = event->delta() > 0 ? -1 : 1;
+ auto delta =
+ -static_cast<int>(std::round((event->angleDelta().y() / (SCROLL_FRACTION_DEGREES * 8))));
+
+ if (delta == 0)
+ return;
- m_address += delta * 3 * sizeof(u32);
+ m_address += delta * sizeof(u32);
Update();
}