Game.UI.Widgets.IconButtonGroup
Assembly: Assembly-CSharp
Namespace: Game.UI.Widgets
Type: class
Base: Widget
Summary:
IconButtonGroup is a container widget that holds an array of IconButton children. It exposes the children array for reading and replacing; when children are assigned, the group applies default settings to each child and notifies the widget system that its children changed so layout/visuals can update. This class also implements the visibleChildren contract required by the Widget base class by returning the current children collection.
Fields
private IconButton[] m_Children = Array.Empty<IconButton>()
Backing field that stores the group's child IconButton instances. It is initialized to an empty array to avoid nulls. Replacing the array reference via the property setter triggers defaulting and a children-changed notification.
Properties
-
public IconButton[] children
Public getter/setter for the child array. Getter returns the backing array. Setter replaces the backing array only if the incoming reference differs from the current one; before assignment it calls ContainerExtensions.SetDefaults(value) to apply per-child default settings and then calls SetChildrenChanged() (inherited from Widget) to inform the widget/layout system that the children list has changed. -
public override IList<IWidget> visibleChildren => children
Overrides the Widget.visibleChildren property to expose the children array as the visible children for layout/interaction. The array is returned so the widget system can enumerate child widgets. (This relies on IconButton being an IWidget implementation and the array being usable as an IListin the widget system.)
Constructors
public IconButtonGroup()
Default parameterless constructor (implicit). The m_Children field is initialized to an empty IconButton[] by the field initializer; no additional initialization logic is present in the class.
Methods
public static IconButtonGroup WithChildren(IconButton[] children)
Factory helper that constructs a new IconButtonGroup with its children property set to the provided array. This is a convenience for fluent initialization:- The assignment to children inside the object initializer runs the property setter logic (SetDefaults and SetChildrenChanged).
- Example usage: IconButtonGroup.WithChildren(new[] { ... });
Additional notes on behavior: - Setting children uses reference equality to determine if work is necessary (it will skip SetDefaults/SetChildrenChanged if the same array reference is assigned). - ContainerExtensions.SetDefaults(value) is expected to set any required default properties on each IconButton before they are used by the UI system. - SetChildrenChanged() is a Widget base-class method that typically triggers layout recomputation / redraw for the container.
Usage Example
// Create some IconButton instances (example constructors — real usage may differ)
var btn1 = new IconButton { /* initialize icon, tooltip, callbacks, etc. */ };
var btn2 = new IconButton { /* ... */ };
// Create a group using the factory helper
var group = IconButtonGroup.WithChildren(new[] { btn1, btn2 });
// Or assign directly
var group2 = new IconButtonGroup();
group2.children = new[] { btn1, btn2 }; // applies defaults and notifies the widget system