From 534163ae5f5b49418d48fdc8547719a0582bbc53 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 25 Oct 2021 17:39:55 -0300 Subject: [PATCH 1/2] Fix painting issues in the debugger filling the line number column correctly --- src/app/commands/debugger.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/app/commands/debugger.cpp b/src/app/commands/debugger.cpp index 9d6675b5f..fd5a9f0c2 100644 --- a/src/app/commands/debugger.cpp +++ b/src/app/commands/debugger.cpp @@ -189,17 +189,11 @@ protected: vp = clientBounds(); auto f = font(); - gfx::Rect linesVp( - vp.x, vp.y, - Graphics::measureUITextLength(base::convert_to(nlines), f) - + 4*guiscale(), // TODO configurable from the theme? - vp.h); - vp.x += linesVp.w; - vp.w -= linesVp.w; + gfx::Rect linesVp(0, vp.y, getLineNumberColumnWidth(), vp.h); // Fill background - g->fillRect(linesBg, linesVp); g->fillRect(bg, vp); + g->fillRect(linesBg, linesVp); if (m_fileContent) { auto icon = theme->parts.debugContinue()->bitmap(0); @@ -240,12 +234,22 @@ protected: m_maxLineWidth = std::max(m_maxLineWidth, Graphics::measureUITextLength(tmp, f)); } } - ev.setSizeHint(gfx::Size(m_maxLineWidth, + + ev.setSizeHint(gfx::Size(m_maxLineWidth + getLineNumberColumnWidth(), m_fileContent->lines.size() * textHeight())); } } private: + + int getLineNumberColumnWidth() const { + auto f = font(); + int nlines = (m_fileContent ? m_fileContent->lines.size(): 0); + return + Graphics::measureUITextLength(base::convert_to(nlines), f) + + 4*guiscale(); // TODO configurable from the theme? + } + FileContentPtr m_fileContent; int m_currentLine = -1; int m_maxLineWidth = 0; From 91e8e5cd46a079fec514c933c46cd4c0da3bf49c Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 25 Oct 2021 17:40:47 -0300 Subject: [PATCH 2/2] Support scrolling the debugger source code viewport w/the mouse wheel --- src/app/commands/debugger.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/app/commands/debugger.cpp b/src/app/commands/debugger.cpp index fd5a9f0c2..2916caa3e 100644 --- a/src/app/commands/debugger.cpp +++ b/src/app/commands/debugger.cpp @@ -170,6 +170,25 @@ public: protected: bool onProcessMessage(Message* msg) override { + switch (msg->type()) { + + case kMouseWheelMessage: { + View* view = View::getView(this); + if (view) { + auto mouseMsg = static_cast(msg); + gfx::Point scroll = view->viewScroll(); + + if (mouseMsg->preciseWheel()) + scroll += mouseMsg->wheelDelta(); + else + scroll += mouseMsg->wheelDelta() * textHeight()*3; + + view->setViewScroll(scroll); + } + break; + } + + } return Widget::onProcessMessage(msg); }