[gnome-taquin/arnaudb/wip/gtk4: 37/56] Make TaquinView a Widget subclass.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-taquin/arnaudb/wip/gtk4: 37/56] Make TaquinView a Widget subclass.
- Date: Wed, 30 Sep 2020 13:55:33 +0000 (UTC)
commit 94b5a011789c0bf2337f615336d5f76fedc8138c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Apr 18 18:18:35 2020 +0200
Make TaquinView a Widget subclass.
src/taquin-view.vala | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/src/taquin-view.vala b/src/taquin-view.vala
index 5380fff..5a6625b 100644
--- a/src/taquin-view.vala
+++ b/src/taquin-view.vala
@@ -29,7 +29,7 @@ private enum Direction
NONE;
}
-private class TaquinView : Gtk.DrawingArea
+private class TaquinView : Gtk.Widget
{
/* Theme */
private const int GRID_SPACING = 1;
@@ -63,13 +63,29 @@ private class TaquinView : Gtk.DrawingArea
private bool finished = false;
private double animation_end_offset;
+ private Gtk.DrawingArea drawing;
+
+ protected override void snapshot (Gtk.Snapshot snap)
+ {
+ drawing.queue_draw ();
+ snapshot_child (drawing, snap);
+ }
+
construct
{
- can_focus = true;
+ Gtk.BinLayout layout = new Gtk.BinLayout ();
+ set_layout_manager (layout);
+
+ drawing = new Gtk.DrawingArea ();
+ drawing.hexpand = true;
+ drawing.vexpand = true;
+ drawing.insert_after (this, /* insert first */ null);
+
init_mouse ();
init_keyboard ();
- set_draw_func (draw);
- size_allocate.connect (on_size_allocate);
+
+ drawing.set_draw_func (draw);
+ drawing.size_allocate.connect (on_size_allocate);
}
private Game? _game = null;
@@ -124,7 +140,7 @@ private class TaquinView : Gtk.DrawingArea
private void configure ()
{
- var size = int.min (get_allocated_width (), get_allocated_height ());
+ var size = int.min (drawing.get_allocated_width (), drawing.get_allocated_height ());
/* tile_size includes a grid spacing */
tile_size = (size * 10 / 12) / game.size;
board_size = tile_size * game.size - GRID_SPACING;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]