[gnome-games/wip/exalm/unified-window: 48/60] fullscreen-box: Port to TitlebarBox
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/unified-window: 48/60] fullscreen-box: Port to TitlebarBox
- Date: Fri, 10 Apr 2020 14:42:34 +0000 (UTC)
commit a72340da00fbb918aae0bb8cbcca4b459c351b04
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Apr 10 16:54:32 2020 +0500
fullscreen-box: Port to TitlebarBox
This also allows to remove the snapshots list margin hack.
data/ui/display-box.ui | 8 ++++----
data/ui/fullscreen-box.ui | 14 ++------------
src/ui/display-box.vala | 14 ++------------
src/ui/fullscreen-box.vala | 23 ++++++++++++-----------
src/ui/snapshots-list.vala | 4 ----
5 files changed, 20 insertions(+), 43 deletions(-)
---
diff --git a/data/ui/display-box.ui b/data/ui/display-box.ui
index f6f76a76..537a024a 100644
--- a/data/ui/display-box.ui
+++ b/data/ui/display-box.ui
@@ -4,8 +4,9 @@
<template class="GamesDisplayBox" parent="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
- <signal name="notify::is-showing-snapshots" handler="block_autohide_changed"/>
- <signal name="notify::is-menu-open" handler="block_autohide_changed"/>
+ <signal name="notify::is-showing-snapshots" handler="update_fullscreen_box"/>
+ <signal name="notify::is-menu-open" handler="update_fullscreen_box"/>
+ <signal name="notify::is-fullscreen" handler="update_fullscreen_box"/>
<child>
<object class="GamesDisplayHeaderBar" id="header_bar">
<property name="visible">True</property>
@@ -22,9 +23,8 @@
<property name="can-fullscreen" bind-source="GamesDisplayBox" bind-property="can-fullscreen"
bind-flags="bidirectional"/>
<property name="game-title" bind-source="GamesDisplayBox" bind-property="game-title"
bind-flags="bidirectional"/>
<property name="is-showing-snapshots" bind-source="GamesDisplayBox"
bind-property="is-showing-snapshots" bind-flags="bidirectional"/>
- <signal name="notify::is-menu-open" handler="block_autohide_changed"/>
+ <signal name="notify::is-menu-open" handler="update_fullscreen_box"/>
<signal name="back" handler="on_fullscreen_header_bar_back"/>
- <signal name="size-allocate" handler="on_fullscreen_header_bar_size_allocated"/>
</object>
</child>
<child>
diff --git a/data/ui/fullscreen-box.ui b/data/ui/fullscreen-box.ui
index 66e3abe7..e7976ed6 100644
--- a/data/ui/fullscreen-box.ui
+++ b/data/ui/fullscreen-box.ui
@@ -6,19 +6,9 @@
<property name="events">pointer-motion-mask</property>
<signal name="motion-notify-event" handler="on_motion_event"/>
<child>
- <object class="GtkOverlay" id="overlay">
+ <object class="GamesTitlebarBox" id="titlebar_box">
<property name="visible">True</property>
- <child type="overlay">
- <object class="GtkRevealer" id="header_bar_revealer">
- <property name="visible" bind-source="GamesFullscreenBox" bind-property="is-fullscreen"
bind-flags="bidirectional">True</property>
- <property name="valign">start</property>
- <property name="hexpand">True</property>
- <property name="transition-type">slide-down</property>
- <property name="transition-duration">500</property>
- <property name="events">pointer-motion-mask</property>
- <signal name="motion-notify-event" handler="on_motion_event"/>
- </object>
- </child>
+ <property name="overlay" bind-source="GamesFullscreenBox" bind-property="overlay"
bind-flags="bidirectional|sync-create"/>
</object>
</child>
</template>
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index ac0983e3..2d11aafc 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -12,10 +12,6 @@ private class Games.DisplayBox : Gtk.Box {
set {
_is_fullscreen = value;
- // A top margin is added to the snapshots list in fullscreen mode
- // so that the fullscreen header bar doesn't cover it
- snapshots_list.set_margin (value ? fullscreen_header_bar_height : 0);
-
windowed_header_bar.visible = !value;
}
}
@@ -78,8 +74,6 @@ private class Games.DisplayBox : Gtk.Box {
get { return _header_bar; }
}
- private int fullscreen_header_bar_height;
-
public void display_running_game_failed (Game game, string error_message) {
stack.visible_child = error_display;
error_display.running_game_failed (game, error_message);
@@ -92,10 +86,11 @@ private class Games.DisplayBox : Gtk.Box {
}
[GtkCallback]
- public void block_autohide_changed () {
+ public void update_fullscreen_box () {
fullscreen_box.autohide = !is_menu_open &&
!fullscreen_header_bar.is_menu_open &&
!is_showing_snapshots;
+ fullscreen_box.overlay = is_fullscreen && !is_showing_snapshots;
}
[GtkCallback]
@@ -142,11 +137,6 @@ private class Games.DisplayBox : Gtk.Box {
return runner.gamepad_button_press_event (button);
}
- [GtkCallback]
- private void on_fullscreen_header_bar_size_allocated (Gtk.Allocation allocation) {
- fullscreen_header_bar_height = allocation.height;
- }
-
[GtkCallback]
private void on_snapshots_list_size_allocate (Gtk.Allocation allocation) {
display_bin.horizontal_offset = -allocation.width / 2;
diff --git a/src/ui/fullscreen-box.vala b/src/ui/fullscreen-box.vala
index 1bfce112..f8c82181 100644
--- a/src/ui/fullscreen-box.vala
+++ b/src/ui/fullscreen-box.vala
@@ -23,6 +23,8 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
}
}
+ public bool overlay { get; set; }
+
private bool _autohide = true;
public bool autohide {
get { return _autohide; }
@@ -48,7 +50,7 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
cursor_timeout_id = -1;
}
- header_bar_revealer.reveal_child = true;
+ titlebar_box.reveal_titlebar = is_fullscreen;
show_cursor (true);
}
}
@@ -76,9 +78,8 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
}
[GtkChild]
- private Gtk.Overlay overlay;
- [GtkChild]
- private Gtk.Revealer header_bar_revealer;
+ private TitlebarBox titlebar_box;
+
private Binding fullscreen_binding;
private uint ui_timeout_id;
@@ -92,17 +93,17 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
public void add_child (Gtk.Builder builder, Object child, string? type) {
var widget = child as Gtk.Widget;
- if (overlay == null || header_bar_revealer == null) {
+ if (titlebar_box == null) {
add (widget);
return;
}
if (type == "titlebar") {
- header_bar_revealer.add (widget);
+ titlebar_box.titlebar = widget;
header_bar = widget;
}
else
- overlay.add (widget);
+ titlebar_box.add (widget);
}
[GtkCallback]
@@ -128,7 +129,7 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
return;
ui_timeout_id = Timeout.add (INACTIVITY_TIME_MILLISECONDS, hide_ui);
- header_bar_revealer.reveal_child = true;
+ titlebar_box.reveal_titlebar = is_fullscreen;
}
private bool hide_ui () {
@@ -137,8 +138,8 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
if (!is_fullscreen)
return false;
- header_bar_revealer.reveal_child = false;
- overlay.grab_focus ();
+ titlebar_box.reveal_titlebar = false;
+ titlebar_box.grab_focus ();
return false;
}
@@ -172,7 +173,7 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
cursor_timeout_id = -1;
}
- header_bar_revealer.reveal_child = false;
+ titlebar_box.reveal_titlebar = false;
on_cursor_moved ();
}
diff --git a/src/ui/snapshots-list.vala b/src/ui/snapshots-list.vala
index 7d27e305..3006472e 100644
--- a/src/ui/snapshots-list.vala
+++ b/src/ui/snapshots-list.vala
@@ -33,10 +33,6 @@ private class Games.SnapshotsList : Gtk.Box {
list_box.set_header_func (update_header);
}
- public void set_margin (int margin) {
- scrolled_window.margin_top = margin;
- }
-
[GtkCallback]
private void on_move_cursor () {
var row = list_box.get_selected_row ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]