mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 07:31:30 -07:00
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:

committed by
Simon Tatham

parent
5e7400403c
commit
5099e4c6d4
@ -36,7 +36,8 @@ enum {
|
|||||||
#define GUTTER (TILE_SIZE / 2)
|
#define GUTTER (TILE_SIZE / 2)
|
||||||
|
|
||||||
#define FROMCOORD(d, x) \
|
#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 SIZE(d) (2*BORDER + GUTTER + TILE_SIZE * (TLBORDER(d) + (d)))
|
||||||
#define GETTILESIZE(d, w) ((double)w / (2.0 + (double)TLBORDER(d) + (double)(d)))
|
#define GETTILESIZE(d, w) ((double)w / (2.0 + (double)TLBORDER(d) + (double)(d)))
|
||||||
|
Reference in New Issue
Block a user