Commit e3e9bb29 authored by Andrei Lisita's avatar Andrei Lisita 🎮

savestates-list: Unpause runner and grab focus after revealer finishes transition

parent 7d25d7cb
Pipeline #103472 passed with stages
in 14 minutes and 1 second
......@@ -201,10 +201,7 @@ public class Games.RetroRunner : Object, Runner {
if (previewed_savestate.has_media_data ())
media_set.selected_media_number = previewed_savestate.get_media_data ();
loop.start ();
is_ready = true;
running = true;
}
public Savestate[] get_savestates () {
......
......@@ -143,6 +143,7 @@ private class Games.DisplayHeaderBar : Gtk.Stack {
[GtkCallback]
private void on_savestates_back_clicked () {
runner.preview_current_state ();
savestates_list_state.is_revealed = false;
}
......
......@@ -65,6 +65,7 @@ private class Games.DisplayView : Object, UiView {
box = new DisplayBox (savestates_list_state);
header_bar = new DisplayHeaderBar (savestates_list_state);
savestates_list_state.on_revealer_transition_end.connect (on_savestates_list_transition_end);
box.back.connect (on_display_back);
header_bar.back.connect (on_display_back);
......@@ -421,6 +422,13 @@ private class Games.DisplayView : Object, UiView {
box.header_bar.media_set = null;
}
public void on_savestates_list_transition_end () {
if (!savestates_list_state.is_revealed && window.is_active) {
box.runner.resume ();
box.runner.get_display ().grab_focus ();
}
}
public void update_pause (bool with_delay) {
if (focus_out_timeout_id != -1) {
Source.remove ((uint) focus_out_timeout_id);
......
private class Games.SavestatesListState : Object {
public signal void load_clicked ();
public signal void delete_clicked ();
public signal void on_revealer_transition_end ();
public bool is_revealed { get; set; }
public Savestate? selected_savestate { get; set; }
......
......@@ -11,22 +11,17 @@ private class Games.SavestatesList : Gtk.Box {
[GtkChild]
private Gtk.ScrolledWindow scrolled_window;
public bool is_revealed {
get { return revealer.reveal_child; }
set { revealer.reveal_child = value; }
}
private SavestatesListState _state;
public SavestatesListState state {
get { return _state; }
set {
if (_state != null)
_state.notify["is-revealed"].disconnect (on_state_changed);
_state.notify["is-revealed"].disconnect (on_revealed_changed);
_state = value;
if (value != null) {
value.notify["is-revealed"].connect (on_state_changed);
value.notify["is-revealed"].connect (on_revealed_changed);
value.load_clicked.connect (on_load_clicked);
value.delete_clicked.connect (on_delete_clicked);
}
......@@ -61,6 +56,7 @@ private class Games.SavestatesList : Gtk.Box {
construct {
list_box.set_header_func (update_header);
revealer.notify["child-revealed"].connect (on_revealer_transition_end);
}
public void set_margin (int margin) {
......@@ -112,7 +108,7 @@ private class Games.SavestatesList : Gtk.Box {
return true;
}
private void on_state_changed () {
private void on_revealed_changed () {
revealer.reveal_child = state.is_revealed;
if (state.is_revealed) {
......@@ -121,8 +117,11 @@ private class Games.SavestatesList : Gtk.Box {
select_savestate_row (null);
}
else
runner.resume ();
// Runner isn't resumed here but after the revealer finishes the transition
}
private void on_revealer_transition_end () {
state.on_revealer_transition_end ();
}
private void on_delete_clicked () {
......
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