diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-20 22:17:01 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-20 22:17:01 +0200 |
commit | 3b16b823d5840096402ec0bddc3d35f6028b75f6 (patch) | |
tree | f12049b85eed1afa9912e45d1911c7c1fb69c9fd /src/ui/window.c | |
parent | 1ca771a41e430f866e3a3270f285fc9a7eacfc65 (diff) |
Revising sidebar placement for phones
In portrait mode, phones have no room for sidebars so need to use a different widget arrangement.
Diffstat (limited to 'src/ui/window.c')
-rw-r--r-- | src/ui/window.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index 559b41a6..c096c00b 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -125,6 +125,20 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) { | |||
125 | SDL_PushEvent(&(SDL_Event){ .type = SDL_QUIT }); | 125 | SDL_PushEvent(&(SDL_Event){ .type = SDL_QUIT }); |
126 | return iTrue; | 126 | return iTrue; |
127 | } | 127 | } |
128 | else if (deviceType_App() == phone_AppDeviceType && equal_Command(cmd, "window.resized")) { | ||
129 | /* Place the sidebar next to or under doctabs depending on orientation. */ | ||
130 | iSidebarWidget *sidebar = findChild_Widget(root, "sidebar"); | ||
131 | removeChild_Widget(parent_Widget(sidebar), sidebar); | ||
132 | if (isLandscape_App()) { | ||
133 | addChildPos_Widget(findChild_Widget(root, "tabs.content"), iClob(sidebar), front_WidgetAddPos); | ||
134 | setWidth_SidebarWidget(sidebar, 73 * gap_UI); | ||
135 | } | ||
136 | else { | ||
137 | addChildPos_Widget(findChild_Widget(root, "stack"), iClob(sidebar), back_WidgetAddPos); | ||
138 | setWidth_SidebarWidget(sidebar, width_Widget(root)); | ||
139 | } | ||
140 | return iFalse; | ||
141 | } | ||
128 | else if (handleCommand_App(cmd)) { | 142 | else if (handleCommand_App(cmd)) { |
129 | return iTrue; | 143 | return iTrue; |
130 | } | 144 | } |
@@ -353,7 +367,9 @@ static void updateNavBarIdentity_(iWidget *navBar) { | |||
353 | const iGmIdentity *ident = | 367 | const iGmIdentity *ident = |
354 | identityForUrl_GmCerts(certs_App(), url_DocumentWidget(document_App())); | 368 | identityForUrl_GmCerts(certs_App(), url_DocumentWidget(document_App())); |
355 | iWidget *button = findChild_Widget(navBar, "navbar.ident"); | 369 | iWidget *button = findChild_Widget(navBar, "navbar.ident"); |
370 | iWidget *tool = findWidget_App("toolbar.ident"); | ||
356 | setFlags_Widget(button, selected_WidgetFlag, ident != NULL); | 371 | setFlags_Widget(button, selected_WidgetFlag, ident != NULL); |
372 | setFlags_Widget(tool, selected_WidgetFlag, ident != NULL); | ||
357 | /* Update menu. */ | 373 | /* Update menu. */ |
358 | iLabelWidget *idItem = child_Widget(findChild_Widget(button, "menu"), 0); | 374 | iLabelWidget *idItem = child_Widget(findChild_Widget(button, "menu"), 0); |
359 | setTextCStr_LabelWidget( | 375 | setTextCStr_LabelWidget( |
@@ -761,9 +777,12 @@ static void setupUserInterface_Window(iWindow *d) { | |||
761 | #endif | 777 | #endif |
762 | } | 778 | } |
763 | /* Tab bar. */ { | 779 | /* Tab bar. */ { |
764 | iWidget *tabBar = makeTabs_Widget(div); | 780 | iWidget *mainStack = new_Widget(); |
781 | setId_Widget(mainStack, "stack"); | ||
782 | addChildFlags_Widget(div, iClob(mainStack), resizeChildren_WidgetFlag | expand_WidgetFlag | | ||
783 | unhittable_WidgetFlag); | ||
784 | iWidget *tabBar = makeTabs_Widget(mainStack); | ||
765 | setId_Widget(tabBar, "doctabs"); | 785 | setId_Widget(tabBar, "doctabs"); |
766 | setFlags_Widget(tabBar, expand_WidgetFlag, iTrue); | ||
767 | setBackgroundColor_Widget(tabBar, uiBackground_ColorId); | 786 | setBackgroundColor_Widget(tabBar, uiBackground_ColorId); |
768 | appendTabPage_Widget(tabBar, iClob(new_DocumentWidget()), "Document", 0, 0); | 787 | appendTabPage_Widget(tabBar, iClob(new_DocumentWidget()), "Document", 0, 0); |
769 | iWidget *buttons = findChild_Widget(tabBar, "tabs.buttons"); | 788 | iWidget *buttons = findChild_Widget(tabBar, "tabs.buttons"); |
@@ -822,7 +841,8 @@ static void setupUserInterface_Window(iWindow *d) { | |||
822 | setBackgroundColor_Widget(toolBar, tmBannerBackground_ColorId); | 841 | setBackgroundColor_Widget(toolBar, tmBannerBackground_ColorId); |
823 | addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f870", "navigate.back")), frameless_WidgetFlag); | 842 | addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f870", "navigate.back")), frameless_WidgetFlag); |
824 | addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f872", "navigate.forward")), frameless_WidgetFlag); | 843 | addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f872", "navigate.forward")), frameless_WidgetFlag); |
825 | addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f464", "sidebar.mode arg:3 show:1")), frameless_WidgetFlag); | 844 | setId_Widget(addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f464", "sidebar.mode arg:3 toggle:1")), frameless_WidgetFlag), "toolbar.ident"); |
845 | addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f588", "sidebar.mode arg:0 toggle:1")), frameless_WidgetFlag); | ||
826 | iLabelWidget *menuButton = makeMenuButton_LabelWidget("\U0001d362", navMenuItems_, iElemCount(navMenuItems_)); | 846 | iLabelWidget *menuButton = makeMenuButton_LabelWidget("\U0001d362", navMenuItems_, iElemCount(navMenuItems_)); |
827 | setFont_LabelWidget(menuButton, uiLabelLarge_FontId); | 847 | setFont_LabelWidget(menuButton, uiLabelLarge_FontId); |
828 | addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag); | 848 | addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag); |