summaryrefslogtreecommitdiff
path: root/lib/astal/gtk3/src/widget/overlay.vala
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-10-14 16:45:03 +0000
committerAylur <[email protected]>2024-10-14 16:45:03 +0000
commit9fab13452a26ed55c01047d4225f699f43bba20d (patch)
tree8dc3097994e8664572c3a94a62257604bdaa1f8d /lib/astal/gtk3/src/widget/overlay.vala
parent6a8c41cd1d5e218d0dacffb836fdd7d4ec6333dd (diff)
feat: Astal3
Diffstat (limited to 'lib/astal/gtk3/src/widget/overlay.vala')
-rw-r--r--lib/astal/gtk3/src/widget/overlay.vala57
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/astal/gtk3/src/widget/overlay.vala b/lib/astal/gtk3/src/widget/overlay.vala
new file mode 100644
index 0000000..603ee66
--- /dev/null
+++ b/lib/astal/gtk3/src/widget/overlay.vala
@@ -0,0 +1,57 @@
+public class Astal.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);
+ }
+}