[four-in-a-row/arnaudb/wip/gtk4] Tmp 2.



commit 623a1ebc9eafaa0b61040d1e269a02dcf4426123
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Sep 26 17:53:00 2020 +0200

    Tmp 2.

 src/game-board-view.vala | 15 +++------------
 src/history-button.vala  | 13 ++-----------
 2 files changed, 5 insertions(+), 23 deletions(-)
---
diff --git a/src/game-board-view.vala b/src/game-board-view.vala
index 809abda..ab94386 100644
--- a/src/game-board-view.vala
+++ b/src/game-board-view.vala
@@ -43,7 +43,6 @@ private class GameBoardView : Gtk.DrawingArea
 
         init_mouse ();
         set_draw_func (draw);
-        map.connect (init_state_watcher);
     }
 
     protected override bool focus (Gtk.DirectionType direction)
@@ -84,17 +83,7 @@ private class GameBoardView : Gtk.DrawingArea
 //                                     tile_size);
     }
 
-    private Gdk.Toplevel surface;
-    private inline void init_state_watcher ()
-    {
-        Gdk.Surface? nullable_surface = ((Gtk.Native) this).get_surface ();
-        if (nullable_surface == null || !((!) nullable_surface is Gdk.Toplevel))
-            assert_not_reached ();
-        surface = (Gdk.Toplevel) (!) nullable_surface;
-        surface.size_changed.connect (on_size_changed);
-    }
-
-    private inline void on_size_changed (Gdk.Surface _surface, int width, int height)
+    private inline void configure_view (int width, int height)
     {
         int size = int.min (width, height);
         tile_size = size / game_board.size;
@@ -118,6 +107,8 @@ private class GameBoardView : Gtk.DrawingArea
 
     private inline void draw (Gtk.DrawingArea _this, Cairo.Context cr, int new_width, int new_height)
     {
+        configure_view (new_width, new_height);
+
         /* background */
         cr.save ();
         cr.translate (board_x, board_y);
diff --git a/src/history-button.vala b/src/history-button.vala
index 6efc1ee..b676783 100644
--- a/src/history-button.vala
+++ b/src/history-button.vala
@@ -89,17 +89,7 @@ private class HistoryButton : ToggleButton, AdaptativeWidget
 
     private Gdk.Pixbuf tileset_pixbuf;
 
-    private Gdk.Toplevel surface;
-    private inline void init_state_watcher ()
-    {
-        Gdk.Surface? nullable_surface = ((Gtk.Native) drawing).get_surface ();
-        if (nullable_surface == null || !((!) nullable_surface is Gdk.Toplevel))
-            assert_not_reached ();
-        surface = (Gdk.Toplevel) (!) nullable_surface;
-        surface.size_changed.connect (on_size_changed);
-    }
-
-    private inline void on_size_changed (Gdk.Surface _surface, int width, int height)
+    private inline void configure_drawing (int width, int height)
     {
         int new_height      = (int) double.min (height, width / 2.0);
 
@@ -129,6 +119,7 @@ private class HistoryButton : ToggleButton, AdaptativeWidget
     {
         if (!drawing_configured)
             return;
+        configure_drawing (new_width, new_height);
 
         draw_arrow (cr);
         draw_piece (cr);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]