summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-10-25 22:08:18 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-10-25 22:08:18 +0300
commitb80c958840a3ac0f824de3ae12717963ba679b20 (patch)
tree1e2b08b69d95677b2785ca33d1959fe774ac73cd
parent7e63026892c1e9d686ba61e6cb8b620e5ad4081d (diff)
Message/question text wrapping; cleanup
-rw-r--r--src/fontpack.c2
-rw-r--r--src/ui/color.h1
-rw-r--r--src/ui/util.c35
3 files changed, 35 insertions, 3 deletions
diff --git a/src/fontpack.c b/src/fontpack.c
index 7c2fb7f4..88aa47e8 100644
--- a/src/fontpack.c
+++ b/src/fontpack.c
@@ -846,7 +846,7 @@ const iString *infoPage_Fonts(iRangecc query) {
846 return exportFontPackIni_Fonts_(d, query); 846 return exportFontPackIni_Fonts_(d, query);
847 } 847 }
848 iString *str = collectNewCStr_String("# ${heading.fontpack.meta}\n" 848 iString *str = collectNewCStr_String("# ${heading.fontpack.meta}\n"
849 "=> gemini://skyjake.fi/fonts Download more fonts\n" 849 "=> gemini://skyjake.fi/fonts/ Download new fonts\n"
850 "=> about:command?!open%20newtab:1%20gotoheading:1%20url:about:help Using fonts in Lagrange\n" 850 "=> about:command?!open%20newtab:1%20gotoheading:1%20url:about:help Using fonts in Lagrange\n"
851 "=> about:command?!open%20newtab:1%20gotoheading:1%20url:about:help How to create a fontpack\n"); 851 "=> about:command?!open%20newtab:1%20gotoheading:1%20url:about:help How to create a fontpack\n");
852 iPtrArray *specsByPack = collectNew_PtrArray(); 852 iPtrArray *specsByPack = collectNew_PtrArray();
diff --git a/src/ui/color.h b/src/ui/color.h
index 5e96c300..03172fcb 100644
--- a/src/ui/color.h
+++ b/src/ui/color.h
@@ -134,6 +134,7 @@ enum iColorId {
134 tmBannerSideTitle_ColorId, 134 tmBannerSideTitle_ColorId,
135 tmInlineContentMetadata_ColorId, 135 tmInlineContentMetadata_ColorId,
136 tmBackgroundAltText_ColorId, /* derived from other theme colors */ 136 tmBackgroundAltText_ColorId, /* derived from other theme colors */
137 tmFrameAltText_ColorId, /* derived from other theme colors */
137 tmBackgroundOpenLink_ColorId, /* derived from other theme colors */ 138 tmBackgroundOpenLink_ColorId, /* derived from other theme colors */
138 tmFrameOpenLink_ColorId, /* derived from other theme colors */ 139 tmFrameOpenLink_ColorId, /* derived from other theme colors */
139 tmLinkCustomIconVisited_ColorId, /* derived from other theme colors */ 140 tmLinkCustomIconVisited_ColorId, /* derived from other theme colors */
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
1761static 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
1761static iBool messageHandler_(iWidget *msg, const char *cmd) { 1775static 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);