summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-01-01 15:22:43 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-01-01 15:22:43 +0200
commit3e371f7ea70b1c2e06e1af50c3b41efdecbd072b (patch)
tree05189b169ead7fa147c888a7cca90a2b1d8dbb8c /src/ui
parent5d247c7fafddcb46d83572af788a04f835d48d42 (diff)
Android: Fixed root sizing; clip menu not showing; toolbar buttons
The keyboard height was miscalculated if there were system keys under the window.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/root.c15
-rw-r--r--src/ui/util.c6
-rw-r--r--src/ui/window.c20
-rw-r--r--src/ui/window.h7
4 files changed, 33 insertions, 15 deletions
diff --git a/src/ui/root.c b/src/ui/root.c
index 31176115..5ec63e91 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -1534,19 +1534,10 @@ void createUserInterface_Root(iRoot *d) {
1534 arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag | 1534 arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag |
1535 commandOnClick_WidgetFlag | 1535 commandOnClick_WidgetFlag |
1536 drawBackgroundToBottom_WidgetFlag, iTrue); 1536 drawBackgroundToBottom_WidgetFlag, iTrue);
1537#if defined (iPlatformAndroidMobile)
1538 /* Android has a system-provided back button (or gesture?), or in the toolbar we can have
1539 a different in the place of Back. */
1540 setId_Widget(addChildFlags_Widget(toolBar,
1541 iClob(newLargeIcon_LabelWidget(close_Icon, "tabs.close")),
1542 frameless_WidgetFlag),
1543 "toolbar.close");
1544#else
1545 setId_Widget(addChildFlags_Widget(toolBar, 1537 setId_Widget(addChildFlags_Widget(toolBar,
1546 iClob(newLargeIcon_LabelWidget("", "...")), 1538 iClob(newLargeIcon_LabelWidget("", "...")),
1547 frameless_WidgetFlag), 1539 frameless_WidgetFlag),
1548 "toolbar.action1"); 1540 "toolbar.action1");
1549#endif
1550 setId_Widget(addChildFlags_Widget(toolBar, 1541 setId_Widget(addChildFlags_Widget(toolBar,
1551 iClob(newLargeIcon_LabelWidget("", "...")), 1542 iClob(newLargeIcon_LabelWidget("", "...")),
1552 frameless_WidgetFlag), 1543 frameless_WidgetFlag),
@@ -1638,6 +1629,12 @@ void createUserInterface_Root(iRoot *d) {
1638 { select_Icon " ${menu.selectall}", 0, 0, "input.selectall" }, 1629 { select_Icon " ${menu.selectall}", 0, 0, "input.selectall" },
1639 }, 8); 1630 }, 8);
1640#endif 1631#endif
1632 if (deviceType_App() == phone_AppDeviceType) {
1633 /* Small screen; conserve space by removing the Cancel item. */
1634 iRelease(removeChild_Widget(clipMenu, lastChild_Widget(clipMenu)));
1635 iRelease(removeChild_Widget(clipMenu, lastChild_Widget(clipMenu)));
1636 iRelease(removeChild_Widget(clipMenu, lastChild_Widget(clipMenu)));
1637 }
1641 iWidget *splitMenu = makeMenu_Widget(root, (iMenuItem[]){ 1638 iWidget *splitMenu = makeMenu_Widget(root, (iMenuItem[]){
1642 { "${menu.split.merge}", '1', 0, "ui.split arg:0" }, 1639 { "${menu.split.merge}", '1', 0, "ui.split arg:0" },
1643 { "${menu.split.swap}", SDLK_x, 0, "ui.split swap:1" }, 1640 { "${menu.split.swap}", SDLK_x, 0, "ui.split swap:1" },
diff --git a/src/ui/util.c b/src/ui/util.c
index 6add5c89..c590caa9 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1204,6 +1204,9 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) {
1204 leftExcess += l; 1204 leftExcess += l;
1205 rightExcess += r; 1205 rightExcess += r;
1206 } 1206 }
1207#elif defined (iPlatformMobile)
1208 /* Reserve space for the keyboard. */
1209 bottomExcess += get_MainWindow()->keyboardHeight;
1207#endif 1210#endif
1208 if (!allowOverflow) { 1211 if (!allowOverflow) {
1209 if (bottomExcess > 0 && (!isPortraitPhone || !isSlidePanel)) { 1212 if (bottomExcess > 0 && (!isPortraitPhone || !isSlidePanel)) {
@@ -2495,8 +2498,9 @@ iWidget *makePreferences_Widget(void) {
2495 }; 2498 };
2496 const iMenuItem colorPanelItems[] = { 2499 const iMenuItem colorPanelItems[] = {
2497 { "title id:heading.prefs.colors" }, 2500 { "title id:heading.prefs.colors" },
2498 //{ "heading id:heading.prefs.uitheme" }, 2501#if !defined (iPlatformAndroidMobile)
2499 { "toggle id:prefs.ostheme" }, 2502 { "toggle id:prefs.ostheme" },
2503#endif
2500 { "radio id:prefs.theme", 0, 0, (const void *) themeItems }, 2504 { "radio id:prefs.theme", 0, 0, (const void *) themeItems },
2501 { "radio id:prefs.accent", 0, 0, (const void *) accentItems }, 2505 { "radio id:prefs.accent", 0, 0, (const void *) accentItems },
2502 { "heading id:heading.prefs.pagecontent" }, 2506 { "heading id:heading.prefs.pagecontent" },
diff --git a/src/ui/window.c b/src/ui/window.c
index 953d5ea4..ef941798 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -606,6 +606,7 @@ void init_MainWindow(iMainWindow *d, iRect rect) {
606#endif 606#endif
607 setCurrent_Text(d->base.text); 607 setCurrent_Text(d->base.text);
608 SDL_GetRendererOutputSize(d->base.render, &d->base.size.x, &d->base.size.y); 608 SDL_GetRendererOutputSize(d->base.render, &d->base.size.x, &d->base.size.y);
609 d->maxDrawableHeight = d->base.size.y;
609 setupUserInterface_MainWindow(d); 610 setupUserInterface_MainWindow(d);
610 postCommand_App("~bindings.changed"); /* update from bindings */ 611 postCommand_App("~bindings.changed"); /* update from bindings */
611 /* Load the border shadow texture. */ { 612 /* Load the border shadow texture. */ {
@@ -1011,8 +1012,19 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) {
1011 if (event.type == SDL_USEREVENT && isCommand_UserEvent(ev, "window.sysframe") && mw) { 1012 if (event.type == SDL_USEREVENT && isCommand_UserEvent(ev, "window.sysframe") && mw) {
1012 /* This command is sent on Android to update the keyboard height. */ 1013 /* This command is sent on Android to update the keyboard height. */
1013 const char *cmd = command_UserEvent(ev); 1014 const char *cmd = command_UserEvent(ev);
1014 setKeyboardHeight_MainWindow(mw, argLabel_Command(cmd, "fullheight") - 1015 /*
1015 argLabel_Command(cmd, "bottom")); 1016 0
1017 |
1018 top
1019 | |
1020 | bottom (top of keyboard) :
1021 | | : keyboardHeight
1022 maxDrawableHeight :
1023 |
1024 fullheight
1025 */
1026 setKeyboardHeight_MainWindow(mw, argLabel_Command(cmd, "top") +
1027 mw->maxDrawableHeight - argLabel_Command(cmd, "bottom"));
1016 return iTrue; 1028 return iTrue;
1017 } 1029 }
1018 if (processEvent_Touch(&event)) { 1030 if (processEvent_Touch(&event)) {
@@ -1245,11 +1257,15 @@ void draw_MainWindow(iMainWindow *d) {
1245 isDrawing_ = iTrue; 1257 isDrawing_ = iTrue;
1246 setCurrent_Text(d->base.text); 1258 setCurrent_Text(d->base.text);
1247 /* Check if root needs resizing. */ { 1259 /* Check if root needs resizing. */ {
1260 const iBool wasPortrait = isPortrait_App();
1248 iInt2 renderSize; 1261 iInt2 renderSize;
1249 SDL_GetRendererOutputSize(w->render, &renderSize.x, &renderSize.y); 1262 SDL_GetRendererOutputSize(w->render, &renderSize.x, &renderSize.y);
1250 if (!isEqual_I2(renderSize, w->size)) { 1263 if (!isEqual_I2(renderSize, w->size)) {
1251 updateSize_MainWindow_(d, iTrue); 1264 updateSize_MainWindow_(d, iTrue);
1252 processEvents_App(postedEventsOnly_AppEventMode); 1265 processEvents_App(postedEventsOnly_AppEventMode);
1266 if (isPortrait_App() != wasPortrait) {
1267 d->maxDrawableHeight = renderSize.y;
1268 }
1253 } 1269 }
1254 } 1270 }
1255 const int winFlags = SDL_GetWindowFlags(d->base.win); 1271 const int winFlags = SDL_GetWindowFlags(d->base.win);
diff --git a/src/ui/window.h b/src/ui/window.h
index ae111f4c..b4e348d2 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -116,7 +116,8 @@ struct Impl_MainWindow {
116 iString * pendingSplitUrl; /* URL to open in a newly opened split */ 116 iString * pendingSplitUrl; /* URL to open in a newly opened split */
117 iString * pendingSplitOrigin; /* tab from where split was initiated, if any */ 117 iString * pendingSplitOrigin; /* tab from where split was initiated, if any */
118 SDL_Texture * appIcon; 118 SDL_Texture * appIcon;
119 int keyboardHeight; /* mobile software keyboards */ 119 int keyboardHeight; /* mobile software keyboards */
120 int maxDrawableHeight;
120}; 121};
121 122
122iLocalDef enum iWindowType type_Window(const iAnyWindow *d) { 123iLocalDef enum iWindowType type_Window(const iAnyWindow *d) {
@@ -187,10 +188,10 @@ void setKeyboardHeight_MainWindow (iMainWindow *, int height);
187void setSplitMode_MainWindow (iMainWindow *, int splitMode); 188void setSplitMode_MainWindow (iMainWindow *, int splitMode);
188void checkPendingSplit_MainWindow (iMainWindow *); 189void checkPendingSplit_MainWindow (iMainWindow *);
189void swapRoots_MainWindow (iMainWindow *); 190void swapRoots_MainWindow (iMainWindow *);
190void showToolbars_MainWindow (iMainWindow *, iBool show); 191//void showToolbars_MainWindow (iMainWindow *, iBool show);
191void resize_MainWindow (iMainWindow *, int w, int h); 192void resize_MainWindow (iMainWindow *, int w, int h);
192 193
193iBool processEvent_MainWindow (iMainWindow *, const SDL_Event *); 194//iBool processEvent_MainWindow (iMainWindow *, const SDL_Event *);
194void draw_MainWindow (iMainWindow *); 195void draw_MainWindow (iMainWindow *);
195void drawWhileResizing_MainWindow (iMainWindow *, int w, int h); /* workaround for SDL bug */ 196void drawWhileResizing_MainWindow (iMainWindow *, int w, int h); /* workaround for SDL bug */
196 197