summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 8e63dcee..5b4af4dd 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -715,7 +715,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse
715 if (d->state == ready_RequestState) { 715 if (d->state == ready_RequestState) {
716 return; 716 return;
717 } 717 }
718 /* TODO: Do this in the background. However, that requires a text metrics calculator 718 /* TODO: Do document update in the background. However, that requires a text metrics calculator
719 that does not try to cache the glyph bitmaps. */ 719 that does not try to cache the glyph bitmaps. */
720 const enum iGmStatusCode statusCode = response->statusCode; 720 const enum iGmStatusCode statusCode = response->statusCode;
721 if (category_GmStatusCode(statusCode) != categoryInput_GmStatusCode) { 721 if (category_GmStatusCode(statusCode) != categoryInput_GmStatusCode) {
@@ -727,7 +727,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse
727 clear_String(&d->sourceMime); 727 clear_String(&d->sourceMime);
728 d->sourceTime = response->when; 728 d->sourceTime = response->when;
729 initBlock_String(&str, &response->body); 729 initBlock_String(&str, &response->body);
730 if (category_GmStatusCode(statusCode) == categorySuccess_GmStatusCode) { 730 if (isSuccess_GmStatusCode(statusCode)) {
731 /* Check the MIME type. */ 731 /* Check the MIME type. */
732 iRangecc charset = range_CStr("utf-8"); 732 iRangecc charset = range_CStr("utf-8");
733 enum iGmDocumentFormat docFormat = undefined_GmDocumentFormat; 733 enum iGmDocumentFormat docFormat = undefined_GmDocumentFormat;
@@ -1158,7 +1158,21 @@ static iBool handleMediaCommand_DocumentWidget_(iDocumentWidget *d, const char *
1158 } 1158 }
1159 if (equal_Command(cmd, "media.updated")) { 1159 if (equal_Command(cmd, "media.updated")) {
1160 /* Pass new data to media players. */ 1160 /* Pass new data to media players. */
1161 1161 const enum iGmStatusCode code = status_GmRequest(req->req);
1162 if (isSuccess_GmStatusCode(code)) {
1163 if (startsWith_String(meta_GmRequest(req->req), "audio/")) {
1164 /* TODO: Use a helper? This is same as below except for the partialData flag. */
1165 setData_Media(media_GmDocument(d->doc),
1166 req->linkId,
1167 meta_GmRequest(req->req),
1168 body_GmRequest(req->req),
1169 partialData_MediaFlag | allowHide_MediaFlag);
1170 redoLayout_GmDocument(d->doc);
1171 updateVisible_DocumentWidget_(d);
1172 invalidate_DocumentWidget_(d);
1173 refresh_Widget(as_Widget(d));
1174 }
1175 }
1162 /* Update the link's progress. */ 1176 /* Update the link's progress. */
1163 invalidateLink_DocumentWidget_(d, req->linkId); 1177 invalidateLink_DocumentWidget_(d, req->linkId);
1164 refresh_Widget(d); 1178 refresh_Widget(d);
@@ -1167,7 +1181,7 @@ static iBool handleMediaCommand_DocumentWidget_(iDocumentWidget *d, const char *
1167 else if (equal_Command(cmd, "media.finished")) { 1181 else if (equal_Command(cmd, "media.finished")) {
1168 const enum iGmStatusCode code = status_GmRequest(req->req); 1182 const enum iGmStatusCode code = status_GmRequest(req->req);
1169 /* Give the media to the document for presentation. */ 1183 /* Give the media to the document for presentation. */
1170 if (code == success_GmStatusCode) { 1184 if (isSuccess_GmStatusCode(code)) {
1171 if (startsWith_String(meta_GmRequest(req->req), "image/") || 1185 if (startsWith_String(meta_GmRequest(req->req), "image/") ||
1172 startsWith_String(meta_GmRequest(req->req), "audio/")) { 1186 startsWith_String(meta_GmRequest(req->req), "audio/")) {
1173 setData_Media(media_GmDocument(d->doc), 1187 setData_Media(media_GmDocument(d->doc),
@@ -2355,8 +2369,9 @@ static void draw_PlayerUI(iPlayerUI *d, iPaint *p) {
2355 const int s2 = right_Rect(d->scrubberRect) - rightWidth - 6 * gap_UI; 2369 const int s2 = right_Rect(d->scrubberRect) - rightWidth - 6 * gap_UI;
2356 const float normPos = totalTime > 0 ? playTime / totalTime : 0.0f; 2370 const float normPos = totalTime > 0 ? playTime / totalTime : 0.0f;
2357 const int part = (s2 - s1) * normPos; 2371 const int part = (s2 - s1) * normPos;
2372 const int scrubMax = (s2 - s1) * streamProgress_Player(d->player);
2358 drawHLine_Paint(p, init_I2(s1, yMid), part, bright); 2373 drawHLine_Paint(p, init_I2(s1, yMid), part, bright);
2359 drawHLine_Paint(p, init_I2(s1 + part, yMid), (s2 - s1) - part, dim); 2374 drawHLine_Paint(p, init_I2(s1 + part, yMid), scrubMax - part, dim);
2360 draw_Text(uiLabel_FontId, 2375 draw_Text(uiLabel_FontId,
2361 init_I2(s1 * (1.0f - normPos) + s2 * normPos - hgt / 3, yMid - hgt / 2), 2376 init_I2(s1 * (1.0f - normPos) + s2 * normPos - hgt / 3, yMid - hgt / 2),
2362 bright, 2377 bright,