Web mobile: Make text input dark instead of light, and don't render chat input behind it at all

This commit is contained in:
UnknownShadow200 2022-09-10 14:19:24 +10:00
parent e287e8db26
commit 3e34665941
13 changed files with 40 additions and 25 deletions

View File

@ -1376,6 +1376,7 @@ void ChatScreen_OpenInput(const cc_string* text) {
OpenKeyboardArgs_Init(&args, text, KEYBOARD_TYPE_TEXT | KEYBOARD_FLAG_SEND);
args.placeholder = "Enter chat";
Window_OpenKeyboard(&args);
s->input.base.disabled = args.opaque;
String_Copy(&s->input.base.text, text);
InputWidget_UpdateText(&s->input.base);

View File

@ -1658,23 +1658,13 @@ void TextInputWidget_SetFont(struct TextInputWidget* w, struct FontDesc* font) {
*#########################################################################################################################*/
static const cc_string chatInputPrefix = String_FromConst("> ");
static void ChatInputWidget_RemakeTexture(void* widget) {
static void ChatInputWidget_MakeTexture(struct InputWidget* w, int width, int height) {
cc_string line; char lineBuffer[STRING_SIZE + 2];
struct InputWidget* w = (struct InputWidget*)widget;
struct DrawTextArgs args;
int width = 0, height = 0;
struct Context2D ctx;
char lastCol;
int i, x, y;
for (i = 0; i < w->GetMaxLines(); i++) {
if (!w->lines[i].length) break;
height += w->lineHeight;
width = max(width, w->lineWidths[i]);
}
if (!width) width = w->prefixWidth;
if (!height) height = w->lineHeight;
Context2D_Alloc(&ctx, width, height);
DrawTextArgs_Make(&args, &chatInputPrefix, w->font, true);
@ -1701,6 +1691,27 @@ static void ChatInputWidget_RemakeTexture(void* widget) {
Context2D_MakeTexture(&w->inputTex, &ctx);
Context2D_Free(&ctx);
}
static void ChatInputWidget_RemakeTexture(void* widget) {
struct InputWidget* w = (struct InputWidget*)widget;
int width = 0, height = 0;
int i;
for (i = 0; i < w->GetMaxLines(); i++) {
if (!w->lines[i].length) break;
height += w->lineHeight;
width = max(width, w->lineWidths[i]);
}
if (!width) width = w->prefixWidth;
if (!height) height = w->lineHeight;
if (w->disabled) {
Gfx_DeleteTexture(&w->inputTex.ID);
} else {
ChatInputWidget_MakeTexture(w, width, height);
}
w->caretAccumulator = 0;
w->width = width;
@ -1716,8 +1727,8 @@ static void ChatInputWidget_Render(void* widget, double delta) {
int x = w->x, y = w->y;
cc_bool caretAtEnd;
int i, width;
if (w->disabled) return;
Gfx_SetTexturing(false);
for (i = 0; i < INPUTWIDGET_MAX_LINES; i++) {
if (i > 0 && !w->lines[i].length) break;

View File

@ -144,11 +144,11 @@ void Window_DrawFramebuffer(Rect2D r);
/* Frees the previously allocated framebuffer. */
void Window_FreeFramebuffer(struct Bitmap* bmp);
struct OpenKeyboardArgs { const cc_string* text; int type; const char* placeholder; };
struct OpenKeyboardArgs { const cc_string* text; int type; const char* placeholder; cc_bool opaque; };
void OpenKeyboardArgs_Init(struct OpenKeyboardArgs* args, STRING_REF const cc_string* text, int type);
/* Displays on-screen keyboard for platforms that lack physical keyboard input. */
/* NOTE: On desktop platforms, this won't do anything. */
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args);
void Window_OpenKeyboard(struct OpenKeyboardArgs* args);
/* Sets the text used for keyboard input. */
/* NOTE: This is only used for mobile on-screen keyboard input with the web client, */
/* because it is backed by a HTML input, rather than true keyboard input events. */

View File

@ -407,7 +407,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
Mem_Free(bmp->scan0);
}
void Window_OpenKeyboard(const struct OpenKeyboardArgs* kArgs) {
void Window_OpenKeyboard(struct OpenKeyboardArgs* kArgs) {
JNIEnv* env;
jvalue args[2];
JavaGetCurrentEnv(env);

View File

@ -646,7 +646,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
CGColorSpaceRelease(colorSpace);
}
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { }
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { }
void Window_SetKeyboardText(const cc_string* text) { }
void Window_CloseKeyboard(void) { }

View File

@ -306,7 +306,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
/* TODO: Do we still need to unlock it though? */
}
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { SDL_StartTextInput(); }
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { SDL_StartTextInput(); }
void Window_SetKeyboardText(const cc_string* text) { }
void Window_CloseKeyboard(void) { SDL_StopTextInput(); }

View File

@ -581,7 +581,7 @@ EMSCRIPTEN_KEEPALIVE void Window_OnTextChanged(const char* src) {
Event_RaiseString(&InputEvents.TextChanged, &str);
}
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) {
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) {
char str[NATIVE_STR_LEN];
keyboardOpen = true;
if (!Input_TouchMode) return;
@ -589,6 +589,7 @@ void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) {
Platform_EncodeUtf8(str, args->text);
Platform_LogConst("OPEN SESAME");
interop_OpenKeyboard(str, args->type, args->placeholder);
args->opaque = true;
}
void Window_SetKeyboardText(const cc_string* text) {

View File

@ -642,7 +642,7 @@ static void InitRawMouse(void) {
rawMouseSupported = false;
}
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { }
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { }
void Window_SetKeyboardText(const cc_string* text) { }
void Window_CloseKeyboard(void) { }

View File

@ -1085,7 +1085,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
if (bmp->scan0 != fb_data) Mem_Free(fb_data);
}
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { }
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { }
void Window_SetKeyboardText(const cc_string* text) { }
void Window_CloseKeyboard(void) { }

View File

@ -68,9 +68,10 @@ void Window_ShowDialog(const char* title, const char* msg) {
}
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->placeholder = "";
args->opaque = false;
}

View File

@ -599,7 +599,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
Mem_Free(bmp->scan0);
}
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { }
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) { }
void Window_SetKeyboardText(const cc_string* text) { }
void Window_CloseKeyboard(void) { }

View File

@ -415,7 +415,7 @@ static void LInput_SetPlaceholder(UITextField* fld, const char* placeholder);
static UITextField* text_input;
static CCKBController* kb_controller;
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) {
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) {
if (!kb_controller) {
kb_controller = [[CCKBController alloc] init];
CFBridgingRetain(kb_controller); // prevent GC TODO even needed?

View File

@ -794,7 +794,8 @@ mergeInto(LibraryManager.library, {
}
if (flags & 0x100) { elem.setAttribute('enterkeyhint', 'send'); }
elem.setAttribute('style', 'position:absolute; left:0; bottom:0; margin: 0px; width: 100%');
//elem.setAttribute('style', 'position:absolute; left:0.5%; bottom:1%; margin: 0px; width: 99%; background-color: #080808; border: none; color: white; opacity: 0.7');
elem.setAttribute('style', 'position:absolute; left:0; bottom:0; margin: 0px; width: 100%; background-color: #222222; border: none; color: white;');
elem.setAttribute('placeholder', UTF8ToString(placeholder));
elem.value = UTF8ToString(text);