[hitori] Allow toggling both tags on a cell simultaneously



commit ea0270a9a9e152b9a9bcef88c2096dbfd70eca75
Author: Philip Withnall <philip tecnocode co uk>
Date:   Fri Nov 12 00:25:54 2010 +0000

    Allow toggling both tags on a cell simultaneously
    
    This also adds a new type of undo/redo event corresponding to toggling both
    tags simultaneously.

 src/interface.c |   15 ++++++++++++++-
 src/main.h      |    3 ++-
 2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/interface.c b/src/interface.c
index 4086fa4..6b53e5a 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -264,7 +264,12 @@ hitori_button_release_cb (GtkWidget *drawing_area, GdkEventButton *event, Hitori
 	undo->undo = hitori->undo_stack;
 	undo->redo = NULL;
 
-	if (event->state & GDK_SHIFT_MASK) {
+	if (event->state & GDK_SHIFT_MASK && event->state & GDK_CONTROL_MASK) {
+		/* Update both tags' state */
+		hitori->board[pos.x][pos.y].status ^= CELL_TAG1;
+		hitori->board[pos.x][pos.y].status ^= CELL_TAG2;
+		undo->type = UNDO_TAGS;
+	} else if (event->state & GDK_SHIFT_MASK) {
 		/* Update tag 1's state */
 		hitori->board[pos.x][pos.y].status ^= CELL_TAG1;
 		undo->type = UNDO_TAG1;
@@ -439,6 +444,10 @@ hitori_undo_cb (GtkAction *action, Hitori *hitori)
 		case UNDO_TAG2:
 			hitori->board[hitori->undo_stack->cell.x][hitori->undo_stack->cell.y].status ^= CELL_TAG2;
 			break;
+		case UNDO_TAGS:
+			hitori->board[hitori->undo_stack->cell.x][hitori->undo_stack->cell.y].status ^= CELL_TAG1;
+			hitori->board[hitori->undo_stack->cell.x][hitori->undo_stack->cell.y].status ^= CELL_TAG2;
+			break;
 		case UNDO_NEW_GAME:
 		default:
 			/* This is just here to stop the compiler warning */
@@ -477,6 +486,10 @@ hitori_redo_cb (GtkAction *action, Hitori *hitori)
 		case UNDO_TAG2:
 			hitori->board[hitori->undo_stack->cell.x][hitori->undo_stack->cell.y].status ^= CELL_TAG2;
 			break;
+		case UNDO_TAGS:
+			hitori->board[hitori->undo_stack->cell.x][hitori->undo_stack->cell.y].status ^= CELL_TAG1;
+			hitori->board[hitori->undo_stack->cell.x][hitori->undo_stack->cell.y].status ^= CELL_TAG2;
+			break;
 		case UNDO_NEW_GAME:
 		default:
 			/* This is just here to stop the compiler warning */
diff --git a/src/main.h b/src/main.h
index d27d1bd..d04b7a3 100644
--- a/src/main.h
+++ b/src/main.h
@@ -36,7 +36,8 @@ typedef enum {
 	UNDO_NEW_GAME,
 	UNDO_PAINT,
 	UNDO_TAG1,
-	UNDO_TAG2
+	UNDO_TAG2,
+	UNDO_TAGS /* = UNDO_TAG1 and UNDO_TAG2 */
 } HitoriUndoType;
 
 typedef struct _HitoriUndo HitoriUndo;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]