summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-06-10 15:01:41 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-06-10 15:01:41 +0300
commitd3030ff846ba3673f96ca142935b2f1e1b954423 (patch)
tree814d8333d6d91206b6e709af33343a211fddca09 /src
parent96675f86a5a35b8d35f0aa4d17db47b200da9ae4 (diff)
Mobile: Horizontal sidebar animation
Also fixing glitch with search input field where pressing Return would insert newline.
Diffstat (limited to 'src')
-rw-r--r--src/app.c3
-rw-r--r--src/app.h1
-rw-r--r--src/ui/inputwidget.c14
-rw-r--r--src/ui/inputwidget.h1
-rw-r--r--src/ui/root.c28
-rw-r--r--src/ui/sidebarwidget.c29
6 files changed, 51 insertions, 25 deletions
diff --git a/src/app.c b/src/app.c
index 12c7dc7d..88d912ab 100644
--- a/src/app.c
+++ b/src/app.c
@@ -2562,7 +2562,8 @@ iBool handleCommand_App(const char *cmd) {
2562 iAnyObject *prog = findWidget_Root("feeds.progress"); 2562 iAnyObject *prog = findWidget_Root("feeds.progress");
2563 const iWidget *navBar = findWidget_Root("navbar"); 2563 const iWidget *navBar = findWidget_Root("navbar");
2564 updateTextAndResizeWidthCStr_LabelWidget( 2564 updateTextAndResizeWidthCStr_LabelWidget(
2565 prog, flags_Widget(navBar) & tight_WidgetFlag ? "\u2605" : "\u2605 ${status.feeds}"); 2565 prog, flags_Widget(navBar) & tight_WidgetFlag || deviceType_App() == phone_AppDeviceType ?
2566 "\u2605" : "\u2605 ${status.feeds}");
2566 showCollapsed_Widget(prog, iTrue); 2567 showCollapsed_Widget(prog, iTrue);
2567 return iFalse; 2568 return iFalse;
2568 } 2569 }
diff --git a/src/app.h b/src/app.h
index 2dd5198d..5d1d42e1 100644
--- a/src/app.h
+++ b/src/app.h
@@ -86,6 +86,7 @@ uint32_t elapsedSinceLastTicker_App (void); /* milliseconds */
86iBool isLandscape_App (void); 86iBool isLandscape_App (void);
87iLocalDef iBool isPortrait_App (void) { return !isLandscape_App(); } 87iLocalDef iBool isPortrait_App (void) { return !isLandscape_App(); }
88enum iAppDeviceType deviceType_App (void); 88enum iAppDeviceType deviceType_App (void);
89iLocalDef iBool isPortraitPhone_App (void) { return isPortrait_App() && deviceType_App() == phone_AppDeviceType; }
89iGmCerts * certs_App (void); 90iGmCerts * certs_App (void);
90iVisited * visited_App (void); 91iVisited * visited_App (void);
91iBookmarks * bookmarks_App (void); 92iBookmarks * bookmarks_App (void);
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index cf128017..9571a97e 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -80,6 +80,7 @@ enum iInputWidgetFlag {
80 markWords_InputWidgetFlag = iBit(8), 80 markWords_InputWidgetFlag = iBit(8),
81 needUpdateBuffer_InputWidgetFlag = iBit(9), 81 needUpdateBuffer_InputWidgetFlag = iBit(9),
82 enterKeyEnabled_InputWidgetFlag = iBit(10), 82 enterKeyEnabled_InputWidgetFlag = iBit(10),
83 enterKeyInsertsLineFeed_InputWidgetFlag = iBit(11),
83}; 84};
84 85
85/*----------------------------------------------------------------------------------------------*/ 86/*----------------------------------------------------------------------------------------------*/
@@ -347,8 +348,11 @@ void init_InputWidget(iInputWidget *d, size_t maxLen) {
347 d->lastCursor = 0; 348 d->lastCursor = 0;
348 d->cursorLine = 0; 349 d->cursorLine = 0;
349 d->lastUpdateWidth = 0; 350 d->lastUpdateWidth = 0;
350 d->verticalMoveX = -1; /* TODO: Use this. */ 351 d->verticalMoveX = -1; /* TODO: Use this. */
351 d->inFlags = eatEscape_InputWidgetFlag | enterKeyEnabled_InputWidgetFlag; 352 d->inFlags = eatEscape_InputWidgetFlag | enterKeyEnabled_InputWidgetFlag;
353 if (deviceType_App() != desktop_AppDeviceType) {
354 d->inFlags |= enterKeyInsertsLineFeed_InputWidgetFlag;
355 }
352 iZap(d->mark); 356 iZap(d->mark);
353 setMaxLen_InputWidget(d, maxLen); 357 setMaxLen_InputWidget(d, maxLen);
354 d->maxLayoutLines = iInvalidSize; 358 d->maxLayoutLines = iInvalidSize;
@@ -464,6 +468,10 @@ void setValidator_InputWidget(iInputWidget *d, iInputWidgetValidatorFunc validat
464 d->validatorContext = context; 468 d->validatorContext = context;
465} 469}
466 470
471void setEnterInsertsLF_InputWidget(iInputWidget *d, iBool enterInsertsLF) {
472 iChangeFlags(d->inFlags, enterKeyInsertsLineFeed_InputWidgetFlag, enterInsertsLF);
473}
474
467void setEnterKeyEnabled_InputWidget(iInputWidget *d, iBool enterKeyEnabled) { 475void setEnterKeyEnabled_InputWidget(iInputWidget *d, iBool enterKeyEnabled) {
468 iChangeFlags(d->inFlags, enterKeyEnabled_InputWidgetFlag, enterKeyEnabled); 476 iChangeFlags(d->inFlags, enterKeyEnabled_InputWidgetFlag, enterKeyEnabled);
469} 477}
@@ -1166,7 +1174,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
1166 case SDLK_KP_ENTER: 1174 case SDLK_KP_ENTER:
1167 if (mods == KMOD_SHIFT || (d->maxLen == 0 && 1175 if (mods == KMOD_SHIFT || (d->maxLen == 0 &&
1168 ~d->inFlags & isUrl_InputWidgetFlag && 1176 ~d->inFlags & isUrl_InputWidgetFlag &&
1169 deviceType_App() != desktop_AppDeviceType)) { 1177 d->inFlags & enterKeyInsertsLineFeed_InputWidgetFlag)) {
1170 pushUndo_InputWidget_(d); 1178 pushUndo_InputWidget_(d);
1171 deleteMarked_InputWidget_(d); 1179 deleteMarked_InputWidget_(d);
1172 insertChar_InputWidget_(d, '\n'); 1180 insertChar_InputWidget_(d, '\n');
diff --git a/src/ui/inputwidget.h b/src/ui/inputwidget.h
index f8c5bf1e..c70d9ad6 100644
--- a/src/ui/inputwidget.h
+++ b/src/ui/inputwidget.h
@@ -51,6 +51,7 @@ void setCursor_InputWidget (iInputWidget *, size_t pos);
51void setContentPadding_InputWidget (iInputWidget *, int left, int right); /* only affects the text entry */ 51void setContentPadding_InputWidget (iInputWidget *, int left, int right); /* only affects the text entry */
52void setMaxLayoutLines_InputWidget (iInputWidget *, size_t maxLayoutLines); 52void setMaxLayoutLines_InputWidget (iInputWidget *, size_t maxLayoutLines);
53void setValidator_InputWidget (iInputWidget *, iInputWidgetValidatorFunc validator, void *context); 53void setValidator_InputWidget (iInputWidget *, iInputWidgetValidatorFunc validator, void *context);
54void setEnterInsertsLF_InputWidget (iInputWidget *, iBool enterInsertsLF);
54void setEnterKeyEnabled_InputWidget (iInputWidget *, iBool enterKeyEnabled); 55void setEnterKeyEnabled_InputWidget (iInputWidget *, iBool enterKeyEnabled);
55void begin_InputWidget (iInputWidget *); 56void begin_InputWidget (iInputWidget *);
56void end_InputWidget (iInputWidget *, iBool accept); 57void end_InputWidget (iInputWidget *, iBool accept);
diff --git a/src/ui/root.c b/src/ui/root.c
index 52bc7364..91e19e46 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -834,20 +834,20 @@ static iBool handleToolBarCommands_(iWidget *toolBar, const char *cmd) {
834 const int viewHeight = size_Root(get_Root()).y; 834 const int viewHeight = size_Root(get_Root()).y;
835 if (arg_Command(cmd) >= 0) { 835 if (arg_Command(cmd) >= 0) {
836 postCommandf_App("sidebar.mode arg:%d show:1", arg_Command(cmd)); 836 postCommandf_App("sidebar.mode arg:%d show:1", arg_Command(cmd));
837 if (!isVisible) { 837// if (!isVisible) {
838 setVisualOffset_Widget(sidebar, viewHeight, 0, 0); 838// setVisualOffset_Widget(sidebar, viewHeight, 0, 0);
839 setVisualOffset_Widget(sidebar, 0, 400, easeOut_AnimFlag | softer_AnimFlag); 839// setVisualOffset_Widget(sidebar, 0, 400, easeOut_AnimFlag | softer_AnimFlag);
840 } 840// }
841 } 841 }
842 else { 842 else {
843 postCommandf_App("sidebar.toggle"); 843 postCommandf_App("sidebar.toggle");
844 if (isVisible) { 844// if (isVisible) {
845 setVisualOffset_Widget(sidebar, height_Widget(sidebar), 250, easeIn_AnimFlag); 845// setVisualOffset_Widget(sidebar, height_Widget(sidebar), 250, easeIn_AnimFlag);
846 } 846// }
847 else { 847// else {
848 setVisualOffset_Widget(sidebar, viewHeight, 0, 0); 848// setVisualOffset_Widget(sidebar, viewHeight, 0, 0);
849 setVisualOffset_Widget(sidebar, 0, 400, easeOut_AnimFlag | softer_AnimFlag); 849// setVisualOffset_Widget(sidebar, 0, 400, easeOut_AnimFlag | softer_AnimFlag);
850 } 850// }
851 } 851 }
852 return iTrue; 852 return iTrue;
853 } 853 }
@@ -855,7 +855,10 @@ static iBool handleToolBarCommands_(iWidget *toolBar, const char *cmd) {
855 /* TODO: Clean this up. */ 855 /* TODO: Clean this up. */
856 iWidget *sidebar = findWidget_App("sidebar"); 856 iWidget *sidebar = findWidget_App("sidebar");
857 iWidget *sidebar2 = findWidget_App("sidebar2"); 857 iWidget *sidebar2 = findWidget_App("sidebar2");
858 dismissSidebar_(sidebar, "toolbar.view"); 858 //dismissSidebar_(sidebar, "toolbar.view");
859 if (isVisible_Widget(sidebar)) {
860 postCommandf_App("sidebar.toggle");
861 }
859 const iBool isVisible = isVisible_Widget(sidebar2); 862 const iBool isVisible = isVisible_Widget(sidebar2);
860 // setFlags_Widget(findChild_Widget(toolBar, "toolbar.ident"), noBackground_WidgetFlag, 863 // setFlags_Widget(findChild_Widget(toolBar, "toolbar.ident"), noBackground_WidgetFlag,
861 // isVisible); 864 // isVisible);
@@ -1225,6 +1228,7 @@ void createUserInterface_Root(iRoot *d) {
1225 setHint_InputWidget(input, "${hint.findtext}"); 1228 setHint_InputWidget(input, "${hint.findtext}");
1226 setSelectAllOnFocus_InputWidget(input, iTrue); 1229 setSelectAllOnFocus_InputWidget(input, iTrue);
1227 setEatEscape_InputWidget(input, iFalse); /* unfocus and close with one keypress */ 1230 setEatEscape_InputWidget(input, iFalse); /* unfocus and close with one keypress */
1231 setEnterInsertsLF_InputWidget(input, iFalse);
1228 setId_Widget(addChildFlags_Widget(searchBar, iClob(input), expand_WidgetFlag), 1232 setId_Widget(addChildFlags_Widget(searchBar, iClob(input), expand_WidgetFlag),
1229 "find.input"); 1233 "find.input");
1230 addChild_Widget(searchBar, iClob(newIcon_LabelWidget(" \u2b9f ", 'g', KMOD_PRIMARY, "find.next"))); 1234 addChild_Widget(searchBar, iClob(newIcon_LabelWidget(" \u2b9f ", 'g', KMOD_PRIMARY, "find.next")));
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 27646b22..2e1e138e 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -678,8 +678,8 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) {
678 iClob(buttons), 678 iClob(buttons),
679 arrangeHorizontal_WidgetFlag | 679 arrangeHorizontal_WidgetFlag |
680 resizeWidthOfChildren_WidgetFlag | 680 resizeWidthOfChildren_WidgetFlag |
681 arrangeHeight_WidgetFlag | resizeToParentWidth_WidgetFlag | 681 arrangeHeight_WidgetFlag | resizeToParentWidth_WidgetFlag); // |
682 drawBackgroundToHorizontalSafeArea_WidgetFlag); 682// drawBackgroundToHorizontalSafeArea_WidgetFlag);
683 setBackgroundColor_Widget(buttons, uiBackgroundSidebar_ColorId); 683 setBackgroundColor_Widget(buttons, uiBackgroundSidebar_ColorId);
684 } 684 }
685 else { 685 else {
@@ -700,13 +700,13 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) {
700 setPadding_Widget(as_Widget(d->list), 0, gap_UI, 0, gap_UI); 700 setPadding_Widget(as_Widget(d->list), 0, gap_UI, 0, gap_UI);
701 addChildFlags_Widget(listAndActions, 701 addChildFlags_Widget(listAndActions,
702 iClob(d->list), 702 iClob(d->list),
703 expand_WidgetFlag | drawBackgroundToHorizontalSafeArea_WidgetFlag); 703 expand_WidgetFlag); // | drawBackgroundToHorizontalSafeArea_WidgetFlag);
704 setId_Widget(addChildPosFlags_Widget(listAndActions, 704 setId_Widget(addChildPosFlags_Widget(listAndActions,
705 iClob(d->actions = new_Widget()), 705 iClob(d->actions = new_Widget()),
706 isPhone ? front_WidgetAddPos : back_WidgetAddPos, 706 isPhone ? front_WidgetAddPos : back_WidgetAddPos,
707 arrangeHorizontal_WidgetFlag | arrangeHeight_WidgetFlag | 707 arrangeHorizontal_WidgetFlag | arrangeHeight_WidgetFlag |
708 resizeWidthOfChildren_WidgetFlag | 708 resizeWidthOfChildren_WidgetFlag), // |
709 drawBackgroundToHorizontalSafeArea_WidgetFlag), 709// drawBackgroundToHorizontalSafeArea_WidgetFlag),
710 "actions"); 710 "actions");
711 setBackgroundColor_Widget(d->actions, uiBackgroundSidebar_ColorId); 711 setBackgroundColor_Widget(d->actions, uiBackgroundSidebar_ColorId);
712 d->contextItem = NULL; 712 d->contextItem = NULL;
@@ -938,7 +938,7 @@ static iBool handleSidebarCommand_SidebarWidget_(iSidebarWidget *d, const char *
938 } 938 }
939 const iBool isAnimated = prefs_App()->uiAnimations && 939 const iBool isAnimated = prefs_App()->uiAnimations &&
940 argLabel_Command(cmd, "noanim") == 0 && 940 argLabel_Command(cmd, "noanim") == 0 &&
941 (deviceType_App() != phone_AppDeviceType); 941 (d->side == left_SideBarSide || deviceType_App() != phone_AppDeviceType);
942 int visX = 0; 942 int visX = 0;
943 if (isVisible_Widget(w)) { 943 if (isVisible_Widget(w)) {
944 visX = left_Rect(bounds_Widget(w)) - left_Rect(w->root->widget->rect); 944 visX = left_Rect(bounds_Widget(w)) - left_Rect(w->root->widget->rect);
@@ -989,6 +989,15 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
989 if (isVisible_Widget(w)) { 989 if (isVisible_Widget(w)) {
990 postCommand_Widget(w, "sidebar.toggle"); 990 postCommand_Widget(w, "sidebar.toggle");
991 } 991 }
992 setFlags_Widget(findChild_Widget(w, "buttons"),
993 drawBackgroundToHorizontalSafeArea_WidgetFlag,
994 isLandscape_App());
995 setFlags_Widget(findChild_Widget(w, "actions"),
996 drawBackgroundToHorizontalSafeArea_WidgetFlag,
997 isLandscape_App());
998 setFlags_Widget(as_Widget(d->list),
999 drawBackgroundToHorizontalSafeArea_WidgetFlag,
1000 isLandscape_App());
992 return iFalse; 1001 return iFalse;
993 } 1002 }
994 } 1003 }
@@ -1528,9 +1537,11 @@ static void draw_SidebarWidget_(const iSidebarWidget *d) {
1528 const iRect bounds = bounds_Widget(w); 1537 const iRect bounds = bounds_Widget(w);
1529 iPaint p; 1538 iPaint p;
1530 init_Paint(&p); 1539 init_Paint(&p);
1531 if (flags_Widget(w) & visualOffset_WidgetFlag && 1540 if (deviceType_App() != phone_AppDeviceType) {
1532 flags_Widget(w) & horizontalOffset_WidgetFlag && isVisible_Widget(w)) { 1541 if (flags_Widget(w) & visualOffset_WidgetFlag &&
1533 fillRect_Paint(&p, boundsWithoutVisualOffset_Widget(w), tmBackground_ColorId); 1542 flags_Widget(w) & horizontalOffset_WidgetFlag && isVisible_Widget(w)) {
1543 fillRect_Paint(&p, boundsWithoutVisualOffset_Widget(w), tmBackground_ColorId);
1544 }
1534 } 1545 }
1535 draw_Widget(w); 1546 draw_Widget(w);
1536 if (isVisible_Widget(w)) { 1547 if (isVisible_Widget(w)) {