mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Rectangles: cancel keyboard drag with Escape.
This commit is contained in:

committed by
Simon Tatham

parent
c469bd285c
commit
e59f820383
@ -786,7 +786,8 @@ around the board. Pressing the return key then allows you to use the
|
|||||||
cursor keys to drag a rectangle out from that position, and pressing
|
cursor keys to drag a rectangle out from that position, and pressing
|
||||||
the return key again completes the rectangle. Using the space bar
|
the return key again completes the rectangle. Using the space bar
|
||||||
instead of the return key allows you to erase the contents of a
|
instead of the return key allows you to erase the contents of a
|
||||||
rectangle without affecting its edges, as above.
|
rectangle without affecting its edges, as above. Pressing escape
|
||||||
|
cancels a drag.
|
||||||
|
|
||||||
When a rectangle of the correct size is completed, it will be shaded.
|
When a rectangle of the correct size is completed, it will be shaded.
|
||||||
|
|
||||||
@ -2922,6 +2923,7 @@ pressing Space does the same as a right button click. Moving with the
|
|||||||
cursor keys while holding Shift will place dots in all squares that
|
cursor keys while holding Shift will place dots in all squares that
|
||||||
are moved through.
|
are moved through.
|
||||||
|
|
||||||
|
|
||||||
(All the actions described in \k{common-actions} are also available.)
|
(All the actions described in \k{common-actions} are also available.)
|
||||||
|
|
||||||
\H{range-parameters} \I{parameters, for Range}Range parameters
|
\H{range-parameters} \I{parameters, for Range}Range parameters
|
||||||
|
48
rect.c
48
rect.c
@ -2187,18 +2187,24 @@ struct game_ui {
|
|||||||
int cur_x, cur_y, cur_visible, cur_dragging;
|
int cur_x, cur_y, cur_visible, cur_dragging;
|
||||||
};
|
};
|
||||||
|
|
||||||
static game_ui *new_ui(const game_state *state)
|
static void reset_ui(game_ui *ui)
|
||||||
{
|
{
|
||||||
game_ui *ui = snew(game_ui);
|
|
||||||
ui->drag_start_x = -1;
|
ui->drag_start_x = -1;
|
||||||
ui->drag_start_y = -1;
|
ui->drag_start_y = -1;
|
||||||
ui->drag_end_x = -1;
|
ui->drag_end_x = -1;
|
||||||
ui->drag_end_y = -1;
|
ui->drag_end_y = -1;
|
||||||
ui->dragged = ui->erasing = FALSE;
|
|
||||||
ui->x1 = -1;
|
ui->x1 = -1;
|
||||||
ui->y1 = -1;
|
ui->y1 = -1;
|
||||||
ui->x2 = -1;
|
ui->x2 = -1;
|
||||||
ui->y2 = -1;
|
ui->y2 = -1;
|
||||||
|
ui->dragged = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static game_ui *new_ui(const game_state *state)
|
||||||
|
{
|
||||||
|
game_ui *ui = snew(game_ui);
|
||||||
|
reset_ui(ui);
|
||||||
|
ui->erasing = FALSE;
|
||||||
ui->cur_x = ui->cur_y = ui->cur_visible = ui->cur_dragging = 0;
|
ui->cur_x = ui->cur_y = ui->cur_visible = ui->cur_dragging = 0;
|
||||||
return ui;
|
return ui;
|
||||||
}
|
}
|
||||||
@ -2381,21 +2387,8 @@ static char *interpret_move(const game_state *from, game_ui *ui,
|
|||||||
coord_round(FROMCOORD((float)x), FROMCOORD((float)y), &xc, &yc);
|
coord_round(FROMCOORD((float)x), FROMCOORD((float)y), &xc, &yc);
|
||||||
|
|
||||||
if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
|
if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
|
||||||
if (ui->drag_start_x >= 0 && ui->cur_dragging) {
|
if (ui->drag_start_x >= 0 && ui->cur_dragging)
|
||||||
/*
|
reset_ui(ui); /* cancel keyboard dragging */
|
||||||
* If a keyboard drag is in progress, unceremoniously
|
|
||||||
* cancel it.
|
|
||||||
*/
|
|
||||||
ui->drag_start_x = -1;
|
|
||||||
ui->drag_start_y = -1;
|
|
||||||
ui->drag_end_x = -1;
|
|
||||||
ui->drag_end_y = -1;
|
|
||||||
ui->x1 = -1;
|
|
||||||
ui->y1 = -1;
|
|
||||||
ui->x2 = -1;
|
|
||||||
ui->y2 = -1;
|
|
||||||
ui->dragged = FALSE;
|
|
||||||
}
|
|
||||||
startdrag = TRUE;
|
startdrag = TRUE;
|
||||||
ui->cur_visible = ui->cur_dragging = FALSE;
|
ui->cur_visible = ui->cur_dragging = FALSE;
|
||||||
active = TRUE;
|
active = TRUE;
|
||||||
@ -2439,6 +2432,15 @@ static char *interpret_move(const game_state *from, game_ui *ui,
|
|||||||
startdrag = TRUE;
|
startdrag = TRUE;
|
||||||
active = TRUE;
|
active = TRUE;
|
||||||
}
|
}
|
||||||
|
} else if (button == '\b' || button == 27) {
|
||||||
|
if (!ui->cur_dragging) {
|
||||||
|
ui->cur_visible = FALSE;
|
||||||
|
} else {
|
||||||
|
assert(ui->cur_visible);
|
||||||
|
reset_ui(ui); /* cancel keyboard dragging */
|
||||||
|
ui->cur_dragging = FALSE;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
} else if (button != LEFT_DRAG && button != RIGHT_DRAG) {
|
} else if (button != LEFT_DRAG && button != RIGHT_DRAG) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2515,15 +2517,7 @@ static char *interpret_move(const game_state *from, game_ui *ui,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->drag_start_x = -1;
|
reset_ui(ui);
|
||||||
ui->drag_start_y = -1;
|
|
||||||
ui->drag_end_x = -1;
|
|
||||||
ui->drag_end_y = -1;
|
|
||||||
ui->x1 = -1;
|
|
||||||
ui->y1 = -1;
|
|
||||||
ui->x2 = -1;
|
|
||||||
ui->y2 = -1;
|
|
||||||
ui->dragged = FALSE;
|
|
||||||
active = TRUE;
|
active = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user