summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/documentwidget.c60
1 files changed, 39 insertions, 21 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 823c37ac..fe2816d2 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -532,12 +532,28 @@ static int pageHeight_DocumentWidget_(const iDocumentWidget *d) {
532 return height_Banner(d->banner) + documentTopPad_DocumentWidget_(d) + size_GmDocument(d->doc).y; 532 return height_Banner(d->banner) + documentTopPad_DocumentWidget_(d) + size_GmDocument(d->doc).y;
533} 533}
534 534
535static int footerButtonsHeight_DocumentWidget_(const iDocumentWidget *d) { 535//static int footerButtonsHeight_DocumentWidget_(const iDocumentWidget *d) {
536 int height = height_Widget(d->footerButtons); 536// int height = height_Widget(d->footerButtons);
537// if (height) { 537//// if (height) {
538// height += 3 * gap_UI; /* padding */ 538//// height += 3 * gap_UI; /* padding */
539// } 539//// }
540 return height; 540// return height;
541//}
542
543static int phoneToolbarHeight_DocumentWidget_(const iDocumentWidget *d) {
544 if (!d->phoneToolbar) {
545 return 0;
546 }
547 const iWidget *w = constAs_Widget(d);
548 return bottom_Rect(rect_Root(w->root)) - top_Rect(boundsWithoutVisualOffset_Widget(d->phoneToolbar));
549}
550
551static int footerHeight_DocumentWidget_(const iDocumentWidget *d) {
552 int hgt = height_Widget(d->footerButtons);
553 if (isPortraitPhone_App()) {
554 hgt += phoneToolbarHeight_DocumentWidget_(d);
555 }
556 return hgt;
541} 557}
542 558
543static iRect documentBounds_DocumentWidget_(const iDocumentWidget *d) { 559static iRect documentBounds_DocumentWidget_(const iDocumentWidget *d) {
@@ -559,10 +575,10 @@ static iRect documentBounds_DocumentWidget_(const iDocumentWidget *d) {
559 rect.size.y = 0; 575 rect.size.y = 0;
560 wasCentered = iTrue; 576 wasCentered = iTrue;
561 } 577 }
562 else if (docSize < rect.size.y - footerButtonsHeight_DocumentWidget_(d)) { 578 else if (docSize < rect.size.y - footerHeight_DocumentWidget_(d)) {
563 /* TODO: Phone toolbar? */ 579 /* TODO: Phone toolbar? */
564 /* Center vertically when the document is short. */ 580 /* Center vertically when the document is short. */
565 const int relMidY = (height_Rect(bounds) - footerButtonsHeight_DocumentWidget_(d)) / 2; 581 const int relMidY = (height_Rect(bounds) - footerHeight_DocumentWidget_(d)) / 2;
566 const int visHeight = size_GmDocument(d->doc).y; 582 const int visHeight = size_GmDocument(d->doc).y;
567 const int offset = -height_Banner(d->banner) - documentTopPad_DocumentWidget_(d); 583 const int offset = -height_Banner(d->banner) - documentTopPad_DocumentWidget_(d);
568 rect.pos.y = top_Rect(bounds) + iMaxi(0, relMidY - visHeight / 2 + offset); 584 rect.pos.y = top_Rect(bounds) + iMaxi(0, relMidY - visHeight / 2 + offset);
@@ -657,9 +673,9 @@ static float normScrollPos_DocumentWidget_(const iDocumentWidget *d) {
657 673
658static int scrollMax_DocumentWidget_(const iDocumentWidget *d) { 674static int scrollMax_DocumentWidget_(const iDocumentWidget *d) {
659 const iWidget *w = constAs_Widget(d); 675 const iWidget *w = constAs_Widget(d);
660 int sm = pageHeight_DocumentWidget_(d) - height_Rect(bounds_Widget(w)) + 676 int sm = pageHeight_DocumentWidget_(d) +
661 (isEmpty_Banner(d->banner) ? 2 : 1) * d->pageMargin * gap_UI + /* top and bottom margins */ 677 (isEmpty_Banner(d->banner) ? 2 : 1) * d->pageMargin * gap_UI + /* top and bottom margins */
662 iMax(height_Widget(d->phoneToolbar), height_Widget(d->footerButtons)); 678 footerHeight_DocumentWidget_(d) - height_Rect(bounds_Widget(w));
663 return sm; 679 return sm;
664} 680}
665 681
@@ -912,11 +928,8 @@ static void updateVisible_DocumentWidget_(iDocumentWidget *d) {
912 const iRect bounds = bounds_Widget(as_Widget(d)); 928 const iRect bounds = bounds_Widget(as_Widget(d));
913 const int scrollMax = updateScrollMax_DocumentWidget_(d); 929 const int scrollMax = updateScrollMax_DocumentWidget_(d);
914 /* Reposition the footer buttons as appropriate. */ 930 /* Reposition the footer buttons as appropriate. */
915 /* TODO: You can just position `footerButtons` here completely without having to get
916 `Widget` involved with the offset in any way. */
917 setRange_ScrollWidget(d->scroll, (iRangei){ 0, scrollMax }); 931 setRange_ScrollWidget(d->scroll, (iRangei){ 0, scrollMax });
918 const int docSize = pageHeight_DocumentWidget_(d) + iMax(height_Widget(d->phoneToolbar), 932 const int docSize = pageHeight_DocumentWidget_(d) + footerHeight_DocumentWidget_(d);
919 height_Widget(d->footerButtons));
920 const float scrollPos = pos_SmoothScroll(&d->scrollY); 933 const float scrollPos = pos_SmoothScroll(&d->scrollY);
921 setThumb_ScrollWidget(d->scroll, 934 setThumb_ScrollWidget(d->scroll,
922 pos_SmoothScroll(&d->scrollY), 935 pos_SmoothScroll(&d->scrollY),
@@ -927,7 +940,7 @@ static void updateVisible_DocumentWidget_(iDocumentWidget *d) {
927 const int hPad = (width_Rect(bounds) - iMin(120 * gap_UI, width_Rect(docBounds))) / 2; 940 const int hPad = (width_Rect(bounds) - iMin(120 * gap_UI, width_Rect(docBounds))) / 2;
928 const int vPad = 3 * gap_UI; 941 const int vPad = 3 * gap_UI;
929 setPadding_Widget(d->footerButtons, hPad, 0, hPad, vPad); 942 setPadding_Widget(d->footerButtons, hPad, 0, hPad, vPad);
930 d->footerButtons->rect.pos.y = height_Rect(bounds) - height_Widget(d->footerButtons) + 943 d->footerButtons->rect.pos.y = height_Rect(bounds) - footerHeight_DocumentWidget_(d) +
931 (scrollMax > 0 ? scrollMax - scrollPos : 0); 944 (scrollMax > 0 ? scrollMax - scrollPos : 0);
932 } 945 }
933 clear_PtrArray(&d->visibleLinks); 946 clear_PtrArray(&d->visibleLinks);
@@ -1198,10 +1211,10 @@ static void makeFooterButtons_DocumentWidget_(iDocumentWidget *d, const iMenuIte
1198 checkIcon_LabelWidget(button); 1211 checkIcon_LabelWidget(button);
1199 setFont_LabelWidget(button, uiContent_FontId); 1212 setFont_LabelWidget(button, uiContent_FontId);
1200 } 1213 }
1201 if (deviceType_App() == phone_AppDeviceType) { 1214// if (deviceType_App() == phone_AppDeviceType) {
1202 /* Footer buttons shouldn't be under the toolbar. */ 1215 /* Footer buttons shouldn't be under the toolbar. */
1203 addChild_Widget(d->footerButtons, iClob(makePadding_Widget(height_Widget(d->phoneToolbar)))); 1216// addChild_Widget(d->footerButtons, iClob(makePadding_Widget(height_Widget(d->phoneToolbar))));
1204 } 1217// }
1205 addChild_Widget(as_Widget(d), iClob(d->footerButtons)); 1218 addChild_Widget(as_Widget(d), iClob(d->footerButtons));
1206 arrange_Widget(d->footerButtons); 1219 arrange_Widget(d->footerButtons);
1207 arrange_Widget(w); 1220 arrange_Widget(w);
@@ -2081,7 +2094,12 @@ static iString *makeQueryUrl_DocumentWidget_(const iDocumentWidget *d,
2081 remove_Block(&url->chars, qPos, iInvalidSize); 2094 remove_Block(&url->chars, qPos, iInvalidSize);
2082 } 2095 }
2083 appendCStr_String(url, "?"); 2096 appendCStr_String(url, "?");
2084 append_String(url, collect_String(urlEncode_String(userEnteredText))); 2097 iString *cleaned = copy_String(userEnteredText);
2098 if (deviceType_App() != desktop_AppDeviceType) {
2099 trim_String(cleaned); /* autocorrect may insert an extra space */
2100 }
2101 append_String(url, collect_String(urlEncode_String(cleaned)));
2102 delete_String(cleaned);
2085 return url; 2103 return url;
2086} 2104}
2087 2105
@@ -5155,7 +5173,7 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) {
5155 iRect indRect = initCentered_Rect(init_I2(mid_Rect(bounds).x, 5173 iRect indRect = initCentered_Rect(init_I2(mid_Rect(bounds).x,
5156 top_Rect(bounds) - 5 * gap_UI - 5174 top_Rect(bounds) - 5 * gap_UI -
5157 pos_SmoothScroll(&d->scrollY)), 5175 pos_SmoothScroll(&d->scrollY)),
5158 init_I2(25 * gap_UI, 2 * gap_UI)); 5176 init_I2(20 * gap_UI, 2 * gap_UI));
5159 setClip_Paint(&ctx.paint, clipBounds); 5177 setClip_Paint(&ctx.paint, clipBounds);
5160 int color = pullPos < 1.0f ? tmBannerItemFrame_ColorId : tmBannerItemText_ColorId; 5178 int color = pullPos < 1.0f ? tmBannerItemFrame_ColorId : tmBannerItemText_ColorId;
5161 drawRect_Paint(&ctx.paint, indRect, color); 5179 drawRect_Paint(&ctx.paint, indRect, color);
@@ -5240,7 +5258,7 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) {
5240 mut->flags &= ~refChildrenOffset_WidgetFlag; 5258 mut->flags &= ~refChildrenOffset_WidgetFlag;
5241 } 5259 }
5242 } 5260 }
5243// drawRect_Paint(&ctx.paint, docBounds, red_ColorId); 5261 drawRect_Paint(&ctx.paint, docBounds, red_ColorId);
5244} 5262}
5245 5263
5246/*----------------------------------------------------------------------------------------------*/ 5264/*----------------------------------------------------------------------------------------------*/