[gnome-taquin/arnaudb/wip/gtk4: 47/56] The size-allocate signal is gone.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-taquin/arnaudb/wip/gtk4: 47/56] The size-allocate signal is gone.
- Date: Wed, 30 Sep 2020 13:55:33 +0000 (UTC)
commit 3cb3c2c2b9549eb20493e7f0f5035d54b689ca2a
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Sep 29 17:34:33 2020 +0200
The size-allocate signal is gone.
src/taquin-view.vala | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/src/taquin-view.vala b/src/taquin-view.vala
index 4bdef1e..b8d7953 100644
--- a/src/taquin-view.vala
+++ b/src/taquin-view.vala
@@ -90,7 +90,6 @@ private class TaquinView : Gtk.Widget
init_keyboard ();
drawing.set_draw_func (draw);
- drawing.size_allocate.connect (on_size_allocate);
}
private Game? _game = null;
@@ -116,7 +115,6 @@ private class TaquinView : Gtk.Widget
x_arrow = 0;
y_arrow = 0;
tiles_pattern = null;
- configure ();
((!) _game).move.connect (move_cb);
((!) _game).complete.connect (complete_cb);
drawing.queue_draw ();
@@ -140,14 +138,17 @@ private class TaquinView : Gtk.Widget
}
}
- private inline void on_size_allocate ()
+ private int old_width = 0;
+ private int old_height = 0;
+ private inline void configure (int new_width, int new_height)
{
- configure ();
- }
+ if (old_width == new_width
+ && old_height == new_height)
+ return;
+ old_width = new_width;
+ old_height = new_height;
- private void configure ()
- {
- var size = int.min (drawing.get_allocated_width (), drawing.get_allocated_height ());
+ var size = int.min (new_width, new_height);
/* tile_size includes a grid spacing */
tile_size = (size * 10 / 12) / game.size;
board_size = tile_size * game.size - GRID_SPACING;
@@ -157,6 +158,7 @@ private class TaquinView : Gtk.Widget
private void draw (Gtk.DrawingArea _this, Cairo.Context cr, int width, int height)
{
+ configure (width, height);
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]