System.Ui
User interfaces in immediate mode: the program describes its whole window again for every frame, from its own state, and a widget reports what the user did with it as its result. There are no widget objects, callbacks or events to unsubscribe, and the state stays in the program’s own structs.
using System.Graphics;using System.Ui;
struct App { int Count; string Name; bool Loud; }
void Draw(Ui ui, ref App app){ ui.Label($"Count: {app.Count}"); using (ui.Row()) { if (ui.Button("-")) app.Count -= 1; if (ui.Button("+")) app.Count += 1; } ui.TextBox("name", ref app.Name); ui.Checkbox("Loud", ref app.Loud);}
int Main(){ var window = try Window.Open("Counter", 320, 200); var ui = Ui.Create(); var app = App { Name = "World" }; while (window.Update()) { ui.Begin(window); Draw(ui, ref app); window.Show(ui); } return 0;}A Ui draws into an Image with the software renderer of System.Graphics.Canvas, so it also works without a
window (tests, screenshots: Ui.Begin with an Input of your own). The window, the input, the keys, the canvas
and the fonts are those of System.Graphics: System.Ui builds on it. Sizes are in pixels at a scale of 1 (96 dpi);
a Window reports the scale of its screen, and the Ui picks a font and the sizes for it.
| Type | Description |
|---|---|
Theme |
The colors of a Ui: Theme.Light (the default) or Theme.Dark, or your own. |
UiTreeNode |
What a Ui.TreeNode did in this frame. |
UiScope |
The end of a group that Ui.Row, Ui.Columns, Ui.Panel, Ui.Scroll, Ui.Id, Ui.Popup, Ui.Modal, Ui.MenuBar, Ui.Menu, Ui.Indent or Ui.TabBar started: `using (ui.Row()) { … |
UiCommand |
One drawing operation of a frame, recorded when a Ui draws with commands instead of pixels (Ui.BeginCommands, Ui.Commands): for windows that draw themselves (the one of AmigaOS draws with graphics.library). |
Ui |
The user interface: one value for the whole program, created once and given every frame to the code that draws it. |
FileDialogMode |
What a Ui.FileDialog chooses. |
UiDialogResult |
What the user did with a dialog of Ui.FileDialog. |
UiCommandKind |
What a UiCommand draws. |