diff options
author | Aylur <[email protected]> | 2024-06-05 13:16:28 +0200 |
---|---|---|
committer | Aylur <[email protected]> | 2024-06-05 13:16:28 +0200 |
commit | e675e9784a20bb07d33f0feb3724a2a1f072f52b (patch) | |
tree | e9593e13571b6ec1fab8462721e61f34eee924ff /src/widget/overlay.vala | |
parent | ca74fb7ad016f9ceee3756a973baa2d87a8aa1d6 (diff) |
more widget subclasses
* levelbar
* overlay
* scrollable
* slider
Diffstat (limited to 'src/widget/overlay.vala')
-rw-r--r-- | src/widget/overlay.vala | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/widget/overlay.vala b/src/widget/overlay.vala new file mode 100644 index 0000000..4833180 --- /dev/null +++ b/src/widget/overlay.vala @@ -0,0 +1,50 @@ +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()) + remove(ch); + + add_overlay(value); + } + } + + public List<weak Gtk.Widget> overlays { + owned get { return get_children(); } + set { + foreach (var ch in get_children()) + remove(ch); + + foreach (var ch in value) + add_overlay(ch); + } + } + + public void set_child(Gtk.Widget widget) { + var ch = get_child(); + if (ch != null) { + remove(ch); + } + add(widget); + } + + 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); + } +} +} |