mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Virtual keyboard: Push slightly upwards to avoid overlapping chat
This commit is contained in:
parent
3e8fc0ddcf
commit
454637f0a1
@ -1551,6 +1551,7 @@ void ChatScreen_OpenInput(const cc_string* text) {
|
||||
OpenKeyboardArgs_Init(&args, text, KEYBOARD_TYPE_TEXT | KEYBOARD_FLAG_SEND);
|
||||
args.placeholder = "Enter chat";
|
||||
args.multiline = true;
|
||||
args.yOffset = 30;
|
||||
OnscreenKeyboard_Open(&args);
|
||||
|
||||
Widget_SetDisabled(&s->input.base, args.opaque);
|
||||
|
@ -18,6 +18,7 @@ static float kb_padXAcc, kb_padYAcc;
|
||||
static char kb_buffer[512];
|
||||
static cc_string kb_str = String_FromArray(kb_buffer);
|
||||
static void (*KB_MarkDirty)(void);
|
||||
static int kb_yOffset;
|
||||
|
||||
#define KB_TILE_SIZE 32
|
||||
static int kb_tileWidth = KB_TILE_SIZE;
|
||||
@ -173,7 +174,7 @@ static void VirtualKeyboard_Draw(struct Context2D* ctx) {
|
||||
|
||||
static void VirtualKeyboard_CalcPosition(int* x, int* y, int width, int height) {
|
||||
/* Draw virtual keyboard at centre of window bottom */
|
||||
*y = height - 1 - VirtualKeyboard_Height();
|
||||
*y = height - 1 - VirtualKeyboard_Height() - kb_yOffset;
|
||||
if (*y < 0) *y = 0;
|
||||
|
||||
*x = (width - VirtualKeyboard_Width()) / 2;
|
||||
@ -410,6 +411,7 @@ static void VirtualKeyboard_Open(struct OpenKeyboardArgs* args, cc_bool launcher
|
||||
kb_padXAcc = 0;
|
||||
kb_padYAcc = 0;
|
||||
kb_shift = false;
|
||||
kb_yOffset = args->yOffset;
|
||||
|
||||
int mode = args->type & 0xFF;
|
||||
int num = mode == KEYBOARD_TYPE_INTEGER || mode == KEYBOARD_TYPE_NUMBER;
|
||||
|
12
src/Window.h
12
src/Window.h
@ -201,10 +201,16 @@ void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp);
|
||||
/* Frees the previously allocated framebuffer. */
|
||||
void Window_FreeFramebuffer(struct Bitmap* bmp);
|
||||
|
||||
struct OpenKeyboardArgs { const cc_string* text; int type; const char* placeholder; cc_bool opaque, multiline; };
|
||||
struct OpenKeyboardArgs {
|
||||
const cc_string* text;
|
||||
int type, yOffset;
|
||||
const char* placeholder;
|
||||
cc_bool opaque, multiline;
|
||||
};
|
||||
static CC_INLINE void OpenKeyboardArgs_Init(struct OpenKeyboardArgs* args, STRING_REF const cc_string* text, int type) {
|
||||
args->text = text;
|
||||
args->type = type;
|
||||
args->text = text;
|
||||
args->type = type;
|
||||
args->yOffset = 0;
|
||||
args->placeholder = "";
|
||||
args->opaque = false;
|
||||
args->multiline = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user