summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-07-11 14:32:11 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-07-11 14:32:11 +0300
commitb1b524876501bed8828742dbda316c49fe1a2d03 (patch)
tree33a94c57ea0ae80b0d2e7269181b8a70e5a59ca0 /src/ui
parent2f60372f8ea9ee6f6bad04d817a79e2b03c91e3b (diff)
Preferences: Settings for smooth scroll speed
IssueID #297
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/command.h4
-rw-r--r--src/ui/documentwidget.c10
-rw-r--r--src/ui/listwidget.c3
-rw-r--r--src/ui/util.c19
4 files changed, 31 insertions, 5 deletions
diff --git a/src/ui/command.h b/src/ui/command.h
index 10a29101..8dbaafad 100644
--- a/src/ui/command.h
+++ b/src/ui/command.h
@@ -41,3 +41,7 @@ const iString * string_Command (const char *, const char *label); /* space-
41iRangecc range_Command (const char *, const char *label); /* space-delimited */ 41iRangecc range_Command (const char *, const char *label); /* space-delimited */
42const char * suffixPtr_Command (const char *, const char *label); /* until end-of-command */ 42const char * suffixPtr_Command (const char *, const char *label); /* until end-of-command */
43iString * suffix_Command (const char *, const char *label); /* until end-of-command */ 43iString * suffix_Command (const char *, const char *label); /* until end-of-command */
44
45iLocalDef iBool hasLabel_Command(const char *d, const char *label) {
46 return suffixPtr_Command(d, label) != NULL;
47}
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 38f34c77..b59233c7 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -201,7 +201,9 @@ static void updateSideIconBuf_DocumentWidget_ (const iDocumentWidget *d);
201static void prerender_DocumentWidget_ (iAny *); 201static void prerender_DocumentWidget_ (iAny *);
202static void scrollBegan_DocumentWidget_ (iAnyObject *, int, uint32_t); 202static void scrollBegan_DocumentWidget_ (iAnyObject *, int, uint32_t);
203 203
204static const int smoothDuration_DocumentWidget_ = 600; /* milliseconds */ 204static const int smoothDuration_DocumentWidget_(enum iScrollType type) {
205 return 600 /* milliseconds */ * scrollSpeedFactor_Prefs(prefs_App(), type);
206}
205 207
206enum iRequestState { 208enum iRequestState {
207 blank_RequestState, 209 blank_RequestState,
@@ -2913,7 +2915,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
2913 const float amount = argLabel_Command(cmd, "full") != 0 ? 1.0f : 0.5f; 2915 const float amount = argLabel_Command(cmd, "full") != 0 ? 1.0f : 0.5f;
2914 smoothScroll_DocumentWidget_(d, 2916 smoothScroll_DocumentWidget_(d,
2915 dir * amount * height_Rect(documentBounds_DocumentWidget_(d)), 2917 dir * amount * height_Rect(documentBounds_DocumentWidget_(d)),
2916 smoothDuration_DocumentWidget_); 2918 smoothDuration_DocumentWidget_(keyboard_ScrollType));
2917 return iTrue; 2919 return iTrue;
2918 } 2920 }
2919 else if (equal_Command(cmd, "scroll.top") && document_App() == d) { 2921 else if (equal_Command(cmd, "scroll.top") && document_App() == d) {
@@ -2942,7 +2944,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
2942 } 2944 }
2943 smoothScroll_DocumentWidget_(d, 2945 smoothScroll_DocumentWidget_(d,
2944 3 * lineHeight_Text(paragraph_FontId) * dir, 2946 3 * lineHeight_Text(paragraph_FontId) * dir,
2945 smoothDuration_DocumentWidget_); 2947 smoothDuration_DocumentWidget_(keyboard_ScrollType));
2946 return iTrue; 2948 return iTrue;
2947 } 2949 }
2948 else if (equal_Command(cmd, "document.goto") && document_App() == d) { 2950 else if (equal_Command(cmd, "document.goto") && document_App() == d) {
@@ -3381,7 +3383,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
3381 smoothScroll_DocumentWidget_( 3383 smoothScroll_DocumentWidget_(
3382 d, 3384 d,
3383 -3 * amount * lineHeight_Text(paragraph_FontId), 3385 -3 * amount * lineHeight_Text(paragraph_FontId),
3384 smoothDuration_DocumentWidget_ * 3386 smoothDuration_DocumentWidget_(mouse_ScrollType) *
3385 /* accelerated speed for repeated wheelings */ 3387 /* accelerated speed for repeated wheelings */
3386 (!isFinished_SmoothScroll(&d->scrollY) && pos_Anim(&d->scrollY.pos) < 0.25f 3388 (!isFinished_SmoothScroll(&d->scrollY) && pos_Anim(&d->scrollY.pos) < 0.25f
3387 ? 0.5f 3389 ? 0.5f
diff --git a/src/ui/listwidget.c b/src/ui/listwidget.c
index f7c43a93..29aa9d1f 100644
--- a/src/ui/listwidget.c
+++ b/src/ui/listwidget.c
@@ -347,7 +347,8 @@ static iBool processEvent_ListWidget_(iListWidget *d, const SDL_Event *ev) {
347 else { 347 else {
348 /* Traditional mouse wheel. */ 348 /* Traditional mouse wheel. */
349 amount *= 3 * d->itemHeight; 349 amount *= 3 * d->itemHeight;
350 moveSpan_SmoothScroll(&d->scrollY, amount, 200); 350 moveSpan_SmoothScroll(
351 &d->scrollY, amount, 200 * scrollSpeedFactor_Prefs(prefs_App(), mouse_ScrollType));
351 } 352 }
352 return iTrue; 353 return iTrue;
353 } 354 }
diff --git a/src/ui/util.c b/src/ui/util.c
index d68274ad..220e3a50 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1678,6 +1678,25 @@ iWidget *makePreferences_Widget(void) {
1678 makeTwoColumnHeading_("${heading.prefs.scrolling}", headings, values); 1678 makeTwoColumnHeading_("${heading.prefs.scrolling}", headings, values);
1679 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.smoothscroll}"))); 1679 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.smoothscroll}")));
1680 addChild_Widget(values, iClob(makeToggle_Widget("prefs.smoothscroll"))); 1680 addChild_Widget(values, iClob(makeToggle_Widget("prefs.smoothscroll")));
1681 /* Scroll speeds. */ {
1682 for (int type = 0; type < max_ScrollType; type++) {
1683 const char *typeStr = (type == mouse_ScrollType ? "mouse" : "keyboard");
1684 addChild_Widget(headings,
1685 iClob(makeHeading_Widget(type == mouse_ScrollType
1686 ? "${prefs.scrollspeed.mouse}"
1687 : "${prefs.scrollspeed.keyboard}")));
1688 iWidget *scrollSpeed = new_Widget();
1689 addRadioButton_(scrollSpeed, format_CStr("prefs.scrollspeed.%s.7", typeStr), "0", format_CStr("scrollspeed arg:7 type:%d", type));
1690 addRadioButton_(scrollSpeed, format_CStr("prefs.scrollspeed.%s.10", typeStr), "1", format_CStr("scrollspeed arg:10 type:%d", type));
1691 addRadioButton_(scrollSpeed, format_CStr("prefs.scrollspeed.%s.13", typeStr), "2", format_CStr("scrollspeed arg:13 type:%d", type));
1692 addRadioButton_(scrollSpeed, format_CStr("prefs.scrollspeed.%s.17", typeStr), "3", format_CStr("scrollspeed arg:17 type:%d", type));
1693 addRadioButton_(scrollSpeed, format_CStr("prefs.scrollspeed.%s.23", typeStr), "4", format_CStr("scrollspeed arg:23 type:%d", type));
1694 addRadioButton_(scrollSpeed, format_CStr("prefs.scrollspeed.%s.30", typeStr), "5", format_CStr("scrollspeed arg:30 type:%d", type));
1695 addRadioButton_(scrollSpeed, format_CStr("prefs.scrollspeed.%s.40", typeStr), "6", format_CStr("scrollspeed arg:40 type:%d", type));
1696 addChildFlags_Widget(
1697 values, iClob(scrollSpeed), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1698 }
1699 }
1681 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.imageloadscroll}"))); 1700 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.imageloadscroll}")));
1682 addChild_Widget(values, iClob(makeToggle_Widget("prefs.imageloadscroll"))); 1701 addChild_Widget(values, iClob(makeToggle_Widget("prefs.imageloadscroll")));
1683 if (deviceType_App() == phone_AppDeviceType) { 1702 if (deviceType_App() == phone_AppDeviceType) {