Skip to content

Latest commit

 

History

History
1178 lines (932 loc) · 31.1 KB

ConfigDialog.md

File metadata and controls

1178 lines (932 loc) · 31.1 KB

Loolib ConfigDialog Reference

Comprehensive documentation for the ConfigDialog GUI rendering system.

Table of Contents

  1. Overview
  2. Dialog Lifecycle
  3. Layout Types
  4. Opening and Closing Dialogs
  5. Navigation
  6. Widget Rendering
  7. Widget Pooling
  8. Blizzard Settings Integration
  9. Styling and Appearance
  10. Events
  11. API Reference
  12. Customization
  13. Troubleshooting

Overview

The ConfigDialog module transforms declarative options tables into interactive graphical user interfaces. It handles:

  • Dialog window creation and management
  • Layout rendering (tree, tab, inline)
  • Widget creation for all option types
  • User interaction handling
  • Integration with WoW's Settings panel
  • Performance optimization through widget pooling

Architecture

+----------------------------------+
|         ConfigDialog             |
|----------------------------------|
| Dialog Management                |
|   - Create/Open/Close dialogs    |
|   - Track active dialogs         |
|----------------------------------|
| Layout System                    |
|   - Tree layout (sidebar + content)|
|   - Tab layout (tabs + content)  |
|   - Simple layout (content only) |
|----------------------------------|
| Widget Rendering                 |
|   - Type-specific renderers      |
|   - Widget pooling               |
|   - Event binding                |
|----------------------------------|
| Blizzard Integration             |
|   - Settings panel registration  |
|   - Category management          |
+----------------------------------+

Module Access

local Loolib = LibStub("Loolib")
local ConfigDialogModule = Loolib:GetModule("ConfigDialog")
local Dialog = ConfigDialogModule.Dialog  -- Singleton instance

-- Or through LoolibConfig
LoolibConfig:Open("MyAddon")

Dialog Lifecycle

Creation Flow

RegisterOptionsTable()
        |
        v
    Open(appName)
        |
        +-- Check if dialog exists
        |       |
        |       +-- Yes: Show existing
        |       |
        |       +-- No: CreateDialog()
        |               |
        |               +-- Create frame
        |               +-- Apply backdrop
        |               +-- Create title
        |               +-- Create close button
        |               +-- Create layout (tree/tab/simple)
        |               +-- Initial render
        |
        v
    RefreshContent()
        |
        +-- Render navigation (tree/tabs)
        +-- Get selected group
        +-- Render options widgets
        |
        v
    Dialog shown

Dialog Structure

+--------------------------------------------------+
|  Title                                       [X] |
+--------------------------------------------------+
|  +----------+  +-----------------------------+   |
|  | Tree     |  | Content Area               |   |
|  | Nav      |  |                            |   |
|  |          |  | [Options render here]       |   |
|  | > Gen    |  |                            |   |
|  | > App    |  |                            |   |
|  | > Adv    |  |                            |   |
|  |          |  |                            |   |
|  +----------+  +-----------------------------+   |
+--------------------------------------------------+

State Management

-- Dialog state stored per app
self.dialogs = {}          -- appName -> dialog frame
self.selectedPaths = {}    -- appName -> current selected path
self.blizPanels = {}       -- appName -> Blizzard settings panel
self.defaultSizes = {}     -- appName -> {width, height}

Layout Types

Tree Layout (Default)

Used when childGroups = "tree" (or default).

local options = {
    type = "group",
    name = "My Addon",
    childGroups = "tree",  -- Or omit for default
    args = { ... }
}

Visual Structure:

+-------+-------------------+
| Tree  | Content           |
+-------+-------------------+
|General| Group Title       |
|  +-Dis| Description...    |
|  +-Col|                   |
|Appear | [x] Option 1      |
|Modules| [x] Option 2      |
|       | Scale: [===|==]   |
+-------+-------------------+

Characteristics:

  • Left sidebar (180px default) with scrollable tree
  • Right content area with scrollable options
  • Supports nested groups (indented in tree)
  • Selected group highlighted in tree

Tab Layout

Used when childGroups = "tab".

