diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-10-23 18:50:30 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-10-23 18:50:30 +0300 |
commit | 57cc6baba013965b1e9aed244ed40ee604e8a872 (patch) | |
tree | 6aa5f8d2a288e30b127d64435f6e78f6d1fab64c /src | |
parent | 7692e8a58a61ee829ce5d7ac808bc5a141c2f5e4 (diff) |
Cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/documentwidget.c | 62 |
1 files changed, 5 insertions, 57 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 9dea6cbb..1f84aed6 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -166,6 +166,7 @@ struct Impl_DocumentWidget { | |||
166 | iWidget widget; | 166 | iWidget widget; |
167 | enum iRequestState state; | 167 | enum iRequestState state; |
168 | iModel mod; | 168 | iModel mod; |
169 | int flags; | ||
169 | iString * titleUser; | 170 | iString * titleUser; |
170 | iGmRequest * request; | 171 | iGmRequest * request; |
171 | iAtomicInt isRequestUpdated; /* request has new content, need to parse it */ | 172 | iAtomicInt isRequestUpdated; /* request has new content, need to parse it */ |
@@ -178,8 +179,6 @@ struct Impl_DocumentWidget { | |||
178 | iDate certExpiry; | 179 | iDate certExpiry; |
179 | iString * certSubject; | 180 | iString * certSubject; |
180 | int redirectCount; | 181 | int redirectCount; |
181 | int flags; | ||
182 | // iBool selecting; | ||
183 | iRangecc selectMark; | 182 | iRangecc selectMark; |
184 | iRangecc foundMark; | 183 | iRangecc foundMark; |
185 | int pageMargin; | 184 | int pageMargin; |
@@ -190,17 +189,10 @@ struct Impl_DocumentWidget { | |||
190 | int playerTimer; | 189 | int playerTimer; |
191 | const iGmRun * hoverLink; | 190 | const iGmRun * hoverLink; |
192 | const iGmRun * contextLink; | 191 | const iGmRun * contextLink; |
193 | // iBool noHoverWhileScrolling; | ||
194 | // iBool showLinkNumbers; | ||
195 | const iGmRun * firstVisibleRun; | 192 | const iGmRun * firstVisibleRun; |
196 | const iGmRun * lastVisibleRun; | 193 | const iGmRun * lastVisibleRun; |
197 | iClick click; | 194 | iClick click; |
198 | float initNormScrollY; | 195 | float initNormScrollY; |
199 | // int scrollY; | ||
200 | // int smoothScroll; | ||
201 | // int smoothSpeed; | ||
202 | // int smoothLastOffset; | ||
203 | // iBool smoothContinue; | ||
204 | iAnim scrollY; | 196 | iAnim scrollY; |
205 | iAnim sideOpacity; | 197 | iAnim sideOpacity; |
206 | iAnim outlineOpacity; | 198 | iAnim outlineOpacity; |
@@ -220,6 +212,7 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
220 | setId_Widget(w, "document000"); | 212 | setId_Widget(w, "document000"); |
221 | setFlags_Widget(w, hover_WidgetFlag, iTrue); | 213 | setFlags_Widget(w, hover_WidgetFlag, iTrue); |
222 | init_Model(&d->mod); | 214 | init_Model(&d->mod); |
215 | d->flags = 0; | ||
223 | iZap(d->certExpiry); | 216 | iZap(d->certExpiry); |
224 | d->certFlags = 0; | 217 | d->certFlags = 0; |
225 | d->certSubject = new_String(); | 218 | d->certSubject = new_String(); |
@@ -232,19 +225,11 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
232 | d->redirectCount = 0; | 225 | d->redirectCount = 0; |
233 | d->initNormScrollY = 0; | 226 | d->initNormScrollY = 0; |
234 | init_Anim(&d->scrollY, 0); | 227 | init_Anim(&d->scrollY, 0); |
235 | // d->scrollY = 0; | ||
236 | // d->smoothScroll = 0; | ||
237 | // d->smoothSpeed = 0; | ||
238 | // d->smoothLastOffset = 0; | ||
239 | // d->smoothContinue = iFalse; | ||
240 | d->flags = 0; | ||
241 | d->selectMark = iNullRange; | 228 | d->selectMark = iNullRange; |
242 | d->foundMark = iNullRange; | 229 | d->foundMark = iNullRange; |
243 | d->pageMargin = 5; | 230 | d->pageMargin = 5; |
244 | d->hoverLink = NULL; | 231 | d->hoverLink = NULL; |
245 | d->contextLink = NULL; | 232 | d->contextLink = NULL; |
246 | // d->noHoverWhileScrolling = iFalse; | ||
247 | // d->showLinkNumbers = iFalse; | ||
248 | d->firstVisibleRun = NULL; | 233 | d->firstVisibleRun = NULL; |
249 | d->lastVisibleRun = NULL; | 234 | d->lastVisibleRun = NULL; |
250 | d->visBuf = new_VisBuf(); | 235 | d->visBuf = new_VisBuf(); |
@@ -931,23 +916,8 @@ static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { | |||
931 | 916 | ||
932 | static void refreshWhileScrolling_DocumentWidget_(iAny *ptr) { | 917 | static void refreshWhileScrolling_DocumentWidget_(iAny *ptr) { |
933 | iDocumentWidget *d = ptr; | 918 | iDocumentWidget *d = ptr; |
934 | // if (isFinished_Anim(&d-> isSmoothScrolling_DocumentWidget_(d)) { | ||
935 | // return; /* was cancelled */ | ||
936 | // } | ||
937 | // const double elapsed = (double) elapsedSinceLastTicker_App() / 1000.0; | ||
938 | // int delta = d->smoothSpeed * elapsed * iSign(d->smoothScroll); | ||
939 | // if (iAbs(d->smoothScroll) <= iAbs(delta)) { | ||
940 | // if (d->smoothContinue) { | ||
941 | // d->smoothScroll += d->smoothLastOffset; | ||
942 | // } | ||
943 | // else { | ||
944 | // delta = d->smoothScroll; | ||
945 | // } | ||
946 | // } | ||
947 | updateVisible_DocumentWidget_(d); | 919 | updateVisible_DocumentWidget_(d); |
948 | refresh_Widget(d); | 920 | refresh_Widget(d); |
949 | // scroll_DocumentWidget_(d, delta); | ||
950 | // d->smoothScroll -= delta; | ||
951 | if (!isFinished_Anim(&d->scrollY)) { | 921 | if (!isFinished_Anim(&d->scrollY)) { |
952 | addTicker_App(refreshWhileScrolling_DocumentWidget_, d); | 922 | addTicker_App(refreshWhileScrolling_DocumentWidget_, d); |
953 | } | 923 | } |
@@ -955,7 +925,6 @@ static void refreshWhileScrolling_DocumentWidget_(iAny *ptr) { | |||
955 | 925 | ||
956 | static void smoothScroll_DocumentWidget_(iDocumentWidget *d, int offset, int duration) { | 926 | static void smoothScroll_DocumentWidget_(iDocumentWidget *d, int offset, int duration) { |
957 | int destY = targetValue_Anim(&d->scrollY) + offset; | 927 | int destY = targetValue_Anim(&d->scrollY) + offset; |
958 | // d->scrollY += offset; | ||
959 | if (destY < 0) { | 928 | if (destY < 0) { |
960 | destY = 0; | 929 | destY = 0; |
961 | } | 930 | } |
@@ -969,14 +938,6 @@ static void smoothScroll_DocumentWidget_(iDocumentWidget *d, int offset, int dur | |||
969 | setValueEased_Anim(&d->scrollY, destY, duration); | 938 | setValueEased_Anim(&d->scrollY, destY, duration); |
970 | updateVisible_DocumentWidget_(d); | 939 | updateVisible_DocumentWidget_(d); |
971 | refresh_Widget(as_Widget(d)); | 940 | refresh_Widget(as_Widget(d)); |
972 | |||
973 | // if (speed == 0) { | ||
974 | // scroll_DocumentWidget_(d, offset); | ||
975 | // return; | ||
976 | // } | ||
977 | // d->smoothSpeed = speed; | ||
978 | // d->smoothScroll += offset; | ||
979 | // d->smoothLastOffset = offset; | ||
980 | if (duration > 0) { | 941 | if (duration > 0) { |
981 | iChangeFlags(d->flags, noHoverWhileScrolling_DocumentWidgetFlag, iTrue); | 942 | iChangeFlags(d->flags, noHoverWhileScrolling_DocumentWidgetFlag, iTrue); |
982 | addTicker_App(refreshWhileScrolling_DocumentWidget_, d); | 943 | addTicker_App(refreshWhileScrolling_DocumentWidget_, d); |
@@ -984,13 +945,9 @@ static void smoothScroll_DocumentWidget_(iDocumentWidget *d, int offset, int dur | |||
984 | } | 945 | } |
985 | 946 | ||
986 | static void scroll_DocumentWidget_(iDocumentWidget *d, int offset) { | 947 | static void scroll_DocumentWidget_(iDocumentWidget *d, int offset) { |
987 | smoothScroll_DocumentWidget_(d, offset, 0 /* instant */); | 948 | smoothScroll_DocumentWidget_(d, offset, 0 /* instantly */); |
988 | } | 949 | } |
989 | 950 | ||
990 | //static iBool isSmoothScrolling_DocumentWidget_(const iDocumentWidget *d) { | ||
991 | // return d->smoothScroll != 0; | ||
992 | //} | ||
993 | |||
994 | static void scrollTo_DocumentWidget_(iDocumentWidget *d, int documentY, iBool centered) { | 951 | static void scrollTo_DocumentWidget_(iDocumentWidget *d, int documentY, iBool centered) { |
995 | init_Anim(&d->scrollY, | 952 | init_Anim(&d->scrollY, |
996 | documentY - (centered ? documentBounds_DocumentWidget_(d).size.y / 2 | 953 | documentY - (centered ? documentBounds_DocumentWidget_(d).size.y / 2 |
@@ -1515,12 +1472,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1515 | } | 1472 | } |
1516 | else if (equalWidget_Command(cmd, w, "scroll.page")) { | 1473 | else if (equalWidget_Command(cmd, w, "scroll.page")) { |
1517 | if (argLabel_Command(cmd, "repeat")) { | 1474 | if (argLabel_Command(cmd, "repeat")) { |
1518 | // if (!d->smoothContinue) { | 1475 | /* TODO: Adjust scroll animation to be linear during repeated scroll? */ |
1519 | // d->smoothContinue = iTrue; | ||
1520 | // } | ||
1521 | // else { | ||
1522 | // return iTrue; | ||
1523 | // } | ||
1524 | } | 1476 | } |
1525 | smoothScroll_DocumentWidget_(d, | 1477 | smoothScroll_DocumentWidget_(d, |
1526 | arg_Command(cmd) * | 1478 | arg_Command(cmd) * |
@@ -1845,8 +1797,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
1845 | smoothScroll_DocumentWidget_( | 1797 | smoothScroll_DocumentWidget_( |
1846 | d, | 1798 | d, |
1847 | -3 * ev->wheel.y * lineHeight_Text(paragraph_FontId) * acceleration, | 1799 | -3 * ev->wheel.y * lineHeight_Text(paragraph_FontId) * acceleration, |
1848 | smoothDuration_DocumentWidget_); /* + | 1800 | smoothDuration_DocumentWidget_); |
1849 | (isSmoothScrolling_DocumentWidget_(d) ? d->smoothSpeed : 0)); */ | ||
1850 | #endif | 1801 | #endif |
1851 | iChangeFlags(d->flags, noHoverWhileScrolling_DocumentWidgetFlag, iTrue); | 1802 | iChangeFlags(d->flags, noHoverWhileScrolling_DocumentWidgetFlag, iTrue); |
1852 | return iTrue; | 1803 | return iTrue; |
@@ -2603,7 +2554,6 @@ const iString *bookmarkTitle_DocumentWidget(const iDocumentWidget *d) { | |||
2603 | return collect_String(joinCStr_StringArray(title, " \u2014 ")); | 2554 | return collect_String(joinCStr_StringArray(title, " \u2014 ")); |
2604 | } | 2555 | } |
2605 | 2556 | ||
2606 | |||
2607 | void serializeState_DocumentWidget(const iDocumentWidget *d, iStream *outs) { | 2557 | void serializeState_DocumentWidget(const iDocumentWidget *d, iStream *outs) { |
2608 | serialize_Model(&d->mod, outs); | 2558 | serialize_Model(&d->mod, outs); |
2609 | } | 2559 | } |
@@ -2650,8 +2600,6 @@ void setRedirectCount_DocumentWidget(iDocumentWidget *d, int count) { | |||
2650 | } | 2600 | } |
2651 | 2601 | ||
2652 | iBool isRequestOngoing_DocumentWidget(const iDocumentWidget *d) { | 2602 | iBool isRequestOngoing_DocumentWidget(const iDocumentWidget *d) { |
2653 | /*return d->state == fetching_RequestState || | ||
2654 | d->state == receivedPartialResponse_RequestState;*/ | ||
2655 | return d->request != NULL; | 2603 | return d->request != NULL; |
2656 | } | 2604 | } |
2657 | 2605 | ||