mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
js: Distinguish manual resizes from device pixel ratio changes
This adds a new callback, rescale_puzzle(), that's called when the device pixel ratio changes. This means that resize_puzzle() can safely set the nominal canvas size, which means that manual resizing of the puzzle now sticks. Still missing: paying attention to the device pixel ratio when choosing the initial (or reset) size.
This commit is contained in:
11
emcc.c
11
emcc.c
@ -195,8 +195,8 @@ static void resize(void)
|
||||
canvas_h = h;
|
||||
}
|
||||
|
||||
/* Called from JS when the user uses the resize handle */
|
||||
void resize_puzzle(int w, int h)
|
||||
/* Called from JS when the device pixel ratio changes */
|
||||
void rescale_puzzle(int w, int h)
|
||||
{
|
||||
midend_size(me, &w, &h, true);
|
||||
if (canvas_w != w || canvas_h != h) {
|
||||
@ -207,6 +207,13 @@ void resize_puzzle(int w, int h)
|
||||
}
|
||||
}
|
||||
|
||||
/* Called from JS when the user uses the resize handle */
|
||||
void resize_puzzle(int w, int h)
|
||||
{
|
||||
rescale_puzzle(w, h);
|
||||
js_canvas_set_nominal_size();
|
||||
}
|
||||
|
||||
/* Called from JS when the user uses the restore button */
|
||||
void restore_puzzle_size(int w, int h)
|
||||
{
|
||||
|
Reference in New Issue
Block a user