summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/sidebarwidget.c29
-rw-r--r--src/ui/sidebarwidget.h4
-rw-r--r--src/ui/window.c4
3 files changed, 21 insertions, 16 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 73eee12d..74784547 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -97,7 +97,7 @@ struct Impl_SidebarWidget {
97 int modeScroll[max_SidebarMode]; 97 int modeScroll[max_SidebarMode];
98 iLabelWidget * modeButtons[max_SidebarMode]; 98 iLabelWidget * modeButtons[max_SidebarMode];
99 int maxButtonLabelWidth; 99 int maxButtonLabelWidth;
100 int width; 100 int widthAsGaps;
101 int itemFonts[2]; 101 int itemFonts[2];
102 size_t numUnreadEntries; 102 size_t numUnreadEntries;
103 iWidget * resizer; 103 iWidget * resizer;
@@ -461,8 +461,8 @@ enum iSidebarMode mode_SidebarWidget(const iSidebarWidget *d) {
461 return d ? d->mode : 0; 461 return d ? d->mode : 0;
462} 462}
463 463
464int width_SidebarWidget(const iSidebarWidget *d) { 464float width_SidebarWidget(const iSidebarWidget *d) {
465 return d ? d->width : 0; 465 return d ? d->widthAsGaps : 0;
466} 466}
467 467
468static const char *normalModeLabels_[max_SidebarMode] = { 468static const char *normalModeLabels_[max_SidebarMode] = {
@@ -520,13 +520,13 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) {
520 d->itemFonts[0] = uiContent_FontId; 520 d->itemFonts[0] = uiContent_FontId;
521 d->itemFonts[1] = uiContentBold_FontId; 521 d->itemFonts[1] = uiContentBold_FontId;
522#if defined (iPlatformAppleMobile) 522#if defined (iPlatformAppleMobile)
523 d->width = 73 * gap_UI; 523 d->widthAsGaps = 73;
524 if (deviceType_App() == phone_AppDeviceType) { 524 if (deviceType_App() == phone_AppDeviceType) {
525 d->itemFonts[0] = defaultBig_FontId; 525 d->itemFonts[0] = defaultBig_FontId;
526 d->itemFonts[1] = defaultBigBold_FontId; 526 d->itemFonts[1] = defaultBigBold_FontId;
527 } 527 }
528#else 528#else
529 d->width = 60 * gap_UI; 529 d->widthAsGaps = 60;
530#endif 530#endif
531 setFlags_Widget(w, fixedWidth_WidgetFlag, iTrue); 531 setFlags_Widget(w, fixedWidth_WidgetFlag, iTrue);
532 iWidget *vdiv = makeVDiv_Widget(); 532 iWidget *vdiv = makeVDiv_Widget();
@@ -720,16 +720,17 @@ static void checkModeButtonLayout_SidebarWidget_(iSidebarWidget *d) {
720 } 720 }
721} 721}
722 722
723void setWidth_SidebarWidget(iSidebarWidget *d, int width) { 723void setWidth_SidebarWidget(iSidebarWidget *d, float widthAsGaps) {
724 const iBool isFixedWidth = deviceType_App() == phone_AppDeviceType;
725 iWidget *w = as_Widget(d); 724 iWidget *w = as_Widget(d);
725 const iBool isFixedWidth = deviceType_App() == phone_AppDeviceType;
726 int width = widthAsGaps * gap_UI;
726 if (!isFixedWidth) { 727 if (!isFixedWidth) {
727 /* Even less space if the other sidebar is visible, too. */ 728 /* Even less space if the other sidebar is visible, too. */
728 const int otherWidth = 729 const int otherWidth =
729 width_Widget(findWidget_App(d->side == left_SideBarSide ? "sidebar2" : "sidebar")); 730 width_Widget(findWidget_App(d->side == left_SideBarSide ? "sidebar2" : "sidebar"));
730 width = iClamp(width, 30 * gap_UI, rootSize_Window(get_Window()).x - 50 * gap_UI - otherWidth); 731 width = iClamp(width, 30 * gap_UI, rootSize_Window(get_Window()).x - 50 * gap_UI - otherWidth);
731 } 732 }
732 d->width = width; 733 d->widthAsGaps = (float) width / (float) gap_UI;
733 if (isVisible_Widget(w)) { 734 if (isVisible_Widget(w)) {
734 w->rect.size.x = width; 735 w->rect.size.x = width;
735 } 736 }
@@ -780,7 +781,8 @@ iBool handleBookmarkEditorCommands_SidebarWidget_(iWidget *editor, const char *c
780static iBool handleSidebarCommand_SidebarWidget_(iSidebarWidget *d, const char *cmd) { 781static iBool handleSidebarCommand_SidebarWidget_(iSidebarWidget *d, const char *cmd) {
781 iWidget *w = as_Widget(d); 782 iWidget *w = as_Widget(d);
782 if (equal_Command(cmd, "width")) { 783 if (equal_Command(cmd, "width")) {
783 setWidth_SidebarWidget(d, arg_Command(cmd)); 784 setWidth_SidebarWidget(d, arg_Command(cmd) *
785 (argLabel_Command(cmd, "gaps") ? 1.0f : (1.0f / gap_UI)));
784 return iTrue; 786 return iTrue;
785 } 787 }
786 else if (equal_Command(cmd, "mode")) { 788 else if (equal_Command(cmd, "mode")) {
@@ -802,7 +804,7 @@ static iBool handleSidebarCommand_SidebarWidget_(iSidebarWidget *d, const char *
802 } 804 }
803 setFlags_Widget(w, hidden_WidgetFlag, isVisible_Widget(w)); 805 setFlags_Widget(w, hidden_WidgetFlag, isVisible_Widget(w));
804 if (isVisible_Widget(w)) { 806 if (isVisible_Widget(w)) {
805 w->rect.size.x = d->width; 807 w->rect.size.x = d->widthAsGaps * gap_UI;
806 invalidate_ListWidget(d->list); 808 invalidate_ListWidget(d->list);
807 } 809 }
808 arrange_Widget(w->parent); 810 arrange_Widget(w->parent);
@@ -826,6 +828,9 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
826 checkModeButtonLayout_SidebarWidget_(d); 828 checkModeButtonLayout_SidebarWidget_(d);
827 } 829 }
828 else if (isMetricsChange_UserEvent(ev)) { 830 else if (isMetricsChange_UserEvent(ev)) {
831 if (isVisible_Widget(w)) {
832 w->rect.size.x = d->widthAsGaps * gap_UI;
833 }
829 updateMetrics_SidebarWidget_(d); 834 updateMetrics_SidebarWidget_(d);
830 arrange_Widget(w); 835 arrange_Widget(w);
831 checkModeButtonLayout_SidebarWidget_(d); 836 checkModeButtonLayout_SidebarWidget_(d);
@@ -889,10 +894,10 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
889 const int resMid = d->resizer->rect.size.x / 2; 894 const int resMid = d->resizer->rect.size.x / 2;
890 setWidth_SidebarWidget( 895 setWidth_SidebarWidget(
891 d, 896 d,
892 (d->side == left_SideBarSide 897 ((d->side == left_SideBarSide
893 ? local.x 898 ? local.x
894 : (rootSize_Window(get_Window()).x - coord_Command(cmd).x)) + 899 : (rootSize_Window(get_Window()).x - coord_Command(cmd).x)) +
895 resMid); 900 resMid) / (float) gap_UI);
896 } 901 }
897 return iTrue; 902 return iTrue;
898 } 903 }
diff --git a/src/ui/sidebarwidget.h b/src/ui/sidebarwidget.h
index d7029b0f..8027adc0 100644
--- a/src/ui/sidebarwidget.h
+++ b/src/ui/sidebarwidget.h
@@ -47,5 +47,5 @@ iBool setMode_SidebarWidget (iSidebarWidget *, enum iSidebar
47void setButtonFont_SidebarWidget (iSidebarWidget *, int font); 47void setButtonFont_SidebarWidget (iSidebarWidget *, int font);
48 48
49enum iSidebarMode mode_SidebarWidget (const iSidebarWidget *); 49enum iSidebarMode mode_SidebarWidget (const iSidebarWidget *);
50int width_SidebarWidget (const iSidebarWidget *); 50float width_SidebarWidget (const iSidebarWidget *);
51void setWidth_SidebarWidget (iSidebarWidget *, int width); 51void setWidth_SidebarWidget (iSidebarWidget *, float widthAsGaps);
diff --git a/src/ui/window.c b/src/ui/window.c
index 82fb8613..ce9d730e 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -161,14 +161,14 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) {
161 isPortrait_App()); 161 isPortrait_App());
162 if (isLandscape_App()) { 162 if (isLandscape_App()) {
163 addChildPos_Widget(findChild_Widget(root, "tabs.content"), iClob(sidebar), front_WidgetAddPos); 163 addChildPos_Widget(findChild_Widget(root, "tabs.content"), iClob(sidebar), front_WidgetAddPos);
164 setWidth_SidebarWidget(sidebar, 73 * gap_UI); 164 setWidth_SidebarWidget(sidebar, 73.0f);
165 if (isVisible_Widget(findWidget_App("sidebar2"))) { 165 if (isVisible_Widget(findWidget_App("sidebar2"))) {
166 postCommand_App("sidebar2.toggle"); 166 postCommand_App("sidebar2.toggle");
167 } 167 }
168 } 168 }
169 else { 169 else {
170 addChildPos_Widget(findChild_Widget(root, "stack"), iClob(sidebar), back_WidgetAddPos); 170 addChildPos_Widget(findChild_Widget(root, "stack"), iClob(sidebar), back_WidgetAddPos);
171 setWidth_SidebarWidget(sidebar, width_Widget(root)); 171 setWidth_SidebarWidget(sidebar, (float) width_Widget(root) / (float) gap_UI);
172 } 172 }
173 return iFalse; 173 return iFalse;
174 } 174 }