mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 16:45:48 -04:00
Mobile: Make menu input overlay clearer and make it actually stay onscreen on an ipad (Thanks Isabella)
This commit is contained in:
parent
c8e6fb0b56
commit
0643c90f3a
21
src/Menus.c
21
src/Menus.c
@ -2043,8 +2043,12 @@ static void MenuInputOverlay_Init(void* screen) {
|
|||||||
s->maxVertices = MENUINPUT_MAX_VERTICES;
|
s->maxVertices = MENUINPUT_MAX_VERTICES;
|
||||||
|
|
||||||
TextInputWidget_Create(&s->input, 400, &s->value, s->desc);
|
TextInputWidget_Create(&s->input, 400, &s->value, s->desc);
|
||||||
ButtonWidget_Init(&s->ok, 40, MenuInputOverlay_OK);
|
|
||||||
ButtonWidget_Init(&s->Default, 200, MenuInputOverlay_Default);
|
ButtonWidget_Init(&s->Default, 200, MenuInputOverlay_Default);
|
||||||
|
#ifdef CC_BUILD_TOUCH
|
||||||
|
ButtonWidget_Init(&s->ok, Input_TouchMode ? 200 : 40, MenuInputOverlay_OK);
|
||||||
|
#else
|
||||||
|
ButtonWidget_Init(&s->ok, 40, MenuInputOverlay_OK);
|
||||||
|
#endif
|
||||||
|
|
||||||
Window_OpenKeyboard(&s->value,
|
Window_OpenKeyboard(&s->value,
|
||||||
(s->desc->VTABLE == &IntInput_VTABLE || s->desc->VTABLE == &FloatInput_VTABLE)
|
(s->desc->VTABLE == &IntInput_VTABLE || s->desc->VTABLE == &FloatInput_VTABLE)
|
||||||
@ -2078,6 +2082,19 @@ static void MenuInputOverlay_Layout(void* screen) {
|
|||||||
Widget_SetLocation(&s->input, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 110);
|
Widget_SetLocation(&s->input, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 110);
|
||||||
Widget_SetLocation(&s->ok, ANCHOR_CENTRE, ANCHOR_CENTRE, 240, 110);
|
Widget_SetLocation(&s->ok, ANCHOR_CENTRE, ANCHOR_CENTRE, 240, 110);
|
||||||
Widget_SetLocation(&s->Default, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 150);
|
Widget_SetLocation(&s->Default, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 150);
|
||||||
|
|
||||||
|
#ifdef CC_BUILD_TOUCH
|
||||||
|
if (!Input_TouchMode) return;
|
||||||
|
if (WindowInfo.SoftKeyboard == SOFT_KEYBOARD_SHIFT) {
|
||||||
|
Widget_SetLocation(&s->input, ANCHOR_CENTRE, ANCHOR_MAX, 0, 65);
|
||||||
|
Widget_SetLocation(&s->ok, ANCHOR_CENTRE, ANCHOR_MAX, 120, 25);
|
||||||
|
Widget_SetLocation(&s->Default, ANCHOR_CENTRE, ANCHOR_MAX, -120, 25);
|
||||||
|
} else {
|
||||||
|
Widget_SetLocation(&s->input, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 110);
|
||||||
|
Widget_SetLocation(&s->ok, ANCHOR_CENTRE, ANCHOR_CENTRE, 120, 150);
|
||||||
|
Widget_SetLocation(&s->Default, ANCHOR_CENTRE, ANCHOR_CENTRE, -120, 150);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MenuInputOverlay_ContextLost(void* screen) {
|
static void MenuInputOverlay_ContextLost(void* screen) {
|
||||||
@ -2306,7 +2323,7 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
|
|||||||
String_InitArray(value, valueBuffer);
|
String_InitArray(value, valueBuffer);
|
||||||
btn->GetValue(&value);
|
btn->GetValue(&value);
|
||||||
desc = &s->descs[s->activeI];
|
desc = &s->descs[s->activeI];
|
||||||
MenuInputOverlay_Show(desc, &value, MenuOptionsScreen_OnDone, false);
|
MenuInputOverlay_Show(desc, &value, MenuOptionsScreen_OnDone, Input_TouchMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MenuOptionsScreen_OnHacksChanged(void* screen) {
|
static void MenuOptionsScreen_OnHacksChanged(void* screen) {
|
||||||
|
@ -1073,7 +1073,7 @@ static void ChatScreen_Layout(void* screen) {
|
|||||||
|
|
||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
if (!Input_TouchMode) return;
|
if (!Input_TouchMode) return;
|
||||||
if (WindowInfo._preferBottom) {
|
if (WindowInfo.SoftKeyboard == SOFT_KEYBOARD_SHIFT) {
|
||||||
Widget_SetLocation(&s->send, ANCHOR_MAX, ANCHOR_MAX, 10, 60);
|
Widget_SetLocation(&s->send, ANCHOR_MAX, ANCHOR_MAX, 10, 60);
|
||||||
Widget_SetLocation(&s->cancel, ANCHOR_MAX, ANCHOR_MAX, 10, 10);
|
Widget_SetLocation(&s->cancel, ANCHOR_MAX, ANCHOR_MAX, 10, 10);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3424,7 +3424,8 @@ void Window_Init(void) {
|
|||||||
/* as the chat/send butons are positioned at the top of the canvas - they */
|
/* as the chat/send butons are positioned at the top of the canvas - they */
|
||||||
/* get pushed offscreen and can't be used at all anymore. So handle this */
|
/* get pushed offscreen and can't be used at all anymore. So handle this */
|
||||||
/* case specially by positioning them at the bottom instead for iOS. */
|
/* case specially by positioning them at the bottom instead for iOS. */
|
||||||
WindowInfo._preferBottom = EM_ASM_INT_V({ return /iPhone|iPad|iPod/i.test(navigator.userAgent); });
|
WindowInfo.SoftKeyboard = EM_ASM_INT_V({ return /iPhone|iPad|iPod/i.test(navigator.userAgent); })
|
||||||
|
? SOFT_KEYBOARD_SHIFT : SOFT_KEYBOARD_RESIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_Create(int width, int height) {
|
void Window_Create(int width, int height) {
|
||||||
@ -3911,7 +3912,7 @@ void Window_Init(void) {
|
|||||||
JavaGetCurrentEnv(env);
|
JavaGetCurrentEnv(env);
|
||||||
JavaRegisterNatives(env, methods);
|
JavaRegisterNatives(env, methods);
|
||||||
|
|
||||||
WindowInfo.SoftKeyboard = true;
|
WindowInfo.SoftKeyboard = SOFT_KEYBOARD_RESIZE;
|
||||||
Input_TouchMode = true;
|
Input_TouchMode = true;
|
||||||
DisplayInfo.Depth = 32;
|
DisplayInfo.Depth = 32;
|
||||||
DisplayInfo.ScaleX = JavaCallFloat(env, "getDpiX", "()F", NULL);
|
DisplayInfo.ScaleX = JavaCallFloat(env, "getDpiX", "()F", NULL);
|
||||||
|
@ -35,6 +35,7 @@ struct DynamicLibSym;
|
|||||||
/* The states the window can be in. */
|
/* The states the window can be in. */
|
||||||
enum WindowState { WINDOW_STATE_NORMAL, WINDOW_STATE_FULLSCREEN, WINDOW_STATE_MINIMISED };
|
enum WindowState { WINDOW_STATE_NORMAL, WINDOW_STATE_FULLSCREEN, WINDOW_STATE_MINIMISED };
|
||||||
enum KeyboardType { KEYBOARD_TYPE_TEXT, KEYBOARD_TYPE_NUMBER, KEYBOARD_TYPE_PASSWORD };
|
enum KeyboardType { KEYBOARD_TYPE_TEXT, KEYBOARD_TYPE_NUMBER, KEYBOARD_TYPE_PASSWORD };
|
||||||
|
enum SoftKeyboard { SOFT_KEYBOARD_NONE, SOFT_KEYBOARD_RESIZE, SOFT_KEYBOARD_SHIFT };
|
||||||
/* Can't name these structs Window/Display, because it conflicts with X11's Window/Display typedef */
|
/* Can't name these structs Window/Display, because it conflicts with X11's Window/Display typedef */
|
||||||
|
|
||||||
/* Data for the display monitor. */
|
/* Data for the display monitor. */
|
||||||
@ -70,9 +71,8 @@ CC_VAR extern struct _WinData {
|
|||||||
cc_bool Exists;
|
cc_bool Exists;
|
||||||
/* Whether the user is interacting with the window. */
|
/* Whether the user is interacting with the window. */
|
||||||
cc_bool Focused;
|
cc_bool Focused;
|
||||||
/* Whether the platform only supports on-screen keyboard. */
|
/* The type of on-screen keyboard this platform supports. (usually SOFT_KEYBOARD_NONE) */
|
||||||
cc_bool SoftKeyboard;
|
cc_uint8 SoftKeyboard;
|
||||||
cc_bool _preferBottom;
|
|
||||||
} WindowInfo;
|
} WindowInfo;
|
||||||
|
|
||||||
/* Initialises state for window. Also sets Display_ members. */
|
/* Initialises state for window. Also sets Display_ members. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user