[gnome-tetravex] Preserve keyboard highlight.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tetravex] Preserve keyboard highlight.
- Date: Wed, 16 Oct 2019 13:20:51 +0000 (UTC)
commit 46baab51ee52146931b0077698addc7d32987dcf
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Oct 16 13:17:29 2019 +0200
Preserve keyboard highlight.
src/gnome-tetravex.vala | 3 +++
src/puzzle-view.vala | 16 ++++++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/gnome-tetravex.vala b/src/gnome-tetravex.vala
index 54047cc..3cba4a8 100644
--- a/src/gnome-tetravex.vala
+++ b/src/gnome-tetravex.vala
@@ -41,6 +41,7 @@ private class Tetravex : Gtk.Application
private History history;
private PuzzleView view;
+
private Button pause_button;
private Button new_game_button;
@@ -342,6 +343,7 @@ private class Tetravex : Gtk.Application
/* align end */ true,
sizegroup);
+ new_game_button.button_press_event.connect (() => { view.disable_highlight (); return false; });
new_game_solve_stack = new Stack ();
new_game_solve_stack.add_named (solve_button, "solve");
new_game_solve_stack.add_named (new_game_button, "new-game");
@@ -696,6 +698,7 @@ private class Tetravex : Gtk.Application
has_been_solved = true;
puzzle.solve ();
new_game_solve_stack.set_visible_child_name ("new-game");
+ new_game_button.grab_focus ();
}
private bool has_been_finished = false;
diff --git a/src/puzzle-view.vala b/src/puzzle-view.vala
index 00a73dc..4f8e58d 100644
--- a/src/puzzle-view.vala
+++ b/src/puzzle-view.vala
@@ -119,8 +119,8 @@ private class PuzzleView : Gtk.DrawingArea
sockets_ys = new double [2 * _puzzle.size, _puzzle.size];
}
- clear_keyboard_highlight (/* only selection */ false);
- _puzzle.solved.connect (() => clear_keyboard_highlight (/* only selection */ false));
+ set_highlight_position ();
+ _puzzle.solved.connect (() => clear_keyboard_highlight (/* only selection */ true));
_puzzle.tile_moved.connect (tile_moved_cb);
_puzzle.notify ["paused"].connect (queue_draw);
queue_resize ();
@@ -493,7 +493,7 @@ private class PuzzleView : Gtk.DrawingArea
draw_image (context, (!) last_selected_tile);
/* Draw highlight */
- if (show_highlight)
+ if (show_highlight && !puzzle.is_solved)
{
context.save ();
context.translate (sockets_xs [highlight_x, highlight_y], sockets_ys [highlight_x, highlight_y]);
@@ -1067,7 +1067,10 @@ private class PuzzleView : Gtk.DrawingArea
if (highlight_set)
/* If keyboard highlight is already set (and visible), this is good. */
return;
-
+ set_highlight_position ();
+ }
+ private void set_highlight_position ()
+ {
// TODO better
highlight_x = puzzle.size;
highlight_y = 0;
@@ -1093,4 +1096,9 @@ private class PuzzleView : Gtk.DrawingArea
kbd_selected_y = uint8.MAX;
}
}
+
+ internal void disable_highlight ()
+ {
+ clear_keyboard_highlight (false);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]