summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-06-25 16:26:53 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-06-25 16:26:53 +0300
commit5dbc85eaaa1bd0a0fc11dd76a75ece2efe763df5 (patch)
tree9721fb7aced603adb10b9bb3f3beb3f8d5fba973 /src/ui/util.c
parent95c527db1484f7758a180c6de051d0182c3b2e81 (diff)
parentf99a9111170f2ff28383fd3172fdaf4b9a1ba069 (diff)
Merge branch 'work/v1.6' into work/serious-unicode
# Conflicts: # res/fonts/SmolEmoji-Regular.ttf
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c104
1 files changed, 63 insertions, 41 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index c4fb8886..e0b05a44 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -710,7 +710,8 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
710 menu, 710 menu,
711 iClob(newKeyMods_LabelWidget(labelText, item->key, item->kmods, item->command)), 711 iClob(newKeyMods_LabelWidget(labelText, item->key, item->kmods, item->command)),
712 noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag | 712 noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag |
713 drawKey_WidgetFlag | (isInfo ? wrapText_WidgetFlag : 0) | itemFlags); 713 drawKey_WidgetFlag | itemFlags);
714 setWrap_LabelWidget(label, isInfo);
714 haveIcons |= checkIcon_LabelWidget(label); 715 haveIcons |= checkIcon_LabelWidget(label);
715 updateSize_LabelWidget(label); /* drawKey was set */ 716 updateSize_LabelWidget(label); /* drawKey was set */
716 if (isInfo) { 717 if (isInfo) {
@@ -776,7 +777,7 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, iBool postCommands) {
776 if (isInstance_Object(i.object, &Class_LabelWidget)) { 777 if (isInstance_Object(i.object, &Class_LabelWidget)) {
777 iLabelWidget *label = i.object; 778 iLabelWidget *label = i.object;
778 const iBool isCaution = startsWith_String(text_LabelWidget(label), uiTextCaution_ColorEscape); 779 const iBool isCaution = startsWith_String(text_LabelWidget(label), uiTextCaution_ColorEscape);
779 if (flags_Widget(as_Widget(label)) & wrapText_WidgetFlag) { 780 if (isWrapped_LabelWidget(label)) {
780 continue; 781 continue;
781 } 782 }
782 if (deviceType_App() == desktop_AppDeviceType) { 783 if (deviceType_App() == desktop_AppDeviceType) {
@@ -979,8 +980,8 @@ static void addTabPage_Widget_(iWidget *tabs, enum iWidgetAddPos addPos, iWidget
979 iClob(newKeyMods_LabelWidget(label, key, kmods, format_CStr("tabs.switch page:%p", page))), 980 iClob(newKeyMods_LabelWidget(label, key, kmods, format_CStr("tabs.switch page:%p", page))),
980 addPos); 981 addPos);
981 setFlags_Widget(button, selected_WidgetFlag, isSel); 982 setFlags_Widget(button, selected_WidgetFlag, isSel);
982 setFlags_Widget( 983 setFlags_Widget(button, commandOnClick_WidgetFlag | expand_WidgetFlag, iTrue);
983 button, noTopFrame_WidgetFlag | commandOnClick_WidgetFlag | expand_WidgetFlag, iTrue); 984 setNoTopFrame_LabelWidget((iLabelWidget *) button, iTrue);
984 addChildPos_Widget(pages, page, addPos); 985 addChildPos_Widget(pages, page, addPos);
985 if (tabCount_Widget(tabs) > 1) { 986 if (tabCount_Widget(tabs) > 1) {
986 setFlags_Widget(buttons, hidden_WidgetFlag, iFalse); 987 setFlags_Widget(buttons, hidden_WidgetFlag, iFalse);
@@ -1317,7 +1318,7 @@ void updateValueInput_Widget(iWidget *d, const char *title, const char *prompt)
1317 1318
1318static iBool messageHandler_(iWidget *msg, const char *cmd) { 1319static iBool messageHandler_(iWidget *msg, const char *cmd) {
1319 /* Almost any command dismisses the sheet. */ 1320 /* Almost any command dismisses the sheet. */
1320 /* TODO: Use a "notification" prefix (like `) to ignore all types of commands line this? */ 1321 /* TODO: Add a "notification" type of user events to separate them from user actions. */
1321 if (!(equal_Command(cmd, "media.updated") || 1322 if (!(equal_Command(cmd, "media.updated") ||
1322 equal_Command(cmd, "media.player.update") || 1323 equal_Command(cmd, "media.player.update") ||
1323 equal_Command(cmd, "bookmarks.request.finished") || 1324 equal_Command(cmd, "bookmarks.request.finished") ||
@@ -1326,6 +1327,7 @@ static iBool messageHandler_(iWidget *msg, const char *cmd) {
1326 equal_Command(cmd, "document.request.updated") || 1327 equal_Command(cmd, "document.request.updated") ||
1327 equal_Command(cmd, "scrollbar.fade") || 1328 equal_Command(cmd, "scrollbar.fade") ||
1328 equal_Command(cmd, "widget.overflow") || 1329 equal_Command(cmd, "widget.overflow") ||
1330 equal_Command(cmd, "edgeswipe.ended") ||
1329 startsWith_CStr(cmd, "window."))) { 1331 startsWith_CStr(cmd, "window."))) {
1330 setupSheetTransition_Mobile(msg, iFalse); 1332 setupSheetTransition_Mobile(msg, iFalse);
1331 destroy_Widget(msg); 1333 destroy_Widget(msg);
@@ -1599,8 +1601,6 @@ iWidget *makePreferences_Widget(void) {
1599 /* General preferences. */ { 1601 /* General preferences. */ {
1600 appendTwoColumnPage_(tabs, "${heading.prefs.general}", '1', &headings, &values); 1602 appendTwoColumnPage_(tabs, "${heading.prefs.general}", '1', &headings, &values);
1601#if defined (LAGRANGE_ENABLE_DOWNLOAD_EDIT) 1603#if defined (LAGRANGE_ENABLE_DOWNLOAD_EDIT)
1602 //addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.downloads}")));
1603 //setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.downloads");
1604 addPrefsInputWithHeading_(headings, values, "prefs.downloads", iClob(new_InputWidget(0))); 1604 addPrefsInputWithHeading_(headings, values, "prefs.downloads", iClob(new_InputWidget(0)));
1605#endif 1605#endif
1606 iInputWidget *searchUrl; 1606 iInputWidget *searchUrl;
@@ -1608,12 +1608,6 @@ iWidget *makePreferences_Widget(void) {
1608 setUrlContent_InputWidget(searchUrl, iTrue); 1608 setUrlContent_InputWidget(searchUrl, iTrue);
1609 addChild_Widget(headings, iClob(makePadding_Widget(bigGap))); 1609 addChild_Widget(headings, iClob(makePadding_Widget(bigGap)));
1610 addChild_Widget(values, iClob(makePadding_Widget(bigGap))); 1610 addChild_Widget(values, iClob(makePadding_Widget(bigGap)));
1611 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.collapsepreonload}")));
1612 addChild_Widget(values, iClob(makeToggle_Widget("prefs.collapsepreonload")));
1613 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.plaintext.wrap}")));
1614 addChild_Widget(values, iClob(makeToggle_Widget("prefs.plaintext.wrap")));
1615 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.centershort}")));
1616 addChild_Widget(values, iClob(makeToggle_Widget("prefs.centershort")));
1617 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.hoverlink}"))); 1611 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.hoverlink}")));
1618 addChild_Widget(values, iClob(makeToggle_Widget("prefs.hoverlink"))); 1612 addChild_Widget(values, iClob(makeToggle_Widget("prefs.hoverlink")));
1619 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.archive.openindex}"))); 1613 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.archive.openindex}")));
@@ -1674,26 +1668,6 @@ iWidget *makePreferences_Widget(void) {
1674 } 1668 }
1675 /* User Interface. */ { 1669 /* User Interface. */ {
1676 appendTwoColumnPage_(tabs, "${heading.prefs.interface}", '2', &headings, &values); 1670 appendTwoColumnPage_(tabs, "${heading.prefs.interface}", '2', &headings, &values);
1677#if defined (iPlatformApple) || defined (iPlatformMSys)
1678 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.ostheme}")));
1679 addChild_Widget(values, iClob(makeToggle_Widget("prefs.ostheme")));
1680#endif
1681 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.theme}")));
1682 iWidget *themes = new_Widget();
1683 /* Themes. */ {
1684 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("${prefs.theme.black}", "theme.set arg:0"))), "prefs.theme.0");
1685 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("${prefs.theme.dark}", "theme.set arg:1"))), "prefs.theme.1");
1686 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("${prefs.theme.light}", "theme.set arg:2"))), "prefs.theme.2");
1687 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("${prefs.theme.white}", "theme.set arg:3"))), "prefs.theme.3");
1688 }
1689 addChildFlags_Widget(values, iClob(themes), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1690 /* Accents. */
1691 iWidget *accent = new_Widget(); {
1692 setId_Widget(addChild_Widget(accent, iClob(new_LabelWidget("${prefs.accent.teal}", "accent.set arg:0"))), "prefs.accent.0");
1693 setId_Widget(addChild_Widget(accent, iClob(new_LabelWidget("${prefs.accent.orange}", "accent.set arg:1"))), "prefs.accent.1");
1694 }
1695 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.accent}")));
1696 addChildFlags_Widget(values, iClob(accent), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1697#if defined (LAGRANGE_ENABLE_CUSTOM_FRAME) 1671#if defined (LAGRANGE_ENABLE_CUSTOM_FRAME)
1698 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.customframe}"))); 1672 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.customframe}")));
1699 addChild_Widget(values, iClob(makeToggle_Widget("prefs.customframe"))); 1673 addChild_Widget(values, iClob(makeToggle_Widget("prefs.customframe")));
@@ -1718,6 +1692,27 @@ iWidget *makePreferences_Widget(void) {
1718 } 1692 }
1719 /* Colors. */ { 1693 /* Colors. */ {
1720 appendTwoColumnPage_(tabs, "${heading.prefs.colors}", '3', &headings, &values); 1694 appendTwoColumnPage_(tabs, "${heading.prefs.colors}", '3', &headings, &values);
1695 makeTwoColumnHeading_("${heading.prefs.uitheme}", headings, values);
1696#if defined (iPlatformApple) || defined (iPlatformMSys)
1697 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.ostheme}")));
1698 addChild_Widget(values, iClob(makeToggle_Widget("prefs.ostheme")));
1699#endif
1700 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.theme}")));
1701 iWidget *themes = new_Widget();
1702 /* Themes. */ {
1703 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("${prefs.theme.black}", "theme.set arg:0"))), "prefs.theme.0");
1704 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("${prefs.theme.dark}", "theme.set arg:1"))), "prefs.theme.1");
1705 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("${prefs.theme.light}", "theme.set arg:2"))), "prefs.theme.2");
1706 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("${prefs.theme.white}", "theme.set arg:3"))), "prefs.theme.3");
1707 }
1708 addChildFlags_Widget(values, iClob(themes), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1709 /* Accents. */
1710 iWidget *accent = new_Widget(); {
1711 setId_Widget(addChild_Widget(accent, iClob(new_LabelWidget("${prefs.accent.teal}", "accent.set arg:0"))), "prefs.accent.0");
1712 setId_Widget(addChild_Widget(accent, iClob(new_LabelWidget("${prefs.accent.orange}", "accent.set arg:1"))), "prefs.accent.1");
1713 }
1714 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.accent}")));
1715 addChildFlags_Widget(values, iClob(accent), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1721 makeTwoColumnHeading_("${heading.prefs.pagecontent}", headings, values); 1716 makeTwoColumnHeading_("${heading.prefs.pagecontent}", headings, values);
1722 for (int i = 0; i < 2; ++i) { 1717 for (int i = 0; i < 2; ++i) {
1723 const iBool isDark = (i == 0); 1718 const iBool isDark = (i == 0);
@@ -1750,14 +1745,15 @@ iWidget *makePreferences_Widget(void) {
1750 } 1745 }
1751 addChildFlags_Widget(values, iClob(sats), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 1746 addChildFlags_Widget(values, iClob(sats), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1752 } 1747 }
1753 /* Layout. */ { 1748 /* Fonts. */ {
1754 setId_Widget(appendTwoColumnPage_(tabs, "${heading.prefs.style}", '4', &headings, &values), "prefs.page.style"); 1749 setId_Widget(appendTwoColumnPage_(tabs, "${heading.prefs.fonts}", '4', &headings, &values), "prefs.page.fonts");
1755 makeTwoColumnHeading_("${heading.prefs.fonts}", headings, values);
1756 /* Fonts. */ { 1750 /* Fonts. */ {
1757 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.headingfont}"))); 1751 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.headingfont}")));
1758 addFontButtons_(values, "headingfont"); 1752 addFontButtons_(values, "headingfont");
1759 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.font}"))); 1753 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.font}")));
1760 addFontButtons_(values, "font"); 1754 addFontButtons_(values, "font");
1755 addChild_Widget(headings, iClob(makePadding_Widget(bigGap)));
1756 addChild_Widget(values, iClob(makePadding_Widget(bigGap)));
1761 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.mono}"))); 1757 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.mono}")));
1762 iWidget *mono = new_Widget(); { 1758 iWidget *mono = new_Widget(); {
1763 iWidget *tog; 1759 iWidget *tog;
@@ -1789,9 +1785,18 @@ iWidget *makePreferences_Widget(void) {
1789 updateSize_LabelWidget((iLabelWidget *) tog); 1785 updateSize_LabelWidget((iLabelWidget *) tog);
1790 } 1786 }
1791 addChildFlags_Widget(values, iClob(boldLink), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 1787 addChildFlags_Widget(values, iClob(boldLink), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1792 addPrefsInputWithHeading_(headings, values, "prefs.userfont", iClob(new_InputWidget(0))); 1788 addChild_Widget(headings, iClob(makePadding_Widget(bigGap)));
1793 } 1789 addChild_Widget(values, iClob(makePadding_Widget(bigGap)));
1794 makeTwoColumnHeading_("${heading.prefs.paragraph}", headings, values); 1790 /* Custom font. */ {
1791 iInputWidget *customFont = new_InputWidget(0);
1792 setHint_InputWidget(customFont, "${hint.prefs.userfont}");
1793 addPrefsInputWithHeading_(headings, values, "prefs.userfont", iClob(customFont));
1794 }
1795 }
1796 }
1797 /* Style. */ {
1798 setId_Widget(appendTwoColumnPage_(tabs, "${heading.prefs.style}", '5', &headings, &values), "prefs.page.style");
1799// makeTwoColumnHeading_("${heading.prefs.paragraph}", headings, values);
1795 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.linewidth}"))); 1800 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.linewidth}")));
1796 iWidget *widths = new_Widget(); 1801 iWidget *widths = new_Widget();
1797 /* Line widths. */ { 1802 /* Line widths. */ {
@@ -1811,14 +1816,20 @@ iWidget *makePreferences_Widget(void) {
1811 addChildFlags_Widget(values, iClob(quote), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 1816 addChildFlags_Widget(values, iClob(quote), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1812 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.biglede}"))); 1817 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.biglede}")));
1813 addChild_Widget(values, iClob(makeToggle_Widget("prefs.biglede"))); 1818 addChild_Widget(values, iClob(makeToggle_Widget("prefs.biglede")));
1819 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.plaintext.wrap}")));
1820 addChild_Widget(values, iClob(makeToggle_Widget("prefs.plaintext.wrap")));
1821 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.collapsepreonload}")));
1822 addChild_Widget(values, iClob(makeToggle_Widget("prefs.collapsepreonload")));
1814// makeTwoColumnHeading_("${heading.prefs.widelayout}", headings, values); 1823// makeTwoColumnHeading_("${heading.prefs.widelayout}", headings, values);
1815 addChild_Widget(headings, iClob(makePadding_Widget(bigGap))); 1824 addChild_Widget(headings, iClob(makePadding_Widget(bigGap)));
1816 addChild_Widget(values, iClob(makePadding_Widget(bigGap))); 1825 addChild_Widget(values, iClob(makePadding_Widget(bigGap)));
1817 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.sideicon}"))); 1826 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.sideicon}")));
1818 addChild_Widget(values, iClob(makeToggle_Widget("prefs.sideicon"))); 1827 addChild_Widget(values, iClob(makeToggle_Widget("prefs.sideicon")));
1828 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.centershort}")));
1829 addChild_Widget(values, iClob(makeToggle_Widget("prefs.centershort")));
1819 } 1830 }
1820 /* Network. */ { 1831 /* Network. */ {
1821 appendTwoColumnPage_(tabs, "${heading.prefs.network}", '5', &headings, &values); 1832 appendTwoColumnPage_(tabs, "${heading.prefs.network}", '6', &headings, &values);
1822 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.decodeurls}"))); 1833 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.decodeurls}")));
1823 addChild_Widget(values, iClob(makeToggle_Widget("prefs.decodeurls"))); 1834 addChild_Widget(values, iClob(makeToggle_Widget("prefs.decodeurls")));
1824 /* Cache size. */ { 1835 /* Cache size. */ {
@@ -1832,6 +1843,17 @@ iWidget *makePreferences_Widget(void) {
1832 resizeToParentHeight_WidgetFlag); 1843 resizeToParentHeight_WidgetFlag);
1833 setContentPadding_InputWidget(cache, 0, width_Widget(unit) - 4 * gap_UI); 1844 setContentPadding_InputWidget(cache, 0, width_Widget(unit) - 4 * gap_UI);
1834 } 1845 }
1846 /* Memory size. */ {
1847 iInputWidget *mem = new_InputWidget(4);
1848 setSelectAllOnFocus_InputWidget(mem, iTrue);
1849 addPrefsInputWithHeading_(headings, values, "prefs.memorysize", iClob(mem));
1850 iWidget *unit =
1851 addChildFlags_Widget(as_Widget(mem),
1852 iClob(new_LabelWidget("${mb}", NULL)),
1853 frameless_WidgetFlag | moveToParentRightEdge_WidgetFlag |
1854 resizeToParentHeight_WidgetFlag);
1855 setContentPadding_InputWidget(mem, 0, width_Widget(unit) - 4 * gap_UI);
1856 }
1835 makeTwoColumnHeading_("${heading.prefs.certs}", headings, values); 1857 makeTwoColumnHeading_("${heading.prefs.certs}", headings, values);
1836 addPrefsInputWithHeading_(headings, values, "prefs.ca.file", iClob(new_InputWidget(0))); 1858 addPrefsInputWithHeading_(headings, values, "prefs.ca.file", iClob(new_InputWidget(0)));
1837 addPrefsInputWithHeading_(headings, values, "prefs.ca.path", iClob(new_InputWidget(0))); 1859 addPrefsInputWithHeading_(headings, values, "prefs.ca.path", iClob(new_InputWidget(0)));
@@ -1843,7 +1865,7 @@ iWidget *makePreferences_Widget(void) {
1843 /* Keybindings. */ 1865 /* Keybindings. */
1844 if (deviceType_App() == desktop_AppDeviceType) { 1866 if (deviceType_App() == desktop_AppDeviceType) {
1845 iBindingsWidget *bind = new_BindingsWidget(); 1867 iBindingsWidget *bind = new_BindingsWidget();
1846 appendFramelessTabPage_(tabs, iClob(bind), "${heading.prefs.keys}", '6', KMOD_PRIMARY); 1868 appendFramelessTabPage_(tabs, iClob(bind), "${heading.prefs.keys}", '7', KMOD_PRIMARY);
1847 } 1869 }
1848 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); 1870 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI)));
1849 updatePreferencesLayout_Widget(dlg); 1871 updatePreferencesLayout_Widget(dlg);