summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-09 06:23:00 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-09 06:23:00 +0300
commit2e336ab65eae652714daccb14e08026c37bb823f (patch)
tree26b870688b6191e8461abf9b981ca56c26ca01bd
parent3ba6ccad2b31e0368257b3b073da3caf7d567998 (diff)
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.
-rw-r--r--src/prefs.c4
-rw-r--r--src/prefs.h2
-rw-r--r--src/ui/documentwidget.c8
-rw-r--r--src/ui/listwidget.c2
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) {
42 d->returnKey = default_ReturnKeyBehavior; 42 d->returnKey = default_ReturnKeyBehavior;
43 d->hoverLink = iFalse; 43 d->hoverLink = iFalse;
44 d->smoothScrolling = iTrue; 44 d->smoothScrolling = iTrue;
45 d->smoothScrollSpeed[keyboard_ScrollType] = 10; 45 d->smoothScrollSpeed[keyboard_ScrollType] = 13;
46 d->smoothScrollSpeed[mouse_ScrollType] = 10; 46 d->smoothScrollSpeed[mouse_ScrollType] = 13;
47 d->loadImageInsteadOfScrolling = iFalse; 47 d->loadImageInsteadOfScrolling = iFalse;
48 d->collapsePreOnLoad = iFalse; 48 d->collapsePreOnLoad = iFalse;
49 d->openArchiveIndexPages = iTrue; 49 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)
96 96
97iLocalDef float scrollSpeedFactor_Prefs(const iPrefs *d, enum iScrollType type) { 97iLocalDef float scrollSpeedFactor_Prefs(const iPrefs *d, enum iScrollType type) {
98 iAssert(type >= 0 && type < max_ScrollType); 98 iAssert(type >= 0 && type < max_ScrollType);
99 return 10.0f / iMax(1, d->smoothScrollSpeed[type]); 99 return 10.0f / iMax(1, d->smoothScrollSpeed[type]) * (type == mouse_ScrollType ? 0.5f : 1.0f);
100} 100}
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
3466 smoothScroll_DocumentWidget_( 3466 smoothScroll_DocumentWidget_(
3467 d, 3467 d,
3468 -3 * amount * lineHeight_Text(paragraph_FontId), 3468 -3 * amount * lineHeight_Text(paragraph_FontId),
3469 smoothDuration_DocumentWidget_(mouse_ScrollType) * 3469 smoothDuration_DocumentWidget_(mouse_ScrollType));
3470 /* accelerated speed for repeated wheelings */ 3470 /* accelerated speed for repeated wheelings */
3471 (!isFinished_SmoothScroll(&d->scrollY) && pos_Anim(&d->scrollY.pos) < 0.25f 3471// * (!isFinished_SmoothScroll(&d->scrollY) && pos_Anim(&d->scrollY.pos) < 0.25f
3472 ? 0.5f 3472// ? 0.5f
3473 : 1.0f)); 3473// : 1.0f));
3474 scrollWideBlock_DocumentWidget_( 3474 scrollWideBlock_DocumentWidget_(
3475 d, mouseCoord, -3 * ev->wheel.x * lineHeight_Text(paragraph_FontId), 167); 3475 d, mouseCoord, -3 * ev->wheel.x * lineHeight_Text(paragraph_FontId), 167);
3476 } 3476 }
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) {
348 /* Traditional mouse wheel. */ 348 /* Traditional mouse wheel. */
349 amount *= 3 * d->itemHeight; 349 amount *= 3 * d->itemHeight;
350 moveSpan_SmoothScroll( 350 moveSpan_SmoothScroll(
351 &d->scrollY, amount, 200 * scrollSpeedFactor_Prefs(prefs_App(), mouse_ScrollType)); 351 &d->scrollY, amount, 600 * scrollSpeedFactor_Prefs(prefs_App(), mouse_ScrollType));
352 } 352 }
353 return iTrue; 353 return iTrue;
354 } 354 }