diff options
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index d338cf04..5d85e275 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -515,6 +515,7 @@ static void invalidateWideRunsWithNonzeroOffset_DocumentWidget_(iDocumentWidget | |||
515 | 515 | ||
516 | static void animate_DocumentWidget_(void *ticker) { | 516 | static void animate_DocumentWidget_(void *ticker) { |
517 | iDocumentWidget *d = ticker; | 517 | iDocumentWidget *d = ticker; |
518 | refresh_Widget(d); | ||
518 | if (!isFinished_Anim(&d->sideOpacity) || !isFinished_Anim(&d->altTextOpacity)) { | 519 | if (!isFinished_Anim(&d->sideOpacity) || !isFinished_Anim(&d->altTextOpacity)) { |
519 | addTicker_App(animate_DocumentWidget_, d); | 520 | addTicker_App(animate_DocumentWidget_, d); |
520 | } | 521 | } |
@@ -557,15 +558,19 @@ static void updateHover_DocumentWidget_(iDocumentWidget *d, iInt2 mouse) { | |||
557 | } | 558 | } |
558 | } | 559 | } |
559 | } | 560 | } |
560 | if (!d->hoverPre && targetValue_Anim(&d->altTextOpacity) > 0.5f) { | 561 | if (!d->hoverPre) { |
561 | setValue_Anim(&d->altTextOpacity, 0.0f, 300); | 562 | setValueSpeed_Anim(&d->altTextOpacity, 0.0f, 2); |
562 | animate_DocumentWidget_(d); | 563 | if (!isFinished_Anim(&d->altTextOpacity)) { |
563 | refresh_Widget(w); | 564 | animate_DocumentWidget_(d); |
565 | } | ||
564 | } | 566 | } |
565 | else if (d->hoverPre && targetValue_Anim(&d->altTextOpacity) < 0.5f && | 567 | else if (d->hoverPre && |
568 | preHasAltText_GmDocument(d->doc, d->hoverPre->preId) && | ||
566 | ~d->flags & noHoverWhileScrolling_DocumentWidgetFlag) { | 569 | ~d->flags & noHoverWhileScrolling_DocumentWidgetFlag) { |
567 | setValue_Anim(&d->altTextOpacity, 1.0f, 0); | 570 | setValueSpeed_Anim(&d->altTextOpacity, 1.0f, 2); |
568 | refresh_Widget(w); | 571 | if (!isFinished_Anim(&d->altTextOpacity)) { |
572 | animate_DocumentWidget_(d); | ||
573 | } | ||
569 | } | 574 | } |
570 | if (isHover_Widget(w) && !contains_Widget(constAs_Widget(d->scroll), mouse)) { | 575 | if (isHover_Widget(w) && !contains_Widget(constAs_Widget(d->scroll), mouse)) { |
571 | setCursor_Window(get_Window(), | 576 | setCursor_Window(get_Window(), |
@@ -886,6 +891,7 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode | |||
886 | updateTheme_DocumentWidget_(d); | 891 | updateTheme_DocumentWidget_(d); |
887 | init_Anim(&d->scrollY, 0); | 892 | init_Anim(&d->scrollY, 0); |
888 | init_Anim(&d->sideOpacity, 0); | 893 | init_Anim(&d->sideOpacity, 0); |
894 | init_Anim(&d->altTextOpacity, 0); | ||
889 | resetWideRuns_DocumentWidget_(d); | 895 | resetWideRuns_DocumentWidget_(d); |
890 | d->state = ready_RequestState; | 896 | d->state = ready_RequestState; |
891 | } | 897 | } |
@@ -1090,6 +1096,7 @@ static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { | |||
1090 | set_Block(&d->sourceContent, &resp->body); | 1096 | set_Block(&d->sourceContent, &resp->body); |
1091 | updateDocument_DocumentWidget_(d, resp, iTrue); | 1097 | updateDocument_DocumentWidget_(d, resp, iTrue); |
1092 | init_Anim(&d->scrollY, d->initNormScrollY * size_GmDocument(d->doc).y); | 1098 | init_Anim(&d->scrollY, d->initNormScrollY * size_GmDocument(d->doc).y); |
1099 | init_Anim(&d->altTextOpacity, 0); | ||
1093 | d->state = ready_RequestState; | 1100 | d->state = ready_RequestState; |
1094 | updateSideOpacity_DocumentWidget_(d, iFalse); | 1101 | updateSideOpacity_DocumentWidget_(d, iFalse); |
1095 | updateSideIconBuf_DocumentWidget_(d); | 1102 | updateSideIconBuf_DocumentWidget_(d); |
@@ -1261,6 +1268,7 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) { | |||
1261 | d->state = receivedPartialResponse_RequestState; | 1268 | d->state = receivedPartialResponse_RequestState; |
1262 | updateTrust_DocumentWidget_(d, resp); | 1269 | updateTrust_DocumentWidget_(d, resp); |
1263 | init_Anim(&d->sideOpacity, 0); | 1270 | init_Anim(&d->sideOpacity, 0); |
1271 | init_Anim(&d->altTextOpacity, 0); | ||
1264 | format_String(&d->sourceHeader, "%d %s", statusCode, get_GmError(statusCode)->title); | 1272 | format_String(&d->sourceHeader, "%d %s", statusCode, get_GmError(statusCode)->title); |
1265 | d->sourceStatus = statusCode; | 1273 | d->sourceStatus = statusCode; |
1266 | switch (category_GmStatusCode(statusCode)) { | 1274 | switch (category_GmStatusCode(statusCode)) { |
@@ -1652,6 +1660,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1652 | updateFetchProgress_DocumentWidget_(d); | 1660 | updateFetchProgress_DocumentWidget_(d); |
1653 | } | 1661 | } |
1654 | init_Anim(&d->sideOpacity, 0); | 1662 | init_Anim(&d->sideOpacity, 0); |
1663 | init_Anim(&d->altTextOpacity, 0); | ||
1655 | updateSideOpacity_DocumentWidget_(d, iFalse); | 1664 | updateSideOpacity_DocumentWidget_(d, iFalse); |
1656 | updateWindowTitle_DocumentWidget_(d); | 1665 | updateWindowTitle_DocumentWidget_(d); |
1657 | allocVisBuffer_DocumentWidget_(d); | 1666 | allocVisBuffer_DocumentWidget_(d); |
@@ -2687,6 +2696,10 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
2687 | return iTrue; | 2696 | return iTrue; |
2688 | } | 2697 | } |
2689 | /* Begin selecting a range of text. */ | 2698 | /* Begin selecting a range of text. */ |
2699 | if (~d->flags & selecting_DocumentWidgetFlag && d->hoverPre && | ||
2700 | preIsFolded_GmDocument(d->doc, d->hoverPre->preId)) { | ||
2701 | return iTrue; | ||
2702 | } | ||
2690 | if (~d->flags & selecting_DocumentWidgetFlag) { | 2703 | if (~d->flags & selecting_DocumentWidgetFlag) { |
2691 | beginMarkingSelection_DocumentWidget_(d, d->click.startPos); | 2704 | beginMarkingSelection_DocumentWidget_(d, d->click.startPos); |
2692 | } | 2705 | } |
@@ -2884,10 +2897,12 @@ static void fillRange_DrawContext_(iDrawContext *d, const iGmRun *run, enum iCol | |||
2884 | if (w > width_Rect(run->visBounds) - x) { | 2897 | if (w > width_Rect(run->visBounds) - x) { |
2885 | w = width_Rect(run->visBounds) - x; | 2898 | w = width_Rect(run->visBounds) - x; |
2886 | } | 2899 | } |
2887 | const iInt2 visPos = | 2900 | if (~run->flags & decoration_GmRunFlag) { |
2888 | add_I2(run->bounds.pos, addY_I2(d->viewPos, -value_Anim(&d->widget->scrollY))); | 2901 | const iInt2 visPos = |
2889 | fillRect_Paint(&d->paint, (iRect){ addX_I2(visPos, x), | 2902 | add_I2(run->bounds.pos, addY_I2(d->viewPos, -value_Anim(&d->widget->scrollY))); |
2890 | init_I2(w, height_Rect(run->bounds)) }, color); | 2903 | fillRect_Paint(&d->paint, (iRect){ addX_I2(visPos, x), |
2904 | init_I2(w, height_Rect(run->bounds)) }, color); | ||
2905 | } | ||
2891 | } | 2906 | } |
2892 | /* Link URLs are not part of the visible document, so they are ignored above. Handle | 2907 | /* Link URLs are not part of the visible document, so they are ignored above. Handle |
2893 | these ranges as a special case. */ | 2908 | these ranges as a special case. */ |
@@ -3473,7 +3488,7 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) { | |||
3473 | } | 3488 | } |
3474 | draw_Widget(w); | 3489 | draw_Widget(w); |
3475 | /* Alt text. */ | 3490 | /* Alt text. */ |
3476 | const float altTextOpacity = value_Anim(&d->altTextOpacity); | 3491 | const float altTextOpacity = value_Anim(&d->altTextOpacity) * 3 - 2; |
3477 | if (d->hoverAltPre && altTextOpacity > 0) { | 3492 | if (d->hoverAltPre && altTextOpacity > 0) { |
3478 | const iGmPreMeta *meta = preMeta_GmDocument(d->doc, d->hoverAltPre->preId); | 3493 | const iGmPreMeta *meta = preMeta_GmDocument(d->doc, d->hoverAltPre->preId); |
3479 | if (meta->flags & topLeft_GmPreMetaFlag && ~meta->flags & decoration_GmRunFlag && | 3494 | if (meta->flags & topLeft_GmPreMetaFlag && ~meta->flags & decoration_GmRunFlag && |