Enhance: make TConsole scrolling smoother#4445
Conversation
Make it scroll by only 1 line of text per mouse wheel click instead of three lines. To compensate for the slower nature of the scrolling now, make the scrolling faster (to a half the number of lines in the upper `TTextEdit` pane per step instead of one line) when the control key is pressed during the wheel event; this thus mimics the same sort of speed up in the map zoom and scrolling through the selected room number/name listing in the 2D mapper. This should close Mudlet#4437 . It also fixes a potential bug in that the `TTextEdit::updateScreenView()` looked to be sending the "screenheight" for both the upper and lower panes to the same variable in the `Host` class - when they are not going to be the same value. It also removes the use of the obsolete `(int) QWheelEvent::delta()` in favour of the recommended `(QPoint) QWheelEvent::angleDelta()` in the `qlWidget` class. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
|
Pasted in Held fingertip at bottom of wheel range status quo: demo: Repeated that a few times, status quo shows a net gain of 10 lines or so. Managed to move 100 lines up just wiggling finger back and forth between same 2 spots at different speeds a few times. With new build, moving back and forth between 2 spots brings it back and forth between the same 2 spots. Moving faster just gets you there faster. Scrolling to an exact line is much easier now. Very nice. From the bottom, scroll up to line 500. status quo: 33 rolls up (at comfortable speed) So it's more exact, but feels pretty different, slower if you're wanting to go back far and not aware of the control key thing. Adjusting multiplier would be judgement call for testing. Tried two fingers on the touchpad of my laptop... status quo: demo: |
I would have an outside variable something vaguely like this, which would be held in-between the events and range from -119 to 119 saying how much wheel movement happened so far but didn't result in scrolling any lines: Then if you move your device by for example 90 points four times in a row then you'll move by 3 lines rather than 0: |
|
I haven't looked at touch pad considerations in this - but IIRC the Qt documentation does make mention of some hi-resolution devices not behaving the same as a clicky mouse scroll wheel, lemme see if I can find it... Ah yeah, it is in the obvious place as part of the
void MyWidget::wheelEvent(QWheelEvent *event)
{
QPoint numPixels = event->pixelDelta();
QPoint numDegrees = event->angleDelta() / 8;
if (!numPixels.isNull()) {
scrollWithPixels(numPixels);
} else if (!numDegrees.isNull()) {
QPoint numSteps = numDegrees / 15;
scrollWithDegrees(numSteps);
}
event->accept();
}
I am going to have to look at this again and see what I can do after a good thunk... |
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Bring in recent upstream changes. Signed-off by: Stephen Lyons <slysven@virginmedia.com>
|
Tried it out in same way as before using trackpad on Logitech k400r, dragged super slow and made progress as intended. I didn't look too close at the code but feels much better and can easily scroll to exact line. I do notice that it can not scroll horizontal. But the release build doesn't scroll horizonal either like it did with #4085. The oldest one on the snapshots page doesn't scroll horizontal either. That got broken at some point more than 14 days ago, but more recent than the last build in my download folder, Mudlet-4.9.1-testing-pr3992-fd96e822-windows from Oct 23. |
src/TTextEdit.cpp
Outdated
| e->ignore(); | ||
| // Make the speed up be half of the (upper pane) lines - need to round it so | ||
| // that a decimal part does not make the end +/- value for up/down different | ||
| // in magitude: |
There was a problem hiding this comment.
| // in magitude: | |
| // in magnitude: |
src/TTextEdit.cpp
Outdated
| // Store the (rounded) remainder | ||
| mMouseWheelRemainder = QPoint(delta.x() - (15 * xDelta), delta.y() - (15 * yDelta)); | ||
|
|
||
| qDebug().noquote().nospace() << "TTextEdit::wheelEvent(...) INFO - in \"" |
There was a problem hiding this comment.
W.I.P. on the horizontal scrolling aspect at the moment and I am using that. Mayhaps I should move that to a separate PR...
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
Thanks for working on this 👍 |
|
I think that this was the last instance of delta() to switch over to angleDelta() and this closes #498. |
Make it scroll by only 1 line of text per mouse wheel click instead of three lines. To compensate for the slower nature of the scrolling now, make the scrolling faster (to a half the number of lines in the upper `TTextEdit` pane per step instead of one line) when the control key is pressed during the wheel event; this thus mimics the same sort of speed up in the map zoom and scrolling through the selected room number/name listing in the 2D mapper. This should close Mudlet#4437 . It also fixes a potential bug in that the `TTextEdit::updateScreenView()` looked to be sending the "screenheight" for both the upper and lower panes to the same variable in the `Host` class - when they are not going to be the same value. It also removes the use of the obsolete `(int) QWheelEvent::delta()` in favour of the recommended `(QPoint) QWheelEvent::angleDelta()` in the `qlWidget` class. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
…n (issue Mudlet#8388) Added historical context for the lowerAppears/QTimer deferred scroll pattern. Key findings: - Code exists from initial repository import (commit 7f58d98) - No explicit documentation found for why QTimer::singleShot was used - Deferred execution is common Qt pattern for layout timing - Likely added to ensure lower pane geometry is calculated before getRowCount() - Unintentionally creates double-scroll bug (timer scroll + immediate scroll) Historical references: - Issue Mudlet#1105: PgUp/PgDown split-screen behavior - Issue Mudlet#2397: Mousewheel scroll modifiers (PR Mudlet#4445) - Issue Mudlet#3204: Multi-view persistence (PR Mudlet#3844) The timer pattern prevents race conditions but wasn't designed to add extra scrolling - that's the bug. Solution 1 (combining both scrolls in one deferred operation) preserves the timing benefits while fixing the double-scroll issue. Related to: Mudlet#8388 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Make it scroll by only 1 line of text per mouse wheel click instead of three lines. To compensate for the slower nature of the scrolling now, make the scrolling faster (to a half the number of lines in the upper
TTextEditpane per step instead of one line) when the control key is pressed during the wheel event; this thus mimics the same sort of speed up in the map zoom and scrolling through the selected room number/name listing in the 2D mapper.This should close #4437 .
It also fixes a potential bug in that the
TTextEdit::updateScreenView()looked to be sending the "screenheight" for both the upper and lower panes to the same variable in theHostclass - when they are not going to be the same value.It also removes the use of the obsolete
(int) QWheelEvent::delta()in favour of the recommended(QPoint) QWheelEvent::angleDelta()in theqlWidgetclass.Signed-off-by: Stephen Lyons slysven@virginmedia.com