[gnome-games] gamepad-view: Stop using Rsvg.Handle.(width|height)
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] gamepad-view: Stop using Rsvg.Handle.(width|height)
- Date: Wed, 27 Nov 2019 07:01:13 +0000 (UTC)
commit 3deeaca451174d13c1cb6c27afcdc27db05d64aa
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Nov 27 12:00:34 2019 +0500
gamepad-view: Stop using Rsvg.Handle.(width|height)
Fixes https://gitlab.gnome.org/GNOME/gnome-games/issues/219
src/ui/gamepad-view.vala | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/src/ui/gamepad-view.vala b/src/ui/gamepad-view.vala
index f917f785..9412b4f3 100644
--- a/src/ui/gamepad-view.vala
+++ b/src/ui/gamepad-view.vala
@@ -26,7 +26,10 @@ private class Games.GamepadView : Gtk.DrawingArea {
critical ("Could not set up gamepad view: %s", e.message);
}
- set_size_request (handle.width, handle.height);
+ double width, height;
+ get_dimensions (out width, out height);
+
+ set_size_request ((int) width, (int) height);
input_highlights = new bool[value.input_paths.length];
reset ();
@@ -39,6 +42,21 @@ private class Games.GamepadView : Gtk.DrawingArea {
input_highlights = {};
}
+ private void get_dimensions (out double width, out double height) {
+ bool has_width, has_height, has_viewbox;
+ Rsvg.Length handle_width, handle_height;
+ Rsvg.Rectangle viewbox;
+
+ handle.get_intrinsic_dimensions (out has_width, out handle_width,
+ out has_height, out handle_height,
+ out has_viewbox, out viewbox);
+
+ assert (has_width && has_height);
+
+ width = handle_width.length;
+ height = handle_height.length;
+ }
+
public void reset () {
for (var i = 0; i < input_highlights.length; ++i)
input_highlights[i] = false;
@@ -98,12 +116,15 @@ private class Games.GamepadView : Gtk.DrawingArea {
}
private void calculate_image_dimensions (out double x, out double y, out double scale) {
- double w = get_allocated_width ();
- double h = get_allocated_height ();
+ double width = get_allocated_width ();
+ double height = get_allocated_height ();
+
+ double image_width, image_height;
+ get_dimensions (out image_width, out image_height);
- scale = double.min (h / handle.height, w / handle.width);
+ scale = double.min (height / image_height, width / image_width);
- x = (w - handle.width * scale) / 2;
- y = (h - handle.height * scale) / 2;
+ x = (width - image_width * scale) / 2;
+ y = (height - image_height * scale) / 2;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]