summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/sidebarwidget.c17
-rw-r--r--src/ui/util.c6
-rw-r--r--src/ui/widget.c9
-rw-r--r--src/ui/window.c26
4 files changed, 43 insertions, 15 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 456bcee7..da76c4d4 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -510,6 +510,9 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) {
510 resizeToParentHeight_WidgetFlag | 510 resizeToParentHeight_WidgetFlag |
511 (side == left_SideBarSide ? moveToParentRightEdge_WidgetFlag 511 (side == left_SideBarSide ? moveToParentRightEdge_WidgetFlag
512 : moveToParentLeftEdge_WidgetFlag)); 512 : moveToParentLeftEdge_WidgetFlag));
513 if (deviceType_App() == phone_AppDeviceType) {
514 setFlags_Widget(d->resizer, hidden_WidgetFlag | disabled_WidgetFlag, iTrue);
515 }
513 setId_Widget(d->resizer, side == left_SideBarSide ? "sidebar.grab" : "sidebar2.grab"); 516 setId_Widget(d->resizer, side == left_SideBarSide ? "sidebar.grab" : "sidebar2.grab");
514 d->resizer->rect.size.x = gap_UI; 517 d->resizer->rect.size.x = gap_UI;
515 setBackgroundColor_Widget(d->resizer, none_ColorId); 518 setBackgroundColor_Widget(d->resizer, none_ColorId);
@@ -603,16 +606,18 @@ static void checkModeButtonLayout_SidebarWidget_(iSidebarWidget *d) {
603} 606}
604 607
605void setWidth_SidebarWidget(iSidebarWidget *d, int width) { 608void setWidth_SidebarWidget(iSidebarWidget *d, int width) {
606 iWidget * w = as_Widget(d); 609 iWidget *w = as_Widget(d);
607 /* Even less space if the other sidebar is visible, too. */ 610 if (deviceType_App() != phone_AppDeviceType) { /* phone doesn't allow resizing */
608 const int otherWidth = 611 /* Even less space if the other sidebar is visible, too. */
609 width_Widget(findWidget_App(d->side == left_SideBarSide ? "sidebar2" : "sidebar")); 612 const int otherWidth =
610 width = iClamp(width, 30 * gap_UI, rootSize_Window(get_Window()).x - 50 * gap_UI - otherWidth); 613 width_Widget(findWidget_App(d->side == left_SideBarSide ? "sidebar2" : "sidebar"));
614 width = iClamp(width, 30 * gap_UI, rootSize_Window(get_Window()).x - 50 * gap_UI - otherWidth);
615 }
611 d->width = width; 616 d->width = width;
612 if (isVisible_Widget(w)) { 617 if (isVisible_Widget(w)) {
613 w->rect.size.x = width; 618 w->rect.size.x = width;
614 } 619 }
615 arrange_Widget(findWidget_App("doctabs")); 620 arrange_Widget(findWidget_App("stack"));
616 checkModeButtonLayout_SidebarWidget_(d); 621 checkModeButtonLayout_SidebarWidget_(d);
617 if (!isRefreshPending_App()) { 622 if (!isRefreshPending_App()) {
618 updateSize_DocumentWidget(document_App()); 623 updateSize_DocumentWidget(document_App());
diff --git a/src/ui/util.c b/src/ui/util.c
index 1ff1b7f7..db9e4507 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -358,13 +358,13 @@ iLabelWidget *makeHeading_Widget(const char *text) {
358 358
359iWidget *makeVDiv_Widget(void) { 359iWidget *makeVDiv_Widget(void) {
360 iWidget *div = new_Widget(); 360 iWidget *div = new_Widget();
361 setFlags_Widget(div, resizeChildren_WidgetFlag | arrangeVertical_WidgetFlag, iTrue); 361 setFlags_Widget(div, resizeChildren_WidgetFlag | arrangeVertical_WidgetFlag | unhittable_WidgetFlag, iTrue);
362 return div; 362 return div;
363} 363}
364 364
365iWidget *makeHDiv_Widget(void) { 365iWidget *makeHDiv_Widget(void) {
366 iWidget *div = new_Widget(); 366 iWidget *div = new_Widget();
367 setFlags_Widget(div, resizeChildren_WidgetFlag | arrangeHorizontal_WidgetFlag, iTrue); 367 setFlags_Widget(div, resizeChildren_WidgetFlag | arrangeHorizontal_WidgetFlag | unhittable_WidgetFlag, iTrue);
368 return div; 368 return div;
369} 369}
370 370
@@ -382,7 +382,7 @@ static iBool isCommandIgnoredByMenus_(const char *cmd) {
382 startsWith_CStr(cmd, "feeds.update.") || 382 startsWith_CStr(cmd, "feeds.update.") ||
383 equal_Command(cmd, "document.request.updated") || 383 equal_Command(cmd, "document.request.updated") ||
384 equal_Command(cmd, "bookmarks.request.finished") || 384 equal_Command(cmd, "bookmarks.request.finished") ||
385 equal_Command(cmd, "window.resized") || 385 (deviceType_App() == desktop_AppDeviceType && equal_Command(cmd, "window.resized")) ||
386 equal_Command(cmd, "window.reload.update") || 386 equal_Command(cmd, "window.reload.update") ||
387 equal_Command(cmd, "window.mouse.exited") || 387 equal_Command(cmd, "window.mouse.exited") ||
388 equal_Command(cmd, "window.mouse.entered") || 388 equal_Command(cmd, "window.mouse.entered") ||
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 0e020080..9320659c 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -763,7 +763,7 @@ size_t childIndex_Widget(const iWidget *d, const iAnyObject *child) {
763} 763}
764 764
765iAny *hitChild_Widget(const iWidget *d, iInt2 coord) { 765iAny *hitChild_Widget(const iWidget *d, iInt2 coord) {
766 if (d->flags & (unhittable_WidgetFlag | hidden_WidgetFlag)) { 766 if (d->flags & hidden_WidgetFlag) {
767 return NULL; 767 return NULL;
768 } 768 }
769 /* Check for on-top widgets first. */ 769 /* Check for on-top widgets first. */
@@ -773,14 +773,17 @@ iAny *hitChild_Widget(const iWidget *d, iInt2 coord) {
773 if (found) return found; 773 if (found) return found;
774 } 774 }
775 } 775 }
776 iForEach(ObjectList, i, d->children) { 776 iReverseForEach(ObjectList, i, d->children) {
777 const iWidget *child = constAs_Widget(i.object); 777 const iWidget *child = constAs_Widget(i.object);
778 if (~child->flags & keepOnTop_WidgetFlag) { 778 if (~child->flags & keepOnTop_WidgetFlag) {
779 iAny *found = hitChild_Widget(child, coord); 779 iAny *found = hitChild_Widget(child, coord);
780 if (found) return found; 780 if (found) return found;
781 } 781 }
782 } 782 }
783 if (contains_Widget(d, coord)) { 783 if (class_Widget(d) == &Class_Widget) {
784 return NULL; /* Plain widgets are not hittable. */
785 }
786 if (~d->flags & unhittable_WidgetFlag && contains_Widget(d, coord)) {
784 return iConstCast(iWidget *, d); 787 return iConstCast(iWidget *, d);
785 } 788 }
786 return NULL; 789 return NULL;
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);