diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-07 22:10:29 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-07 22:10:29 +0300 |
commit | 4ce9a07bbd4a4a82ff0b310d9c9e0768febe8d61 (patch) | |
tree | ca8c41fa1d792fdc764c787cb343ddbb6cfbef5a /src/ui/util.c | |
parent | c10fc7a058c05edcedeb23bdcc9faae635f1780d (diff) |
Mobile: Redoing Preferences
Contents of the Preferences split panel view are created based on arrays of MenuItems. This removes the confusing indirection of trying to modify the desktop widget tree to fit mobile.
Diffstat (limited to 'src/ui/util.c')
-rw-r--r-- | src/ui/util.c | 247 |
1 files changed, 174 insertions, 73 deletions
diff --git a/src/ui/util.c b/src/ui/util.c index 906d30ae..995b730e 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -707,6 +707,9 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | |||
707 | iBool haveIcons = iFalse; | 707 | iBool haveIcons = iFalse; |
708 | for (size_t i = 0; i < n; ++i) { | 708 | for (size_t i = 0; i < n; ++i) { |
709 | const iMenuItem *item = &items[i]; | 709 | const iMenuItem *item = &items[i]; |
710 | if (!item->label) { | ||
711 | break; | ||
712 | } | ||
710 | if (equal_CStr(item->label, "---")) { | 713 | if (equal_CStr(item->label, "---")) { |
711 | addChild_Widget(menu, iClob(makeMenuSeparator_())); | 714 | addChild_Widget(menu, iClob(makeMenuSeparator_())); |
712 | } | 715 | } |
@@ -1506,7 +1509,7 @@ static void addRadioButton_(iWidget *parent, const char *id, const char *label, | |||
1506 | id); | 1509 | id); |
1507 | } | 1510 | } |
1508 | 1511 | ||
1509 | static void addFontButtons_(iWidget *parent, const char *id) { | 1512 | static const iArray *makeFontItems_(const char *id) { |
1510 | const struct { | 1513 | const struct { |
1511 | const char * name; | 1514 | const char * name; |
1512 | enum iTextFont cfgId; | 1515 | enum iTextFont cfgId; |
@@ -1518,7 +1521,7 @@ static void addFontButtons_(iWidget *parent, const char *id) { | |||
1518 | { "Tinos", tinos_TextFont }, | 1521 | { "Tinos", tinos_TextFont }, |
1519 | { "---", -1 }, | 1522 | { "---", -1 }, |
1520 | { "Iosevka", iosevka_TextFont } }; | 1523 | { "Iosevka", iosevka_TextFont } }; |
1521 | iArray *items = new_Array(sizeof(iMenuItem)); | 1524 | iArray *items = collectNew_Array(sizeof(iMenuItem)); |
1522 | iForIndices(i, fonts) { | 1525 | iForIndices(i, fonts) { |
1523 | pushBack_Array(items, | 1526 | pushBack_Array(items, |
1524 | &(iMenuItem){ fonts[i].name, | 1527 | &(iMenuItem){ fonts[i].name, |
@@ -1528,11 +1531,18 @@ static void addFontButtons_(iWidget *parent, const char *id) { | |||
1528 | ? format_CStr("!%s.set arg:%d", id, fonts[i].cfgId) | 1531 | ? format_CStr("!%s.set arg:%d", id, fonts[i].cfgId) |
1529 | : NULL }); | 1532 | : NULL }); |
1530 | } | 1533 | } |
1531 | iLabelWidget *button = makeMenuButton_LabelWidget("Source Sans 3", data_Array(items), size_Array(items)); | 1534 | pushBack_Array(items, &(iMenuItem){ NULL }); /* terminator */ |
1532 | setBackgroundColor_Widget(findChild_Widget(as_Widget(button), "menu"), uiBackgroundMenu_ColorId); | 1535 | return items; |
1536 | } | ||
1537 | |||
1538 | static void addFontButtons_(iWidget *parent, const char *id) { | ||
1539 | const iArray *items = makeFontItems_(id); | ||
1540 | iLabelWidget *button = makeMenuButton_LabelWidget("Source Sans 3", | ||
1541 | constData_Array(items), size_Array(items)); | ||
1542 | setBackgroundColor_Widget(findChild_Widget(as_Widget(button), "menu"), | ||
1543 | uiBackgroundMenu_ColorId); | ||
1533 | setId_Widget(as_Widget(button), format_CStr("prefs.%s", id)); | 1544 | setId_Widget(as_Widget(button), format_CStr("prefs.%s", id)); |
1534 | addChildFlags_Widget(parent, iClob(button), alignLeft_WidgetFlag); | 1545 | addChildFlags_Widget(parent, iClob(button), alignLeft_WidgetFlag); |
1535 | delete_Array(items); | ||
1536 | } | 1546 | } |
1537 | 1547 | ||
1538 | #if 0 | 1548 | #if 0 |
@@ -1615,7 +1625,7 @@ static void addPrefsInputWithHeading_(iWidget *headings, iWidget *values, | |||
1615 | static size_t findWidestItemLabel_(const iMenuItem *items, size_t num) { | 1625 | static size_t findWidestItemLabel_(const iMenuItem *items, size_t num) { |
1616 | int widest = 0; | 1626 | int widest = 0; |
1617 | size_t widestPos = iInvalidPos; | 1627 | size_t widestPos = iInvalidPos; |
1618 | for (size_t i = 0; i < num; i++) { | 1628 | for (size_t i = 0; i < num && items[i].label; i++) { |
1619 | const int width = | 1629 | const int width = |
1620 | measure_Text(uiLabel_FontId, | 1630 | measure_Text(uiLabel_FontId, |
1621 | translateCStr_Lang(items[i].label)) | 1631 | translateCStr_Lang(items[i].label)) |
@@ -1629,6 +1639,153 @@ static size_t findWidestItemLabel_(const iMenuItem *items, size_t num) { | |||
1629 | } | 1639 | } |
1630 | 1640 | ||
1631 | iWidget *makePreferences_Widget(void) { | 1641 | iWidget *makePreferences_Widget(void) { |
1642 | /* Common items. */ | ||
1643 | const iMenuItem langItems[] = { { "${lang.de} - de", 0, 0, "uilang id:de" }, | ||
1644 | { "${lang.en} - en", 0, 0, "uilang id:en" }, | ||
1645 | { "${lang.es} - es", 0, 0, "uilang id:es" }, | ||
1646 | { "${lang.fi} - fi", 0, 0, "uilang id:fi" }, | ||
1647 | { "${lang.fr} - fr", 0, 0, "uilang id:fr" }, | ||
1648 | { "${lang.ia} - ia", 0, 0, "uilang id:ia" }, | ||
1649 | { "${lang.ie} - ie", 0, 0, "uilang id:ie" }, | ||
1650 | { "${lang.pl} - pl", 0, 0, "uilang id:pl" }, | ||
1651 | { "${lang.ru} - ru", 0, 0, "uilang id:ru" }, | ||
1652 | { "${lang.sr} - sr", 0, 0, "uilang id:sr" }, | ||
1653 | { "${lang.tok} - tok", 0, 0, "uilang id:tok" }, | ||
1654 | { "${lang.zh.hans} - zh", 0, 0, "uilang id:zh_Hans" }, | ||
1655 | { "${lang.zh.hant} - zh", 0, 0, "uilang id:zh_Hant" }, | ||
1656 | { NULL } }; | ||
1657 | const iMenuItem returnKeyBehaviors[] = { | ||
1658 | { "${prefs.returnkey.linebreak} " uiTextAction_ColorEscape shift_Icon return_Icon | ||
1659 | restore_ColorEscape | ||
1660 | " ${prefs.returnkey.accept} " uiTextAction_ColorEscape return_Icon, | ||
1661 | 0, | ||
1662 | 0, | ||
1663 | format_CStr("returnkey.set arg:%d", default_ReturnKeyBehavior) }, | ||
1664 | { "${prefs.returnkey.linebreak} " uiTextAction_ColorEscape return_Icon restore_ColorEscape | ||
1665 | " ${prefs.returnkey.accept} " uiTextAction_ColorEscape shift_Icon return_Icon, | ||
1666 | 0, | ||
1667 | 0, | ||
1668 | format_CStr("returnkey.set arg:%d", acceptWithShift_ReturnKeyBehavior) }, | ||
1669 | { "${prefs.returnkey.linebreak} " uiTextAction_ColorEscape return_Icon restore_ColorEscape | ||
1670 | " ${prefs.returnkey.accept} " uiTextAction_ColorEscape | ||
1671 | #if defined (iPlatformApple) | ||
1672 | "\u2318" return_Icon, | ||
1673 | #else | ||
1674 | "Ctrl" return_Icon, | ||
1675 | #endif | ||
1676 | 0, | ||
1677 | 0, | ||
1678 | format_CStr("returnkey.set arg:%d", acceptWithPrimaryMod_ReturnKeyBehavior) }, | ||
1679 | { NULL } | ||
1680 | }; | ||
1681 | iMenuItem docThemes[2][max_GmDocumentTheme + 1]; | ||
1682 | for (int i = 0; i < 2; ++i) { | ||
1683 | const iBool isDark = (i == 0); | ||
1684 | const char *mode = isDark ? "dark" : "light"; | ||
1685 | const iMenuItem items[max_GmDocumentTheme + 1] = { | ||
1686 | { "${prefs.doctheme.name.colorfuldark}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, colorfulDark_GmDocumentTheme) }, | ||
1687 | { "${prefs.doctheme.name.colorfullight}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, colorfulLight_GmDocumentTheme) }, | ||
1688 | { "${prefs.doctheme.name.black}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, black_GmDocumentTheme) }, | ||
1689 | { "${prefs.doctheme.name.gray}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, gray_GmDocumentTheme) }, | ||
1690 | { "${prefs.doctheme.name.white}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, white_GmDocumentTheme) }, | ||
1691 | { "${prefs.doctheme.name.sepia}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, sepia_GmDocumentTheme) }, | ||
1692 | { "${prefs.doctheme.name.highcontrast}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, highContrast_GmDocumentTheme) }, | ||
1693 | { NULL } | ||
1694 | }; | ||
1695 | memcpy(docThemes[i], items, sizeof(items)); | ||
1696 | } | ||
1697 | const iMenuItem imgStyles[] = { | ||
1698 | { "${prefs.imagestyle.original}", 0, 0, format_CStr("imagestyle.set arg:%d", original_ImageStyle) }, | ||
1699 | { "${prefs.imagestyle.grayscale}", 0, 0, format_CStr("imagestyle.set arg:%d", grayscale_ImageStyle) }, | ||
1700 | { "${prefs.imagestyle.bgfg}", 0, 0, format_CStr("imagestyle.set arg:%d", bgFg_ImageStyle) }, | ||
1701 | { "${prefs.imagestyle.text}", 0, 0, format_CStr("imagestyle.set arg:%d", textColorized_ImageStyle) }, | ||
1702 | { "${prefs.imagestyle.preformat}", 0, 0, format_CStr("imagestyle.set arg:%d", preformatColorized_ImageStyle) }, | ||
1703 | { NULL } | ||
1704 | }; | ||
1705 | /* Create the Preferences UI. */ | ||
1706 | if (deviceType_App() != desktop_AppDeviceType) { | ||
1707 | const iMenuItem pinSplit[] = { | ||
1708 | { "button id:prefs.pinsplit.0 label:prefs.pinsplit.none", 0, 0, "pinsplit.set arg:0" }, | ||
1709 | { "button id:prefs.pinsplit.1 label:prefs.pinsplit.left", 0, 0, "pinsplit.set arg:1" }, | ||
1710 | { "button id:prefs.pinsplit.2 label:prefs.pinsplit.right", 0, 0, "pinsplit.set arg:2" }, | ||
1711 | { NULL } | ||
1712 | }; | ||
1713 | const iMenuItem themeItems[] = { | ||
1714 | { "button id:prefs.theme.0 label:prefs.theme.black", 0, 0, "theme.set arg:0" }, | ||
1715 | { "button id:prefs.theme.1 label:prefs.theme.dark", 0, 0, "theme.set arg:1" }, | ||
1716 | { "button id:prefs.theme.2 label:prefs.theme.light", 0, 0, "theme.set arg:2" }, | ||
1717 | { "button id:prefs.theme.3 label:prefs.theme.white", 0, 0, "theme.set arg:3" }, | ||
1718 | { NULL } | ||
1719 | }; | ||
1720 | const iMenuItem accentItems[] = { | ||
1721 | { "button id:prefs.accent.0 label:prefs.accent.teal", 0, 0, "accent.set arg:0" }, | ||
1722 | { "button id:prefs.accent.1 label:prefs.accent.orange", 0, 0, "accent.set arg:1" }, | ||
1723 | { NULL } | ||
1724 | }; | ||
1725 | const iMenuItem satItems[] = { | ||
1726 | { "button id:prefs.saturation.3 text:100 %", 0, 0, "saturation.set arg:100" }, | ||
1727 | { "button id:prefs.saturation.2 text:66 %", 0, 0, "saturation.set arg:66" }, | ||
1728 | { "button id:prefs.saturation.1 text:33 %", 0, 0, "saturation.set arg:33" }, | ||
1729 | { "button id:prefs.saturation.0 text:0 %", 0, 0, "saturation.set arg:0" }, | ||
1730 | { NULL } | ||
1731 | }; | ||
1732 | const iMenuItem generalItems[] = { | ||
1733 | { "title id:heading.prefs.general", 0, 0, NULL }, | ||
1734 | { "input id:prefs.searchurl url:1", 0, 0, NULL }, | ||
1735 | { "padding", 0, 0, NULL }, | ||
1736 | { "toggle id:prefs.hoverlink", 0, 0, NULL }, | ||
1737 | { "toggle id:prefs.archive.openindex", 0, 0, NULL }, | ||
1738 | { "radio device:1 id:prefs.pinsplit", 0, 0, (const void *) pinSplit }, | ||
1739 | { "padding", 0, 0, NULL }, | ||
1740 | { "dropdown id:prefs.uilang", 0, 0, (const void *) langItems }, | ||
1741 | { NULL } | ||
1742 | }; | ||
1743 | const iMenuItem uiItems[] = { | ||
1744 | { "title id:heading.prefs.interface", 0, 0, NULL }, | ||
1745 | { "dropdown device:1 id:prefs.returnkey", 0, 0, (const void *) returnKeyBehaviors }, | ||
1746 | { "padding device:1", 0, 0, NULL }, | ||
1747 | { "toggle device:2 id:prefs.hidetoolbarscroll", 0, 0, NULL }, | ||
1748 | { "heading id:heading.prefs.sizing", 0, 0, NULL }, | ||
1749 | { "input id:prefs.uiscale maxlen:8", 0, 0, NULL }, | ||
1750 | { NULL } | ||
1751 | }; | ||
1752 | const iMenuItem colorItems[] = { | ||
1753 | { "title id:heading.prefs.colors", 0, 0, NULL }, | ||
1754 | { "heading id:heading.prefs.uitheme", 0, 0, NULL }, | ||
1755 | { "toggle id:prefs.ostheme", 0, 0, NULL }, | ||
1756 | { "radio id:prefs.theme", 0, 0, (const void *) themeItems }, | ||
1757 | { "radio id:prefs.accent", 0, 0, (const void *) accentItems }, | ||
1758 | { "heading id:heading.prefs.pagecontent", 0, 0, NULL }, | ||
1759 | { "dropdown id:prefs.doctheme.dark", 0, 0, (const void *) docThemes[0] }, | ||
1760 | { "dropdown id:prefs.doctheme.light", 0, 0, (const void *) docThemes[1] }, | ||
1761 | { "radio id:prefs.saturation", 0, 0, (const void *) satItems }, | ||
1762 | { "padding", 0, 0, NULL }, | ||
1763 | { "dropdown id:prefs.imagestyle", 0, 0, (const void *) imgStyles }, | ||
1764 | { NULL } | ||
1765 | }; | ||
1766 | const iMenuItem fontItems[] = { | ||
1767 | { "title id:heading.prefs.fonts", 0, 0, NULL }, | ||
1768 | { "dropdown id:prefs.headingfont", 0, 0, (const void *) constData_Array(makeFontItems_("headingfont")) }, | ||
1769 | { "dropdown id:prefs.font", 0, 0, (const void *) constData_Array(makeFontItems_("font")) }, | ||
1770 | { NULL } | ||
1771 | }; | ||
1772 | const iMenuItem items[] = { { "panel icon:0x2699 id:heading.prefs.general", | ||
1773 | '1', 0, | ||
1774 | (const void *) generalItems }, | ||
1775 | { "panel icon:0x1f4f1 id:heading.prefs.interface", | ||
1776 | '2', 0, | ||
1777 | (const void *) uiItems }, | ||
1778 | { "panel icon:0x1f3a8 id:heading.prefs.colors", | ||
1779 | '3', 0, | ||
1780 | (const void *) colorItems }, | ||
1781 | { "panel icon:0x1f5da id:heading.prefs.fonts", | ||
1782 | '4', 0, | ||
1783 | (const void *) fontItems }, | ||
1784 | { NULL } }; | ||
1785 | iWidget *dlg = makeSplitMultiPanel_Mobile(items); | ||
1786 | setupSheetTransition_Mobile(dlg, iTrue); | ||
1787 | return dlg; | ||
1788 | } | ||
1632 | iWidget *dlg = makeSheet_Widget("prefs"); | 1789 | iWidget *dlg = makeSheet_Widget("prefs"); |
1633 | addChildFlags_Widget(dlg, | 1790 | addChildFlags_Widget(dlg, |
1634 | iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.prefs}", NULL)), | 1791 | iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.prefs}", NULL)), |
@@ -1666,22 +1823,7 @@ iWidget *makePreferences_Widget(void) { | |||
1666 | addChild_Widget(values, iClob(makePadding_Widget(bigGap))); | 1823 | addChild_Widget(values, iClob(makePadding_Widget(bigGap))); |
1667 | /* UI languages. */ { | 1824 | /* UI languages. */ { |
1668 | iArray *uiLangs = collectNew_Array(sizeof(iMenuItem)); | 1825 | iArray *uiLangs = collectNew_Array(sizeof(iMenuItem)); |
1669 | const iMenuItem langItems[] = { | 1826 | pushBackN_Array(uiLangs, langItems, iElemCount(langItems) - 1); |
1670 | { "${lang.de} - de", 0, 0, "uilang id:de" }, | ||
1671 | { "${lang.en} - en", 0, 0, "uilang id:en" }, | ||
1672 | { "${lang.es} - es", 0, 0, "uilang id:es" }, | ||
1673 | { "${lang.fi} - fi", 0, 0, "uilang id:fi" }, | ||
1674 | { "${lang.fr} - fr", 0, 0, "uilang id:fr" }, | ||
1675 | { "${lang.ia} - ia", 0, 0, "uilang id:ia" }, | ||
1676 | { "${lang.ie} - ie", 0, 0, "uilang id:ie" }, | ||
1677 | { "${lang.pl} - pl", 0, 0, "uilang id:pl" }, | ||
1678 | { "${lang.ru} - ru", 0, 0, "uilang id:ru" }, | ||
1679 | { "${lang.sr} - sr", 0, 0, "uilang id:sr" }, | ||
1680 | { "${lang.tok} - tok", 0, 0, "uilang id:tok" }, | ||
1681 | { "${lang.zh.hans} - zh", 0, 0, "uilang id:zh_Hans" }, | ||
1682 | { "${lang.zh.hant} - zh", 0, 0, "uilang id:zh_Hant" }, | ||
1683 | }; | ||
1684 | pushBackN_Array(uiLangs, langItems, iElemCount(langItems)); | ||
1685 | /* TODO: Add an arrange flag for resizing parent to widest child. */ | 1827 | /* TODO: Add an arrange flag for resizing parent to widest child. */ |
1686 | size_t widestPos = findWidestItemLabel_(data_Array(uiLangs), size_Array(uiLangs)); | 1828 | size_t widestPos = findWidestItemLabel_(data_Array(uiLangs), size_Array(uiLangs)); |
1687 | addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.uilang}"))); | 1829 | addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.uilang}"))); |
@@ -1702,39 +1844,12 @@ iWidget *makePreferences_Widget(void) { | |||
1702 | #endif | 1844 | #endif |
1703 | addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.returnkey}"))); | 1845 | addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.returnkey}"))); |
1704 | /* Return key behaviors. */ { | 1846 | /* Return key behaviors. */ { |
1705 | const iMenuItem returnKeyBehaviors[] = { | ||
1706 | { "${prefs.returnkey.linebreak} " | ||
1707 | uiTextAction_ColorEscape shift_Icon return_Icon restore_ColorEscape | ||
1708 | " ${prefs.returnkey.accept} " | ||
1709 | uiTextAction_ColorEscape return_Icon, | ||
1710 | 0, | ||
1711 | 0, | ||
1712 | format_CStr("returnkey.set arg:%d", default_ReturnKeyBehavior) }, | ||
1713 | { "${prefs.returnkey.linebreak} " | ||
1714 | uiTextAction_ColorEscape return_Icon restore_ColorEscape | ||
1715 | " ${prefs.returnkey.accept} " | ||
1716 | uiTextAction_ColorEscape shift_Icon return_Icon, | ||
1717 | 0, | ||
1718 | 0, | ||
1719 | format_CStr("returnkey.set arg:%d", acceptWithShift_ReturnKeyBehavior) }, | ||
1720 | { "${prefs.returnkey.linebreak} " | ||
1721 | uiTextAction_ColorEscape return_Icon restore_ColorEscape | ||
1722 | " ${prefs.returnkey.accept} " uiTextAction_ColorEscape | ||
1723 | #if defined (iPlatformApple) | ||
1724 | "\u2318" return_Icon, | ||
1725 | #else | ||
1726 | "Ctrl" return_Icon, | ||
1727 | #endif | ||
1728 | 0, | ||
1729 | 0, | ||
1730 | format_CStr("returnkey.set arg:%d", acceptWithPrimaryMod_ReturnKeyBehavior) }, | ||
1731 | }; | ||
1732 | iLabelWidget *returnKey = makeMenuButton_LabelWidget( | 1847 | iLabelWidget *returnKey = makeMenuButton_LabelWidget( |
1733 | returnKeyBehaviors[findWidestItemLabel_(returnKeyBehaviors, | 1848 | returnKeyBehaviors[findWidestItemLabel_(returnKeyBehaviors, |
1734 | iElemCount(returnKeyBehaviors))] | 1849 | iElemCount(returnKeyBehaviors) - 1)] |
1735 | .label, | 1850 | .label, |
1736 | returnKeyBehaviors, | 1851 | returnKeyBehaviors, |
1737 | iElemCount(returnKeyBehaviors)); | 1852 | iElemCount(returnKeyBehaviors) - 1); |
1738 | setBackgroundColor_Widget(findChild_Widget(as_Widget(returnKey), "menu"), | 1853 | setBackgroundColor_Widget(findChild_Widget(as_Widget(returnKey), "menu"), |
1739 | uiBackgroundMenu_ColorId); | 1854 | uiBackgroundMenu_ColorId); |
1740 | setId_Widget(addChildFlags_Widget(values, iClob(returnKey), alignLeft_WidgetFlag), | 1855 | setId_Widget(addChildFlags_Widget(values, iClob(returnKey), alignLeft_WidgetFlag), |
@@ -1804,20 +1919,13 @@ iWidget *makePreferences_Widget(void) { | |||
1804 | for (int i = 0; i < 2; ++i) { | 1919 | for (int i = 0; i < 2; ++i) { |
1805 | const iBool isDark = (i == 0); | 1920 | const iBool isDark = (i == 0); |
1806 | const char *mode = isDark ? "dark" : "light"; | 1921 | const char *mode = isDark ? "dark" : "light"; |
1807 | const iMenuItem themes[] = { | ||
1808 | { "${prefs.doctheme.name.colorfuldark}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, colorfulDark_GmDocumentTheme) }, | ||
1809 | { "${prefs.doctheme.name.colorfullight}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, colorfulLight_GmDocumentTheme) }, | ||
1810 | { "${prefs.doctheme.name.black}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, black_GmDocumentTheme) }, | ||
1811 | { "${prefs.doctheme.name.gray}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, gray_GmDocumentTheme) }, | ||
1812 | { "${prefs.doctheme.name.white}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, white_GmDocumentTheme) }, | ||
1813 | { "${prefs.doctheme.name.sepia}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, sepia_GmDocumentTheme) }, | ||
1814 | { "${prefs.doctheme.name.highcontrast}", 0, 0, format_CStr("doctheme.%s.set arg:%d", mode, highContrast_GmDocumentTheme) }, | ||
1815 | }; | ||
1816 | addChild_Widget(headings, iClob(makeHeading_Widget(isDark ? "${prefs.doctheme.dark}" : "${prefs.doctheme.light}"))); | 1922 | addChild_Widget(headings, iClob(makeHeading_Widget(isDark ? "${prefs.doctheme.dark}" : "${prefs.doctheme.light}"))); |
1817 | iLabelWidget *button = | 1923 | iLabelWidget *button = makeMenuButton_LabelWidget( |
1818 | makeMenuButton_LabelWidget(themes[1].label, themes, iElemCount(themes)); | 1924 | docThemes[i][findWidestItemLabel_(docThemes[i], max_GmDocumentTheme)].label, |
1819 | // setFrameColor_Widget(findChild_Widget(as_Widget(button), "menu"), | 1925 | docThemes[i], |
1820 | // uiBackgroundSelected_ColorId); | 1926 | max_GmDocumentTheme); |
1927 | // setFrameColor_Widget(findChild_Widget(as_Widget(button), "menu"), | ||
1928 | // uiBackgroundSelected_ColorId); | ||
1821 | setBackgroundColor_Widget(findChild_Widget(as_Widget(button), "menu"), uiBackgroundMenu_ColorId); | 1929 | setBackgroundColor_Widget(findChild_Widget(as_Widget(button), "menu"), uiBackgroundMenu_ColorId); |
1822 | setId_Widget(addChildFlags_Widget(values, iClob(button), alignLeft_WidgetFlag), | 1930 | setId_Widget(addChildFlags_Widget(values, iClob(button), alignLeft_WidgetFlag), |
1823 | format_CStr("prefs.doctheme.%s", mode)); | 1931 | format_CStr("prefs.doctheme.%s", mode)); |
@@ -1833,17 +1941,10 @@ iWidget *makePreferences_Widget(void) { | |||
1833 | addChildFlags_Widget(values, iClob(sats), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | 1941 | addChildFlags_Widget(values, iClob(sats), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); |
1834 | /* Colorize images. */ { | 1942 | /* Colorize images. */ { |
1835 | addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.imagestyle}"))); | 1943 | addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.imagestyle}"))); |
1836 | const iMenuItem imgStyles[] = { | ||
1837 | { "${prefs.imagestyle.original}", 0, 0, format_CStr("imagestyle.set arg:%d", original_ImageStyle) }, | ||
1838 | { "${prefs.imagestyle.grayscale}", 0, 0, format_CStr("imagestyle.set arg:%d", grayscale_ImageStyle) }, | ||
1839 | { "${prefs.imagestyle.bgfg}", 0, 0, format_CStr("imagestyle.set arg:%d", bgFg_ImageStyle) }, | ||
1840 | { "${prefs.imagestyle.text}", 0, 0, format_CStr("imagestyle.set arg:%d", textColorized_ImageStyle) }, | ||
1841 | { "${prefs.imagestyle.preformat}", 0, 0, format_CStr("imagestyle.set arg:%d", preformatColorized_ImageStyle) }, | ||
1842 | }; | ||
1843 | iLabelWidget *button = makeMenuButton_LabelWidget( | 1944 | iLabelWidget *button = makeMenuButton_LabelWidget( |
1844 | imgStyles[findWidestItemLabel_(imgStyles, iElemCount(imgStyles))].label, | 1945 | imgStyles[findWidestItemLabel_(imgStyles, iElemCount(imgStyles) - 1)].label, |
1845 | imgStyles, | 1946 | imgStyles, |
1846 | iElemCount(imgStyles)); | 1947 | iElemCount(imgStyles) - 1); |
1847 | setBackgroundColor_Widget(findChild_Widget(as_Widget(button), "menu"), | 1948 | setBackgroundColor_Widget(findChild_Widget(as_Widget(button), "menu"), |
1848 | uiBackgroundMenu_ColorId); | 1949 | uiBackgroundMenu_ColorId); |
1849 | setId_Widget(addChildFlags_Widget(values, iClob(button), alignLeft_WidgetFlag), | 1950 | setId_Widget(addChildFlags_Widget(values, iClob(button), alignLeft_WidgetFlag), |