-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use overlaybar style, cleanup * ZoomOverlay: use overlaybar * Remove extra styles
- Loading branch information
1 parent
8fabe6c
commit 2166ef3
Showing
2 changed files
with
41 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,44 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io) | ||
*/ | ||
|
||
public class Terminal.Widgets.ZoomOverlay : Granite.Widgets.OverlayBar { | ||
private int visible_duration; | ||
private uint timer_id; | ||
private bool will_hide; | ||
|
||
public ZoomOverlay (Gtk.Overlay overlay) { | ||
base (overlay); | ||
} | ||
|
||
namespace Terminal.Widgets { | ||
|
||
public class ZoomOverlay : Gtk.Bin { | ||
private Gtk.Overlay overlay; | ||
private Gtk.Revealer revealer; | ||
private Gtk.Label zoom_label; | ||
private int visible_duration; | ||
private uint timer_id; | ||
private bool will_hide; | ||
|
||
construct { | ||
overlay = new Gtk.Overlay (); | ||
|
||
revealer = new Gtk.Revealer () { | ||
hexpand = false, | ||
vexpand = false, | ||
halign = Gtk.Align.CENTER, | ||
valign = Gtk.Align.CENTER, | ||
transition_type = Gtk.RevealerTransitionType.CROSSFADE | ||
}; | ||
|
||
zoom_label = new Gtk.Label ("") { | ||
use_markup = true | ||
}; | ||
|
||
revealer.add (zoom_label); | ||
overlay.add_overlay (revealer); | ||
overlay.set_overlay_pass_through (revealer, true); | ||
|
||
visible_duration = 1500; | ||
will_hide = false; | ||
construct { | ||
visible_duration = 1500; | ||
will_hide = false; | ||
} | ||
|
||
add (overlay); | ||
show_all (); | ||
} | ||
public void show_zoom_level (double zoom_level) { | ||
label = _("Zoom: %.0f%%").printf (zoom_level * 100); | ||
show (); | ||
|
||
public void add_overlay_child (Gtk.Widget child) { | ||
overlay.add (child); | ||
if (will_hide) { | ||
GLib.Source.remove (timer_id); | ||
} | ||
|
||
public void show_zoom_level (double zoom_level) { | ||
revealer.reveal_child = true; | ||
zoom_label.label = "<span face='monospaced' size='24pt' alpha='20000'><b>%.0f%%</b></span>".printf (zoom_level * 100); | ||
|
||
if (will_hide) { | ||
GLib.Source.remove (timer_id); | ||
} | ||
|
||
will_hide = true; | ||
timer_id = GLib.Timeout.add (visible_duration, () => { | ||
revealer.reveal_child = false; | ||
will_hide = false; | ||
return false; | ||
}); | ||
} | ||
will_hide = true; | ||
timer_id = GLib.Timeout.add (visible_duration, () => { | ||
hide (); | ||
will_hide = false; | ||
return false; | ||
}); | ||
} | ||
|
||
public void hide_zoom_level () { | ||
revealer.reveal_child = false; | ||
if (will_hide) { | ||
will_hide = false; | ||
GLib.Source.remove (timer_id); | ||
} | ||
public void hide_zoom_level () { | ||
hide (); | ||
if (will_hide) { | ||
will_hide = false; | ||
GLib.Source.remove (timer_id); | ||
} | ||
|
||
} | ||
|
||
} |