[gnome-taquin] Use configure event.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-taquin] Use configure event.
- Date: Thu, 2 Jan 2020 12:05:43 +0000 (UTC)
commit 0941ec5e07ffb90355e77e0766ec4d69c4ba5b2e
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Dec 30 16:12:23 2019 +0100
Use configure event.
src/taquin-view.vala | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/src/taquin-view.vala b/src/taquin-view.vala
index c8a0da2..d5c4f29 100644
--- a/src/taquin-view.vala
+++ b/src/taquin-view.vala
@@ -43,16 +43,6 @@ private class TaquinView : Gtk.DrawingArea
[CCode (notify = false)] private int x_offset { get { return (get_allocated_width () - board_size) / 2
- grid_border_main; }}
[CCode (notify = false)] private int y_offset { get { return (get_allocated_height () - board_size) / 2
- grid_border_main; }}
- private void calculate ()
- {
- var size = int.min (get_allocated_width (), get_allocated_height ());
- /* tile_size includes a grid spacing */
- tile_size = (size * 10 / 12) / game.size;
- board_size = tile_size * game.size - GRID_SPACING;
- grid_border_main = (size - board_size) / 2;
- arrows = size / 100;
- }
-
/* Arrows (or lights) place */
private int8 x_arrow = 0;
private int8 y_arrow = 0;
@@ -99,6 +89,7 @@ private class TaquinView : Gtk.DrawingArea
draw_lights = false;
x_arrow = 0;
y_arrow = 0;
+ configure ();
((!) _game).move.connect (move_cb);
((!) _game).complete.connect (complete_cb);
queue_draw ();
@@ -119,13 +110,24 @@ private class TaquinView : Gtk.DrawingArea
}
}
- protected override bool draw (Cairo.Context cr)
+ protected override bool configure_event (Gdk.EventConfigure e)
{
-// if (game == null)
-// return false;
+ configure ();
+ return true;
+ }
- calculate ();
+ private void configure ()
+ {
+ var size = int.min (get_allocated_width (), get_allocated_height ());
+ /* tile_size includes a grid spacing */
+ tile_size = (size * 10 / 12) / game.size;
+ board_size = tile_size * game.size - GRID_SPACING;
+ grid_border_main = (size - board_size) / 2;
+ arrows = size / 100;
+ }
+ protected override bool draw (Cairo.Context cr)
+ {
if (tiles_pattern == null || render_size != tile_size)
{
render_size = tile_size;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]