UIDialog Class
Definition
Namespace: Brine2D.UI
Modal dialog box with customizable buttons.
Inheritance System.Object → UIDialog
Implements IUIComponent
| Constructors | |
|---|---|
| UIDialog\(string, string, Vector2\) | Creates a dialog. The dialog is centered using ScreenSize \(defaults to 1280×720\). When added to a UICanvas it will be re-centered to match the canvas's actual ScreenSize automatically. |
| Properties | |
|---|---|
| AllowEscapeClose | Pressing Escape fires OnEscapeDismissed when true. Defaults to true. |
| BackgroundColor | Background color. |
| BackgroundTexture | Optional nine-slice texture for the dialog body background. When set, replaces the solid BackgroundColor fill. |
| BackgroundTextureBorder | Nine-slice border insets \(texels\) for BackgroundTexture. |
| BackgroundTextureTint | Tint color applied to BackgroundTexture. Defaults to white. |
| BorderColor | Border color. |
| ButtonAreaHeight | Button area height. |
| ButtonHeight | Height of buttons added via AddButton\(string, Action\). Defaults to 35. |
| ButtonSpacing | Horizontal spacing between buttons added via AddButton\(string, Action\). Defaults to 10. |
| ButtonWidth | Width of buttons added via AddButton\(string, Action\). Defaults to 100. |
| CloseButtonColor | Background color of the close button. Defaults to a slightly lighter title bar shade. |
| CloseButtonHoverColor | Background color of the close button when hovered. |
| CloseButtonTextColor | Text color of the X glyph on the close button. |
| IsDraggable | When true, the dialog can be repositioned by clicking and dragging the title bar. Defaults to false. |
| Message | Dialog message text. |
| MessageMaxWidth | Maximum width for message text before wrapping \(0 = full content width\). |
| OverlayColor | Overlay color \(darkens background behind dialog\). |
| Padding | Message area padding. |
| ScreenSize | Screen size for overlay rendering. Set via CenterOnScreen\(Vector2\). |
| ShowCloseButton | Shows an X button in the top-right of the title bar that fires OnEscapeDismissed on click. Defaults to false. |
| ShowOverlay | Whether to show overlay behind dialog. |
| SuppressOverlay | When true, the overlay is suppressed during rendering. Set by UICanvas so only the topmost dialog draws the darkening overlay. |
| TextColor | Text color. |
| Title | Dialog title text. |
| TitleBarColor | Title bar color. |
| TitleBarHeight | Title bar height. |
| TitleBarTexture | Optional nine-slice texture for the title bar. When set, replaces the solid TitleBarColor fill. |
| TitleBarTextureBorder | Nine-slice border insets \(texels\) for TitleBarTexture. |
| TitleBarTextureTint | Tint color applied to TitleBarTexture. Defaults to white. |
| Methods | |
|---|---|
| AddButton\(string, Action\) | Adds a button to the dialog's button area. Buttons are laid out left-to-right in add order, centered horizontally as a group. Call RepositionButtons() after adding all buttons if you need positions to be correct before the first render. |
| AddChild\(IUIComponent\) | Adds an arbitrary UI component to the dialog's content area. Child positions are dialog-relative: (0, 0) is the top-left corner of the dialog. The component is offset by the dialog's current Brine2D.UI.UIDialog.Position during rendering and input dispatch, so it moves with the dialog when it is dragged or re-centered. |
| BringChildToFront\(IUIComponent\) | Moves a child component to the end of the render/input order so it renders on top of all other children inside the dialog. No-op if the child is not present or is already at the front. |
| CenterOnScreen\(Vector2\) | Centers the dialog on screen and updates the screen size used for overlay rendering. Called automatically by UICanvas on Add\(IUIComponent\) and whenever ScreenSize changes. |
| ClearButtons() | Removes all buttons. |
| ClearChildren() | Removes all child components added via AddChild\(IUIComponent\). Does not affect buttons added via AddButton\(string, Action\). |
| EscapeDismiss() | Called by UICanvas when Escape is pressed while this is the active modal. Fires OnEscapeDismissed if AllowEscapeClose is true. |
| GetButtons() | Gets all buttons. |
| GetChildren() | Gets all child components added via AddChild\(IUIComponent\). |
| IsOverCloseButton\(Vector2\) | Returns true when screenPosition is over the close button. |
| IsOverTitleBar\(Vector2\) | Returns true when screenPosition is within the title bar. Used by UICanvas to initiate a drag when IsDraggable is enabled. |
| ProcessButtonInput\(Vector2, bool, bool\) | Called by UICanvas to handle button input. |
| RemoveChild\(IUIComponent\) | Removes a child component previously added via AddChild\(IUIComponent\). |
| RepositionButtons() | Recomputes button positions so they are centered horizontally across the bottom of the dialog in the order they were added. Called automatically by AddButton\(string, Action\). |
| SetCloseButtonHovered\(bool\) | Updates the close button hover highlight. Called each frame by UICanvas. |
| Events | |
|---|---|
| OnEscapeDismissed | Fired when Escape is pressed and AllowEscapeClose is true, or when the close button is clicked. Typical handler: dialog.Visible = false. |