summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-24 12:48:34 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-24 12:48:34 +0200
commitc83d76e7e4059b208a99ec9938d1723f62fb15e3 (patch)
tree331b9d75c0b27f8638eda7a75c03a32b8e214819 /src/ui
parentb8b81eead1f3d072a09d124ebb608ea15da3f988 (diff)
Lock button is embedded in the URL field
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/inputwidget.c8
-rw-r--r--src/ui/window.c30
2 files changed, 25 insertions, 13 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 76053f8b..600a4462 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -605,7 +605,11 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
605 return iTrue; 605 return iTrue;
606 } 606 }
607 if (ev->type == SDL_MOUSEMOTION && isHover_Widget(d)) { 607 if (ev->type == SDL_MOUSEMOTION && isHover_Widget(d)) {
608 setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_IBEAM); 608 const iInt2 local = localCoord_Widget(w, init_I2(ev->motion.x, ev->motion.y));
609 setCursor_Window(get_Window(),
610 local.x >= 2 * gap_UI + d->leftPadding && local.x < width_Widget(w) - d->rightPadding
611 ? SDL_SYSTEM_CURSOR_IBEAM
612 : SDL_SYSTEM_CURSOR_ARROW);
609 } 613 }
610 switch (processEvent_Click(&d->click, ev)) { 614 switch (processEvent_Click(&d->click, ev)) {
611 case none_ClickResult: 615 case none_ClickResult:
@@ -839,7 +843,7 @@ static void draw_InputWidget_(const iInputWidget *d) {
839 isFocused ? gap_UI / 4 : 1, 843 isFocused ? gap_UI / 4 : 1,
840 isFocused ? uiInputFrameFocused_ColorId 844 isFocused ? uiInputFrameFocused_ColorId
841 : isHover ? uiInputFrameHover_ColorId : uiInputFrame_ColorId); 845 : isHover ? uiInputFrameHover_ColorId : uiInputFrame_ColorId);
842 setClip_Paint(&p, bounds); 846 setClip_Paint(&p, adjusted_Rect(bounds, init_I2(d->leftPadding, 0), init_I2(-d->rightPadding, 0)));
843 const iInt2 textOrigin = textOrigin_InputWidget_(d, cstr_String(text)); 847 const iInt2 textOrigin = textOrigin_InputWidget_(d, cstr_String(text));
844 if (isFocused && !isEmpty_Range(&d->mark)) { 848 if (isFocused && !isEmpty_Range(&d->mark)) {
845 /* Draw the selected range. */ 849 /* Draw the selected range. */
diff --git a/src/ui/window.c b/src/ui/window.c
index b545cc10..ef2c91d8 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -492,7 +492,7 @@ static void showSearchQueryIndicator_(iBool show) {
492 iWidget *indicator = findWidget_App("input.indicator.search"); 492 iWidget *indicator = findWidget_App("input.indicator.search");
493 setFlags_Widget(indicator, hidden_WidgetFlag, !show); 493 setFlags_Widget(indicator, hidden_WidgetFlag, !show);
494 setContentPadding_InputWidget( 494 setContentPadding_InputWidget(
495 (iInputWidget *) parent_Widget(indicator), 0, show ? width_Widget(indicator) : 0); 495 (iInputWidget *) parent_Widget(indicator), -1, show ? width_Widget(indicator) : 0);
496} 496}
497 497
498static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { 498static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
@@ -504,12 +504,17 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
504 iForEach(ObjectList, i, navBar->children) { 504 iForEach(ObjectList, i, navBar->children) {
505 iWidget *child = as_Widget(i.object); 505 iWidget *child = as_Widget(i.object);
506 setFlags_Widget( 506 setFlags_Widget(
507 child, tight_WidgetFlag, isNarrow || !cmp_String(id_Widget(child), "lock")); 507 child, tight_WidgetFlag, isNarrow);
508 if (isInstance_Object(i.object, &Class_LabelWidget)) { 508 if (isInstance_Object(i.object, &Class_LabelWidget)) {
509 iLabelWidget *label = i.object; 509 iLabelWidget *label = i.object;
510 updateSize_LabelWidget(label); 510 updateSize_LabelWidget(label);
511 } 511 }
512 } 512 }
513 /* Note that InputWidget uses the `tight` flag to adjust its inner padding. */
514 setContentPadding_InputWidget(findChild_Widget(navBar, "url"),
515 width_Widget(findChild_Widget(navBar, "navbar.lock")) -
516 (isNarrow ? 2.0f : 2.75f) * gap_UI,
517 -1);
513 } 518 }
514 if (isPhone) { 519 if (isPhone) {
515 static const char *buttons[] = { 520 static const char *buttons[] = {
@@ -866,14 +871,6 @@ static void setupUserInterface_Window(iWindow *d) {
866 "\U0001f464", identityButtonMenuItems_, iElemCount(identityButtonMenuItems_)); 871 "\U0001f464", identityButtonMenuItems_, iElemCount(identityButtonMenuItems_));
867 setAlignVisually_LabelWidget(idMenu, iTrue); 872 setAlignVisually_LabelWidget(idMenu, iTrue);
868 setId_Widget(addChildFlags_Widget(navBar, iClob(idMenu), collapse_WidgetFlag), "navbar.ident"); 873 setId_Widget(addChildFlags_Widget(navBar, iClob(idMenu), collapse_WidgetFlag), "navbar.ident");
869 iLabelWidget *lock =
870 addChildFlags_Widget(navBar,
871 iClob(newIcon_LabelWidget("\U0001f513", SDLK_i, KMOD_PRIMARY, "document.info")),
872 frameless_WidgetFlag |
873 (deviceType_App() == desktop_AppDeviceType ? tight_WidgetFlag : 0));
874 setId_Widget(as_Widget(lock), "navbar.lock");
875 setFont_LabelWidget(lock, defaultSymbols_FontId);
876 updateTextCStr_LabelWidget(lock, "\U0001f512");
877 /* URL input field. */ { 874 /* URL input field. */ {
878 iInputWidget *url = new_InputWidget(0); 875 iInputWidget *url = new_InputWidget(0);
879 setSelectAllOnFocus_InputWidget(url, iTrue); 876 setSelectAllOnFocus_InputWidget(url, iTrue);
@@ -882,7 +879,18 @@ static void setupUserInterface_Window(iWindow *d) {
882 setNotifyEdits_InputWidget(url, iTrue); 879 setNotifyEdits_InputWidget(url, iTrue);
883 setTextCStr_InputWidget(url, "gemini://"); 880 setTextCStr_InputWidget(url, "gemini://");
884 addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag); 881 addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag);
885 setPadding_Widget(as_Widget(url), 0, 0, gap_UI * 1, 0); 882 setPadding_Widget(as_Widget(url), 0, 0, gap_UI, 0);
883 /* Page information/certificate warning. */ {
884 iLabelWidget *lock =
885 addChildFlags_Widget(as_Widget(url),
886 iClob(newIcon_LabelWidget("\U0001f513", SDLK_i, KMOD_PRIMARY, "document.info")),
887 noBackground_WidgetFlag | frameless_WidgetFlag | moveToParentLeftEdge_WidgetFlag |
888 (deviceType_App() == desktop_AppDeviceType ? tight_WidgetFlag : 0));
889 setId_Widget(as_Widget(lock), "navbar.lock");
890 setFont_LabelWidget(lock, defaultSymbols_FontId);
891 updateTextCStr_LabelWidget(lock, "\U0001f512");
892 setContentPadding_InputWidget(url, width_Widget(lock) - 2.75f * gap_UI, -1);
893 }
886 /* Feeds refresh indicator is inside the input field. */ { 894 /* Feeds refresh indicator is inside the input field. */ {
887 iLabelWidget *fprog = new_LabelWidget(uiTextCaution_ColorEscape 895 iLabelWidget *fprog = new_LabelWidget(uiTextCaution_ColorEscape
888 "\u2605 Refreshing Feeds...", NULL); 896 "\u2605 Refreshing Feeds...", NULL);