Constructors
Widget() Widget(Widget parent, Boolean isDarkWindow) The default widget constructor
parent — The parent to attach this to. This can be null while you're sorting stuff out, before you add it to a layout or something - but generally a null parent is something a window has. isDarkWindow — If true we'll run a function on startup to force this to be a darkmode window. Basically pass true if this is going to be a window and we'll all be friends. Properties
| Name | Type | Description |
|---|---|---|
Enabled | Boolean | Makes the widget not interactable. This is also usually be reflected visually by the widget. The widget will not process any keyboard or mouse inputs. Applies retroactively to all children. |
ReadOnly virtual | Boolean | Makes the widget read only. I.e. You can copy text of a text entry, but can't edit it. Applies retroactively to all children. |
Parent | Widget | Parent widget. If non null, position of this widget will be relative to the parent widget. Certain events will also propagate to the parent widget if unhandled. |
ContentMargins | Margin | |
ContentRect | Rect | |
Size | Vector2 | Size of this widget. |
LocalRect | Rect | This panel's rect at 0,0 |
ScreenRect | Rect | This panel's rect in screen coordinates |
Width | Single | Utility to interact with a widget's width - use Size where possible |
Height | Single | Utility to interact with a widget's width - use Size where possible |
MinimumSize | Vector2 | Sets MinimumWidth and MinimumHeight simultaneously. |
MinimumWidth | Single | This widgets width should never be smaller than the given value. |
MinimumHeight | Single | This widgets height should never be smaller than the given value. |
FixedHeight | Single | Sets the fixed height for this widget |
FixedWidth | Single | Sets the fixed width for this widget |
FixedSize | Vector2 | |
MaximumWidth | Single | This widgets width should never be larger than the given value. |
MaximumHeight | Single | This widgets height should never be larger than the given value. |
MaximumSize | Vector2 | Sets MaximumWidth and MaximumHeight simultaneously. |
Position | Vector2 | Position of this widget, relative to its parent if it has one. |
Visible | Boolean | Whether this widget is visible or not, in the tree. This will return false if a parent is hidden. You might want to set Hidden if you're looking to check local visible status on a widget. |
Hidden | Boolean | Whether this widget is hidden. This differs from Visible because this will return the state for this particular widget, where as Visible returns false if a parent is hidden etc. |
Name | String | Name of the widget, usually for debugging purposes. |
TranslucentBackground | Boolean | |
NoSystemBackground | Boolean | |
TransparentForMouseEvents | Boolean | |
ShowWithoutActivating | Boolean | |
MouseTracking | Boolean | |
AcceptDrops | Boolean | Accept drag and dropping shit on us |
IsFramelessWindow | Boolean | |
IsTooltip | Boolean | |
IsPopup | Boolean | |
IsWindow | Boolean | |
HasMaximizeButton | Boolean | |
DeleteOnClose | Boolean | Delete this widget when close is pressed |
DpiScale | Single | The scale this widget is using (multiplying Size by this value gives the actual native size) |
IsFocused | Boolean | Whether this widget has keyboard focus. |
IsActiveWindow | Boolean | |
FocusMode | FocusMode | Sets the focus mode for this widget. This determines both how it will get focus and whether it will receive keyboard input. |
ContextMenuEnabled | Boolean | Enables or disables the context menu on this widget. |
WindowFlags | WindowFlags | |
Children | IEnumerable<Widget> | Child widgets of this widget. |
Cursor virtual | CursorShape | Cursor override for this widget. |
PixmapCursor virtual | Pixmap | Custom cursor override for this widget. Will override Cursor with CustomCursor. |
ScreenPosition | Vector2 | Position of the widget relative to the monitor's top left corner. |
FocusProxy | Widget | |
IsUnderMouse | Boolean | |
HorizontalSizeMode | SizeMode | |
VerticalSizeMode | SizeMode | |
ToolTip virtual | String | If set, this text will be displayed after a certain delay of hovering this widget with the mouse cursor. |
StatusTip | String | If set, hovering over this widget will set the text of a StatusBar of the window the widget belongs to. |
ScreenGeometry | Rect | Returns the geometry of the screen this widget is currently on. |
WindowTitle virtual | String | |
IsMinimized | Boolean | |
IsMaximized | Boolean | |
WindowOpacity | Single | |
UpdatesEnabled | Boolean | If true, Update will call |
DebugModeEnabled | Boolean | Enable debug mode on this widget. |
ProvidesDebugMode virtual | Boolean | If true then this widget has a debug mode that can be activated |
IsPressed | Boolean | Whether this widget is currently being pressed down or not. |
IsDraggable | Boolean | Whether this widget can be drag and dropped onto other widgets. |
IsBeingDroppedOn | Boolean | Whether something is being dragged over this widget. |
Layout | Layout | The widget's internal layout, if any |
Methods
Void SetContext(String key, Object value) Set a context value on this widget. This context will be available to its children via FindContext.
Void ClearContext(String key) Remove a context on this widget. This will NOT remove contexts set from parent objects.
key T GetContext(String key, T defaultIfMissing = null) Find a context on this widget. If not found, look at the parent. If not found, look at the parent. This is useful for passing information down to child widgets without any effort.
T GetAncestor() Find the closest ancestor widget of type
IEnumerable<T> GetDescendants() Get all descendants of type T
Boolean IsDescendantOf(Widget parent) Returns whether or not the specified Widget is a descendent of this Widget.
Boolean IsAncestorOf(Widget child) Returns whether or not the specified Widget is an ancestor of this Widget.
Void Focus(Boolean activateWindow = True) Void Blur() Clear keyboard focus from this widget.
Void SetStyles(String sheet) Directly set CSS style sheet(s) for this widget. Same format as a .css file.
sheet Void SetStylesheetFile(String filename) Set a file to load CSS for this widget from.
Void DestroyChildren() Destroys all child widgets of this widget.
virtual Void Update() Tell this widget that shit changed and it needs to redraw
Vector2 ToScreen(Vector2 p) Transform coordinates relative to the panel's top left corner, to coordinates relative to monitors's top left corner.
p — Position on the panel, relative it its top left corner. Vector2 FromScreen(Vector2 p) Transform coordinates relative to the monitors's top left corner, to coordinates relative to panel's top left corner.
p — Position relative to the monitors top left corner. Void PostKeyEvent(KeyCode key) String SaveGeometry() Serialize position and size of this widget to a string, which can then be passed to String).
Void RestoreGeometry(String state) Restore position and size previously stored via SaveGeometry.
state virtual Void ChildValuesChanged(Widget source) Void MakeSignal(String name) Void AdjustSize() Adjusts the size of the widget to fit its contents.
Void ConstrainToScreen() Constrain this widget to the screen it's currently on.
Void ConstrainTo(Rect parentRect) Reposition this widget to ensure it is within the given rectangle.
parentRect — Rectangle to constraint to, relative to the parent widget. virtual Void SetWindowIcon(String name) virtual Void SetWindowIcon(Pixmap icon) virtual Void Show() Make this widget visible.
virtual Void Hide() Make this widget not visible.
virtual Void Close() If a window - will close
Void MakeMinimized() Void MakeMaximized() Void MakeWindowed() Void SetModal(Boolean on, Boolean application = False) Set this window to be modal. This means it will appear on top of everything and block input to everything else.
Boolean IsModal() Returns true if this is a modal window. This means it will appear on top of everything and block input to everything else.
Void DisableWindowActivation() Calling this will set the WS_EX_NOACTIVATE flag on the window internally, which will stop it taking focus away from other windows.
Void SetEffectOpacity(Single f) Boolean SetContentHash(Int32 hash, Single secondsDebounce = 0.1) Call every frame/tick to redraw this Widget on content change
Boolean SetContentHash(Func<Int32> getHash, Single secondsDebounce = 0.1) virtual Void AlignToParent(TextFlag alignment, Vector2 offset = null) Align this widget to its parents edge, with an offset.
Void UpdateGeometry() Tell everything that the geometry of this has changed
Widget GetWindow() Get the top level window widget
virtual Void OnDragLeave() Cursor with drag and drop data left the bounds of this widget. Requires AcceptDrops to function.
virtual Void OnDragHover(DragEvent ev) Cursor with drag and drop data moved on this widget. Requires AcceptDrops to function.
ev — The drag event info. virtual Void OnDragDrop(DragEvent ev) Something was dragged and dropped on this widget. Apply the data here, if its valid. Requires AcceptDrops to function.
ev — The drag event info. Void Raise() Raises this widget to the top of the parent widget's stack. After this call the widget will be visually in front of any overlapping sibling widgets.
Void Lower() Lowers the widget to the bottom of the parent widget's stack. After this call the widget will be visually behind (and therefore obscured by) any overlapping sibling widgets.
Fields
| Name | Type | Description |
|---|---|---|
MouseRelease | Action | |
MouseClick | Action | |
MouseRightClick | Action | |
MouseLeftPress | Action | Called when this widget is left clicked (on mouse press). |
MouseRightPress | Action | Called when this widget is right clicked (on mouse press). |
MouseMiddlePress | Action | Called when this widget is clicked with the mouse wheel (on mouse press). |
MouseMove | Action<Vector2> | |
OnPaintOverride | Func<Boolean> | Override the widget's paint process. Return to prevent the default paint action, which is to call OnPaint. |