diff --git a/xwords4/wasm/main.c b/xwords4/wasm/main.c index 1e9ddf313..761cba496 100644 --- a/xwords4/wasm/main.c +++ b/xwords4/wasm/main.c @@ -1014,17 +1014,8 @@ initWindow( Globals* globals, int winWidth, int winHeight ) { // we're ready to go IFF we are inited. if ( !!globals->vtMgr ) { /* inited? */ - /* Figure height as twice width, then set to use 3/4 of it */ - int useWidth = winWidth; - int useHeight = useWidth * 2; - if ( useHeight > winHeight ) { - useHeight = winHeight; - useWidth = useHeight / 2; - } - useHeight = useHeight * 100 / 145; - - globals->useWidth = useWidth; - globals->useHeight = useHeight; + globals->useWidth = winWidth; + globals->useHeight = winHeight; if ( !!globals->window ) { SDL_DestroyRenderer(globals->renderer); @@ -1033,7 +1024,7 @@ initWindow( Globals* globals, int winWidth, int winHeight ) globals->window = NULL; } - SDL_CreateWindowAndRenderer( useWidth, useHeight, 0, + SDL_CreateWindowAndRenderer( winWidth, winHeight, 0, &globals->window, &globals->renderer ); /* wipe the canvas to background */ @@ -1041,10 +1032,11 @@ initWindow( Globals* globals, int winWidth, int winHeight ) SDL_RenderClear( globals->renderer ); if ( !!globals->draw ) { - wasm_draw_resize( globals->draw, useWidth, useHeight ); + wasm_draw_resize( globals->draw, winWidth, winHeight ); resizeBoards( globals ); } else { - globals->draw = wasm_draw_make( MPPARM(globals->mpool) useWidth, useHeight ); + globals->draw = wasm_draw_make( MPPARM(globals->mpool) + winWidth, winHeight ); } GameState* gs = getCurGame( globals ); @@ -2085,11 +2077,13 @@ gotDictBinary( GotDictProc proc, void* closure, const char* xwd, } void -onResize(void* closure, int width, int height) +onResize( void* closure, int width, int height ) { CAST_GLOB( Globals*, globals, closure ); XP_LOGFF( "width=%d, height=%d)", width, height ); initWindow( globals, width, height ); + updateGameButtons( globals ); + updateDeviceButtons( globals ); } /* On first launch, we may have an invitation. Or not. We want to ask for a diff --git a/xwords4/wasm/shell_minimal.html b/xwords4/wasm/shell_minimal.html index 40ea1fafe..a8845a851 100644 --- a/xwords4/wasm/shell_minimal.html +++ b/xwords4/wasm/shell_minimal.html @@ -13,7 +13,7 @@ margin-right: auto; } button.xwbutton { - font-size: 2.6rem; + } div.emscripten { text-align: center; } div.emscripten_border { border: 1px solid black; } @@ -73,13 +73,11 @@ border-color: #000; vertical-align: top; padding: 10px; - font-size: 2.0rem; } textarea.stringedit { height: 1em; resize: none; - font-size: 2.0rem; } @@ -96,9 +94,9 @@
-
+

-
+

diff --git a/xwords4/wasm/xwutils.js b/xwords4/wasm/xwutils.js index 6a69e1dea..8e7875fbc 100644 --- a/xwords4/wasm/xwutils.js +++ b/xwords4/wasm/xwutils.js @@ -6,6 +6,10 @@ var state = {client: null, connChangeStamp: 0, }; +function fontSize() { + return (state.height / 500) + 'rem'; +} + function ccallString(proc, closure, str) { Module.ccall('cbckString', null, ['number', 'number', 'string'], [proc, closure, str]); @@ -210,8 +214,18 @@ function jssetup(closure, dbg, devid, gitrev, now, noTabProc, focusProc, msgProc }); function callResize() { - ccall('onResize', null, ['number', 'number', 'number'], - [state.closure, window.innerWidth, window.innerHeight]); + state.width = window.innerWidth; + state.height = state.width * 2; + if ( state.height > window.innerHeight ) { + state.height = window.innerHeight; + state.width = state.height / 2; + } + state.height = state.height * 100 / 151; + + document.getElementById('nbalert').style['font-size'] = fontSize(); + + ccall('onResize', null, ['number', 'number', 'number'], + [state.closure, state.width, state.height]); } window.addEventListener('resize', function() { const innerWidth = window.innerWidth; @@ -270,6 +284,7 @@ function newButtonDiv(buttons, proc, asDivs) { let button = document.createElement('button'); button.classList.add('xwbutton'); button.textContent = buttonTxt; + button.style['font-size'] = fontSize(); button.onclick = function() { proc(ii); }; if ( asDivs ) { let bdiv = document.createElement('div'); @@ -364,6 +379,7 @@ function nbGetString(msg, dflt, proc, closure) { let tarea = document.createElement('textarea'); tarea.classList.add('stringedit'); + tarea.style['font-size'] = fontSize(); tarea.value = dflt; div.appendChild( tarea );
MQTT Dev ID: