summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/documentwidget.c3
-rw-r--r--src/ui/util.c52
-rw-r--r--src/ui/util.h6
3 files changed, 36 insertions, 25 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 2b46c7b5..87c86192 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -348,6 +348,9 @@ void init_DocumentWidget(iDocumentWidget *d) {
348 d->ordinalBase = 0; 348 d->ordinalBase = 0;
349 d->initNormScrollY = 0; 349 d->initNormScrollY = 0;
350 init_SmoothScroll(&d->scrollY, w, scrollBegan_DocumentWidget_); 350 init_SmoothScroll(&d->scrollY, w, scrollBegan_DocumentWidget_);
351 if (deviceType_App() != desktop_AppDeviceType) {
352 d->scrollY.flags |= pullDownAction_SmoothScrollFlag; /* pull to refresh */
353 }
351 d->animWideRunId = 0; 354 d->animWideRunId = 0;
352 init_Anim(&d->animWideRunOffset, 0); 355 init_Anim(&d->animWideRunOffset, 0);
353 d->selectMark = iNullRange; 356 d->selectMark = iNullRange;
diff --git a/src/ui/util.c b/src/ui/util.c
index 097eb548..6e139856 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -480,6 +480,7 @@ void init_SmoothScroll(iSmoothScroll *d, iWidget *owner, iSmoothScrollNotifyFunc
480 d->widget = owner; 480 d->widget = owner;
481 d->notify = notify; 481 d->notify = notify;
482 d->pullActionTriggered = 0; 482 d->pullActionTriggered = 0;
483 d->flags = 0;
483} 484}
484 485
485void reset_SmoothScroll(iSmoothScroll *d) { 486void reset_SmoothScroll(iSmoothScroll *d) {
@@ -550,7 +551,7 @@ void moveSpan_SmoothScroll(iSmoothScroll *d, int offset, uint32_t span) {
550 } 551 }
551#endif 552#endif
552 int destY = targetValue_Anim(&d->pos) + offset; 553 int destY = targetValue_Anim(&d->pos) + offset;
553 if (destY < -pullActionThreshold_SmoothScroll_(d)) { 554 if (d->flags & pullDownAction_SmoothScrollFlag && destY < -pullActionThreshold_SmoothScroll_(d)) {
554 if (d->pullActionTriggered == 0) { 555 if (d->pullActionTriggered == 0) {
555 d->pullActionTriggered = iTrue; 556 d->pullActionTriggered = iTrue;
556#if defined (iPlatformAppleMobile) 557#if defined (iPlatformAppleMobile)
@@ -764,12 +765,13 @@ void makeMenuItems_Widget(iWidget *menu, const iMenuItem *items, size_t n) {
764 drawKey_WidgetFlag | itemFlags); 765 drawKey_WidgetFlag | itemFlags);
765 setWrap_LabelWidget(label, isInfo); 766 setWrap_LabelWidget(label, isInfo);
766 haveIcons |= checkIcon_LabelWidget(label); 767 haveIcons |= checkIcon_LabelWidget(label);
767 updateSize_LabelWidget(label); /* drawKey was set */
768 setFlags_Widget(as_Widget(label), disabled_WidgetFlag, isDisabled); 768 setFlags_Widget(as_Widget(label), disabled_WidgetFlag, isDisabled);
769 if (isInfo) { 769 if (isInfo) {
770 setFlags_Widget(as_Widget(label), fixedHeight_WidgetFlag, iTrue); /* wrap changes height */ 770 setFlags_Widget(as_Widget(label), resizeToParentWidth_WidgetFlag |
771 fixedHeight_WidgetFlag, iTrue); /* wrap changes height */
771 setTextColor_LabelWidget(label, uiTextAction_ColorId); 772 setTextColor_LabelWidget(label, uiTextAction_ColorId);
772 } 773 }
774 updateSize_LabelWidget(label); /* drawKey was set */
773 } 775 }
774 } 776 }
775 if (deviceType_App() == phone_AppDeviceType) { 777 if (deviceType_App() == phone_AppDeviceType) {
@@ -1051,7 +1053,8 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) {
1051#else 1053#else
1052 const iRect rootRect = rect_Root(d->root); 1054 const iRect rootRect = rect_Root(d->root);
1053 const iInt2 rootSize = rootRect.size; 1055 const iInt2 rootSize = rootRect.size;
1054 const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); 1056 const iBool isPhone = (deviceType_App() == phone_AppDeviceType);
1057 const iBool isPortraitPhone = (isPhone && isPortrait_App());
1055 const iBool isSlidePanel = (flags_Widget(d) & horizontalOffset_WidgetFlag) != 0; 1058 const iBool isSlidePanel = (flags_Widget(d) & horizontalOffset_WidgetFlag) != 0;
1056 if (postCommands) { 1059 if (postCommands) {
1057 postCommand_App("cancel"); /* dismiss any other menus */ 1060 postCommand_App("cancel"); /* dismiss any other menus */
@@ -1139,16 +1142,14 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) {
1139 raise_Widget(d); 1142 raise_Widget(d);
1140 if (deviceType_App() != desktop_AppDeviceType) { 1143 if (deviceType_App() != desktop_AppDeviceType) {
1141 setFlags_Widget(d, arrangeWidth_WidgetFlag | resizeChildrenToWidestChild_WidgetFlag, 1144 setFlags_Widget(d, arrangeWidth_WidgetFlag | resizeChildrenToWidestChild_WidgetFlag,
1142 !isPortraitPhone); 1145 !isPhone);
1143 setFlags_Widget(d, 1146 setFlags_Widget(d,
1144 resizeWidthOfChildren_WidgetFlag | drawBackgroundToBottom_WidgetFlag | 1147 resizeWidthOfChildren_WidgetFlag | drawBackgroundToBottom_WidgetFlag |
1145 drawBackgroundToVerticalSafeArea_WidgetFlag, 1148 drawBackgroundToVerticalSafeArea_WidgetFlag,
1146 isPortraitPhone); 1149 isPhone);
1147 if (isPortraitPhone) { 1150 if (isPhone) {
1148 if (!isSlidePanel) { 1151 setFlags_Widget(d, borderTop_WidgetFlag, !isSlidePanel && isPortrait_App()); /* menu is otherwise frameless */
1149 setFlags_Widget(d, borderTop_WidgetFlag, iTrue); 1152 setFixedSize_Widget(d, init_I2(iMin(rootSize.x, rootSize.y), -1));
1150 }
1151 d->rect.size.x = rootSize.x;
1152 } 1153 }
1153 else { 1154 else {
1154 d->rect.size.x = 0; 1155 d->rect.size.x = 0;
@@ -1156,12 +1157,18 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) {
1156 } 1157 }
1157 updateMenuItemFonts_Widget_(d); 1158 updateMenuItemFonts_Widget_(d);
1158 arrange_Widget(d); 1159 arrange_Widget(d);
1159 if (isPortraitPhone) { 1160 if (!isSlidePanel) {
1161 /* LAYOUT BUG: Height of wrapped menu items is incorrect with a single arrange! */
1162 arrange_Widget(d);
1163 }
1164 if (deviceType_App() == phone_AppDeviceType) {
1160 if (isSlidePanel) { 1165 if (isSlidePanel) {
1161 d->rect.pos = zero_I2(); 1166 d->rect.pos = zero_I2();
1162 } 1167 }
1163 else { 1168 else {
1164 d->rect.pos = init_I2(0, rootSize.y); 1169 d->rect.pos = windowToLocal_Widget(d,
1170 init_I2(rootSize.x / 2 - d->rect.size.x / 2,
1171 rootSize.y));
1165 } 1172 }
1166 } 1173 }
1167 else if (menuOpenFlags & center_MenuOpenFlags) { 1174 else if (menuOpenFlags & center_MenuOpenFlags) {
@@ -1638,7 +1645,7 @@ static void acceptValueInput_(iWidget *dlg) {
1638 } 1645 }
1639} 1646}
1640 1647
1641static void updateValueInputWidth_(iWidget *dlg) { 1648static void updateValueInputSizing_(iWidget *dlg) {
1642 const iRect safeRoot = safeRect_Root(dlg->root); 1649 const iRect safeRoot = safeRect_Root(dlg->root);
1643 const iInt2 rootSize = safeRoot.size; 1650 const iInt2 rootSize = safeRoot.size;
1644 iWidget * title = findChild_Widget(dlg, "valueinput.title"); 1651 iWidget * title = findChild_Widget(dlg, "valueinput.title");
@@ -1651,20 +1658,15 @@ static void updateValueInputWidth_(iWidget *dlg) {
1651 iMin(rootSize.x, iMaxi(iMaxi(100 * gap_UI, title->rect.size.x), prompt->rect.size.x)); 1658 iMin(rootSize.x, iMaxi(iMaxi(100 * gap_UI, title->rect.size.x), prompt->rect.size.x));
1652 } 1659 }
1653 /* Adjust the maximum number of visible lines. */ 1660 /* Adjust the maximum number of visible lines. */
1654 int footer = 6 * gap_UI + get_MainWindow()->keyboardHeight; 1661 int footer = 6 * gap_UI;
1655#if defined (iPlatformAppleMobile)
1656 if (deviceType_App() == phone_AppDeviceType) {
1657 footer -= 12 * gap_UI; /* A little suspect, this... Check the math? */
1658 }
1659#endif
1660 iWidget *buttons = findChild_Widget(dlg, "dialogbuttons"); 1662 iWidget *buttons = findChild_Widget(dlg, "dialogbuttons");
1661 if (buttons) { 1663 if (buttons && deviceType_App() == desktop_AppDeviceType) {
1662 footer += height_Widget(buttons); 1664 footer += height_Widget(buttons);
1663 } 1665 }
1664 iInputWidget *input = findChild_Widget(dlg, "input"); 1666 iInputWidget *input = findChild_Widget(dlg, "input");
1665 setLineLimits_InputWidget(input, 1667 setLineLimits_InputWidget(input,
1666 1, 1668 1,
1667 (bottom_Rect(safeRect_Root(dlg->root)) - footer - 1669 (bottom_Rect(visibleRect_Root(dlg->root)) - footer -
1668 top_Rect(boundsWithoutVisualOffset_Widget(as_Widget(input)))) / 1670 top_Rect(boundsWithoutVisualOffset_Widget(as_Widget(input)))) /
1669 lineHeight_Text(font_InputWidget(input))); 1671 lineHeight_Text(font_InputWidget(input)));
1670} 1672}
@@ -1673,7 +1675,7 @@ iBool valueInputHandler_(iWidget *dlg, const char *cmd) {
1673 iWidget *ptr = as_Widget(pointer_Command(cmd)); 1675 iWidget *ptr = as_Widget(pointer_Command(cmd));
1674 if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "keyboard.changed")) { 1676 if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "keyboard.changed")) {
1675 if (isVisible_Widget(dlg)) { 1677 if (isVisible_Widget(dlg)) {
1676 updateValueInputWidth_(dlg); 1678 updateValueInputSizing_(dlg);
1677 arrange_Widget(dlg); 1679 arrange_Widget(dlg);
1678 } 1680 }
1679 return iFalse; 1681 return iFalse;
@@ -1847,7 +1849,7 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con
1847 dlg->rect.pos.y -= delta; 1849 dlg->rect.pos.y -= delta;
1848 } 1850 }
1849 } 1851 }
1850 updateValueInputWidth_(dlg); 1852 updateValueInputSizing_(dlg);
1851 setupSheetTransition_Mobile(dlg, incoming_TransitionFlag | top_TransitionDir); 1853 setupSheetTransition_Mobile(dlg, incoming_TransitionFlag | top_TransitionDir);
1852 return dlg; 1854 return dlg;
1853} 1855}
@@ -1855,7 +1857,7 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con
1855void updateValueInput_Widget(iWidget *d, const char *title, const char *prompt) { 1857void updateValueInput_Widget(iWidget *d, const char *title, const char *prompt) {
1856 setTextCStr_LabelWidget(findChild_Widget(d, "valueinput.title"), title); 1858 setTextCStr_LabelWidget(findChild_Widget(d, "valueinput.title"), title);
1857 setTextCStr_LabelWidget(findChild_Widget(d, "valueinput.prompt"), prompt); 1859 setTextCStr_LabelWidget(findChild_Widget(d, "valueinput.prompt"), prompt);
1858 updateValueInputWidth_(d); 1860 updateValueInputSizing_(d);
1859} 1861}
1860 1862
1861static void updateQuestionWidth_(iWidget *dlg) { 1863static void updateQuestionWidth_(iWidget *dlg) {
diff --git a/src/ui/util.h b/src/ui/util.h
index 023fa7ae..b9109aee 100644
--- a/src/ui/util.h
+++ b/src/ui/util.h
@@ -179,11 +179,17 @@ iDeclareType(SmoothScroll)
179 179
180typedef void (*iSmoothScrollNotifyFunc)(iAnyObject *, int offset, uint32_t span); 180typedef void (*iSmoothScrollNotifyFunc)(iAnyObject *, int offset, uint32_t span);
181 181
182enum iSmoothScrollFlags {
183 pullDownAction_SmoothScrollFlag = iBit(1),
184 pullUpAction_SmoothScrollFlag = iBit(2),
185};
186
182struct Impl_SmoothScroll { 187struct Impl_SmoothScroll {
183 iAnim pos; 188 iAnim pos;
184 int max; 189 int max;
185 int overscroll; 190 int overscroll;
186 iWidget *widget; 191 iWidget *widget;
192 int flags;
187 int pullActionTriggered; 193 int pullActionTriggered;
188 iSmoothScrollNotifyFunc notify; 194 iSmoothScrollNotifyFunc notify;
189}; 195};