[retro-gtk] Add CoreView



commit 60af55bd8a53b0c3875abd4d05c27a917c288c24
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Jul 4 16:40:06 2017 +0200

    Add CoreView
    
    This will make building using retro-gtk simpler by packing many input
    and outputs into one ready to use widget.

 retro-gtk/Makefile.am          |    1 +
 retro-gtk/retro-core-view.vala |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index e056b05..91bfc82 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -56,6 +56,7 @@ libretro_gtk_la_SOURCES = \
        retro.vala \
        retro-core-descriptor.vala \
        retro-core-descriptor-error.vala \
+       retro-core-view.vala \
        retro-log.c \
        retro-module-query.vala \
        retro-module-iterator.vala \
diff --git a/retro-gtk/retro-core-view.vala b/retro-gtk/retro-core-view.vala
new file mode 100644
index 0000000..d46d55e
--- /dev/null
+++ b/retro-gtk/retro-core-view.vala
@@ -0,0 +1,39 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+public class Retro.CoreView : Gtk.EventBox {
+       private Core core;
+       private CairoDisplay display;
+       private InputDeviceManager input;
+       private Keyboard keyboard;
+       private Mouse mouse;
+
+       construct {
+               can_focus = true;
+
+               display = new CairoDisplay ();
+               display.visible = true;
+               display.can_focus = false;
+               add (display);
+
+               input = new InputDeviceManager ();
+               keyboard = new Keyboard (this);
+               mouse = new Mouse (this);
+
+               input.set_keyboard (keyboard);
+               input.set_controller_device (0, mouse);
+       }
+
+       public void set_core (Core? core) {
+               if (this.core != null) {
+                       display.set_core (null);
+                       core.input_interface = null;
+               }
+
+               this.core = core;
+
+               if (core != null) {
+                       display.set_core (core);
+                       core.input_interface = input;
+               }
+       }
+}


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