[five-or-more/gsoc-vala-port: 14/29] Split draw callback
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [five-or-more/gsoc-vala-port: 14/29] Split draw callback
- Date: Mon, 13 Aug 2018 05:50:22 +0000 (UTC)
commit ef43f6d15d340878f7ce1e11a8c8e1519646332f
Author: Ruxandra Simion <ruxandra simion93 gmail com>
Date: Wed Aug 1 21:10:50 2018 +0300
Split draw callback
src-vala/view.vala | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/src-vala/view.vala b/src-vala/view.vala
index bcf44fb..600eaf4 100644
--- a/src-vala/view.vala
+++ b/src-vala/view.vala
@@ -173,17 +173,15 @@ public class View : Gtk.DrawingArea
return true;
}
- public override bool draw (Cairo.Context cr)
+ private void fill_background (Cairo.Context cr)
{
- if (theme == null)
- return false;
-
- //fill background color
Gdk.cairo_set_source_rgba (cr, background_color);
Gdk.cairo_rectangle (cr, board_rectangle);
cr.fill ();
+ }
- // draw gridlines
+ private void draw_gridlines (Cairo.Context cr)
+ {
Gdk.RGBA grid_color = Gdk.RGBA ();
grid_color.parse ("#525F6C");
Gdk.cairo_set_source_rgba (cr, grid_color);
@@ -208,8 +206,10 @@ public class View : Gtk.DrawingArea
Gdk.cairo_rectangle (cr, line_rectangle);
cr.stroke ();
+ }
- // draw shapes
+ private void draw_shapes (Cairo.Context cr)
+ {
for (int row = 0; row < game.n_rows; row++)
{
for (int col = 0; col < game.n_cols; col++)
@@ -225,8 +225,10 @@ public class View : Gtk.DrawingArea
}
}
}
+ }
- // draw path animation
+ private void draw_path (Cairo.Context cr)
+ {
if (game.current_path != null && game.current_path.size > 0 && game.current_path_cell_pos != -1)
{
Cell current_cell = game.current_path[game.current_path_cell_pos];
@@ -237,6 +239,17 @@ public class View : Gtk.DrawingArea
current_cell.row * piece_size,
piece_size);
}
+ }
+
+ public override bool draw (Cairo.Context cr)
+ {
+ if (theme == null)
+ return false;
+
+ fill_background (cr);
+ draw_gridlines (cr);
+ draw_shapes (cr);
+ draw_path (cr);
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]