summaryrefslogtreecommitdiff
path: root/src/ui/sidebarwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-17 09:21:16 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-17 09:21:16 +0300
commitd74e1dc35d108d1f17342ff203838b83d135537e (patch)
treeea0e01f68de20f9f993e873db861ca3816ec5686 /src/ui/sidebarwidget.c
parent9a7438c82f6dfc0605f28207648c4cdde7d98f1f (diff)
SidebarWidget: Button font glitches
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r--src/ui/sidebarwidget.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index eb129424..fe33c540 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -100,7 +100,7 @@ struct Impl_SidebarWidget {
100 int modeScroll[max_SidebarMode]; 100 int modeScroll[max_SidebarMode];
101 iLabelWidget * modeButtons[max_SidebarMode]; 101 iLabelWidget * modeButtons[max_SidebarMode];
102 int maxButtonLabelWidth; 102 int maxButtonLabelWidth;
103 int widthAsGaps; 103 float widthAsGaps;
104 int buttonFont; 104 int buttonFont;
105 int itemFonts[2]; 105 int itemFonts[2];
106 size_t numUnreadEntries; 106 size_t numUnreadEntries;
@@ -143,7 +143,9 @@ static iLabelWidget *addActionButton_SidebarWidget_(iSidebarWidget *d, const cha
143 //(deviceType_App() != desktop_AppDeviceType ? 143 //(deviceType_App() != desktop_AppDeviceType ?
144 // extraPadding_WidgetFlag : 0) | 144 // extraPadding_WidgetFlag : 0) |
145 flags); 145 flags);
146 setFont_LabelWidget(btn, d->buttonFont); 146 setFont_LabelWidget(btn, deviceType_App() == phone_AppDeviceType && d->side == right_SidebarSide
147 ? defaultBig_FontId
148 : d->buttonFont);
147 checkIcon_LabelWidget(btn); 149 checkIcon_LabelWidget(btn);
148 return btn; 150 return btn;
149} 151}
@@ -641,7 +643,7 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) {
641 d->mode = -1; 643 d->mode = -1;
642 d->feedsMode = all_FeedsMode; 644 d->feedsMode = all_FeedsMode;
643 d->numUnreadEntries = 0; 645 d->numUnreadEntries = 0;
644 d->buttonFont = uiLabel_FontId; 646 d->buttonFont = uiLabel_FontId; /* wiil be changed later */
645 d->itemFonts[0] = uiContent_FontId; 647 d->itemFonts[0] = uiContent_FontId;
646 d->itemFonts[1] = uiContentBold_FontId; 648 d->itemFonts[1] = uiContentBold_FontId;
647#if defined (iPlatformMobile) 649#if defined (iPlatformMobile)
@@ -649,9 +651,9 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) {
649 d->itemFonts[0] = defaultBig_FontId; 651 d->itemFonts[0] = defaultBig_FontId;
650 d->itemFonts[1] = defaultBigBold_FontId; 652 d->itemFonts[1] = defaultBigBold_FontId;
651 } 653 }
652 d->widthAsGaps = 73; 654 d->widthAsGaps = 73.0f;
653#else 655#else
654 d->widthAsGaps = 60; 656 d->widthAsGaps = 60.0f;
655#endif 657#endif
656 setFlags_Widget(w, fixedWidth_WidgetFlag, iTrue); 658 setFlags_Widget(w, fixedWidth_WidgetFlag, iTrue);
657 iWidget *vdiv = makeVDiv_Widget(); 659 iWidget *vdiv = makeVDiv_Widget();
@@ -745,14 +747,18 @@ void deinit_SidebarWidget(iSidebarWidget *d) {
745 deinit_String(&d->cmdPrefix); 747 deinit_String(&d->cmdPrefix);
746} 748}
747 749
748void setButtonFont_SidebarWidget(iSidebarWidget *d, int font) { 750iBool setButtonFont_SidebarWidget(iSidebarWidget *d, int font) {
749 d->buttonFont = font; 751 if (d->buttonFont != font) {
750 for (int i = 0; i < max_SidebarMode; i++) { 752 d->buttonFont = font;
751 if (d->modeButtons[i]) { 753 for (int i = 0; i < max_SidebarMode; i++) {
752 setFont_LabelWidget(d->modeButtons[i], font); 754 if (d->modeButtons[i]) {
755 setFont_LabelWidget(d->modeButtons[i], font);
756 }
753 } 757 }
758 updateMetrics_SidebarWidget_(d);
759 return iTrue;
754 } 760 }
755 updateMetrics_SidebarWidget_(d); 761 return iFalse;
756} 762}
757 763
758static const iGmIdentity *constHoverIdentity_SidebarWidget_(const iSidebarWidget *d) { 764static const iGmIdentity *constHoverIdentity_SidebarWidget_(const iSidebarWidget *d) {
@@ -827,8 +833,10 @@ static void checkModeButtonLayout_SidebarWidget_(iSidebarWidget *d) {
827 if (d->itemFonts[0] != fonts[0]) { 833 if (d->itemFonts[0] != fonts[0]) {
828 d->itemFonts[0] = fonts[0]; 834 d->itemFonts[0] = fonts[0];
829 d->itemFonts[1] = fonts[1]; 835 d->itemFonts[1] = fonts[1];
830 updateMetrics_SidebarWidget_(d); 836// updateMetrics_SidebarWidget_(d);
837 updateItemHeight_SidebarWidget_(d);
831 } 838 }
839 setButtonFont_SidebarWidget(d, isPortrait_App() ? defaultBig_FontId : uiLabel_FontId);
832 } 840 }
833 const iBool isTight = 841 const iBool isTight =
834 (width_Rect(bounds_Widget(as_Widget(d->modeButtons[0]))) < d->maxButtonLabelWidth); 842 (width_Rect(bounds_Widget(as_Widget(d->modeButtons[0]))) < d->maxButtonLabelWidth);
@@ -858,7 +866,7 @@ static void checkModeButtonLayout_SidebarWidget_(iSidebarWidget *d) {
858void setWidth_SidebarWidget(iSidebarWidget *d, float widthAsGaps) { 866void setWidth_SidebarWidget(iSidebarWidget *d, float widthAsGaps) {
859 iWidget *w = as_Widget(d); 867 iWidget *w = as_Widget(d);
860 const iBool isFixedWidth = deviceType_App() == phone_AppDeviceType; 868 const iBool isFixedWidth = deviceType_App() == phone_AppDeviceType;
861 int width = widthAsGaps * gap_UI; 869 int width = widthAsGaps * gap_UI; /* in pixels */
862 if (!isFixedWidth) { 870 if (!isFixedWidth) {
863 /* Even less space if the other sidebar is visible, too. */ 871 /* Even less space if the other sidebar is visible, too. */
864 const int otherWidth = 872 const int otherWidth =
@@ -866,9 +874,7 @@ void setWidth_SidebarWidget(iSidebarWidget *d, float widthAsGaps) {
866 width = iClamp(width, 30 * gap_UI, size_Root(w->root).x - 50 * gap_UI - otherWidth); 874 width = iClamp(width, 30 * gap_UI, size_Root(w->root).x - 50 * gap_UI - otherWidth);
867 } 875 }
868 d->widthAsGaps = (float) width / (float) gap_UI; 876 d->widthAsGaps = (float) width / (float) gap_UI;
869 if (isVisible_Widget(w)) { 877 w->rect.size.x = width;
870 w->rect.size.x = width;
871 }
872 arrange_Widget(findWidget_Root("stack")); 878 arrange_Widget(findWidget_Root("stack"));
873 checkModeButtonLayout_SidebarWidget_(d); 879 checkModeButtonLayout_SidebarWidget_(d);
874 updateItemHeight_SidebarWidget_(d); 880 updateItemHeight_SidebarWidget_(d);
@@ -935,6 +941,7 @@ static iBool handleSidebarCommand_SidebarWidget_(iSidebarWidget *d, const char *
935 if (wasChanged) { 941 if (wasChanged) {
936 postCommandf_App("%s.mode.changed arg:%d", cstr_String(id_Widget(w)), d->mode); 942 postCommandf_App("%s.mode.changed arg:%d", cstr_String(id_Widget(w)), d->mode);
937 } 943 }
944 refresh_Widget(findChild_Widget(w, "buttons"));
938 return iTrue; 945 return iTrue;
939 } 946 }
940 else if (equal_Command(cmd, "toggle")) { 947 else if (equal_Command(cmd, "toggle")) {
@@ -1556,7 +1563,7 @@ static void draw_SidebarWidget_(const iSidebarWidget *d) {
1556 const iRect bounds = bounds_Widget(w); 1563 const iRect bounds = bounds_Widget(w);
1557 iPaint p; 1564 iPaint p;
1558 init_Paint(&p); 1565 init_Paint(&p);
1559 if (deviceType_App() != phone_AppDeviceType) { 1566 if (!isPortraitPhone_App()) { /* this would erase page contents during transition on the phone */
1560 if (flags_Widget(w) & visualOffset_WidgetFlag && 1567 if (flags_Widget(w) & visualOffset_WidgetFlag &&
1561 flags_Widget(w) & horizontalOffset_WidgetFlag && isVisible_Widget(w)) { 1568 flags_Widget(w) & horizontalOffset_WidgetFlag && isVisible_Widget(w)) {
1562 fillRect_Paint(&p, boundsWithoutVisualOffset_Widget(w), tmBackground_ColorId); 1569 fillRect_Paint(&p, boundsWithoutVisualOffset_Widget(w), tmBackground_ColorId);