local options = {
    type = "group",
    name = "My Addon",
    childGroups = "tab",
    args = { ... }
}

Visual Structure:

+---------------------------+
| [Gen] [Appear] [Modules]  |
+---------------------------+
| Group Title               |
| Description...            |
|                           |
| [x] Option 1              |
| [x] Option 2              |
| Scale: [===|==]           |
+---------------------------+

Characteristics:

  • Horizontal tabs at top
  • Selected tab highlighted
  • Good for 3-5 top-level groups
  • Not nested (only first level shows as tabs)

Simple Layout

Used when no child groups or childGroups = "select".

local options = {
    type = "group",
    name = "My Addon",
    childGroups = "select",  -- Or no child groups
    args = { ... }
}

Visual Structure:

+---------------------------+
| Content fills entire      |
| dialog area               |
|                           |
| Options render directly   |
+---------------------------+

Inline Groups

Groups with inline = true render within their parent:

appearance = {
    type = "group",
    name = "Appearance",
    args = {
        colors = {
            type = "group",
            name = "Colors",
            inline = true,
            args = {
                background = { type = "color", name = "Background" },
                text = { type = "color", name = "Text" },
            },
        },
    },
}

Visual Structure:

+-----------------------------+
| Appearance                  |
+-----------------------------+
| +-------------------------+ |
| | Colors                  | |
| | Background: [##]        | |
| | Text: [##]              | |
| +-------------------------+ |
+-----------------------------+

Opening and Closing Dialogs

Opening

-- Basic open
LoolibConfig:Open("MyAddon")

-- Open to specific group
LoolibConfig:Open("MyAddon", "appearance")

-- Open to nested group
LoolibConfig:Open("MyAddon", "appearance", "colors")

-- Direct dialog access
local dialog = ConfigDialogModule.Dialog:Open("MyAddon", nil, "appearance")

Closing

-- Close specific dialog
LoolibConfig:Close("MyAddon")

-- Close all dialogs
LoolibConfig:Close()

-- Direct access
ConfigDialogModule.Dialog:Close("MyAddon")
ConfigDialogModule.Dialog:CloseAll()

Dialog Visibility

local dialog = ConfigDialogModule.Dialog.dialogs["MyAddon"]
if dialog and dialog:IsShown() then
    -- Dialog is visible
end

Custom Container

Open within a parent frame:

local myFrame = CreateFrame("Frame", nil, UIParent)
myFrame:SetSize(800, 600)
myFrame:SetPoint("CENTER")

-- Dialog will be embedded in myFrame
local dialog = ConfigDialogModule.Dialog:Open("MyAddon", myFrame)

Navigation

Selecting Groups

-- Navigate to group
LoolibConfig:Open("MyAddon", "appearance")

-- After dialog open, change selection
ConfigDialogModule.Dialog:SelectGroup("MyAddon", "modules")

-- Navigate to nested group
ConfigDialogModule.Dialog:SelectGroup("MyAddon", "appearance", "colors")

Getting Current Selection

local currentPath = ConfigDialogModule.Dialog.selectedPaths["MyAddon"]
-- currentPath = {"appearance", "colors"} or {}

Programmatic Navigation

-- Build your own navigation
local function GoToOption(appName, ...)
    local Dialog = ConfigDialogModule.Dialog

    -- Ensure dialog is open
    if not Dialog.dialogs[appName] or not Dialog.dialogs[appName]:IsShown() then
        Dialog:Open(appName, nil, ...)
    else
        Dialog:SelectGroup(appName, ...)
    end
end

Navigation Events

ConfigDialogModule.Dialog:RegisterCallback("OnGroupSelected", function(appName, ...)
    local path = {...}
    print("Selected:", table.concat(path, " > "))
end)

Widget Rendering

Rendering Pipeline

RenderOptions(dialog, group, rootOptions, registry, path)
    |
    +-- Release existing widgets
    |
    +-- Render group header (if path > 0)
    |
    +-- Render group description
    |
    +-- For each option in sorted order:
            |
            +-- Skip if hidden
            |
            +-- If inline group: RenderInlineGroup()
            |
            +-- Else: RenderWidget()
                    |
                    +-- Dispatch to type-specific renderer:
                        - RenderHeader()
                        - RenderDescription()
                        - RenderToggle()
                        - RenderInput()
                        - RenderRange()
                        - RenderSelect()
                        - RenderMultiSelect()
                        - RenderColor()
                        - RenderExecute()
                        - RenderKeybinding()
                        - RenderTexture()
                        - RenderFont()

Type-Specific Renderers

Each option type has a dedicated render function:

Renderer Creates Notes
RenderHeader FontString + Line Section divider
RenderDescription FontString Static text, optional image
RenderToggle CheckButton UICheckButtonTemplate
RenderInput EditBox + Label BackdropTemplate for border
RenderRange Slider + Label + Value OptionsSliderTemplate
RenderSelect Button + Popup Menu Custom dropdown
RenderMultiSelect Multiple CheckButtons Grid layout
RenderColor Button + Swatch Opens ColorPickerFrame
RenderExecute Button UIPanelButtonTemplate
RenderKeybinding Button + Capture Custom capture logic
RenderTexture Frame + Texture Optional selection
RenderFont Button + Popup Menu Font preview in items

Widget Width Calculation

local WIDTH_MULTIPLIERS = {
    half = 0.5,
    normal = 1.0,
    double = 2.0,
    full = 3.0,
}

-- Calculation
local widthMod = WIDTH_MULTIPLIERS[option.width] or WIDTH_MULTIPLIERS.normal
if option.width == "full" then
    widthMod = contentWidth / LABEL_WIDTH
elseif type(option.width) == "number" then
    widthMod = option.width
end

Layout Constants

local DIALOG_WIDTH = 700
local DIALOG_HEIGHT = 500
local TREE_WIDTH = 180
local CONTENT_PADDING = 16
local WIDGET_SPACING = 8
local LABEL_WIDTH = 200

Widget Pooling

ConfigDialog uses frame pools to optimize performance.

Pool Architecture

self.widgetPools = {}  -- type -> { inactive = {} }

-- Acquire from pool
function LoolibConfigDialogMixin:AcquireWidget(widgetType, parent, template, frameTypeOverride)
    local pool = self.widgetPools[widgetType]
    if not pool then
        pool = { inactive = {} }
        self.widgetPools[widgetType] = pool
    end

    local widget = table.remove(pool.inactive)
    if not widget then
        -- Create new widget
        widget = CreateFrame(frameType, nil, parent, template)
        widget.pooledWidgetType = widgetType
    end

    -- Reset and return
    widget:SetParent(parent)
    widget:Show()
    widget:ClearAllPoints()
    return widget
end

Releasing Widgets

function LoolibConfigDialogMixin:ReleaseWidgets(container)
    local children = {container:GetChildren()}
    for _, child in ipairs(children) do
        -- Recursively release children
        self:ReleaseWidgets(child)

        if child.pooledWidgetType and self.widgetPools[child.pooledWidgetType] then
            -- Clean up scripts
            child:Hide()
            child:ClearAllPoints()
            child:SetScript("OnEnter", nil)
            child:SetScript("OnLeave", nil)
            child:SetScript("OnClick", nil)
            -- ... more cleanup

            -- Return to pool
            table.insert(pool.inactive, child)
        end
    end
end

Widget Types in Pool

  • "button"
  • "checkbutton"
  • "editbox"
  • "slider"
  • "scrollframe"
  • "group_frame" (for inline groups)

Blizzard Settings Integration

Adding to Settings

-- Add to root of Settings > Addons
LoolibConfig:AddToBlizOptions("MyAddon", "My Addon")

-- Add as sub-category
LoolibConfig:AddToBlizOptions("MyAddon", "Combat Module", "My Addon")

-- With path to specific group
LoolibConfig:AddToBlizOptions("MyAddon", "Colors", "My Addon", "appearance", "colors")

Panel Creation

function LoolibConfigDialogMixin:AddToBlizOptions(appName, name, parent, ...)
    -- Create settings panel frame
    local panel = CreateFrame("Frame", "LoolibBlizPanel_" .. appName, UIParent)
    panel.name = name or appName

    -- OnShow creates content
    panel:SetScript("OnShow", function(self)
        if not self.initialized then
            self.initialized = true
            -- Create title, description, "Open Config" button
        end
    end)

    -- Register with WoW 10.0+ Settings API
    if Settings and Settings.RegisterCanvasLayoutCategory then
        local category
        if parent then
            local parentCategory = Settings.GetCategory(parent)
            if parentCategory then
                category = Settings.RegisterCanvasLayoutSubcategory(parentCategory, panel, panel.name)
            end
        end
        if not category then
            category = Settings.RegisterCanvasLayoutCategory(panel, panel.name)
        end
        Settings.RegisterAddOnCategory(category)
    else
        -- Legacy InterfaceOptions fallback
        if parent then panel.parent = parent end
        InterfaceOptions_AddCategory(panel)
    end

    return panel
end

Settings Panel Content

The Blizzard Settings panel shows:

  1. Addon title
  2. Description (from options.desc)
  3. "Open Config" button - opens full dialog

Opening Settings Programmatically

-- WoW 10.0+
Settings.OpenToCategory("My Addon")

-- Legacy
InterfaceOptionsFrame_OpenToCategory("My Addon")

Theming the Dialog

Added in Loolib 2.1.0. Earlier consumers continue to render with the built-in default theme; no migration is required.

ConfigDialog ships with a sparse, layered theming system. Every color, backdrop, and font that the renderer applies is resolved through a DialogTheme table at render time. Consumers can:

  • Override appearance for a specific app via RegisterAppTheme(appName, ...)
  • Register named global themes via RegisterDialogTheme(name, ...)
  • Replace whole widget creators via the widgetFactories table
  • Post-style any created widget via the afterCreateWidget hook

Resolution order

For any token (color, backdrop, font, layout), the resolver walks:

  1. Per-app override - whatever RegisterAppTheme(appName, ...) provided
  2. Active global theme - whatever SetActiveDialogTheme(name) selected
  3. Built-in default - the verbatim values from pre-2.1 ConfigDialog

A theme table is sparse: missing keys fall through transparently. This means consumers can override one color and inherit the rest.

Theme table shape

{
    colors = {
        -- Surfaces
        dialogBg, treeContainerBg, contentContainerBg, inlineGroupBg,
        inputBg, inputBgDisabled, dropdownBg, dropdownBgDisabled,
        dropdownMenuBg, filterButtonBg, filterMenuBg,
        keyButtonBg, keyButtonBgDisabled, textureFrameBg, searchBoxBg,

        -- Borders
        treeContainerBorder, contentContainerBorder, inlineGroupBorder,

        -- Tree / tab states
        treeHoverBg, treeSelectionBg, treeTextSelected,
        tabBgActive, tabBgInactive, tabActiveAccent,
        tabTextActive, tabTextInactive,

        -- Filter / dropdown highlights
        filterButtonHover, dropdownItemHover, dropdownItemSelected,

        -- Text
        headerText, descriptionText, labelText, labelTextDisabled,
        noResultsText, searchIcon,

        -- Decorative
        separator, textureMissing,
    },

    backdrops = {
        dialog, container, input, popupMenu, inlineGroup, textureFrame,
        -- Each is a Blizzard backdrop table:
        -- { bgFile=..., edgeFile=..., tile=..., tileSize=..., edgeSize=..., insets={...} }
    },

    fonts = {
        title, groupHeader, label, labelDisabled, description, treeNode,
        -- Each is a font object name string (e.g. "GameFontNormal")
    },

    layout = {
        dialogWidth, dialogHeight, treeWidth,
        contentPadding, widgetSpacing, labelWidth,
    },

    -- Optional: replace the renderer's CreateFrame call for a widget type.
    -- factory(dialog, parent, option, info) -> Frame
    widgetFactories = {
        toggle, range, input, select, multiselect, color,
        execute, header, description, keybinding, texture, font,
    },

    -- Optional: post-style hook fired after every widget is created.
    -- Receives (widgetType, widget, option, info). Use this to apply
    -- a consistent skin without replacing widget creation.
    afterCreateWidget = function(widgetType, widget, option, info) end,
}

All keys are optional. The default theme provides values for everything.

End-to-end example: Loothing's amber accent theme

This is the actual code Loothing uses to make its config dialog match the rest of the addon.

local Loolib = LibStub("Loolib")
local Config = Loolib.Config
local SkinningMixin = Loothing.SkinningMixin

-- Helper that pulls a color from Loothing's existing palette
local function GetSkinColor(key)
    return SkinningMixin:GetColor(key)
end

local function RegisterTheme()
    Config:RegisterAppTheme("Loothing", {
        colors = {
            dialogBg            = GetSkinColor("frame"),
            treeContainerBg     = GetSkinColor("panelInset"),
            treeContainerBorder = GetSkinColor("border"),
            treeSelectionBg     = GetSkinColor("rowSelected"),
            treeHoverBg         = GetSkinColor("rowHover"),
            treeTextSelected    = GetSkinColor("accent"),
            contentContainerBg  = GetSkinColor("panel"),
            inlineGroupBg       = GetSkinColor("panelAlt"),
            inputBg             = GetSkinColor("panelInset"),
            dropdownBg          = GetSkinColor("panelInset"),
            dropdownMenuBg      = GetSkinColor("panelInset"),
            headerText          = GetSkinColor("accent"),
            labelText           = GetSkinColor("text"),
            descriptionText     = GetSkinColor("textMuted"),
            labelTextDisabled   = GetSkinColor("textSubtle"),
            tabActiveAccent     = GetSkinColor("accent"),
            separator           = GetSkinColor("border"),
        },

        afterCreateWidget = function(widgetType, widget)
            -- Apply Loothing's primary button style to every action button
            if widgetType == "execute" then
                SkinningMixin:StylePlainButton(widget, "primary")
            end
        end,
    })
end

-- Register on init, and re-register when the user changes accent
RegisterTheme()
SkinningMixin:RegisterCallback("OnAccentChanged", RegisterTheme)

Repainting an open dialog

RegisterAppTheme, RegisterDialogTheme, and SetActiveDialogTheme all notify the dialog system. If a dialog for the affected app is currently open, it is refreshed in place — no need to close and reopen.

Public API summary

Config:RegisterAppTheme(appName, themeTable)        -- per-app override
Config:RegisterDialogTheme(themeName, themeTable)   -- named global theme
Config:SetActiveDialogTheme(themeName)              -- switch global default
Config:GetDialogTheme(appName)                      -- resolved theme table

Styling and Appearance

Note: as of Loolib 2.1.0, every value in this section is the default theme. To override any of them, use the theming API documented above. The hardcoded sections below remain for reference on what the dialog looks like out of the box.

Dialog Backdrop

dialog:SetBackdrop({
    bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark",
    edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
    tile = true, tileSize = 32, edgeSize = 32,
    insets = {left = 11, right = 12, top = 12, bottom = 11}
})

Tree Container Backdrop

treeContainer:SetBackdrop({
    bgFile = "Interface\\Buttons\\WHITE8X8",
    edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
    tile = true, tileSize = 16, edgeSize = 16,
    insets = {left = 3, right = 3, top = 3, bottom = 3}
})
treeContainer:SetBackdropColor(0.1, 0.1, 0.1, 0.8)
treeContainer:SetBackdropBorderColor(0.4, 0.4, 0.4, 1)

Content Container Backdrop

optionsContainer:SetBackdrop({
    bgFile = "Interface\\Buttons\\WHITE8X8",
    edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
    tile = true, tileSize = 16, edgeSize = 16,
    insets = {left = 3, right = 3, top = 3, bottom = 3}
})
optionsContainer:SetBackdropColor(0.1, 0.1, 0.1, 0.6)
optionsContainer:SetBackdropBorderColor(0.4, 0.4, 0.4, 1)

Inline Group Styling

groupFrame:SetBackdrop({
    bgFile = "Interface\\Buttons\\WHITE8X8",
    edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
    tile = true, tileSize = 16, edgeSize = 12,
    insets = {left = 2, right = 2, top = 2, bottom = 2}
})
groupFrame:SetBackdropColor(0.15, 0.15, 0.2, 0.5)
groupFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 0.8)

Custom Dialog Size

-- Before opening
ConfigDialogModule.Dialog:SetDefaultSize("MyAddon", 800, 600)

-- Then open
LoolibConfig:Open("MyAddon")

Color Scheme

Element Color
Background (0.1, 0.1, 0.1)
Tree background (0.1, 0.1, 0.1, 0.8)
Content background (0.1, 0.1, 0.1, 0.6)
Inline group (0.15, 0.15, 0.2, 0.5)
Border (0.4, 0.4, 0.4) to (0.6, 0.6, 0.6)
Selection highlight (0.2, 0.4, 0.6, 0.8)
Hover highlight (0.3, 0.3, 0.5, 0.5)
Header text Gold (1, 0.82, 0)
Selected text Yellow (1, 1, 0)
Disabled text Gray (0.5, 0.5, 0.5)

Events

Available Events

Event Parameters Description
OnDialogOpened appName Dialog opened
OnDialogClosed appName Dialog closed
OnGroupSelected appName, path... Group navigation
OnOptionChanged appName, path..., value Option value changed

Registering for Events

local Dialog = ConfigDialogModule.Dialog

-- On dialog open
Dialog:RegisterCallback("OnDialogOpened", function(appName)
    print("Config opened for:", appName)
end)

-- On dialog close
Dialog:RegisterCallback("OnDialogClosed", function(appName)
    print("Config closed for:", appName)
end)

-- On navigation
Dialog:RegisterCallback("OnGroupSelected", function(appName, ...)
    local path = {...}
    print("Navigated to:", table.concat(path, " > "))
end)

-- With specific owner
local myFrame = CreateFrame("Frame")
Dialog:RegisterCallback("OnDialogOpened", function(appName)
    -- Handler code
end, myFrame)

-- Unregister
Dialog:UnregisterCallback("OnDialogOpened", myFrame)

Config Table Change

The dialog also listens for config changes:

-- Trigger refresh when options change
LoolibConfig:NotifyChange("MyAddon")

-- Or directly
ConfigRegistryModule.Registry:NotifyChange("MyAddon")

API Reference

LoolibConfigDialogMixin

The dialog singleton instance provides these methods:

Init

function LoolibConfigDialogMixin:Init()

Initialize the dialog system. Called automatically.

Open

function LoolibConfigDialogMixin:Open(appName, container, ...)

Open configuration dialog.

Parameter Type Description
appName string Registered app name
container Frame Optional parent (nil = standalone)
... strings Optional path to group

Returns: Frame - Dialog frame

Close

function LoolibConfigDialogMixin:Close(appName)

Close dialog for specific app.

CloseAll

function LoolibConfigDialogMixin:CloseAll()

Close all open dialogs.

SelectGroup

function LoolibConfigDialogMixin:SelectGroup(appName, ...)

Navigate to specific group.

Parameter Type Description
appName string App name
... strings Path components

Returns: boolean - Success

SetDefaultSize

function LoolibConfigDialogMixin:SetDefaultSize(appName, width, height)

Set default dialog dimensions.

Parameter Type Description
appName string App name
width number Width in pixels
height number Height in pixels

AddToBlizOptions

function LoolibConfigDialogMixin:AddToBlizOptions(appName, name, parent, ...)

Add to Blizzard Settings panel.

Parameter Type Description
appName string App name
name string Display name
parent string Parent category (optional)
... strings Path to group (optional)

Returns: Frame - Settings panel frame

RefreshContent

function LoolibConfigDialogMixin:RefreshContent(appName)

Refresh dialog content for app.

AcquireWidget

function LoolibConfigDialogMixin:AcquireWidget(widgetType, parent, template, frameTypeOverride)

Get widget from pool or create new.

ReleaseWidgets

function LoolibConfigDialogMixin:ReleaseWidgets(container)

Release all widgets in container back to pools.

Render Functions

Each type has a render function returning new yOffset:

function LoolibConfigDialogMixin:RenderHeader(parent, name, yOffset, contentWidth)
function LoolibConfigDialogMixin:RenderDescription(parent, option, name, desc, yOffset, contentWidth)
function LoolibConfigDialogMixin:RenderToggle(parent, option, name, desc, registry, info, disabled, yOffset)
function LoolibConfigDialogMixin:RenderInput(parent, option, name, desc, registry, info, disabled, yOffset, widthMod)
function LoolibConfigDialogMixin:RenderRange(parent, option, name, desc, registry, info, disabled, yOffset, widthMod)
function LoolibConfigDialogMixin:RenderSelect(parent, option, name, desc, registry, info, disabled, yOffset, widthMod)
function LoolibConfigDialogMixin:RenderMultiSelect(parent, option, name, desc, registry, info, disabled, yOffset, contentWidth)
function LoolibConfigDialogMixin:RenderColor(parent, option, name, desc, registry, info, disabled, yOffset)
function LoolibConfigDialogMixin:RenderExecute(parent, option, name, desc, registry, info, disabled, yOffset, widthMod)
function LoolibConfigDialogMixin:RenderKeybinding(parent, option, name, desc, registry, info, disabled, yOffset)
function LoolibConfigDialogMixin:RenderTexture(parent, option, name, desc, registry, info, disabled, yOffset, widthMod)
function LoolibConfigDialogMixin:RenderFont(parent, option, name, desc, registry, info, disabled, yOffset, widthMod)
function LoolibConfigDialogMixin:RenderInlineGroup(parent, group, rootOptions, registry, path, yOffset, contentWidth, appName)

Customization

Custom Dialog Title

The title comes from options.name:

local options = {
    type = "group",
    name = "My Custom Title",  -- This appears in title bar
    args = { ... }
}

Dynamic title:

name = function(info)
    return "My Addon v" .. GetAddOnMetadata("MyAddon", "Version")
end,

Custom Default Size

-- Before first open
ConfigDialogModule.Dialog:SetDefaultSize("MyAddon", 900, 700)

Post-Processing

Listen for dialog open to customize:

ConfigDialogModule.Dialog:RegisterCallback("OnDialogOpened", function(appName)
    if appName == "MyAddon" then
        local dialog = ConfigDialogModule.Dialog.dialogs[appName]
        -- Customize dialog frame
        dialog:SetFrameStrata("FULLSCREEN")
    end
end)

Custom Refresh Behavior

Force refresh when your addon state changes:

function MyAddon:OnStateChange()
    -- Update your data
    self.db.state = newState

    -- Refresh config dialog if open
    if ConfigDialogModule.Dialog.dialogs["MyAddon"] then
        ConfigDialogModule.Dialog:RefreshContent("MyAddon")
    end
end

Troubleshooting

Dialog Not Opening

-- Check if options registered
if not LoolibConfig:IsRegistered("MyAddon") then
    print("Options not registered!")
end

-- Check for errors in options table
local options = LoolibConfig:GetOptionsTable("MyAddon")
if not options then
    print("Failed to get options table")
end

Dialog Not Showing Options

-- Ensure args table exists
local options = {
    type = "group",
    name = "Test",
    args = {},  -- Must exist, even if empty
}

-- Check hidden property
{
    type = "toggle",
    name = "Test",
    hidden = function(info)
        print("Hidden check called")
        return false
    end,
}

Options Not Updating

-- Make sure to notify changes
LoolibConfig:NotifyChange("MyAddon")

-- Check that get/set work correctly
get = function(info)
    local value = db.setting
    print("Get called, value:", value)
    return value
end,

Memory Leaks

-- Ensure dialogs are properly closed
-- Widget pooling should handle most cases

-- If you create custom widgets, clean them up:
dialog:SetScript("OnHide", function()
    -- Cleanup code
end)

Performance Issues

  1. Avoid expensive operations in get/set functions
  2. Cache dynamic values when possible
  3. Use static values where dynamic not needed
  4. Minimize NotifyChange calls
-- Bad: expensive in get
get = function()
    local items = {}
    for i = 1, 1000 do
        items[i] = GetItemInfo(i)  -- API call each time!
    end
    return items
end,

-- Good: cache results
local itemCache
values = function()
    if not itemCache then
        itemCache = {}
        -- Build once
    end
    return itemCache
end,

See Also