[gnome-games/wip/exalm/ds] Add overlay button
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/ds] Add overlay button
- Date: Tue, 8 Jan 2019 20:33:30 +0000 (UTC)
commit 119a6478b9dd8271173e80b1e5b14284a959ea60
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Wed Jan 9 01:14:37 2019 +0500
Add overlay button
data/gtk-style.css | 5 +++
data/ui/display-box.ui | 8 +++-
plugins/nintendo-ds/data/nintendo-ds.gresource.xml | 1 +
plugins/nintendo-ds/data/ui/nintendo-ds-overlay.ui | 35 ++++++++++++++++++
plugins/nintendo-ds/src/meson.build | 1 +
plugins/nintendo-ds/src/nintendo-ds-overlay.vala | 43 ++++++++++++++++++++++
plugins/nintendo-ds/src/nintendo-ds-runner.vala | 7 ++++
src/command/command-runner.vala | 4 ++
src/core/runner.vala | 1 +
src/dummy/dummy-runner.vala | 4 ++
src/retro/retro-runner.vala | 4 ++
src/ui/display-box.vala | 25 ++++++++++++-
12 files changed, 136 insertions(+), 2 deletions(-)
---
diff --git a/data/gtk-style.css b/data/gtk-style.css
index 7203e785..08ca0567 100644
--- a/data/gtk-style.css
+++ b/data/gtk-style.css
@@ -30,3 +30,8 @@ stacksidebar list {
border-right-width: 0px;
}
+/* Workaround for https://gitlab.gnome.org/GNOME/gtk/issues/861 */
+.osd-circular {
+ border-radius: 9999px;
+ -gtk-outline-radius: 9999px;
+}
diff --git a/data/ui/display-box.ui b/data/ui/display-box.ui
index 2e7d8aad..9b1cb852 100644
--- a/data/ui/display-box.ui
+++ b/data/ui/display-box.ui
@@ -25,8 +25,14 @@
</packing>
</child>
<child>
- <object class="GtkEventBox" id="display_bin">
+ <object class="GtkOverlay" id="overlay">
<property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkEventBox" id="display_bin">
+ <property name="visible">True</property>
+ </object>
+ </child>
</object>
<packing>
<property name="name">display</property>
diff --git a/plugins/nintendo-ds/data/nintendo-ds.gresource.xml
b/plugins/nintendo-ds/data/nintendo-ds.gresource.xml
index 8496b28c..8d6788b6 100644
--- a/plugins/nintendo-ds/data/nintendo-ds.gresource.xml
+++ b/plugins/nintendo-ds/data/nintendo-ds.gresource.xml
@@ -1,6 +1,7 @@
<gresources>
<gresource prefix="/org/gnome/Games/plugins/nintendo-ds">
<file>ui/nintendo-ds-layout-switcher.ui</file>
+ <file>ui/nintendo-ds-overlay.ui</file>
<file>icons/screen-layout-left-right-symbolic.svg</file>
<file>icons/screen-layout-quick-switch-symbolic.svg</file>
<file>icons/screen-layout-right-left-symbolic.svg</file>
diff --git a/plugins/nintendo-ds/data/ui/nintendo-ds-overlay.ui
b/plugins/nintendo-ds/data/ui/nintendo-ds-overlay.ui
new file mode 100644
index 00000000..2614d13c
--- /dev/null
+++ b/plugins/nintendo-ds/data/ui/nintendo-ds-overlay.ui
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.16"/>
+ <template class="GamesNintendoDsOverlay" parent="GtkRevealer">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">end</property>
+ <property name="margin">24</property>
+ <property name="transition-type">crossfade</property>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="width-request">48</property>
+ <property name="height-request">48</property>
+ <signal name="clicked" handler="button_clicked"/>
+ <style>
+ <class name="osd"/>
+ <class name="osd-circular"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject">
+ <property name="accessible-name" translatable="yes">View Top Screen</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="icon">
+ <property name="visible">True</property>
+ <property name="icon-name">go-up-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/plugins/nintendo-ds/src/meson.build b/plugins/nintendo-ds/src/meson.build
index 29993a5d..8f912a58 100644
--- a/plugins/nintendo-ds/src/meson.build
+++ b/plugins/nintendo-ds/src/meson.build
@@ -1,6 +1,7 @@
vala_sources = [
'nintendo-ds-icon.vala',
'nintendo-ds-layout-switcher.vala',
+ 'nintendo-ds-overlay.vala',
'nintendo-ds-plugin.vala',
'nintendo-ds-runner.vala',
]
diff --git a/plugins/nintendo-ds/src/nintendo-ds-overlay.vala
b/plugins/nintendo-ds/src/nintendo-ds-overlay.vala
new file mode 100644
index 00000000..d3741742
--- /dev/null
+++ b/plugins/nintendo-ds/src/nintendo-ds-overlay.vala
@@ -0,0 +1,43 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/plugins/nintendo-ds/ui/nintendo-ds-overlay.ui")]
+private class Games.NintendoDsOverlay : Gtk.Revealer {
+ private Settings settings;
+
+ private bool _view_bottom_screen;
+ public bool view_bottom_screen {
+ get { return _view_bottom_screen; }
+ set {
+ _view_bottom_screen = value;
+
+ icon.icon_name = value ? "go-up-symbolic" : "go-down-symbolic";
+// valign = value ? Gtk.Align.START : Gtk.Align.END;
+ }
+ }
+
+ [GtkChild]
+ private Gtk.Image icon;
+
+ construct {
+ // Somehow this doesn't work from XML
+ transition_type = Gtk.RevealerTransitionType.CROSSFADE;
+
+ settings = new Settings ("org.gnome.Games.plugins.nintendo-ds");
+ settings.bind ("view-bottom-screen", this, "view-bottom-screen",
+ SettingsBindFlags.DEFAULT);
+ settings.changed.connect (on_settings_changed);
+ on_settings_changed ("screen-layout");
+ }
+
+ private void on_settings_changed (string key) {
+ if (key == "screen-layout") {
+ var value = settings.get_string ("screen-layout");
+ reveal_child = (value == "quick switch");
+ }
+ }
+
+ [GtkCallback]
+ private void button_clicked () {
+ view_bottom_screen = !view_bottom_screen;
+ }
+}
diff --git a/plugins/nintendo-ds/src/nintendo-ds-runner.vala b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
index dd433883..7ff61bbe 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-runner.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
@@ -105,6 +105,13 @@ private class Games.NintendoDsRunner : Object, Runner {
return new NintendoDsLayoutSwitcher ();
}
+ public Gtk.Widget? get_overlay () {
+ if (!core_supports_layouts ())
+ return null;
+
+ return new NintendoDsOverlay ();
+ }
+
public void start () throws Error {
runner.start ();
}
diff --git a/src/command/command-runner.vala b/src/command/command-runner.vala
index c70191d6..5a07edaf 100644
--- a/src/command/command-runner.vala
+++ b/src/command/command-runner.vala
@@ -49,6 +49,10 @@ public class Games.CommandRunner : Object, Runner {
return null;
}
+ public Gtk.Widget? get_overlay () {
+ return null;
+ }
+
public void start () throws Error {
string? working_directory = null;
string[]? envp = null;
diff --git a/src/core/runner.vala b/src/core/runner.vala
index c140405a..576d5394 100644
--- a/src/core/runner.vala
+++ b/src/core/runner.vala
@@ -12,6 +12,7 @@ public interface Games.Runner : Object {
public abstract bool check_is_valid (out string error_message) throws Error;
public abstract Gtk.Widget get_display ();
public abstract Gtk.Widget? get_extra_widget ();
+ public abstract Gtk.Widget? get_overlay ();
public abstract void start () throws Error;
public abstract void resume () throws Error;
public abstract void pause ();
diff --git a/src/dummy/dummy-runner.vala b/src/dummy/dummy-runner.vala
index af443a54..6cdd14aa 100644
--- a/src/dummy/dummy-runner.vala
+++ b/src/dummy/dummy-runner.vala
@@ -36,6 +36,10 @@ private class Games.DummyRunner : Object, Runner {
return null;
}
+ public Gtk.Widget? get_overlay () {
+ return null;
+ }
+
public void start () throws Error {
}
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 8b1e2a8d..60f04fb7 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -137,6 +137,10 @@ public class Games.RetroRunner : Object, Runner {
return null;
}
+ public Gtk.Widget? get_overlay () {
+ return null;
+ }
+
public void start () throws Error {
load_media_data ();
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 97e96039..a054afe7 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -14,17 +14,38 @@ private class Games.DisplayBox : Gtk.Bin {
public Runner runner {
get { return _runner; }
set {
- stack.visible_child = display_bin;
+ stack.visible_child = overlay;
_runner = value;
remove_display ();
header_bar.runner = runner;
+ overlay_widget = null;
if (runner == null)
return;
var display = runner.get_display ();
set_display (display);
+ overlay_widget = runner.get_overlay ();
+ }
+ }
+
+ private Gtk.Widget _overlay_widget;
+ private Gtk.Widget overlay_widget {
+ get { return _overlay_widget; }
+ set {
+ if (overlay_widget == value)
+ return;
+
+ if (overlay_widget != null)
+ overlay.remove (overlay_widget);
+
+ _overlay_widget = value;
+
+ if (overlay_widget != null) {
+ overlay.add_overlay (overlay_widget);
+ overlay.set_overlay_pass_through (overlay_widget, true);
+ }
}
}
@@ -35,6 +56,8 @@ private class Games.DisplayBox : Gtk.Bin {
[GtkChild]
private ErrorDisplay error_display;
[GtkChild]
+ private Gtk.Overlay overlay;
+ [GtkChild]
private Gtk.EventBox display_bin;
[GtkChild]
private DisplayHeaderBar fullscreen_header_bar;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]