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




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

    Tmp 2.

 src/game-actionbar.vala  | 10 +++++-----
 src/game-board-view.vala | 15 +++------------
 src/history-button.vala  | 14 ++------------
 3 files changed, 10 insertions(+), 29 deletions(-)
---
diff --git a/src/game-actionbar.vala b/src/game-actionbar.vala
index 3b7bf34..dc53fcf 100644
--- a/src/game-actionbar.vala
+++ b/src/game-actionbar.vala
@@ -118,11 +118,11 @@ private class GameActionBarPlaceHolder : Widget, AdaptativeWidget
     private Gdk.Toplevel surface;
     private inline void init_state_watcher ()
     {
-        Gdk.Surface? nullable_surface = ((Gtk.Native) actionbar).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);
+//        Gdk.Surface? nullable_surface = ((Gtk.Native) actionbar).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)
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..f8c8991 100644
--- a/src/history-button.vala
+++ b/src/history-button.vala
@@ -47,7 +47,6 @@ private class HistoryButton : ToggleButton, AdaptativeWidget
         BinLayout layout = new BinLayout ();
         set_layout_manager (layout);
 
-        drawing.map.connect (init_state_watcher);
         drawing.set_draw_func (update_drawing);
         theme_manager.theme_changed.connect (() => {
                 if (!drawing_configured)
@@ -89,17 +88,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 +118,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]