[retro-gtk/pointer: 1/4] video: Add get_coordinates_on_display()
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/pointer: 1/4] video: Add get_coordinates_on_display()
- Date: Sat, 29 Jul 2017 11:57:53 +0000 (UTC)
commit 406427bab612ac9995077ddf1f581ce823257874
Author: Adrien Plazas <kekun plazas laposte net>
Date: Tue Jul 25 12:10:30 2017 +0200
video: Add get_coordinates_on_display()
This will be used to support the Libretro pointer controllers.
retro-gtk/video/cairo-display.vala | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/retro-gtk/video/cairo-display.vala b/retro-gtk/video/cairo-display.vala
index 5302b78..19c271a 100644
--- a/retro-gtk/video/cairo-display.vala
+++ b/retro-gtk/video/cairo-display.vala
@@ -39,6 +39,17 @@ public class Retro.CairoDisplay : Gtk.DrawingArea {
queue_draw ();
}
+ public bool get_coordinates_on_display (double widget_x, double widget_y, out double display_x, out
double display_y) {
+ double w, h, x, y;
+ get_video_box (out w, out h, out x, out y);
+
+ // Return coordinates as a [-1.0,1.0] scale, (0.0,0.0) is the center.
+ display_x = ((widget_x-x) * 2.0 - w) / w;
+ display_y = ((widget_y-y) * 2.0 - h) / h;
+
+ return (-1.0 <= display_x <= 1.0) && (-1.0 <= display_y <= 1.0);
+ }
+
private void on_video_output (uint8[] data, uint width, uint height, size_t pitch, PixelFormat
pixel_format, float aspect_ratio) {
this.aspect_ratio = aspect_ratio;
pixbuf = gdk_pixbuf_new_from_video (data, width, height, pitch, pixel_format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]