Commit e93531d9 authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko
Browse files

display-view: Use HdyFlap for the snapshots list

parent 6f884c89
Pipeline #290750 passed with stage
in 55 minutes and 39 seconds
......@@ -163,7 +163,6 @@ vala_sources = [
'ui/collection-view.vala',
'ui/collections-main-page.vala',
'ui/collections-page.vala',
'ui/display-bin.vala',
'ui/display-view.vala',
'ui/error-info-bar.vala',
'ui/flash-box.vala',
......
// This file is part of GNOME Games. License: GPL-3.0+.
public class Games.DisplayBin : Gtk.EventBox {
private int _child_width;
public int child_width {
get { return _child_width; }
set {
if (child_width == value)
return;
_child_width = value;
queue_allocate ();
}
}
public override void get_preferred_width (out int minimum, out int natural) {
var child = get_child ();
minimum = 0;
if (child != null)
child.get_preferred_width (null, out natural);
else
natural = 0;
}
public override void size_allocate (Gtk.Allocation alloc) {
base.size_allocate (alloc);
int delta = alloc.width - child_width;
var child = get_child ();
if (child != null)
child.size_allocate ({ delta / 2, 0, child_width, alloc.height });
}
}
......@@ -204,13 +204,21 @@
</object>
</child>
<child>
<object class="GtkBox" id="display_box">
<object class="HdyFlap" id="display_flap">
<property name="visible">True</property>
<child>
<property name="flap-position">end</property>
<property name="reveal-flap" bind-source="GamesDisplayView" bind-property="is-showing-snapshots" bind-flags="bidirectional|sync-create"/>
<property name="locked">True</property>
<property name="swipe-to-open">False</property>
<property name="modal">False</property>
<signal name="notify::reveal-progress" handler="maybe_resume_game"/>
<signal name="notify::reveal-flap" handler="maybe_resume_game"/>
<child type="content">
<object class="GtkOverlay">
<property name="visible">True</property>
<property name="width-request">360</property>
<child>
<object class="GamesDisplayBin" id="display_bin">
<object class="GtkEventBox" id="display_bin">
<property name="visible">True</property>
<property name="hexpand">True</property>
</object>
......@@ -223,12 +231,10 @@
</child>
</object>
</child>
<child>
<child type="flap">
<object class="GamesSnapshotsList" id="snapshots_list">
<property name="visible">True</property>
<property name="halign">end</property>
<property name="is-revealed" bind-source="GamesDisplayView" bind-property="is-showing-snapshots" bind-flags="bidirectional"/>
<signal name="hidden" handler="on_snapshots_hidden"/>
</object>
</child>
</object>
......
......@@ -29,9 +29,9 @@ private class Games.DisplayView : Gtk.Box, UiView {
[GtkChild]
private unowned Gtk.Button restart_btn;
[GtkChild]
private unowned Gtk.Box display_box;
private unowned Hdy.Flap display_flap;
[GtkChild]
private unowned DisplayBin display_bin;
private unowned Gtk.EventBox display_bin;
[GtkChild]
private unowned FullscreenBox fullscreen_box;
[GtkChild]
......@@ -82,7 +82,7 @@ private class Games.DisplayView : Gtk.Box, UiView {
if (runner == null)
return;
stack.visible_child = display_box;
stack.visible_child = display_flap;
var display = runner.get_display ();
set_display (display);
......@@ -620,8 +620,8 @@ private class Games.DisplayView : Gtk.Box, UiView {
}
[GtkCallback]
private void on_snapshots_hidden () {
if (window.is_active) {
private void maybe_resume_game () {
if (window.is_active && display_flap.reveal_progress <= 0 && !display_flap.reveal_flap) {
runner.resume ();
runner.get_display ().grab_focus ();
}
......@@ -674,8 +674,10 @@ private class Games.DisplayView : Gtk.Box, UiView {
}
private void show_snapshots () {
if (runner != null)
if (runner != null) {
is_showing_snapshots = true;
snapshots_list.reveal ();
}
}
private void restart () {
......@@ -744,12 +746,6 @@ private class Games.DisplayView : Gtk.Box, UiView {
display_bin.remove (child);
}
protected override void size_allocate (Gtk.Allocation allocation) {
display_bin.child_width = allocation.width;
base.size_allocate (allocation);
}
[GtkCallback]
private void update_fullscreen_box () {
var is_menu_open = media_button.active ||
......
......@@ -2,118 +2,109 @@
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="GamesSnapshotsList" parent="GtkBox">
<signal name="notify::is-revealed" handler="on_revealed_changed"/>
<style>
<class name="background"/>
</style>
<child>
<object class="GtkRevealer">
<object class="GtkBox">
<property name="visible">True</property>
<property name="transition-type">slide-left</property>
<property name="reveal-child" bind-source="GamesSnapshotsList" bind-property="is-revealed" bind-flags="sync-create|bidirectional"/>
<signal name="notify::child-revealed" handler="on_revealer_transition_end"/>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="vexpand">True</property>
<property name="hscrollbar-policy">never</property>
<property name="width-request">360</property>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<object class="GtkListBox" id="list_box">
<property name="visible">True</property>
<property name="vexpand">True</property>
<property name="hscrollbar-policy">never</property>
<property name="width-request">360</property>
<signal name="move-cursor" after="yes" handler="on_move_cursor"/>
<signal name="row-activated" after="yes" handler="on_row_activated"/>
<style>
<class name="sidebar"/>
</style>
<child>
<object class="GtkListBox" id="list_box">
<object class="GtkListBoxRow" id="new_snapshot_row">
<property name="visible">True</property>
<signal name="move-cursor" after="yes" handler="on_move_cursor"/>
<signal name="row-activated" after="yes" handler="on_row_activated"/>
<property name="selectable">False</property>
<style>
<class name="sidebar"/>
<class name="snapshot-row"/>
</style>
<child>
<object class="GtkListBoxRow" id="new_snapshot_row">
<object class="GtkBox">
<property name="visible">True</property>
<property name="selectable">False</property>
<style>
<class name="snapshot-row"/>
</style>
<property name="margin-top">2</property>
<property name="margin-bottom">2</property>
<property name="margin-start">2</property>
<property name="margin-end">2</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">list-add-symbolic</property>
<property name="pixel-size">32</property>
<property name="width-request">64</property>
<property name="height-request">64</property>
<property name="margin-top">7</property>
<property name="margin-bottom">7</property>
<property name="margin-start">7</property>
<property name="margin-end">7</property>
<style>
<class name="snapshot-thumbnail"/>
</style>
</object>
</child>
<child>
<object class="GtkBox">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="margin-top">2</property>
<property name="margin-bottom">2</property>
<property name="margin-start">2</property>
<property name="margin-end">2</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">list-add-symbolic</property>
<property name="pixel-size">32</property>
<property name="width-request">64</property>
<property name="height-request">64</property>
<property name="margin-top">7</property>
<property name="margin-bottom">7</property>
<property name="margin-start">7</property>
<property name="margin-end">7</property>
<style>
<class name="snapshot-thumbnail"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="margin-start">6</property>
<property name="margin-top">3</property>
<property name="margin-bottom">3</property>
<property name="margin-end">3</property>
<property name="label" translatable="yes">Create new snapshot</property>
<property name="wrap">True</property>
<style>
<class name="snapshot-name"/>
</style>
</object>
</child>
<property name="margin-start">6</property>
<property name="margin-top">3</property>
<property name="margin-bottom">3</property>
<property name="margin-end">3</property>
<property name="label" translatable="yes">Create new snapshot</property>
<property name="wrap">True</property>
<style>
<class name="snapshot-name"/>
</style>
</object>
</child>
</object>
</child>
<style>
<class name="snapshot-list"/>
</style>
</object>
</child>
<style>
<class name="snapshot-list"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkActionBar">
<property name="visible">True</property>
<child>
<object class="GtkActionBar">
<object class="GtkButton" id="delete_btn">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="delete_btn">
<property name="visible">True</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Delete</property>
<signal name="clicked" handler="on_delete_clicked"/>
<style>
<class name="destructive-action"/>
</style>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
<child>
<object class="GtkButton" id="rename_btn">
<property name="visible">True</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Rename</property>
<signal name="clicked" handler="on_rename_clicked"/>
</object>
<packing>
<property name="pack-type">start</property>
</packing>
</child>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Delete</property>
<signal name="clicked" handler="on_delete_clicked"/>
<style>
<class name="destructive-action"/>
</style>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
<child>
<object class="GtkButton" id="rename_btn">
<property name="visible">True</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Rename</property>
<signal name="clicked" handler="on_rename_clicked"/>
</object>
<packing>
<property name="pack-type">start</property>
</packing>
</child>
</object>
</child>
......
......@@ -2,8 +2,6 @@
[GtkTemplate (ui = "/org/gnome/Games/ui/snapshots-list.ui")]
private class Games.SnapshotsList : Gtk.Box {
public signal void hidden ();
[GtkChild]
private unowned Gtk.ListBox list_box;
[GtkChild]
......@@ -26,7 +24,6 @@ private class Games.SnapshotsList : Gtk.Box {
private Snapshot selected_snapshot;
public bool is_revealed { get; set; }
public Runner runner { get; set; }
construct {
......@@ -87,19 +84,10 @@ private class Games.SnapshotsList : Gtk.Box {
}
}
[GtkCallback]
private void on_revealed_changed () {
if (is_revealed) {
runner.pause ();
populate_list_box ();
select_snapshot_row (null);
}
}
[GtkCallback]
private void on_revealer_transition_end () {
if (!is_revealed)
hidden ();
public void reveal () {
runner.pause ();
populate_list_box ();
select_snapshot_row (null);
}
[GtkCallback]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment