mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
js: Add a new function whereby C can ask JS for a preferred board size
Currently JS has no opinion.
This commit is contained in:
5
emcc.c
5
emcc.c
@ -83,6 +83,7 @@ extern void js_canvas_copy_to_blitter(int id, int x, int y, int w, int h);
|
|||||||
extern void js_canvas_copy_from_blitter(int id, int x, int y, int w, int h);
|
extern void js_canvas_copy_from_blitter(int id, int x, int y, int w, int h);
|
||||||
extern void js_canvas_remove_statusbar(void);
|
extern void js_canvas_remove_statusbar(void);
|
||||||
extern void js_canvas_set_statusbar(const char *text);
|
extern void js_canvas_set_statusbar(const char *text);
|
||||||
|
extern bool js_canvas_get_preferred_size(int *wp, int *hp);
|
||||||
extern void js_canvas_set_size(int w, int h);
|
extern void js_canvas_set_size(int w, int h);
|
||||||
extern double js_get_device_pixel_ratio();
|
extern double js_get_device_pixel_ratio();
|
||||||
|
|
||||||
@ -192,8 +193,10 @@ static int canvas_w, canvas_h;
|
|||||||
static void resize()
|
static void resize()
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
|
bool user;
|
||||||
w = h = INT_MAX;
|
w = h = INT_MAX;
|
||||||
midend_size(me, &w, &h, false, js_get_device_pixel_ratio());
|
user = js_canvas_get_preferred_size(&w, &h);
|
||||||
|
midend_size(me, &w, &h, user, js_get_device_pixel_ratio());
|
||||||
js_canvas_set_size(w, h);
|
js_canvas_set_size(w, h);
|
||||||
canvas_w = w;
|
canvas_w = w;
|
||||||
canvas_h = h;
|
canvas_h = h;
|
||||||
|
14
emcclib.js
14
emcclib.js
@ -563,6 +563,20 @@ mergeInto(LibraryManager.library, {
|
|||||||
statusbar.textContent = UTF8ToString(ptr);
|
statusbar.textContent = UTF8ToString(ptr);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* bool js_canvas_get_preferred_size(int *wp, int *hp);
|
||||||
|
*
|
||||||
|
* This is called before calling midend_size() to set a puzzle to
|
||||||
|
* the default size. If the JavaScript layer has an opinion about
|
||||||
|
* how big the puzzle should be, it can overwrite *wp and *hp with
|
||||||
|
* its preferred size, and return true if the "user" parameter to
|
||||||
|
* midend_size() should be true. Otherwise it should leave them
|
||||||
|
* alone and return false.
|
||||||
|
*/
|
||||||
|
js_canvas_get_preferred_size: function(wp, hp) {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void js_canvas_set_size(int w, int h);
|
* void js_canvas_set_size(int w, int h);
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user