[gnome-2048] Move idle resizing to controller
- From: Juan R. Garcia Blanco <juanrgar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-2048] Move idle resizing to controller
- Date: Fri, 13 Feb 2015 23:39:03 +0000 (UTC)
commit 9890ec8c4019da90171d90c1a11e8b00fe0491b3
Author: Juan R. GarcĂa Blanco <juanrgar gmail com>
Date: Sat Feb 14 00:36:08 2015 +0100
Move idle resizing to controller
src/game.vala | 23 +++++++++++++++++++++++
src/view.vala | 15 ++++-----------
2 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/src/game.vala b/src/game.vala
index 8643a0b..96f32f4 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -52,6 +52,8 @@ public class Game : GLib.Object
private string _saved_path;
+ private uint _resize_view_id;
+
public signal void finished ();
public Game (GLib.Settings settings)
@@ -257,6 +259,27 @@ public class Game : GLib.Object
}
}
}
+
+ if (_resize_view_id == 0)
+ _resize_view_id = Clutter.Threads.Timeout.add (1000, _idle_resize_view);
+ }
+
+ private bool _idle_resize_view ()
+ {
+ int rows = _grid.rows;
+ int cols = _grid.cols;
+ for (int i = 0; i < rows; i++) {
+ for (int j = 0; j < cols; j++) {
+ _background[i,j].idle_resize ();
+
+ if (_foreground_cur[i,j] != null) {
+ _foreground_cur[i,j].idle_resize ();
+ }
+ }
+ }
+
+ _resize_view_id = 0;
+ return false;
}
private void _create_random_tile ()
diff --git a/src/view.vala b/src/view.vala
index 380913f..3d0428d 100644
--- a/src/view.vala
+++ b/src/view.vala
@@ -21,7 +21,6 @@ public class RoundedRectangle : GLib.Object
protected Clutter.Actor _actor;
protected Clutter.Canvas _canvas;
protected Clutter.Color? _color;
- protected uint _resize_id;
public RoundedRectangle (float x, float y, float width, float height, Clutter.Color? color)
{
@@ -45,8 +44,7 @@ public class RoundedRectangle : GLib.Object
private void _on_allocation_changed (Clutter.ActorBox box, Clutter.AllocationFlags flags)
{
- if (_resize_id == 0)
- Clutter.Threads.Timeout.add (1000, _idle_resize);
+ debug ("allocation changed");
}
public Clutter.Actor actor {
@@ -73,12 +71,9 @@ public class RoundedRectangle : GLib.Object
_actor.height = height;
}
- protected virtual bool _idle_resize ()
+ public void idle_resize ()
{
_canvas.invalidate ();
- _resize_id = 0;
-
- return false;
}
protected virtual bool _draw (Cairo.Context ctx, int width, int height)
@@ -133,14 +128,12 @@ public class TileView : RoundedRectangle
get; set; default = 2;
}
- protected override bool _idle_resize ()
+ public new void idle_resize ()
{
- base._idle_resize ();
+ base.idle_resize ();
_text.x = _actor.width/2.0f - _text.width/2.0f;
_text.y = _actor.height/2.0f - _text.height/2.0f;
-
- return false;
}
private Clutter.Color _pick_color ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]