diff options
author | Aylur <[email protected]> | 2024-09-01 02:06:50 +0200 |
---|---|---|
committer | Aylur <[email protected]> | 2024-09-01 02:06:50 +0200 |
commit | 0738194780ce52b9047c430b9498487417b2cd07 (patch) | |
tree | e0cdbcbc31ccbe1620a5f228f18fead658487652 /core/src/widget/overlay.vala | |
parent | 49cdf5d5e010c9abb9b02034999eef2f49f066b9 (diff) |
move libastal to /core
starting point of the monorepo
Diffstat (limited to 'core/src/widget/overlay.vala')
-rw-r--r-- | core/src/widget/overlay.vala | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/core/src/widget/overlay.vala b/core/src/widget/overlay.vala new file mode 100644 index 0000000..207aaa7 --- /dev/null +++ b/core/src/widget/overlay.vala @@ -0,0 +1,59 @@ +namespace Astal { +public class Overlay : Gtk.Overlay { + public bool pass_through { get; set; } + + public Gtk.Widget? overlay { + get { return overlays.nth_data(0); } + set { + foreach (var ch in get_children()) { + if (ch != child) + remove(ch); + } + + if (value != null) + add_overlay(value); + } + } + + public List<weak Gtk.Widget> overlays { + owned get { return get_children(); } + set { + foreach (var ch in get_children()) { + if (ch != child) + remove(ch); + } + + foreach (var ch in value) + add_overlay(ch); + } + } + + public new Gtk.Widget? child { + get { return get_child(); } + set { + var ch = get_child(); + if (ch != null) + remove(ch); + + if (value != null) + add(value); + } + } + + construct { + notify["pass-through"].connect(() => { + update_pass_through(); + }); + } + + private void update_pass_through() { + foreach (var child in get_children()) + set_overlay_pass_through(child, pass_through); + } + + public new void add_overlay(Gtk.Widget widget) { + base.add_overlay(widget); + set_overlay_pass_through(widget, pass_through); + } +} +} |