diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-07-11 14:32:11 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-07-11 14:32:11 +0300 |
commit | b1b524876501bed8828742dbda316c49fe1a2d03 (patch) | |
tree | 33a94c57ea0ae80b0d2e7269181b8a70e5a59ca0 /src/app.c | |
parent | 2f60372f8ea9ee6f6bad04d817a79e2b03c91e3b (diff) |
Preferences: Settings for smooth scroll speed
IssueID #297
Diffstat (limited to 'src/app.c')
-rw-r--r-- | src/app.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -210,6 +210,8 @@ static iString *serializePrefs_App_(const iApp *d) { | |||
210 | appendFormat_String(str, "headingfont.set arg:%d\n", d->prefs.headingFont); | 210 | appendFormat_String(str, "headingfont.set arg:%d\n", d->prefs.headingFont); |
211 | appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent); | 211 | appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent); |
212 | appendFormat_String(str, "smoothscroll arg:%d\n", d->prefs.smoothScrolling); | 212 | appendFormat_String(str, "smoothscroll arg:%d\n", d->prefs.smoothScrolling); |
213 | appendFormat_String(str, "scrollspeed arg:%d type:%d\n", d->prefs.smoothScrollSpeed[keyboard_ScrollType], keyboard_ScrollType); | ||
214 | appendFormat_String(str, "scrollspeed arg:%d type:%d\n", d->prefs.smoothScrollSpeed[mouse_ScrollType], mouse_ScrollType); | ||
213 | appendFormat_String(str, "imageloadscroll arg:%d\n", d->prefs.loadImageInsteadOfScrolling); | 215 | appendFormat_String(str, "imageloadscroll arg:%d\n", d->prefs.loadImageInsteadOfScrolling); |
214 | appendFormat_String(str, "cachesize.set arg:%d\n", d->prefs.maxCacheSize); | 216 | appendFormat_String(str, "cachesize.set arg:%d\n", d->prefs.maxCacheSize); |
215 | appendFormat_String(str, "memorysize.set arg:%d\n", d->prefs.maxMemorySize); | 217 | appendFormat_String(str, "memorysize.set arg:%d\n", d->prefs.maxMemorySize); |
@@ -1604,6 +1606,15 @@ static void updatePrefsPinSplitButtons_(iWidget *d, int value) { | |||
1604 | } | 1606 | } |
1605 | } | 1607 | } |
1606 | 1608 | ||
1609 | static void updateScrollSpeedButtons_(iWidget *d, enum iScrollType type, const int value) { | ||
1610 | const char *typeStr = (type == mouse_ScrollType ? "mouse" : "keyboard"); | ||
1611 | for (int i = 0; i <= 40; i++) { | ||
1612 | setFlags_Widget(findChild_Widget(d, format_CStr("prefs.scrollspeed.%s.%d", typeStr, i)), | ||
1613 | selected_WidgetFlag, | ||
1614 | i == value); | ||
1615 | } | ||
1616 | } | ||
1617 | |||
1607 | static void updateDropdownSelection_(iLabelWidget *dropButton, const char *selectedCommand) { | 1618 | static void updateDropdownSelection_(iLabelWidget *dropButton, const char *selectedCommand) { |
1608 | iWidget *menu = findChild_Widget(as_Widget(dropButton), "menu"); | 1619 | iWidget *menu = findChild_Widget(as_Widget(dropButton), "menu"); |
1609 | iForEach(ObjectList, i, children_Widget(menu)) { | 1620 | iForEach(ObjectList, i, children_Widget(menu)) { |
@@ -1692,6 +1703,10 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) { | |||
1692 | updatePrefsPinSplitButtons_(d, arg_Command(cmd)); | 1703 | updatePrefsPinSplitButtons_(d, arg_Command(cmd)); |
1693 | return iFalse; | 1704 | return iFalse; |
1694 | } | 1705 | } |
1706 | else if (equal_Command(cmd, "scrollspeed")) { | ||
1707 | updateScrollSpeedButtons_(d, argLabel_Command(cmd, "type"), arg_Command(cmd)); | ||
1708 | return iFalse; | ||
1709 | } | ||
1695 | else if (equal_Command(cmd, "doctheme.dark.set")) { | 1710 | else if (equal_Command(cmd, "doctheme.dark.set")) { |
1696 | updateColorThemeButton_(findChild_Widget(d, "prefs.doctheme.dark"), arg_Command(cmd)); | 1711 | updateColorThemeButton_(findChild_Widget(d, "prefs.doctheme.dark"), arg_Command(cmd)); |
1697 | return iFalse; | 1712 | return iFalse; |
@@ -2065,6 +2080,13 @@ iBool handleCommand_App(const char *cmd) { | |||
2065 | d->prefs.smoothScrolling = arg_Command(cmd); | 2080 | d->prefs.smoothScrolling = arg_Command(cmd); |
2066 | return iTrue; | 2081 | return iTrue; |
2067 | } | 2082 | } |
2083 | else if (equal_Command(cmd, "scrollspeed")) { | ||
2084 | const int type = argLabel_Command(cmd, "type"); | ||
2085 | if (type == keyboard_ScrollType || type == mouse_ScrollType) { | ||
2086 | d->prefs.smoothScrollSpeed[type] = iClamp(arg_Command(cmd), 1, 40); | ||
2087 | } | ||
2088 | return iTrue; | ||
2089 | } | ||
2068 | else if (equal_Command(cmd, "decodeurls")) { | 2090 | else if (equal_Command(cmd, "decodeurls")) { |
2069 | d->prefs.decodeUserVisibleURLs = arg_Command(cmd); | 2091 | d->prefs.decodeUserVisibleURLs = arg_Command(cmd); |
2070 | return iTrue; | 2092 | return iTrue; |
@@ -2501,6 +2523,8 @@ iBool handleCommand_App(const char *cmd) { | |||
2501 | setToggle_Widget(findChild_Widget(dlg, "prefs.animate"), d->prefs.uiAnimations); | 2523 | setToggle_Widget(findChild_Widget(dlg, "prefs.animate"), d->prefs.uiAnimations); |
2502 | setText_InputWidget(findChild_Widget(dlg, "prefs.userfont"), &d->prefs.symbolFontPath); | 2524 | setText_InputWidget(findChild_Widget(dlg, "prefs.userfont"), &d->prefs.symbolFontPath); |
2503 | updatePrefsPinSplitButtons_(dlg, d->prefs.pinSplit); | 2525 | updatePrefsPinSplitButtons_(dlg, d->prefs.pinSplit); |
2526 | updateScrollSpeedButtons_(dlg, mouse_ScrollType, d->prefs.smoothScrollSpeed[mouse_ScrollType]); | ||
2527 | updateScrollSpeedButtons_(dlg, keyboard_ScrollType, d->prefs.smoothScrollSpeed[keyboard_ScrollType]); | ||
2504 | updateDropdownSelection_(findChild_Widget(dlg, "prefs.uilang"), cstr_String(&d->prefs.uiLanguage)); | 2528 | updateDropdownSelection_(findChild_Widget(dlg, "prefs.uilang"), cstr_String(&d->prefs.uiLanguage)); |
2505 | setToggle_Widget(findChild_Widget(dlg, "prefs.retainwindow"), d->prefs.retainWindowSize); | 2529 | setToggle_Widget(findChild_Widget(dlg, "prefs.retainwindow"), d->prefs.retainWindowSize); |
2506 | setText_InputWidget(findChild_Widget(dlg, "prefs.uiscale"), | 2530 | setText_InputWidget(findChild_Widget(dlg, "prefs.uiscale"), |