summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-11-06 16:04:59 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-11-06 16:04:59 +0200
commit6ffe005a8ad62fb5ecdd5fc6d63f914b9c45142c (patch)
tree69f4b088a2326807d92e7bdd63c78135f894785a /src
parenta4a7a75cd70d41e45f12afbaba0b0bb3faa5dfd3 (diff)
Added an option to disable smooth scrolling
IssueID #27
Diffstat (limited to 'src')
-rw-r--r--src/app.c8
-rw-r--r--src/prefs.c1
-rw-r--r--src/prefs.h3
-rw-r--r--src/ui/documentwidget.c10
-rw-r--r--src/ui/util.c4
5 files changed, 23 insertions, 3 deletions
diff --git a/src/app.c b/src/app.c
index 37279391..a76e135b 100644
--- a/src/app.c
+++ b/src/app.c
@@ -180,6 +180,7 @@ static iString *serializePrefs_App_(const iApp *d) {
180 appendFormat_String(str, "font.set arg:%d\n", d->prefs.font); 180 appendFormat_String(str, "font.set arg:%d\n", d->prefs.font);
181 appendFormat_String(str, "headingfont.set arg:%d\n", d->prefs.headingFont); 181 appendFormat_String(str, "headingfont.set arg:%d\n", d->prefs.headingFont);
182 appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent); 182 appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent);
183 appendFormat_String(str, "smoothscroll arg:%d\n", d->prefs.smoothScrolling);
183 appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth); 184 appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth);
184 appendFormat_String(str, "prefs.biglede.changed arg:%d\n", d->prefs.bigFirstParagraph); 185 appendFormat_String(str, "prefs.biglede.changed arg:%d\n", d->prefs.bigFirstParagraph);
185 appendFormat_String(str, "prefs.sideicon.changed arg:%d\n", d->prefs.sideIcon); 186 appendFormat_String(str, "prefs.sideicon.changed arg:%d\n", d->prefs.sideIcon);
@@ -735,6 +736,8 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) {
735 cstr_String(text_InputWidget(findChild_Widget(d, "prefs.downloads")))); 736 cstr_String(text_InputWidget(findChild_Widget(d, "prefs.downloads"))));
736 postCommandf_App("window.retain arg:%d", 737 postCommandf_App("window.retain arg:%d",
737 isSelected_Widget(findChild_Widget(d, "prefs.retainwindow"))); 738 isSelected_Widget(findChild_Widget(d, "prefs.retainwindow")));
739 postCommandf_App("smoothscroll arg:%d",
740 isSelected_Widget(findChild_Widget(d, "prefs.smoothscroll")));
738 postCommandf_App("ostheme arg:%d", 741 postCommandf_App("ostheme arg:%d",
739 isSelected_Widget(findChild_Widget(d, "prefs.ostheme"))); 742 isSelected_Widget(findChild_Widget(d, "prefs.ostheme")));
740 postCommandf_App("proxy.http address:%s", 743 postCommandf_App("proxy.http address:%s",
@@ -942,6 +945,10 @@ iBool handleCommand_App(const char *cmd) {
942 postCommand_App("window.unfreeze"); 945 postCommand_App("window.unfreeze");
943 return iTrue; 946 return iTrue;
944 } 947 }
948 else if (equal_Command(cmd, "smoothscroll")) {
949 d->prefs.smoothScrolling = arg_Command(cmd);
950 return iTrue;
951 }
945 else if (equal_Command(cmd, "forcewrap.toggle")) { 952 else if (equal_Command(cmd, "forcewrap.toggle")) {
946 d->prefs.forceLineWrap = !d->prefs.forceLineWrap; 953 d->prefs.forceLineWrap = !d->prefs.forceLineWrap;
947 updateSize_DocumentWidget(document_App()); 954 updateSize_DocumentWidget(document_App());
@@ -1119,6 +1126,7 @@ iBool handleCommand_App(const char *cmd) {
1119 updatePrefsThemeButtons_(dlg); 1126 updatePrefsThemeButtons_(dlg);
1120 setText_InputWidget(findChild_Widget(dlg, "prefs.downloads"), &d->prefs.downloadDir); 1127 setText_InputWidget(findChild_Widget(dlg, "prefs.downloads"), &d->prefs.downloadDir);
1121 setToggle_Widget(findChild_Widget(dlg, "prefs.hoveroutline"), d->prefs.hoverOutline); 1128 setToggle_Widget(findChild_Widget(dlg, "prefs.hoveroutline"), d->prefs.hoverOutline);
1129 setToggle_Widget(findChild_Widget(dlg, "prefs.smoothscroll"), d->prefs.smoothScrolling);
1122 setToggle_Widget(findChild_Widget(dlg, "prefs.ostheme"), d->prefs.useSystemTheme); 1130 setToggle_Widget(findChild_Widget(dlg, "prefs.ostheme"), d->prefs.useSystemTheme);
1123 setToggle_Widget(findChild_Widget(dlg, "prefs.retainwindow"), d->prefs.retainWindowSize); 1131 setToggle_Widget(findChild_Widget(dlg, "prefs.retainwindow"), d->prefs.retainWindowSize);
1124 setText_InputWidget(findChild_Widget(dlg, "prefs.uiscale"), 1132 setText_InputWidget(findChild_Widget(dlg, "prefs.uiscale"),
diff --git a/src/prefs.c b/src/prefs.c
index 8d1dd8fe..815dac52 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -28,6 +28,7 @@ void init_Prefs(iPrefs *d) {
28 d->useSystemTheme = iTrue; 28 d->useSystemTheme = iTrue;
29 d->retainWindowSize = iTrue; 29 d->retainWindowSize = iTrue;
30 d->zoomPercent = 100; 30 d->zoomPercent = 100;
31 d->smoothScrolling = iTrue;
31 d->forceLineWrap = iFalse; 32 d->forceLineWrap = iFalse;
32 d->quoteIcon = iTrue; 33 d->quoteIcon = iTrue;
33 d->font = nunito_TextFont; 34 d->font = nunito_TextFont;
diff --git a/src/prefs.h b/src/prefs.h
index eadfea64..bf642600 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -35,8 +35,9 @@ iDeclareType(Prefs)
35struct Impl_Prefs { 35struct Impl_Prefs {
36 int dialogTab; 36 int dialogTab;
37 iBool retainWindowSize; 37 iBool retainWindowSize;
38 float uiScale; 38 float uiScale;
39 int zoomPercent; 39 int zoomPercent;
40 iBool smoothScrolling;
40 iBool useSystemTheme; 41 iBool useSystemTheme;
41 enum iColorTheme theme; 42 enum iColorTheme theme;
42 iString gopherProxy; 43 iString gopherProxy;
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 13f21df6..f1506fc3 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -947,6 +947,9 @@ static void refreshWhileScrolling_DocumentWidget_(iAny *ptr) {
947} 947}
948 948
949static void smoothScroll_DocumentWidget_(iDocumentWidget *d, int offset, int duration) { 949static void smoothScroll_DocumentWidget_(iDocumentWidget *d, int offset, int duration) {
950 if (!prefs_App()->smoothScrolling) {
951 duration = 0; /* always instant */
952 }
950 int destY = targetValue_Anim(&d->scrollY) + offset; 953 int destY = targetValue_Anim(&d->scrollY) + offset;
951 if (destY < 0) { 954 if (destY < 0) {
952 destY = 0; 955 destY = 0;
@@ -958,7 +961,12 @@ static void smoothScroll_DocumentWidget_(iDocumentWidget *d, int offset, int dur
958 else { 961 else {
959 destY = 0; 962 destY = 0;
960 } 963 }
961 setValueEased_Anim(&d->scrollY, destY, duration); 964 if (duration) {
965 setValueEased_Anim(&d->scrollY, destY, duration);
966 }
967 else {
968 setValue_Anim(&d->scrollY, destY, 0);
969 }
962 updateVisible_DocumentWidget_(d); 970 updateVisible_DocumentWidget_(d);
963 refresh_Widget(as_Widget(d)); 971 refresh_Widget(as_Widget(d));
964 if (duration > 0) { 972 if (duration > 0) {
diff --git a/src/ui/util.c b/src/ui/util.c
index ceab01b8..e65e089d 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -188,7 +188,7 @@ static float valueAt_Anim_(const iAnim *d, const uint32_t now) {
188void setValue_Anim(iAnim *d, float to, uint32_t span) { 188void setValue_Anim(iAnim *d, float to, uint32_t span) {
189 if (span == 0) { 189 if (span == 0) {
190 d->from = d->to = to; 190 d->from = d->to = to;
191 d->when = d->due = SDL_GetTicks(); 191 d->when = d->due = frameTime_Window(get_Window()); /* effectively in the past */
192 } 192 }
193 else if (fabsf(to - d->to) > 0.00001f) { 193 else if (fabsf(to - d->to) > 0.00001f) {
194 const uint32_t now = SDL_GetTicks(); 194 const uint32_t now = SDL_GetTicks();
@@ -997,6 +997,8 @@ iWidget *makePreferences_Widget(void) {
997 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.downloads"); 997 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.downloads");
998 addChild_Widget(headings, iClob(makeHeading_Widget("Outline on scrollbar:"))); 998 addChild_Widget(headings, iClob(makeHeading_Widget("Outline on scrollbar:")));
999 addChild_Widget(values, iClob(makeToggle_Widget("prefs.hoveroutline"))); 999 addChild_Widget(values, iClob(makeToggle_Widget("prefs.hoveroutline")));
1000 addChild_Widget(headings, iClob(makeHeading_Widget("Smooth scrolling:")));
1001 addChild_Widget(values, iClob(makeToggle_Widget("prefs.smoothscroll")));
1000 makeTwoColumnHeading_("WINDOW", headings, values); 1002 makeTwoColumnHeading_("WINDOW", headings, values);
1001#if defined (iPlatformApple) || defined (iPlatformMSys) 1003#if defined (iPlatformApple) || defined (iPlatformMSys)
1002 addChild_Widget(headings, iClob(makeHeading_Widget("Use system theme:"))); 1004 addChild_Widget(headings, iClob(makeHeading_Widget("Use system theme:")));