From 2e336ab65eae652714daccb14e08026c37bb823f Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 9 Sep 2021 06:23:00 +0300 Subject: Tuned mouse wheel smooth scrolling Removed the two-stage acceleration of mouse wheel scrolling in favor of slightly faster base scrolling speed overall. This makes the behavior more consistent and predictable. --- src/prefs.c | 4 ++-- src/prefs.h | 2 +- src/ui/documentwidget.c | 8 ++++---- src/ui/listwidget.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/prefs.c b/src/prefs.c index 13a95a3d..ef1ce1b0 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -42,8 +42,8 @@ void init_Prefs(iPrefs *d) { d->returnKey = default_ReturnKeyBehavior; d->hoverLink = iFalse; d->smoothScrolling = iTrue; - d->smoothScrollSpeed[keyboard_ScrollType] = 10; - d->smoothScrollSpeed[mouse_ScrollType] = 10; + d->smoothScrollSpeed[keyboard_ScrollType] = 13; + d->smoothScrollSpeed[mouse_ScrollType] = 13; d->loadImageInsteadOfScrolling = iFalse; d->collapsePreOnLoad = iFalse; d->openArchiveIndexPages = iTrue; diff --git a/src/prefs.h b/src/prefs.h index 58c73bf7..a947a595 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -96,5 +96,5 @@ iDeclareTypeConstruction(Prefs) iLocalDef float scrollSpeedFactor_Prefs(const iPrefs *d, enum iScrollType type) { iAssert(type >= 0 && type < max_ScrollType); - return 10.0f / iMax(1, d->smoothScrollSpeed[type]); + return 10.0f / iMax(1, d->smoothScrollSpeed[type]) * (type == mouse_ScrollType ? 0.5f : 1.0f); } diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 7e138902..638906cf 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -3466,11 +3466,11 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e smoothScroll_DocumentWidget_( d, -3 * amount * lineHeight_Text(paragraph_FontId), - smoothDuration_DocumentWidget_(mouse_ScrollType) * + smoothDuration_DocumentWidget_(mouse_ScrollType)); /* accelerated speed for repeated wheelings */ - (!isFinished_SmoothScroll(&d->scrollY) && pos_Anim(&d->scrollY.pos) < 0.25f - ? 0.5f - : 1.0f)); +// * (!isFinished_SmoothScroll(&d->scrollY) && pos_Anim(&d->scrollY.pos) < 0.25f +// ? 0.5f +// : 1.0f)); scrollWideBlock_DocumentWidget_( d, mouseCoord, -3 * ev->wheel.x * lineHeight_Text(paragraph_FontId), 167); } diff --git a/src/ui/listwidget.c b/src/ui/listwidget.c index 46d32e9a..d51516d1 100644 --- a/src/ui/listwidget.c +++ b/src/ui/listwidget.c @@ -348,7 +348,7 @@ static iBool processEvent_ListWidget_(iListWidget *d, const SDL_Event *ev) { /* Traditional mouse wheel. */ amount *= 3 * d->itemHeight; moveSpan_SmoothScroll( - &d->scrollY, amount, 200 * scrollSpeedFactor_Prefs(prefs_App(), mouse_ScrollType)); + &d->scrollY, amount, 600 * scrollSpeedFactor_Prefs(prefs_App(), mouse_ScrollType)); } return iTrue; } -- cgit v1.2.3