-
Notifications
You must be signed in to change notification settings - Fork 0
UI Controls
The UI module (RGXUI) provides widget factories for common interface controls and a full options panel builder with tab system and scroll container.
Create a horizontal slider control.
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
parent |
Frame | Yes | — | Parent frame |
opts.label |
string | Yes | — | Label text above slider |
opts.min |
number | Yes | — | Minimum value |
opts.max |
number | Yes | — | Maximum value |
opts.step |
number | No | 1 | Step increment |
opts.value |
number | Yes | — | Initial value |
opts.onChange |
function | No | — |
onChange(value) callback |
opts.width |
number | No | 200 | Slider track width |
opts.format |
string | No | "%.0f" |
Value display format |
Returns: { frame, slider, label, valueText }
local slider = UI:CreateSlider(parent, {
label = "Font Size",
min = 8,
max = 24,
step = 1,
value = 12,
onChange = function(val)
myFontString:SetFont(myFont, val, "")
end,
})
slider.frame:SetPoint("TOPLEFT", 10, -10)Create a checkbox toggle control.
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
parent |
Frame | Yes | — | Parent frame |
opts.label |
string | Yes | — | Label text beside checkbox |
opts.value |
bool | Yes | — | Initial checked state |
opts.onChange |
function | No | — |
onChange(checked) callback |
opts.width |
number | No | auto | Label width |
Returns: { frame, checkbox, label }
local toggle = UI:CreateToggle(parent, {
label = "Enable Notifications",
value = true,
onChange = function(checked)
MyAddonDB.profile.notifications = checked
end,
})Create a styled label.
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
parent |
Frame | Yes | — | Parent frame |
opts.text |
string | Yes | — | Label text |
opts.font |
string | No | default | Font name |
opts.size |
number | No | 12 | Font size |
opts.flags |
string | No | "" | Font flags |
opts.color |
table | No | {1,1,1,1} | Font color |
opts.justifyH |
string | No | "LEFT" | Horizontal justify |
local label = UI:CreateLabel(parent, {
text = "Configuration",
font = "Inter-Bold",
size = 14,
color = {1, 0.9, 0.2, 1},
})Create a color swatch control that opens the ColorPicker on click.
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
parent |
Frame | Yes | — | Parent frame |
opts.label |
string | No | — | Label text |
opts.value |
table | No | {1,1,1,1} | Initial color {r,g,b,a} |
opts.onChange |
function | No | — |
onChange(r, g, b, a) callback |
Returns: { frame, swatch, label }
local cp = UI:CreateColorPicker(parent, {
label = "Background Color",
value = {0.1, 0.1, 0.2, 1.0},
onChange = function(r, g, b, a)
myFrame:SetBackdropColor(r, g, b, a)
end,
})Color swatch + label bound to a saved variable. Changes write directly to storage[key].
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
parent |
Frame | Yes | Parent frame |
opts.label |
string | Yes | Label text |
opts.storage |
table | Yes | Saved variable table |
opts.key |
string | Yes | Key within storage |
opts.onChange |
function | No | Additional change callback |
local ctrl = UI:CreateColorSettingControl(parent, {
label = "Bar Color",
storage = MyAddonDB.profile,
key = "barColor",
})Statusbar texture selection dropdown. Delegates to the Textures module.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
parent |
Frame | Yes | Parent frame |
opts.label |
string | No | Label text |
opts.value |
string | No | Initial statusbar name |
opts.onChange |
function | No |
onChange(barName) callback |
Font family selection dropdown. Delegates to the Fonts module.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
parent |
Frame | Yes | Parent frame |
opts.label |
string | No | Label text |
opts.value |
string | No | Initial font name |
opts.onChange |
function | No |
onChange(fontName) callback |
Font dropdown + reset button bound to storage[key]. Delegates to the Fonts module.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
parent |
Frame | Yes | Parent frame |
opts.label |
string | Yes | Label text |
opts.storage |
table | Yes | Saved variable table |
opts.key |
string | Yes | Key within storage |
opts.onChange |
function | No | Additional change callback |
Create a full options panel with tab system, scroll container, and header.
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name |
string | Yes | — | Panel name (used as frame name) |
opts.title |
string | No | name | Title text in header |
opts.subtitle |
string | No | "" | Subtitle text |
opts.width |
number | No | 800 | Panel width |
opts.height |
number | No | 600 | Panel height |
opts.version |
string | No | — | Version string shown in header |
opts.author |
string | No | — | Author string shown in header |
opts.website |
string | No | — | Website URL shown in header |
Returns: Panel object with methods below.
Add a tab to the panel. buildFn(container) is called once when the tab is first shown.
panel:AddTab("General", function(container)
UI:CreateToggle(container, { label = "Enabled", value = true })
UI:CreateSlider(container, { label = "Scale", min = 0.5, max = 2.0, step = 0.1, value = 1.0 })
end)
panel:AddTab("Fonts", function(container)
UI:CreateFontDropdown(container, { label = "Header Font" })
UI:CreateFontDropdown(container, { label = "Body Font" })
end)
panel:AddTab("Colors", function(container)
UI:CreateColorPicker(container, { label = "Primary Color" })
end)Open the panel and navigate to it in Interface Options:
panel:Open()Switch to a tab by 1-based index:
panel:SelectTab(2) -- switch to Fonts tabSwitch to a tab by its name:
panel:SelectTabByName("Fonts")Mark all tabs for rebuild. Next time each tab is shown, its buildFn will be re-executed:
panel:InvalidateAllTabs()Force-refresh the currently visible tab:
panel:Refresh()local UI = RGX:GetUI()
local panel = UI:CreateOptionsPanel("MyAddonOptions", {
title = "My Addon",
subtitle = "v1.0.0 by Me",
width = 800,
height = 600,
})
panel:AddTab("General", function(container)
UI:CreateToggle(container, {
label = "Enable Addon",
value = MyAddonDB.profile.enabled,
onChange = function(v) MyAddonDB.profile.enabled = v end,
})
UI:CreateSlider(container, {
label = "Update Interval",
min = 0.1,
max = 5.0,
step = 0.1,
value = MyAddonDB.profile.interval,
onChange = function(v) MyAddonDB.profile.interval = v end,
})
end)
panel:AddTab("Appearance", function(container)
UI:CreateFontDropdown(container, {
label = "Font Family",
value = MyAddonDB.profile.fontFamily,
onChange = function(v) MyAddonDB.profile.fontFamily = v end,
})
UI:CreateSlider(container, {
label = "Font Size",
min = 8,
max = 24,
step = 1,
value = MyAddonDB.profile.fontSize,
onChange = function(v) MyAddonDB.profile.fontSize = v end,
})
UI:CreateColorPicker(container, {
label = "Text Color",
value = MyAddonDB.profile.textColor,
onChange = function(r, g, b, a)
MyAddonDB.profile.textColor = {r, g, b, a}
end,
})
UI:CreateStatusBarDropdown(container, {
label = "Bar Texture",
value = MyAddonDB.profile.barTexture,
onChange = function(v) MyAddonDB.profile.barTexture = v end,
})
end)
-- Register with WoW
InterfaceOptions_AddCategory(panel.frame)
-- Open from slash command
SLASH_MYADDON1 = "/myaddon"
SlashCmdList.MYADDON = function()
panel:Open()
end- Controls are positioned automatically within the scroll container
- Each control is anchored below the previous one
- Use
container(the scroll child) as the parent for all controls - The scroll container handles overflow automatically
- Tab content is built lazily on first show and cached unless invalidated