mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Clean up the behaviour of drags off the edge of the grid. These have
always been a convenient way to cancel a drag you decided was an error, but now it's more obvious that this is the case. [originally from svn r5941]
This commit is contained in:
13
rect.c
13
rect.c
@ -2138,11 +2138,11 @@ static void coord_round(float x, float y, int *xr, int *yr)
|
|||||||
/* Vertical edge: x-coord of corner,
|
/* Vertical edge: x-coord of corner,
|
||||||
* y-coord of square centre. */
|
* y-coord of square centre. */
|
||||||
*xr = 2 * (int)xv;
|
*xr = 2 * (int)xv;
|
||||||
*yr = 1 + 2 * (int)ys;
|
*yr = 1 + 2 * (int)floor(ys);
|
||||||
} else {
|
} else {
|
||||||
/* Horizontal edge: x-coord of square centre,
|
/* Horizontal edge: x-coord of square centre,
|
||||||
* y-coord of corner. */
|
* y-coord of corner. */
|
||||||
*xr = 1 + 2 * (int)xs;
|
*xr = 1 + 2 * (int)floor(xs);
|
||||||
*yr = 2 * (int)yv;
|
*yr = 2 * (int)yv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2233,6 +2233,8 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds,
|
|||||||
ui->dragged = TRUE;
|
ui->dragged = TRUE;
|
||||||
active = TRUE;
|
active = TRUE;
|
||||||
|
|
||||||
|
if (xc >= 0 && xc <= 2*from->w &&
|
||||||
|
yc >= 0 && yc <= 2*from->h) {
|
||||||
ui->x1 = ui->drag_start_x;
|
ui->x1 = ui->drag_start_x;
|
||||||
ui->x2 = ui->drag_end_x;
|
ui->x2 = ui->drag_end_x;
|
||||||
if (ui->x2 < ui->x1) { t = ui->x1; ui->x1 = ui->x2; ui->x2 = t; }
|
if (ui->x2 < ui->x1) { t = ui->x1; ui->x1 = ui->x2; ui->x2 = t; }
|
||||||
@ -2245,7 +2247,12 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds,
|
|||||||
ui->x2 = (ui->x2+1) / 2; /* rounds up */
|
ui->x2 = (ui->x2+1) / 2; /* rounds up */
|
||||||
ui->y1 = ui->y1 / 2; /* rounds down */
|
ui->y1 = ui->y1 / 2; /* rounds down */
|
||||||
ui->y2 = (ui->y2+1) / 2; /* rounds up */
|
ui->y2 = (ui->y2+1) / 2; /* rounds up */
|
||||||
|
} else {
|
||||||
|
ui->x1 = -1;
|
||||||
|
ui->y1 = -1;
|
||||||
|
ui->x2 = -1;
|
||||||
|
ui->y2 = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
|
Reference in New Issue
Block a user