Cosmetic fix for mouse-to-tile coordinate transformation.

Clicking just outside the left or top edges of the grid in Pattern
has the same effect as clicking just inside the same edge.
This happens because the FROMCOORD macro uses integer division,
which rounds towards zero rather than towards negative infinity.

One way to fix this is to add TILE_SIZE before the division
and subtract 1 afterwards.
This commit is contained in:
Bo Lindbergh
2024-12-20 18:00:53 +01:00
committed by Simon Tatham
parent 5e7400403c
commit 5099e4c6d4

View File

@ -36,7 +36,8 @@ enum {
#define GUTTER (TILE_SIZE / 2)
#define FROMCOORD(d, x) \
( ((x) - (BORDER + GUTTER + TILE_SIZE * TLBORDER(d))) / TILE_SIZE )
( ((x) - (BORDER + GUTTER + TILE_SIZE * (TLBORDER(d) - 1))) \
/ TILE_SIZE - 1)
#define SIZE(d) (2*BORDER + GUTTER + TILE_SIZE * (TLBORDER(d) + (d)))
#define GETTILESIZE(d, w) ((double)w / (2.0 + (double)TLBORDER(d) + (double)(d)))