Commit 90b7cf63 authored by Andrey Kutejko's avatar Andrey Kutejko

Do not draw focused or highlighted cell when board is not in focus

parent 99699e3e
Pipeline #201389 passed with stages
in 3 minutes and 10 seconds
......@@ -334,7 +334,7 @@ private class SudokuCellView : DrawingArea
public override bool draw (Cairo.Context c)
{
RGBA background_color;
if (_selected)
if (_selected && is_focus)
background_color = selected_bg_color;
else if (is_fixed)
background_color = fixed_cell_color;
......@@ -465,15 +465,21 @@ public class SudokuView : AspectFrame
private DrawingArea drawing;
private Grid grid;
private int selected_row = 0;
private int selected_col = 0;
private int selected_row = -1;
private int selected_col = -1;
private void set_selected (int cell_row, int cell_col)
{
cells[selected_row, selected_col].selected = false;
cells[selected_row, selected_col].queue_draw ();
if (selected_row >= 0 && selected_col >= 0)
{
cells[selected_row, selected_col].selected = false;
cells[selected_row, selected_col].queue_draw ();
}
selected_row = cell_row;
selected_col = cell_col;
cells[selected_row, selected_col].selected = true;
if (selected_row >= 0 && selected_col >= 0)
{
cells[selected_row, selected_col].selected = true;
}
}
public SudokuView (SudokuGame game)
......@@ -545,7 +551,8 @@ public class SudokuView : AspectFrame
for (var col_tmp = 0; col_tmp < game.board.cols; col_tmp++)
{
for (var row_tmp = 0; row_tmp < game.board.rows; row_tmp++) {
for (var row_tmp = 0; row_tmp < game.board.rows; row_tmp++)
{
cells[row_tmp, col_tmp].highlighted = _highlighter && (
col_tmp == cell_col ||
row_tmp == cell_row ||
......@@ -560,6 +567,25 @@ public class SudokuView : AspectFrame
return false;
});
cell.focus_out_event.connect (() => {
if (game.paused)
return false;
this.set_selected (-1, -1);
for (var col_tmp = 0; col_tmp < game.board.cols; col_tmp++)
{
for (var row_tmp = 0; row_tmp < game.board.rows; row_tmp++)
{
cells[row_tmp, col_tmp].highlighted = false;
}
}
queue_draw ();
return false;
});
cell.notify["value"].connect ((s, p)=> {
if (_show_possibilities || _show_warnings || game.board.broken || previous_board_broken_state)
previous_board_broken_state = game.board.broken;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment