Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(MediaViewer): media_buttons revealer #372

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/Views/MediaViewer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ public class Tuba.Views.MediaViewer : Gtk.Box {
gesture.scale_changed.connect ((zm) => safe_get ((int) carousel.position)?.zoom (zm));
add_controller (gesture);

var motion = new Gtk.EventControllerMotion ();
motion.motion.connect (on_motion);
add_controller (motion);

orientation = Gtk.Orientation.VERTICAL;
spacing = 0;

Expand Down Expand Up @@ -299,6 +303,25 @@ public class Tuba.Views.MediaViewer : Gtk.Box {
message ("Destroying MediaViewer");
}

protected void on_motion (double x, double y) {
on_reveal_media_buttons ();
}

uint revealer_timeout = 0;
protected void on_reveal_media_buttons () {
media_buttons_revealer.set_reveal_child (true);

if (revealer_timeout > 0) GLib.Source.remove (revealer_timeout);
revealer_timeout = Timeout.add (5 * 1000, on_hide_media_buttons, Priority.LOW);
}

protected bool on_hide_media_buttons () {
media_buttons_revealer.set_reveal_child (false);
revealer_timeout = 0;

return GLib.Source.REMOVE;
}

protected bool on_keypress (uint keyval, uint keycode, Gdk.ModifierType state) {
// Don't handle it if there's
// a modifier
Expand Down Expand Up @@ -501,7 +524,8 @@ public class Tuba.Views.MediaViewer : Gtk.Box {

private Gtk.Button zoom_out_btn;
private Gtk.Button zoom_in_btn;
private Gtk.Box generate_media_buttons () {
private Gtk.Revealer media_buttons_revealer;
private Gtk.Widget generate_media_buttons () {
var media_buttons = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
hexpand = true,
valign = Gtk.Align.END,
Expand Down Expand Up @@ -583,7 +607,13 @@ public class Tuba.Views.MediaViewer : Gtk.Box {
media_buttons.append (page_btns);
media_buttons.append (zoom_btns);

return media_buttons;
media_buttons_revealer = new Gtk.Revealer () {
child = media_buttons,
transition_type = Gtk.RevealerTransitionType.CROSSFADE,
valign = Gtk.Align.END
};

return media_buttons_revealer;
}

public void on_zoom_change () {
Expand Down