summaryrefslogtreecommitdiff
path: root/src/ui/window.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-02 17:56:31 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-02 17:56:31 +0300
commit89e11130e0af438564e32eee6b97f31087eb4849 (patch)
treeb7339951bc20c51f39ed3c7a5caf11d0c9d126e7 /src/ui/window.c
parentf3d083d3f150c1e940c4086f39165fb55935344a (diff)
Window: Narrow layout mode for the navbar
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index b438c301..add9d420 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -79,7 +79,25 @@ static const char *reloadCStr_ = "\U0001f503";
79static const char *stopCStr_ = orange_ColorEscape "\U0001f310"; 79static const char *stopCStr_ = orange_ColorEscape "\U0001f310";
80 80
81static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { 81static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
82 if (equal_Command(cmd, "input.ended")) { 82 if (equal_Command(cmd, "window.resized")) {
83 const iBool isNarrow = width_Rect(bounds_Widget(navBar)) / gap_UI < 140;
84 if (isNarrow ^ ((flags_Widget(navBar) & tight_WidgetFlag) != 0)) {
85 setFlags_Widget(navBar, tight_WidgetFlag, isNarrow);
86 iForEach(ObjectList, i, navBar->children) {
87 iWidget *child = as_Widget(i.object);
88 setFlags_Widget(
89 child, tight_WidgetFlag, isNarrow || !cmp_String(id_Widget(child), "lock"));
90 if (isInstance_Object(i.object, &Class_LabelWidget)) {
91 iLabelWidget *label = (iLabelWidget *) i.object;
92 updateSize_LabelWidget(label);
93 }
94 }
95 }
96 arrange_Widget(navBar);
97 refresh_Widget(navBar);
98 return iFalse;
99 }
100 else if (equal_Command(cmd, "input.ended")) {
83 iInputWidget *url = findChild_Widget(navBar, "url"); 101 iInputWidget *url = findChild_Widget(navBar, "url");
84 if (arg_Command(cmd) && pointer_Command(cmd) == url) { 102 if (arg_Command(cmd) && pointer_Command(cmd) == url) {
85 postCommandf_App( 103 postCommandf_App(
@@ -179,16 +197,23 @@ static void setupUserInterface_Window(iWindow *d) {
179 addChild_Widget(div, iClob(navBar)); 197 addChild_Widget(div, iClob(navBar));
180 setBackgroundColor_Widget(navBar, gray25_ColorId); 198 setBackgroundColor_Widget(navBar, gray25_ColorId);
181 setCommandHandler_Widget(navBar, handleNavBarCommands_); 199 setCommandHandler_Widget(navBar, handleNavBarCommands_);
182 addChild_Widget(navBar, iClob(new_LabelWidget(" \u25c4 ", 0, 0, "navigate.back"))); 200 addChild_Widget(navBar, iClob(newIcon_LabelWidget(" \U0001f860 ", 0, 0, "navigate.back")));
183 addChild_Widget(navBar, iClob(new_LabelWidget(" \u25ba ", 0, 0, "navigate.forward"))); 201 addChild_Widget(navBar, iClob(newIcon_LabelWidget("\U0001f862", 0, 0, "navigate.forward")));
184 addChild_Widget(navBar, iClob(new_LabelWidget("\U0001f3e0", 0, 0, "navigate.home"))); 202 addChild_Widget(navBar, iClob(newIcon_LabelWidget("\U0001f3e0", 0, 0, "navigate.home")));
203 iLabelWidget *lock = addChildFlags_Widget(navBar,
204 iClob(newIcon_LabelWidget("\U0001f512", 0, 0, "cert.server")),
205 frameless_WidgetFlag | tight_WidgetFlag);
206 setId_Widget(as_Widget(lock), "lock");
207 setFont_LabelWidget(lock, symbols_FontId);
185 iInputWidget *url = new_InputWidget(0); 208 iInputWidget *url = new_InputWidget(0);
186 setId_Widget(as_Widget(url), "url"); 209 setId_Widget(as_Widget(url), "url");
187 setTextCStr_InputWidget(url, "gemini://"); 210 setTextCStr_InputWidget(url, "gemini://");
188 addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag); 211 addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag);
189 setId_Widget( 212 setId_Widget(
190 addChild_Widget(navBar, iClob(new_LabelWidget(reloadCStr_, 0, 0, "navigate.reload"))), 213 addChild_Widget(navBar, iClob(newIcon_LabelWidget(reloadCStr_, 0, 0, "navigate.reload"))),
191 "reload"); 214 "reload");
215 addChild_Widget(navBar, iClob(newIcon_LabelWidget("\U0001f464", 0, 0, "cert.client")));
216 addChild_Widget(navBar, iClob(newIcon_LabelWidget("\U0001d362", 0, 0, "navbar.menu")));
192 } 217 }
193 218
194 addChildFlags_Widget(div, iClob(new_DocumentWidget()), expand_WidgetFlag); 219 addChildFlags_Widget(div, iClob(new_DocumentWidget()), expand_WidgetFlag);
@@ -207,9 +232,9 @@ static void setupUserInterface_Window(iWindow *d) {
207 iInputWidget *input = new_InputWidget(0); 232 iInputWidget *input = new_InputWidget(0);
208 setId_Widget(addChildFlags_Widget(searchBar, iClob(input), expand_WidgetFlag), 233 setId_Widget(addChildFlags_Widget(searchBar, iClob(input), expand_WidgetFlag),
209 "find.input"); 234 "find.input");
210 addChild_Widget(searchBar, iClob(new_LabelWidget(" \U0001f86b ", 'g', KMOD_PRIMARY, "find.next"))); 235 addChild_Widget(searchBar, iClob(newIcon_LabelWidget(" \U0001f86b ", 'g', KMOD_PRIMARY, "find.next")));
211 addChild_Widget(searchBar, iClob(new_LabelWidget(" \U0001f869 ", 'g', KMOD_PRIMARY | KMOD_SHIFT, "find.prev"))); 236 addChild_Widget(searchBar, iClob(newIcon_LabelWidget(" \U0001f869 ", 'g', KMOD_PRIMARY | KMOD_SHIFT, "find.prev")));
212 addChild_Widget(searchBar, iClob(new_LabelWidget("\U0001f7a8", SDLK_ESCAPE, 0, "find.close"))); 237 addChild_Widget(searchBar, iClob(newIcon_LabelWidget("\U0001f7a8", SDLK_ESCAPE, 0, "find.close")));
213 } 238 }
214 239
215#if 0 240#if 0