using Xui.Core.Canvas; using Xui.Core.Math2D; using Xui.Core.UI; using Xui.ToolKit.UI.Design; using Xui.ToolKit.UI.Widgets; public sealed class OverlayExample : Border { private IOverlay? overlay; private readonly Button action; public OverlayExample() { action = new Button { Text = "Show a note", Margin = 24, Clicked = ShowNote }; Content = new DesignSystemView(new VerticalStack { Content = [action] }); } private void ShowNote() { overlay ??= GetService(typeof(IOverlay)) as IOverlay; if (overlay is null) return; var topLeft = action.LocalToGlobal(action.Frame.TopLeft); var anchor = new Rect(topLeft, action.Frame.Size); overlay.Show(new Border { BackgroundColor = new Color(0xEADCFBFF), Padding = 20, Content = new Label { Text = "Click outside to close.", FontFamily = "Inter", FontSize = 16 } }, anchor, PopupPlacement.Below, new Size(280, 100)); } protected override void OnDeactivate() { overlay?.Dispose(); overlay = null; base.OnDeactivate(); } }