[gnome-sudoku] Set an earmark instead of the value if earmark picker is active



commit 1e8ebc849807df0e227c7a8f90f69b17c93e0d40
Author: shak-mar <shakmar openmailbox org>
Date:   Sun Jul 7 17:31:42 2019 +0200

    Set an earmark instead of the value if earmark picker is active
    
    If you left-click, a value picker opens;  if you right-click, an earmark
    picker opens.  Let's call the resulting states "value mode" and "earmark
    mode".
    
    Before this commit, this was the mapping from user input to action:
    
                                    value mode                  earmark mode
    ------------------------------------------------------------------------
    click number                    set value                   set earmark
    press (keyboard) number         set value                   *set value*
    ctrl-press (keyboard) number    set earmark                 set earmark
    
    This commit changes the entry marked with *stars* to become "set
    earmark":  If the user right-clicked to enter earmark mode, pressing a
    number should set an earmark.
    
    Note that I do not propose to change the "set earmark" in value mode if
    the user presses control:  In that case, the explicit (because ctrl is
    pressed) intent of the user is to set an earmark.
    
    This enables a hybrid mouse-keyboard usage of the application:  Use the
    mouse to select which cell you want to edit (faster than arrow keys),
    and use the keypad on your keyboard to select which number you want to
    put there (faster than clicking the number).
    
    Previously, if you wanted to select a cell with the mouse and then set
    an earmark, you would need to press control on the keyboard too, which
    is very uncomfortable.

 src/sudoku-view.vala | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/sudoku-view.vala b/src/sudoku-view.vala
index c6323a1..68d6517 100644
--- a/src/sudoku-view.vala
+++ b/src/sudoku-view.vala
@@ -284,7 +284,9 @@ private class SudokuCellView : Gtk.DrawingArea
             k_no = key_map_keypad (k_name);
         if (k_no >= 1 && k_no <= 9)
         {
-            if ((event.state & ModifierType.CONTROL_MASK) > 0 && game.mode == GameMode.PLAY)
+            bool want_earmark = (earmark_picker != null && earmark_picker.is_visible())
+                || (event.state & ModifierType.CONTROL_MASK) > 0;
+            if (want_earmark && game.mode == GameMode.PLAY)
             {
                 var new_state = !game.board.is_earmark_enabled (row, col, k_no);
                 if (earmark_picker == null)


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