[gnome-chess/arnaudb/wip/gtk4: 7/27] Adapt to DrawingArea API.




commit 876d13f9be4fbe9291918fd9d20aafd3e1600c72
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Apr 7 10:33:18 2020 +0200

    Adapt to DrawingArea API.

 src/chess-view.vala | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/src/chess-view.vala b/src/chess-view.vala
index 0731a04..cb19c05 100644
--- a/src/chess-view.vala
+++ b/src/chess-view.vala
@@ -43,6 +43,7 @@ public class ChessView : Gtk.DrawingArea
         add_events (Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK);
 
         init_mouse ();
+        set_draw_func (draw);
     }
 
     public override bool configure_event (Gdk.EventConfigure event)
@@ -111,11 +112,11 @@ public class ChessView : Gtk.DrawingArea
         loaded_theme_name = scene.theme_name;
     }
 
-    public override bool draw (Cairo.Context c)
+    private inline void draw (Gtk.DrawingArea _this, Cairo.Context c, int new_width, int new_height)
     {
         load_theme (c);
 
-        c.translate (get_allocated_width () / 2, get_allocated_height () / 2);
+        c.translate (new_width / 2, new_height / 2);
         //c.scale (s, s);
         c.rotate (Math.PI * scene.board_angle / 180.0);
 
@@ -222,7 +223,7 @@ public class ChessView : Gtk.DrawingArea
         {
             c.rotate (Math.PI * scene.board_angle / 180.0);
             draw_paused_overlay (c);
-            return true;
+            return;
         }
 
         /* Draw the pieces */
@@ -235,7 +236,7 @@ public class ChessView : Gtk.DrawingArea
 
             draw_piece (c,
                         model.is_selected ? selected_model_surface : model_surface,
-                                               model.is_selected ? selected_square_size : square_size,
+                        model.is_selected ? selected_square_size : square_size,
                         model.piece, model.under_threat && scene.show_move_hints ? 0.8 : 1.0);
 
             c.restore ();
@@ -259,8 +260,6 @@ public class ChessView : Gtk.DrawingArea
                 }
             }
         }
-
-        return true;
     }
 
     private void draw_piece (Cairo.Context c, Cairo.Surface surface, int size, ChessPiece piece, double 
alpha)


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