summaryrefslogtreecommitdiff
path: root/src/ui/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 1249a0b4..bd2b1493 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -191,7 +191,7 @@ static const iMenuItem navMenuItems_[] = {
191 { add_Icon " New Tab", 't', KMOD_PRIMARY, "tabs.new" }, 191 { add_Icon " New Tab", 't', KMOD_PRIMARY, "tabs.new" },
192 { "Open Location...", SDLK_l, KMOD_PRIMARY, "navigate.focus" }, 192 { "Open Location...", SDLK_l, KMOD_PRIMARY, "navigate.focus" },
193 { "---", 0, 0, NULL }, 193 { "---", 0, 0, NULL },
194 { download_Icon " Save to Downloads", SDLK_s, KMOD_PRIMARY, "document.save" }, 194 { download_Icon " " saveToDownloads_Label, SDLK_s, KMOD_PRIMARY, "document.save" },
195 { "Copy Source Text", SDLK_c, KMOD_PRIMARY, "copy" }, 195 { "Copy Source Text", SDLK_c, KMOD_PRIMARY, "copy" },
196 { "---", 0, 0, NULL }, 196 { "---", 0, 0, NULL },
197 { leftHalf_Icon " Toggle Left Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" }, 197 { leftHalf_Icon " Toggle Left Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" },
@@ -259,7 +259,7 @@ static const iMenuItem fileMenuItems_[] = {
259 { "New Tab", SDLK_t, KMOD_PRIMARY, "tabs.new" }, 259 { "New Tab", SDLK_t, KMOD_PRIMARY, "tabs.new" },
260 { "Open Location...", SDLK_l, KMOD_PRIMARY, "navigate.focus" }, 260 { "Open Location...", SDLK_l, KMOD_PRIMARY, "navigate.focus" },
261 { "---", 0, 0, NULL }, 261 { "---", 0, 0, NULL },
262 { "Save to Downloads", SDLK_s, KMOD_PRIMARY, "document.save" }, 262 { saveToDownloads_Label, SDLK_s, KMOD_PRIMARY, "document.save" },
263}; 263};
264 264
265static const iMenuItem editMenuItems_[] = { 265static const iMenuItem editMenuItems_[] = {
@@ -576,7 +576,9 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
576 if (isPhone) { 576 if (isPhone) {
577 static const char *buttons[] = { "navbar.back", "navbar.forward", "navbar.sidebar", 577 static const char *buttons[] = { "navbar.back", "navbar.forward", "navbar.sidebar",
578 "navbar.ident", "navbar.home", "navbar.menu" }; 578 "navbar.ident", "navbar.home", "navbar.menu" };
579 setFlags_Widget(findWidget_App("toolbar"), hidden_WidgetFlag, isLandscape_App()); 579 iWidget *toolBar = findWidget_App("toolbar");
580 setVisualOffset_Widget(toolBar, 0, 0, 0);
581 setFlags_Widget(toolBar, hidden_WidgetFlag, isLandscape_App());
580 iForIndices(i, buttons) { 582 iForIndices(i, buttons) {
581 iLabelWidget *btn = findChild_Widget(navBar, buttons[i]); 583 iLabelWidget *btn = findChild_Widget(navBar, buttons[i]);
582 setFlags_Widget(as_Widget(btn), hidden_WidgetFlag, isPortrait_App()); 584 setFlags_Widget(as_Widget(btn), hidden_WidgetFlag, isPortrait_App());
@@ -936,7 +938,6 @@ static void setupUserInterface_Window(iWindow *d) {
936 setBackgroundColor_Widget(winBar, uiBackground_ColorId); 938 setBackgroundColor_Widget(winBar, uiBackground_ColorId);
937 } 939 }
938#endif 940#endif
939
940 /* Navigation bar. */ { 941 /* Navigation bar. */ {
941 iWidget *navBar = new_Widget(); 942 iWidget *navBar = new_Widget();
942 setId_Widget(navBar, "navbar"); 943 setId_Widget(navBar, "navbar");
@@ -1119,8 +1120,9 @@ static void setupUserInterface_Window(iWindow *d) {
1119 setBackgroundColor_Widget(searchBar, uiBackground_ColorId); 1120 setBackgroundColor_Widget(searchBar, uiBackground_ColorId);
1120 setCommandHandler_Widget(searchBar, handleSearchBarCommands_); 1121 setCommandHandler_Widget(searchBar, handleSearchBarCommands_);
1121 addChildFlags_Widget( 1122 addChildFlags_Widget(
1122 searchBar, iClob(new_LabelWidget(magnifyingGlass_Icon " Text", NULL)), frameless_WidgetFlag); 1123 searchBar, iClob(new_LabelWidget(magnifyingGlass_Icon, NULL)), frameless_WidgetFlag);
1123 iInputWidget *input = new_InputWidget(0); 1124 iInputWidget *input = new_InputWidget(0);
1125 setHint_InputWidget(input, "Find text on page");
1124 setSelectAllOnFocus_InputWidget(input, iTrue); 1126 setSelectAllOnFocus_InputWidget(input, iTrue);
1125 setEatEscape_InputWidget(input, iFalse); /* unfocus and close with one keypress */ 1127 setEatEscape_InputWidget(input, iFalse); /* unfocus and close with one keypress */
1126 setId_Widget(addChildFlags_Widget(searchBar, iClob(input), expand_WidgetFlag), 1128 setId_Widget(addChildFlags_Widget(searchBar, iClob(input), expand_WidgetFlag),
@@ -1133,10 +1135,12 @@ static void setupUserInterface_Window(iWindow *d) {
1133 /* Bottom toolbar. */ 1135 /* Bottom toolbar. */
1134 if (isPhone_iOS()) { 1136 if (isPhone_iOS()) {
1135 iWidget *toolBar = new_Widget(); 1137 iWidget *toolBar = new_Widget();
1136 addChild_Widget(div, iClob(toolBar)); 1138 addChild_Widget(d->root, iClob(toolBar));
1137 setId_Widget(toolBar, "toolbar"); 1139 setId_Widget(toolBar, "toolbar");
1138 setCommandHandler_Widget(toolBar, handleToolBarCommands_); 1140 setCommandHandler_Widget(toolBar, handleToolBarCommands_);
1139 setFlags_Widget(toolBar, collapse_WidgetFlag | resizeWidthOfChildren_WidgetFlag | 1141 setFlags_Widget(toolBar, moveToParentBottomEdge_WidgetFlag |
1142 parentCannotResizeHeight_WidgetFlag |
1143 resizeWidthOfChildren_WidgetFlag |
1140 arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag, iTrue); 1144 arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag, iTrue);
1141 setBackgroundColor_Widget(toolBar, tmBannerBackground_ColorId); 1145 setBackgroundColor_Widget(toolBar, tmBannerBackground_ColorId);
1142 addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f870", "navigate.back")), frameless_WidgetFlag); 1146 addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f870", "navigate.back")), frameless_WidgetFlag);
@@ -1214,6 +1218,21 @@ static void setupUserInterface_Window(iWindow *d) {
1214 updateMetrics_Window_(d); 1218 updateMetrics_Window_(d);
1215} 1219}
1216 1220
1221void showToolbars_Window(iWindow *d, iBool show) {
1222 if (isLandscape_App()) return;
1223 iWidget *toolBar = findChild_Widget(d->root, "toolbar");
1224 if (!toolBar) return;
1225 const int height = rootSize_Window(d).y - top_Rect(boundsWithoutVisualOffset_Widget(toolBar));
1226 if (show && !isVisible_Widget(toolBar)) {
1227 setFlags_Widget(toolBar, hidden_WidgetFlag, iFalse);
1228 setVisualOffset_Widget(toolBar, 0, 200, easeOut_AnimFlag);
1229 }
1230 else if (!show && isVisible_Widget(toolBar)) {
1231 setFlags_Widget(toolBar, hidden_WidgetFlag, iTrue);
1232 setVisualOffset_Widget(toolBar, height, 200, easeOut_AnimFlag);
1233 }
1234}
1235
1217static void updateRootSize_Window_(iWindow *d, iBool notifyAlways) { 1236static void updateRootSize_Window_(iWindow *d, iBool notifyAlways) {
1218 iInt2 *size = &d->root->rect.size; 1237 iInt2 *size = &d->root->rect.size;
1219 const iInt2 oldSize = *size; 1238 const iInt2 oldSize = *size;