[iagno] Split draw_highlight method.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Split draw_highlight method.
- Date: Mon, 15 Jul 2019 21:43:16 +0000 (UTC)
commit 4702420e1dc2e81c38890c55a2280d6b89e2b143
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Jun 5 20:22:32 2019 +0200
Split draw_highlight method.
src/game-view.vala | 55 ++++++++++++++++++++++++++++++------------------------
1 file changed, 31 insertions(+), 24 deletions(-)
---
diff --git a/src/game-view.vala b/src/game-view.vala
index 5a17a73..b3a16f3 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -355,30 +355,7 @@ private class GameView : Gtk.DrawingArea
}
cr.fill ();
- if (!game.is_complete // TODO highlight last played tile on game.is_complete, even if it's
the opponent one...
- && (highlight_x == x && highlight_y == y)
- && (show_highlight || highlight_state != 0))
- {
- /* manage animated highlight */
- if (show_highlight && highlight_state != HIGHLIGHT_MAX)
- {
- highlight_state ++;
- queue_draw_area (board_x + tile_x, board_y + tile_y, tile_size, tile_size);
- }
- else if (!show_highlight && highlight_state != 0)
- highlight_state = 0; // TODO highlight_state--; on mouse click, conflict updating
coords & showing the anim on previous place
-
- /* draw animated highlight */
- cr.set_source_rgba (highlight_red, highlight_green, highlight_blue, highlight_alpha);
- rounded_square (cr,
- // TODO odd/even sizes problem
- tile_x + tile_size * (HIGHLIGHT_MAX - highlight_state) / (2 *
HIGHLIGHT_MAX),
- tile_y + tile_size * (HIGHLIGHT_MAX - highlight_state) / (2 *
HIGHLIGHT_MAX),
- tile_size * highlight_state / HIGHLIGHT_MAX,
- 0,
- background_radius);
- cr.fill ();
- }
+ draw_highlight (cr, x, y, tile_x, tile_y);
/* draw pieces */
if (pixmaps [x, y] == 0)
@@ -398,6 +375,36 @@ private class GameView : Gtk.DrawingArea
return false;
}
+ private void draw_highlight (Cairo.Context cr, uint8 x, uint8 y, int tile_x, int tile_y)
+ {
+ if (game.is_complete) // TODO highlight last played tile on game.is_complete, even if it's the
opponent one...
+ return;
+ if (highlight_x != x || highlight_y != y)
+ return;
+ if (!show_highlight && highlight_state == 0)
+ return;
+
+ /* manage animated highlight */
+ if (show_highlight && highlight_state != HIGHLIGHT_MAX)
+ {
+ highlight_state ++;
+ queue_draw_area (board_x + tile_x, board_y + tile_y, tile_size, tile_size);
+ }
+ else if (!show_highlight && highlight_state != 0)
+ highlight_state = 0; // TODO highlight_state--; on mouse click, conflict updating coords &
showing the anim on previous place
+
+ /* draw animated highlight */
+ cr.set_source_rgba (highlight_red, highlight_green, highlight_blue, highlight_alpha);
+ rounded_square (cr,
+ // TODO odd/even sizes problem
+ tile_x + tile_size * (HIGHLIGHT_MAX - highlight_state) / (2 * HIGHLIGHT_MAX),
+ tile_y + tile_size * (HIGHLIGHT_MAX - highlight_state) / (2 * HIGHLIGHT_MAX),
+ tile_size * highlight_state / HIGHLIGHT_MAX,
+ 0,
+ background_radius);
+ cr.fill ();
+ }
+
private const double HALF_PI = Math.PI / 2.0;
private void rounded_square (Cairo.Context cr, double x, double y, int size, double width, double
radius_percent)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]