[gnome-games/wip/exalm/rebrand: 123/124] titlebar-box: Replace with HdyFlap
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/rebrand: 123/124] titlebar-box: Replace with HdyFlap
- Date: Sat, 19 Jun 2021 14:37:47 +0000 (UTC)
commit 6f884c896694b4e129badcf88b19cf76c02e509c
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat Jun 19 19:15:21 2021 +0500
titlebar-box: Replace with HdyFlap
src/gtk-style.css | 9 ++
src/meson.build | 1 -
src/ui/fullscreen-box.ui | 11 +-
src/ui/fullscreen-box.vala | 34 ++++--
src/ui/titlebar-box.vala | 270 ---------------------------------------------
5 files changed, 42 insertions(+), 283 deletions(-)
---
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 267b3c81..a04dbe40 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -127,3 +127,12 @@ window.fullscreen headerbar:backdrop {
border-color: alpha(#202020, .75);
background: image(alpha(#353535, .75));
}
+
+flap.titlebar-box dimming,
+flap.titlebar-box border,
+flap.titlebar-box outline,
+flap.titlebar-box shadow {
+ background: none;
+ min-width: 0;
+ min-height: 0;
+}
diff --git a/src/meson.build b/src/meson.build
index bf4d8b49..d0aabac0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -185,7 +185,6 @@ vala_sources = [
'ui/snapshot-row.vala',
'ui/snapshot-thumbnail.vala',
'ui/snapshots-list.vala',
- 'ui/titlebar-box.vala',
'ui/ui-view.vala',
'ui/undo-notification.vala',
diff --git a/src/ui/fullscreen-box.ui b/src/ui/fullscreen-box.ui
index e7976ed6..93d36b41 100644
--- a/src/ui/fullscreen-box.ui
+++ b/src/ui/fullscreen-box.ui
@@ -6,9 +6,16 @@
<property name="events">pointer-motion-mask</property>
<signal name="motion-notify-event" handler="on_motion_event"/>
<child>
- <object class="GamesTitlebarBox" id="titlebar_box">
+ <object class="HdyFlap" id="flap">
<property name="visible">True</property>
- <property name="overlay" bind-source="GamesFullscreenBox" bind-property="overlay"
bind-flags="bidirectional|sync-create"/>
+ <property name="orientation">vertical</property>
+ <property name="locked">True</property>
+ <property name="modal">False</property>
+ <property name="swipe-to-open">False</property>
+ <property name="swipe-to-close">False</property>
+ <style>
+ <class name="titlebar-box"/>
+ </style>
</object>
</child>
</template>
diff --git a/src/ui/fullscreen-box.vala b/src/ui/fullscreen-box.vala
index 99425855..12354ff5 100644
--- a/src/ui/fullscreen-box.vala
+++ b/src/ui/fullscreen-box.vala
@@ -23,7 +23,21 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
}
}
- public bool overlay { get; set; }
+ private bool _overlay;
+ public bool overlay {
+ get { return _overlay; }
+ set {
+ if (value == overlay)
+ return;
+
+ _overlay = value;
+
+ if (flap == null)
+ return;
+
+ flap.fold_policy = overlay ? Hdy.FlapFoldPolicy.ALWAYS : Hdy.FlapFoldPolicy.NEVER;
+ }
+ }
private bool _autohide = true;
public bool autohide {
@@ -50,14 +64,14 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
cursor_timeout_id = -1;
}
- titlebar_box.reveal_titlebar = true;
+ flap.reveal_flap = true;
show_cursor (true);
}
}
}
[GtkChild]
- private unowned TitlebarBox titlebar_box;
+ private unowned Hdy.Flap flap;
private uint ui_timeout_id;
private uint cursor_timeout_id;
@@ -70,15 +84,15 @@ 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 (titlebar_box == null) {
+ if (flap == null) {
add (widget);
return;
}
if (type == "titlebar")
- titlebar_box.titlebar = widget;
+ flap.flap = widget;
else
- titlebar_box.add (widget);
+ flap.content = widget;
}
[GtkCallback]
@@ -104,7 +118,7 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
return;
ui_timeout_id = Timeout.add (INACTIVITY_TIME_MILLISECONDS, hide_ui);
- titlebar_box.reveal_titlebar = true;
+ flap.reveal_flap = true;
}
private bool hide_ui () {
@@ -113,8 +127,8 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
if (!is_fullscreen)
return false;
- titlebar_box.reveal_titlebar = false;
- titlebar_box.grab_focus ();
+ flap.reveal_flap = false;
+ flap.grab_focus ();
return false;
}
@@ -150,7 +164,7 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
// This is needed when restoring via a keyboard shortcut when the
// titlebar is concealed.
- titlebar_box.reveal_titlebar = true;
+ flap.reveal_flap = true;
on_cursor_moved ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]