summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-06-14 22:12:19 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-06-14 22:12:19 +0300
commit4bcb7acb840627a197f8e9ed40256fc8ac0a01a9 (patch)
tree1c0c6dbeb0a4b23df83253bf2ad97e9663907139 /src/ui
parentacad729245e09d927f1b16de2c6619b84f88c59e (diff)
Mobile: Toolbar color depends on sidebar
Toolbar should reflect the colors of the current view, whether it's a page or the sidebar.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c8
-rw-r--r--src/ui/root.c26
-rw-r--r--src/ui/root.h3
-rw-r--r--src/ui/sidebarwidget.c1
4 files changed, 31 insertions, 7 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 3fc22bdf..bd624059 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1674,7 +1674,7 @@ static void scrollBegan_DocumentWidget_(iAnyObject *any, int offset, uint32_t du
1674 if (deviceType_App() == phone_AppDeviceType) { 1674 if (deviceType_App() == phone_AppDeviceType) {
1675 const float normPos = normScrollPos_DocumentWidget_(d); 1675 const float normPos = normScrollPos_DocumentWidget_(d);
1676 if (prefs_App()->hideToolbarOnScroll && iAbs(offset) > 5 && normPos >= 0) { 1676 if (prefs_App()->hideToolbarOnScroll && iAbs(offset) > 5 && normPos >= 0) {
1677 showToolbars_Root(as_Widget(d)->root, offset < 0); 1677 showToolbar_Root(as_Widget(d)->root, offset < 0);
1678 } 1678 }
1679 } 1679 }
1680 updateVisible_DocumentWidget_(d); 1680 updateVisible_DocumentWidget_(d);
@@ -2840,7 +2840,11 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
2840 if (d->flags & openedFromSidebar_DocumentWidgetFlag && 2840 if (d->flags & openedFromSidebar_DocumentWidgetFlag &&
2841 !isVisible_Widget(findWidget_App("sidebar"))) { 2841 !isVisible_Widget(findWidget_App("sidebar"))) {
2842 postCommand_App("sidebar.toggle"); 2842 postCommand_App("sidebar.toggle");
2843 showToolbars_Root(get_Root(), iTrue); 2843 showToolbar_Root(get_Root(), iTrue);
2844#if defined (iPlatformAppleMobile)
2845 /* TODO: Add a softer tap? */
2846// playHapticEffect_iOS(tap_HapticEffect);
2847#endif
2844 return iTrue; 2848 return iTrue;
2845 } 2849 }
2846 d->flags &= ~openedFromSidebar_DocumentWidgetFlag; 2850 d->flags &= ~openedFromSidebar_DocumentWidgetFlag;
diff --git a/src/ui/root.c b/src/ui/root.c
index 0a5eb96e..6c00db0f 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -514,6 +514,24 @@ void updatePadding_Root(iRoot *d) {
514#endif 514#endif
515} 515}
516 516
517void updateToolbarColors_Root(iRoot *d) {
518#if defined (iPlatformMobile)
519 iWidget *toolBar = findChild_Widget(d->widget, "toolbar");
520 if (toolBar) {
521 const iBool isSidebarVisible = isVisible_Widget(findChild_Widget(d->widget, "sidebar"));
522 setBackgroundColor_Widget(toolBar, isSidebarVisible ? uiBackgroundSidebar_ColorId :
523 tmBannerBackground_ColorId);
524 iForEach(ObjectList, i, children_Widget(toolBar)) {
525 iLabelWidget *btn = i.object;
526 setTextColor_LabelWidget(i.object, isSidebarVisible ? uiTextDim_ColorId :
527 tmBannerIcon_ColorId);
528 }
529 }
530#else
531 iUnused(d);
532#endif
533}
534
517void dismissPortraitPhoneSidebars_Root(iRoot *d) { 535void dismissPortraitPhoneSidebars_Root(iRoot *d) {
518 if (deviceType_App() == phone_AppDeviceType && isPortrait_App()) { 536 if (deviceType_App() == phone_AppDeviceType && isPortrait_App()) {
519 iWidget *sidebar = findChild_Widget(d->widget, "sidebar"); 537 iWidget *sidebar = findChild_Widget(d->widget, "sidebar");
@@ -1247,7 +1265,6 @@ void createUserInterface_Root(iRoot *d) {
1247 arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag | 1265 arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag |
1248 commandOnClick_WidgetFlag | 1266 commandOnClick_WidgetFlag |
1249 drawBackgroundToBottom_WidgetFlag, iTrue); 1267 drawBackgroundToBottom_WidgetFlag, iTrue);
1250 setBackgroundColor_Widget(toolBar, tmBannerBackground_ColorId);
1251 setId_Widget(addChildFlags_Widget(toolBar, 1268 setId_Widget(addChildFlags_Widget(toolBar,
1252 iClob(newLargeIcon_LabelWidget("\U0001f870", "navigate.back")), 1269 iClob(newLargeIcon_LabelWidget("\U0001f870", "navigate.back")),
1253 frameless_WidgetFlag), 1270 frameless_WidgetFlag),
@@ -1269,12 +1286,13 @@ void createUserInterface_Root(iRoot *d) {
1269 setFont_LabelWidget(menuButton, uiLabelLarge_FontId); 1286 setFont_LabelWidget(menuButton, uiLabelLarge_FontId);
1270 setId_Widget(as_Widget(menuButton), "toolbar.navmenu"); 1287 setId_Widget(as_Widget(menuButton), "toolbar.navmenu");
1271 addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag); 1288 addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag);
1289// setBackgroundColor_Widget(toolBar, tmBannerBackground_ColorId);
1272 iForEach(ObjectList, i, children_Widget(toolBar)) { 1290 iForEach(ObjectList, i, children_Widget(toolBar)) {
1273 iLabelWidget *btn = i.object; 1291 iLabelWidget *btn = i.object;
1274 setFlags_Widget(i.object, noBackground_WidgetFlag, iTrue); 1292 setFlags_Widget(i.object, noBackground_WidgetFlag, iTrue);
1275 setTextColor_LabelWidget(i.object, tmBannerIcon_ColorId); 1293// setTextColor_LabelWidget(i.object, tmBannerIcon_ColorId);
1276 // setBackgroundColor_Widget(i.object, tmBannerSideTitle_ColorId);
1277 } 1294 }
1295 updateToolbarColors_Root(d);
1278 const iMenuItem items[] = { 1296 const iMenuItem items[] = {
1279 { book_Icon " ${sidebar.bookmarks}", 0, 0, "toolbar.showview arg:0" }, 1297 { book_Icon " ${sidebar.bookmarks}", 0, 0, "toolbar.showview arg:0" },
1280 { star_Icon " ${sidebar.feeds}", 0, 0, "toolbar.showview arg:1" }, 1298 { star_Icon " ${sidebar.feeds}", 0, 0, "toolbar.showview arg:1" },
@@ -1356,7 +1374,7 @@ void createUserInterface_Root(iRoot *d) {
1356 } 1374 }
1357} 1375}
1358 1376
1359void showToolbars_Root(iRoot *d, iBool show) { 1377void showToolbar_Root(iRoot *d, iBool show) {
1360 /* The toolbar is only used on phone portrait layout. */ 1378 /* The toolbar is only used on phone portrait layout. */
1361 if (isLandscape_App()) return; 1379 if (isLandscape_App()) return;
1362 iWidget *toolBar = findChild_Widget(d->widget, "toolbar"); 1380 iWidget *toolBar = findChild_Widget(d->widget, "toolbar");
diff --git a/src/ui/root.h b/src/ui/root.h
index 96864a15..740e97c9 100644
--- a/src/ui/root.h
+++ b/src/ui/root.h
@@ -34,7 +34,8 @@ void postArrange_Root (iRoot *);
34void updateMetrics_Root (iRoot *); 34void updateMetrics_Root (iRoot *);
35void updatePadding_Root (iRoot *); /* TODO: is part of metrics? */ 35void updatePadding_Root (iRoot *); /* TODO: is part of metrics? */
36void dismissPortraitPhoneSidebars_Root (iRoot *); 36void dismissPortraitPhoneSidebars_Root (iRoot *);
37void showToolbars_Root (iRoot *, iBool show); 37void showToolbar_Root (iRoot *, iBool show);
38void updateToolbarColors_Root (iRoot *);
38 39
39iInt2 size_Root (const iRoot *); 40iInt2 size_Root (const iRoot *);
40iRect rect_Root (const iRoot *); 41iRect rect_Root (const iRoot *);
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index f7181037..5b836670 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -971,6 +971,7 @@ static iBool handleSidebarCommand_SidebarWidget_(iSidebarWidget *d, const char *
971 w, -w->rect.size.x - safePad, 300, easeOut_AnimFlag | softer_AnimFlag); 971 w, -w->rect.size.x - safePad, 300, easeOut_AnimFlag | softer_AnimFlag);
972 } 972 }
973 } 973 }
974 updateToolbarColors_Root(w->root);
974 arrange_Widget(w->parent); 975 arrange_Widget(w->parent);
975 /* BUG: Rearranging because the arrange above didn't fully resolve the height. */ 976 /* BUG: Rearranging because the arrange above didn't fully resolve the height. */
976 arrange_Widget(w); 977 arrange_Widget(w);