diff options
Diffstat (limited to 'src/ui/util.c')
-rw-r--r-- | src/ui/util.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/ui/util.c b/src/ui/util.c index e3454cd9..11a304d1 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1758,6 +1758,20 @@ void updateValueInput_Widget(iWidget *d, const char *title, const char *prompt) | |||
1758 | updateValueInputWidth_(d); | 1758 | updateValueInputWidth_(d); |
1759 | } | 1759 | } |
1760 | 1760 | ||
1761 | static void updateQuestionWidth_(iWidget *dlg) { | ||
1762 | iWidget *title = findChild_Widget(dlg, "question.title"); | ||
1763 | iWidget *msg = findChild_Widget(dlg, "question.msg"); | ||
1764 | if (title && msg) { | ||
1765 | const iRect safeRoot = safeRect_Root(dlg->root); | ||
1766 | const iInt2 rootSize = safeRoot.size; | ||
1767 | const int padding = 6 * gap_UI; | ||
1768 | dlg->rect.size.x = | ||
1769 | iMin(iMin(150 * gap_UI, rootSize.x), | ||
1770 | iMaxi(iMaxi(100 * gap_UI, padding + title->rect.size.x), | ||
1771 | padding + msg->rect.size.x)); | ||
1772 | } | ||
1773 | } | ||
1774 | |||
1761 | static iBool messageHandler_(iWidget *msg, const char *cmd) { | 1775 | static iBool messageHandler_(iWidget *msg, const char *cmd) { |
1762 | /* Almost any command dismisses the sheet. */ | 1776 | /* Almost any command dismisses the sheet. */ |
1763 | /* TODO: Add a "notification" type of user events to separate them from user actions. */ | 1777 | /* TODO: Add a "notification" type of user events to separate them from user actions. */ |
@@ -1767,13 +1781,20 @@ static iBool messageHandler_(iWidget *msg, const char *cmd) { | |||
1767 | equal_Command(cmd, "document.autoreload") || | 1781 | equal_Command(cmd, "document.autoreload") || |
1768 | equal_Command(cmd, "document.reload") || | 1782 | equal_Command(cmd, "document.reload") || |
1769 | equal_Command(cmd, "document.request.updated") || | 1783 | equal_Command(cmd, "document.request.updated") || |
1784 | equal_Command(cmd, "document.linkkeys") || | ||
1770 | equal_Command(cmd, "scrollbar.fade") || | 1785 | equal_Command(cmd, "scrollbar.fade") || |
1771 | equal_Command(cmd, "widget.overflow") || | 1786 | equal_Command(cmd, "widget.overflow") || |
1772 | equal_Command(cmd, "edgeswipe.ended") || | 1787 | equal_Command(cmd, "edgeswipe.ended") || |
1788 | equal_Command(cmd, "layout.changed") || | ||
1789 | equal_Command(cmd, "theme.changed") || | ||
1790 | startsWith_CStr(cmd, "feeds.update.") || | ||
1773 | startsWith_CStr(cmd, "window."))) { | 1791 | startsWith_CStr(cmd, "window."))) { |
1774 | setupSheetTransition_Mobile(msg, iFalse); | 1792 | setupSheetTransition_Mobile(msg, iFalse); |
1775 | destroy_Widget(msg); | 1793 | destroy_Widget(msg); |
1776 | } | 1794 | } |
1795 | else if (equal_Command(cmd, "window.resized")) { | ||
1796 | updateQuestionWidth_(msg); | ||
1797 | } | ||
1777 | return iFalse; | 1798 | return iFalse; |
1778 | } | 1799 | } |
1779 | 1800 | ||
@@ -1819,8 +1840,16 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg, | |||
1819 | } | 1840 | } |
1820 | iWidget *dlg = makeSheet_Widget(""); | 1841 | iWidget *dlg = makeSheet_Widget(""); |
1821 | setCommandHandler_Widget(dlg, messageHandler_); | 1842 | setCommandHandler_Widget(dlg, messageHandler_); |
1822 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag); | 1843 | setId_Widget( |
1823 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, NULL)), frameless_WidgetFlag); | 1844 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag), |
1845 | "question.title"); | ||
1846 | iLabelWidget *msgLabel; | ||
1847 | setId_Widget(addChildFlags_Widget(dlg, | ||
1848 | iClob(msgLabel = new_LabelWidget(msg, NULL)), | ||
1849 | frameless_WidgetFlag | fixedHeight_WidgetFlag | | ||
1850 | resizeToParentWidth_WidgetFlag), | ||
1851 | "question.msg"); | ||
1852 | setWrap_LabelWidget(msgLabel, iTrue); | ||
1824 | /* Check for value selections. */ | 1853 | /* Check for value selections. */ |
1825 | for (size_t i = 0; i < numItems; i++) { | 1854 | for (size_t i = 0; i < numItems; i++) { |
1826 | const iMenuItem *item = &items[i]; | 1855 | const iMenuItem *item = &items[i]; |
@@ -1842,6 +1871,8 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg, | |||
1842 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); | 1871 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); |
1843 | addChild_Widget(dlg, iClob(makeDialogButtons_Widget(items, numItems))); | 1872 | addChild_Widget(dlg, iClob(makeDialogButtons_Widget(items, numItems))); |
1844 | addChild_Widget(dlg->root->widget, iClob(dlg)); | 1873 | addChild_Widget(dlg->root->widget, iClob(dlg)); |
1874 | updateQuestionWidth_(dlg); | ||
1875 | class_Widget(as_Widget(msgLabel))->sizeChanged(as_Widget(msgLabel)); | ||
1845 | arrange_Widget(dlg); /* BUG: This extra arrange shouldn't be needed but the dialog won't | 1876 | arrange_Widget(dlg); /* BUG: This extra arrange shouldn't be needed but the dialog won't |
1846 | be arranged correctly unless it's here. */ | 1877 | be arranged correctly unless it's here. */ |
1847 | setupSheetTransition_Mobile(dlg, iTrue); | 1878 | setupSheetTransition_Mobile(dlg, iTrue); |