Comprehensive documentation for the Loolib fluent API widget enhancement system.
- Overview
- Quick Start
- WidgetMod Mixin
- EnhancedSlider
- PopupMenu
- EnhancedDropdown
- Usage Examples
- API Reference
The Loolib Enhanced Widgets system provides a fluent API for creating and configuring WoW UI widgets. Instead of writing verbose code with many separate method calls, you chain methods together for concise, readable widget configuration.
Traditional WoW widget configuration:
local slider = CreateFrame("Slider", nil, parent, "MinimalSliderTemplate")
slider:SetSize(200, 20)
slider:SetPoint("CENTER")
slider:SetMinMaxValues(0, 100)
slider:SetValue(50)
slider:SetScript("OnValueChanged", function(self, value)
print("Value changed:", value)
end)With Loolib's fluent API:
local slider = LoolibCreateEnhancedSlider(parent)
:Size(200, 20)
:Point("CENTER")
:Range(0, 100)
:SetTo(50)
:OnChange(function(self, value)
print("Value changed:", value)
end)The Enhanced Widgets system includes four main components:
| Component | Purpose |
|---|---|
| WidgetMod | Base mixin providing fluent API for any frame |
| EnhancedSlider | Advanced slider with labels, value display, and formatting |
| PopupMenu | Context menus with icons, checkboxes, submenus |
| EnhancedDropdown | Feature-rich dropdown with nested menus, embedded controls |
Inspired by MaxDps Rotation Tool's Mod() pattern, but designed specifically for WoW's native frame system:
| Feature | Loolib WidgetMod | MRT Mod() |
|---|---|---|
| Chaining API | Yes | Yes |
| Native frames | Yes | Custom system |
| External deps | None | MRT framework |
| Mixins | LoolibMixin | Custom |
| Event handling | Native scripts | Custom |
| Profile support | Via SavedVariables | Built-in |
Enhance any existing frame with the WidgetMod API:
-- Apply to existing frame
local frame = CreateFrame("Frame", nil, UIParent)
LoolibApplyWidgetMod(frame)
frame:Size(200, 100)
:Point("CENTER")
:Alpha(0.9)
:Tooltip("This is a tooltip")
:OnClick(function(self)
print("Clicked!")
end)local slider = LoolibCreateEnhancedSlider(UIParent)
:Size(200, 20)
:Point("CENTER")
:Title("Volume")
:Range(0, 100)
:Step(5)
:SetTo(50)
:ShowValue("%d%%")
:ShowLabels("Quiet", "Loud")
:OnChange(function(self, value, userInput)
SetVolume(value / 100)
end)
:Tooltip("Adjust the volume level")local menu = LoolibCreatePopupMenu()
:SetOptions({
{text = "Copy", value = "copy", icon = "Interface\\Icons\\INV_Misc_Note_01"},
{text = "Paste", value = "paste", disabled = not HasClipboard()},
{isSeparator = true},
{text = "Delete", value = "delete", colorCode = "|cffff0000"},
})
:OnSelect(function(value, item)
HandleAction(value)
end)
:ShowAtCursor()local dropdown = LoolibCreateEnhancedDropdown(parent)
:Size(150, 24)
:Point("TOPLEFT", 10, -10)
:SetList({
{text = "Option 1", value = 1},
{text = "Option 2", value = 2},
{text = "Submenu", subMenu = {
{text = "Sub 1", value = "sub1"},
{text = "Sub 2", value = "sub2"},
}},
})
:SetValue(1)
:OnSelect(function(value)
print("Selected:", value)
end)The base mixin that provides fluent API methods to any frame.
local frame = CreateFrame("Button", nil, UIParent)
LoolibApplyWidgetMod(frame)
-- Now you can chain methods
frame:Size(100, 30):Point("CENTER"):Text("Click Me")local frame = LoolibCreateModFrame("Frame", UIParent)
:Size(200, 100)
:Point("CENTER")
:Alpha(0.8)Set width and height:
-- Both dimensions
frame:Size(200, 100)
-- Square (height defaults to width)
frame:Size(100)Set individual dimensions:
frame:Width(250)
frame:Height(150)Smart positioning with multiple signatures:
-- Simple anchor to parent
frame:Point("CENTER")
-- Anchor with offsets
frame:Point("TOPLEFT", 10, -10)
-- Anchor to another frame
frame:Point("TOPLEFT", otherFrame, 5, -5)
-- Full anchor specification
frame:Point("TOPLEFT", otherFrame, "BOTTOMLEFT", 0, -5)
-- SetAllPoints to frame
frame:Point(otherFrame)
-- Two numbers = TOPLEFT + offsets
frame:Point(10, -10) -- Same as Point("TOPLEFT", 10, -10)
-- Special: 'x' means parent
frame:Point("LEFT", 'x', "RIGHT", 5, 0) -- Anchor to parent's rightClear all points and set a new one:
frame:NewPoint("CENTER")
frame:NewPoint("TOPLEFT", 20, -20)Clear all anchor points:
frame:ClearPoints()Set transparency:
frame:Alpha(0.8) -- 0 = invisible, 1 = opaqueSet scale multiplier:
frame:Scale(1.5)Conditional visibility:
frame:Shown(shouldShow) -- true to show, false to hide
frame:Shown(db.enabled)Explicit show/hide:
frame:ShowFrame()
frame:HideFrame()Control layering:
frame:FrameLevel(10)
frame:FrameStrata("DIALOG")All script handlers return self for chaining.
button:OnClick(function(self, button, down)
if button == "LeftButton" then
print("Left clicked!")
end
end)Mouse hover handlers:
frame:OnEnter(function(self, motion)
self:SetAlpha(1)
end)
:OnLeave(function(self, motion)
self:SetAlpha(0.8)
end)frame:OnShow(function(self)
print("Frame shown")
end)
:OnHide(function(self)
print("Frame hidden")
end)
-- Skip first run (don't execute immediately)
frame:OnShow(function(self)
RefreshData()
end, true) -- skipFirstRunframe:OnUpdate(function(self, elapsed)
self.timer = (self.timer or 0) + elapsed
if self.timer > 1 then
self.timer = 0
DoSomething()
end
end)frame:OnMouseDown(function(self, button)
print("Mouse down:", button)
end)
:OnMouseUp(function(self, button)
print("Mouse up:", button)
end)
:OnMouseWheel(function(self, delta)
AdjustZoom(delta)
end)frame:OnDragStart(function(self, button)
self:StartMoving()
end)
:OnDragStop(function(self)
self:StopMovingOrSizing()
end)For sliders and editboxes:
slider:OnValueChanged(function(self, value)
print("Value:", value)
end)
editbox:OnTextChanged(function(self, userInput)
if userInput then
ValidateInput(self:GetText())
end
end)editbox:OnEnterPressed(function(self)
SubmitValue(self:GetText())
self:ClearFocus()
end)
:OnEscapePressed(function(self)
self:SetText(originalValue)
self:ClearFocus()
end)Add tooltip to widget. Uses HookScript internally so it does not clobber
existing OnEnter/OnLeave handlers. Calling :Tooltip() multiple times
safely updates the tooltip text without re-hooking.
-- Simple tooltip
button:Tooltip("Click to activate")
-- Multi-line tooltip
button:Tooltip({
"Feature Name",
"Description line 1",
"Description line 2",
})Set tooltip anchor point:
button:Tooltip("Help text")
:TooltipAnchor("ANCHOR_TOP")Available anchors:
"ANCHOR_RIGHT"(default)"ANCHOR_LEFT""ANCHOR_TOP""ANCHOR_BOTTOM""ANCHOR_CURSOR""ANCHOR_TOPRIGHT""ANCHOR_TOPLEFT""ANCHOR_BOTTOMRIGHT""ANCHOR_BOTTOMLEFT"
Execute a function inline while chaining:
frame:Size(100, 100)
:Run(function(self)
self.customProperty = true
self.data = {}
end)
:Point("CENTER")Control interactive state:
button:EnableWidget()
button:DisableWidget()
button:SetEnabled(hasPermission)Set text content:
button:Text("Click Me")
fontString:Text("Hello World")
editbox:Text("Default value")Enable mouse input:
frame:Mouse(true) -- Enable mouse
frame:Mouse(false) -- Disable mouse
frame:MouseWheel() -- Enable mouse wheelMake frame draggable:
frame:Movable() -- Left button (default)
frame:Movable("RightButton") -- Right button drag
-- Automatically sets up drag handlers if not presentPrevent frame from going off-screen:
frame:ClampedToScreen(true)
frame:ClampedToScreen(false)Change parent frame:
frame:Parent(newParent)local button = LoolibCreateModFrame("Button", UIParent, "UIPanelButtonTemplate")
:Size(120, 30)
:Point("CENTER")
:Text("My Button")
:Tooltip("Click to do something")
:OnClick(function(self)
DoAction()
end)
:OnEnter(function(self)
self:SetAlpha(1)
end)
:OnLeave(function(self)
self:SetAlpha(0.8)
end)
:SetEnabled(true)
:Alpha(0.8)Advanced slider widget with value display, labels, and fluent API.
local slider = LoolibCreateEnhancedSlider(parent, name, template)| Parameter | Type | Required | Description |
|---|---|---|---|
parent |
Frame | Yes | Parent frame |
name |
string | No | Global name |
template |
string | No | Template (default: "MinimalSliderTemplate") |
All methods return self for chaining.
Set minimum and maximum values:
slider:Range(0, 100)
slider:Range(-10, 10)
-- Get current range
local min, max = slider:GetRange()Set step increment:
slider:Step(5) -- Steps of 5
slider:Step(0.1) -- Decimal steps
slider:Step(1) -- Integer steps
-- Get current step
local step = slider:GetStep()Set current value:
slider:SetTo(50)
-- Get current value
local value = slider:GetTo()Set change callback:
slider:OnChange(function(self, value, userInput)
-- value: new slider value
-- userInput: true if changed by user, false if programmatic
if userInput then
db.volume = value
UpdateVolume()
end
end)Display value above slider:
slider:ShowValue() -- Show with default format "%d"
slider:ShowValue("%d%%") -- Percentage: "50%"
slider:ShowValue("%.1f") -- Decimal: "50.5"
slider:ShowValue("%d sec") -- With units: "50 sec"
-- Hide value display
slider:HideValue()Show min/max labels below slider:
-- Custom labels
slider:ShowLabels("Quiet", "Loud")
-- Automatic labels (uses min/max values)
slider:ShowLabels()
-- Hide labels
slider:HideLabels()Set slider title/label:
slider:Title("Volume")
slider:Title("Opacity")
-- Hide title
slider:HideTitle()Change value format string:
slider:ValueFormat("%d%%")
slider:ValueFormat("%.2f seconds")Enable or disable slider:
slider:SetEnabled(true) -- Enabled, alpha 1
slider:SetEnabled(false) -- Disabled, alpha 0.5Add tooltip:
slider:Tooltip("Adjust the volume level")
-- Multi-line tooltip
slider:Tooltip({
"Volume Control",
"Adjusts game volume from 0% to 100%",
"Use mouse wheel for fine adjustments",
})slider:TooltipAnchor("ANCHOR_RIGHT")Customize text appearance:
-- Set font for all text
slider:Font("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
-- Set size only
slider:FontSize(14)
-- Set color
slider:TextColor(1, 1, 0) -- Yellow
slider:TextColor(1, 1, 1, 0.8) -- White with alphaAdd right-click to reset:
slider:SetDefault(50) -- Right-click resets to 50Vertical or horizontal:
slider:Orientation("HORIZONTAL") -- Default
slider:Orientation("VERTICAL")Control step behavior:
slider:ObeyStepOnDrag(true) -- Snap to steps while dragging
slider:ObeyStepOnDrag(false) -- Smooth dragginglocal volumeSlider = LoolibCreateEnhancedSlider(settingsFrame)
:Size(250, 20)
:Point("TOPLEFT", 20, -60)
:Title("Master Volume")
:Range(0, 100)
:Step(5)
:SetTo(db.volume or 50)
:ShowValue("%d%%")
:ShowLabels("Mute", "Max")
:OnChange(function(self, value, userInput)
if userInput then
db.volume = value
SetVolume(value / 100)
end
end)
:Tooltip({
"Master Volume",
"Control overall game volume",
"Right-click to reset to default",
})
:SetDefault(50)EnhancedSlider creates these child elements:
| Element | Type | Purpose |
|---|---|---|
slider.titleText |
FontString | Title above slider |
slider.valueText |
FontString | Value display |
slider.minLabel |
FontString | Minimum label |
slider.maxLabel |
FontString | Maximum label |
Access if needed:
slider.titleText:SetTextColor(1, 1, 0)
slider.valueText:SetFont("Fonts\\ARIALN.TTF", 14)Context menus with icons, checkboxes, submenus, and more.
local menu = LoolibCreatePopupMenu(parent, name)| Parameter | Type | Required | Description |
|---|---|---|---|
parent |
Frame | No | Parent frame (default: UIParent) |
name |
string | No | Global name |
For simple use cases, use the shared menu:
local menu = LoolibGetSharedPopupMenu()Menu items are defined as tables with these properties:
{
-- Required
text = "Menu Item", -- Display text
-- Value/Action
value = any, -- Value passed to callback
func = function(value), -- Item-specific callback
-- Appearance
icon = "Interface\\Icons\\...", -- Icon texture path
iconIsAtlas = false, -- If true, icon is atlas name
colorCode = "|cFFRRGGBB", -- Text color prefix
-- State
disabled = false, -- Grayed out, not clickable
checked = false, -- Show checkmark
radio = false, -- Radio button style
-- Special Types
isTitle = false, -- Bold header, non-clickable
isSeparator = false, -- Horizontal line
-- Behavior
keepOpen = false, -- Don't close menu on click
subMenu = { ... }, -- Nested menu items
-- Tooltip
tooltip = "Help text", -- Hover tooltip
}Set menu items:
menu:SetOptions({
{text = "New", value = "new"},
{text = "Open", value = "open"},
{isSeparator = true},
{text = "Exit", value = "exit"},
})Add single item:
menu:AddOption({
text = "Delete",
value = "delete",
icon = "Interface\\Icons\\INV_Misc_QuestionMark",
colorCode = "|cffff0000",
})Add horizontal divider:
menu:AddSeparator()Add section header:
menu:AddTitle("File Operations")Set selection callback:
menu:OnSelect(function(value, menuItem)
print("Selected:", value)
print("Item text:", menuItem.text)
end)Set menu width:
menu:SetMenuWidth(200)Show menu at cursor position:
menu:ShowAtCursor()Show anchored to frame:
menu:ShowAt(anchorFrame)
menu:ShowAt(anchorFrame, "TOPLEFT", "BOTTOMLEFT")
menu:ShowAt(anchorFrame, "TOPLEFT", "BOTTOMLEFT", 0, -5)| Parameter | Type | Default | Description |
|---|---|---|---|
anchorFrame |
Frame | Required | Anchor frame |
anchor |
string | "TOPLEFT" | Menu anchor point |
relativeAnchor |
string | "BOTTOMLEFT" | Frame anchor point |
xOffset |
number | 0 | X offset |
yOffset |
number | 0 | Y offset |
Close the menu:
menu:Close()Texture or atlas icons:
-- Texture icon
{
text = "Item",
icon = "Interface\\Icons\\INV_Misc_Bag_08",
}
-- Atlas icon
{
text = "Settings",
icon = "Gamepad_Ltr_Menu_64",
iconIsAtlas = true,
}Show checked state:
{
text = "Enable Feature",
value = "enable",
checked = db.featureEnabled,
}Mutually exclusive selection:
{
text = "Mode A",
value = "modeA",
radio = true,
checked = db.mode == "modeA",
},
{
text = "Mode B",
value = "modeB",
radio = true,
checked = db.mode == "modeB",
}{
text = "Delete",
colorCode = "|cffff0000", -- Red
},
{
text = "Success",
colorCode = "|cff00ff00", -- Green
}{
text = "Disabled Action",
disabled = true,
}{text = "File", isTitle = true},
{text = "New", value = "new"},
{text = "Open", value = "open"},
{isSeparator = true},
{text = "Edit", isTitle = true},
{text = "Copy", value = "copy"},Nested menus:
{
text = "Export",
subMenu = {
{text = "As JSON", value = "json"},
{text = "As XML", value = "xml"},
{text = "As CSV", value = "csv"},
},
}{
text = "Do Action",
func = function(value)
PerformAction()
end,
}Prevent menu from closing:
{
text = "Toggle Debug",
keepOpen = true,
func = function()
db.debug = not db.debug
end,
}{
text = "Advanced",
tooltip = "This is an advanced feature that requires caution",
}local contextMenu = LoolibCreatePopupMenu()
:SetOptions({
-- Title
{text = "Actions", isTitle = true},
-- Basic actions with icons
{
text = "Copy",
value = "copy",
icon = "Interface\\Icons\\INV_Misc_Note_01",
disabled = not HasSelection(),
},
{
text = "Paste",
value = "paste",
icon = "Interface\\Icons\\INV_Misc_Note_02",
disabled = not HasClipboard(),
},
{isSeparator = true},
-- Submenu
{
text = "Export",
subMenu = {
{text = "As String", value = "export_string"},
{text = "To File", value = "export_file"},
},
},
{isSeparator = true},
-- Dangerous action
{
text = "Delete",
value = "delete",
colorCode = "|cffff0000",
icon = "Interface\\Icons\\INV_Misc_QuestionMark",
iconIsAtlas = false,
},
})
:OnSelect(function(value, item)
if value == "copy" then
DoCopy()
elseif value == "paste" then
DoPaste()
elseif value == "delete" then
DoDelete()
end
end)
-- Show on right-click
frame:SetScript("OnMouseUp", function(self, button)
if button == "RightButton" then
contextMenu:ShowAtCursor()
end
end)Alternative API for building menus:
local menu = LoolibPopupMenu()
:AddTitle("File")
:AddOption("New", "new")
:AddOption("Open", "open")
:AddSeparator()
:AddOption("Exit", "exit")
:OnSelect(function(value)
HandleFileAction(value)
end)
:ShowAtCursor()Menus automatically close when:
- Clicking outside the menu
- Pressing Escape
- Selecting an item (unless
keepOpen = true) - Opening a different menu
Advanced dropdown with submenus, embedded controls, and extensive customization.
local dropdown = LoolibCreateEnhancedDropdown(parent, name)| Parameter | Type | Required | Description |
|---|---|---|---|
parent |
Frame | Yes | Parent frame |
name |
string | No | Global name |
Extended option structure with embedded controls:
{
-- Basic Properties
text = "Label", -- Display text (required)
value = any, -- Value to store/return
-- Appearance
icon = "path" or atlasName, -- Left-side icon
iconIsAtlas = false, -- If true, icon is atlas
iconCoords = {l,r,t,b}, -- Texture coordinates for icon
colorCode = "|cFFRRGGBB", -- Color code prefix
font = "FontObject", -- Custom font
-- State
disabled = false, -- Grayed out
-- Special Types
isTitle = false, -- Non-selectable header
isSeparator = false, -- Horizontal divider
-- Navigation
subMenu = { ... }, -- Nested options
-- Advanced Features (MRT-inspired)
slider = {min, max, value, callback, step}, -- Embedded slider
editBox = {defaultText, callback, width}, -- Embedded edit box
checkState = bool, -- Checkbox state
onCheckChange = function, -- Checkbox callback
radio = false, -- Radio button style
padding = 0, -- Extra vertical padding
-- Help
tooltip = "text", -- Hover tooltip
}Set dropdown options:
dropdown:SetList({
{text = "Option 1", value = 1},
{text = "Option 2", value = 2},
{text = "Option 3", value = 3},
})Add single option:
dropdown:AddOption({
text = "New Option",
value = "new",
})Remove all options:
dropdown:ClearOptions()Set selected value:
dropdown:SetValue(2)
-- Get selected value
local value = dropdown:GetValue()Manually set button text:
dropdown:SetText("Custom Text")Set selection callback:
dropdown:OnSelect(function(value, option)
print("Selected:", value)
db.setting = value
ApplySettings()
end)Set menu width:
dropdown:SetMenuWidth(200)Set maximum visible lines before scrolling:
dropdown:SetMaxLines(15) -- Default
dropdown:SetMaxLines(20)Control automatic text update:
dropdown:SetAutoText(true) -- Auto-update button text (default)
dropdown:SetAutoText(false) -- Manual text controlAdd tooltip to button:
dropdown:Tooltip("Select an option from the list")Enable or disable dropdown:
dropdown:SetEnabled(true)
dropdown:SetEnabled(false)Open the dropdown menu:
dropdown:OpenMenu()Close the dropdown menu:
dropdown:CloseMenu()Toggle menu open/closed:
dropdown:Toggle()Add a slider within a dropdown item:
{
text = "Opacity",
slider = {
0, -- min
1, -- max
0.8, -- current value
function(value) -- callback
db.opacity = value
UpdateOpacity()
end,
0.05, -- step (optional)
},
}Add a text input within a dropdown item:
{
text = "Custom Name",
editBox = {
db.customName, -- default text
function(text) -- callback
db.customName = text
UpdateName()
end,
150, -- width (optional)
},
}Toggle options within dropdown:
{
text = "Enable Feature",
checkState = db.featureEnabled,
onCheckChange = function(checked)
db.featureEnabled = checked
UpdateFeature()
end,
}Mutually exclusive options:
{
text = "Mode A",
value = "modeA",
radio = true,
checkState = db.mode == "modeA",
}Multi-level nested menus:
{
text = "Advanced",
subMenu = {
{text = "Sub Option 1", value = "sub1"},
{text = "Sub Option 2", value = "sub2"},
{
text = "More Options",
subMenu = {
{text = "Deep Option 1", value = "deep1"},
{text = "Deep Option 2", value = "deep2"},
},
},
},
}local qualityDropdown = LoolibCreateEnhancedDropdown(settingsFrame)
:Size(200, 24)
:Point("TOPLEFT", 20, -100)
:SetList({
-- Header
{text = "Quality Settings", isTitle = true},
-- Simple options
{text = "Low", value = 1, icon = "Interface\\Icons\\Spell_Nature_Sleep"},
{text = "Medium", value = 2, icon = "Interface\\Icons\\Spell_Nature_NatureTouchGrow"},
{text = "High", value = 3, icon = "Interface\\Icons\\Spell_Nature_HealingTouch"},
{isSeparator = true},
-- Submenu
{
text = "Custom",
subMenu = {
{
text = "Resolution Scale",
slider = {0.5, 2.0, db.resScale or 1.0, function(v)
db.resScale = v
ApplyResolutionScale()
end, 0.1},
},
{
text = "Shadow Quality",
slider = {0, 5, db.shadowQuality or 3, function(v)
db.shadowQuality = v
ApplyShadowQuality()
end, 1},
},
},
},
{isSeparator = true},
-- Checkbox options
{
text = "Enable Anti-Aliasing",
checkState = db.antiAliasing,
onCheckChange = function(checked)
db.antiAliasing = checked
ApplyAASettings()
end,
},
{
text = "Enable Bloom",
checkState = db.bloom,
onCheckChange = function(checked)
db.bloom = checked
ApplyBloomSettings()
end,
},
})
:SetValue(db.quality or 2)
:OnSelect(function(value, option)
db.quality = value
ApplyQuality()
end)
:Tooltip("Select graphics quality preset")EnhancedDropdown creates these elements:
| Element | Type | Purpose |
|---|---|---|
dropdown.icon |
Texture | Button icon (left) |
dropdown.text |
FontString | Button text |
dropdown.arrow |
Texture | Dropdown arrow (right) |
dropdown.highlight |
Texture | Hover highlight |
local panel = LoolibCreateModFrame("Frame", UIParent, "BackdropTemplate")
:Size(400, 300)
:Point("CENTER")
:Run(function(self)
self:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
edgeFile = "Interface\\Buttons\\WHITE8x8",
edgeSize = 1,
})
self:SetBackdropColor(0.1, 0.1, 0.1, 0.9)
self:SetBackdropBorderColor(0.3, 0.3, 0.3, 1)
end)
-- Volume slider
local volumeSlider = LoolibCreateEnhancedSlider(panel)
:Size(300, 20)
:Point("TOP", 0, -40)
:Title("Master Volume")
:Range(0, 100)
:Step(5)
:SetTo(db.volume)
:ShowValue("%d%%")
:ShowLabels("Mute", "Max")
:OnChange(function(self, value, userInput)
if userInput then
db.volume = value
SetVolume(value / 100)
end
end)
-- Opacity slider
local opacitySlider = LoolibCreateEnhancedSlider(panel)
:Size(300, 20)
:Point("TOP", volumeSlider, "BOTTOM", 0, -40)
:Title("Window Opacity")
:Range(0, 1)
:Step(0.05)
:SetTo(db.opacity)
:ShowValue("%.0f%%")
:OnChange(function(self, value, userInput)
if userInput then
db.opacity = value
panel:SetAlpha(value)
end
end)
-- Scale slider
local scaleSlider = LoolibCreateEnhancedSlider(panel)
:Size(300, 20)
:Point("TOP", opacitySlider, "BOTTOM", 0, -40)
:Title("UI Scale")
:Range(0.5, 2.0)
:Step(0.1)
:SetTo(db.scale)
:ShowValue("%.1fx")
:OnChange(function(self, value, userInput)
if userInput then
db.scale = value
panel:SetScale(value)
end
end)
:SetDefault(1.0)-- Create list frame with right-click menu
local listFrame = LoolibCreateModFrame("Frame", UIParent)
:Size(200, 400)
:Point("CENTER")
-- Create context menu
local contextMenu = LoolibCreatePopupMenu()
-- Right-click handler
listFrame:EnableMouse(true)
listFrame:SetScript("OnMouseUp", function(self, button)
if button == "RightButton" then
local item = GetItemUnderMouse()
contextMenu:SetOptions({
{text = item.name, isTitle = true},
{isSeparator = true},
{
text = "Edit",
value = "edit",
icon = "Interface\\Icons\\INV_Misc_Note_01",
},
{
text = "Duplicate",
value = "duplicate",
icon = "Interface\\Icons\\INV_Misc_Note_02",
},
{isSeparator = true},
{
text = "Delete",
value = "delete",
colorCode = "|cffff0000",
icon = "Interface\\Icons\\Ability_Rogue_FeignDeath",
},
})
contextMenu:OnSelect(function(value)
if value == "edit" then
EditItem(item)
elseif value == "duplicate" then
DuplicateItem(item)
elseif value == "delete" then
DeleteItem(item)
end
end)
contextMenu:ShowAtCursor()
end
end)local classDropdown = LoolibCreateEnhancedDropdown(frame)
:Size(150, 24)
:Point("TOPLEFT", 20, -20)
:SetList({
-- Warrior specs
{
text = "Warrior",
icon = "Interface\\Icons\\ClassIcon_Warrior",
subMenu = {
{text = "Arms", value = "warrior_arms"},
{text = "Fury", value = "warrior_fury"},
{text = "Protection", value = "warrior_prot"},
},
},
-- Paladin specs
{
text = "Paladin",
icon = "Interface\\Icons\\ClassIcon_Paladin",
subMenu = {
{text = "Holy", value = "paladin_holy"},
{text = "Protection", value = "paladin_prot"},
{text = "Retribution", value = "paladin_ret"},
},
},
-- Hunter specs
{
text = "Hunter",
icon = "Interface\\Icons\\ClassIcon_Hunter",
subMenu = {
{text = "Beast Mastery", value = "hunter_bm"},
{text = "Marksmanship", value = "hunter_mm"},
{text = "Survival", value = "hunter_sv"},
},
},
})
:OnSelect(function(value, option)
db.selectedSpec = value
LoadSpecProfile(value)
end)local displayDropdown = LoolibCreateEnhancedDropdown(frame)
:Size(200, 24)
:Point("TOP", 0, -50)
:SetList({
-- Simple options
{text = "Small", value = "small"},
{text = "Medium", value = "medium"},
{text = "Large", value = "large"},
{isSeparator = true},
-- Custom size with embedded slider
{
text = "Custom Size",
slider = {
50, -- min
500, -- max
db.customSize or 200,
function(value)
db.customSize = value
ResizeDisplay(value)
end,
10, -- step
},
},
{isSeparator = true},
-- Custom opacity with embedded slider
{
text = "Opacity",
slider = {
0,
1,
db.displayOpacity or 1,
function(value)
db.displayOpacity = value
SetDisplayOpacity(value)
end,
0.05,
},
},
{isSeparator = true},
-- Toggle options
{
text = "Show Borders",
checkState = db.showBorders,
onCheckChange = function(checked)
db.showBorders = checked
UpdateBorders()
end,
},
{
text = "Show Icons",
checkState = db.showIcons,
onCheckChange = function(checked)
db.showIcons = checked
UpdateIcons()
end,
},
})local movableFrame = LoolibCreateModFrame("Frame", UIParent, "BackdropTemplate")
:Size(300, 200)
:Point("CENTER")
:Run(function(self)
self:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
tile = true,
tileSize = 32,
edgeSize = 32,
insets = {left = 8, right = 8, top = 8, bottom = 8},
})
end)
:Movable() -- Enable dragging
:ClampedToScreen(true)
:Run(function(self)
-- Add title bar
local title = self:CreateFontString(nil, "OVERLAY", "GameFontNormal")
title:SetPoint("TOP", 0, -12)
title:SetText("Movable Window")
-- Add close button
local closeButton = CreateFrame("Button", nil, self, "UIPanelCloseButton")
LoolibApplyWidgetMod(closeButton)
closeButton:Point("TOPRIGHT", -8, -8)
:OnClick(function()
self:Hide()
end)
end)LoolibApplyWidgetMod(frame) → FrameApply WidgetMod mixin to an existing frame.
LoolibCreateModFrame(frameType, parent, template) → FrameCreate a new frame with WidgetMod already applied.
frame:Size(width, height) → self
frame:Width(width) → self
frame:Height(height) → selfframe:Point(...) → self
frame:NewPoint(...) → self
frame:ClearPoints() → selfframe:Alpha(alpha) → self
frame:Scale(scale) → self
frame:Shown(bool) → self
frame:ShowFrame() → self
frame:HideFrame() → self
frame:FrameLevel(level) → self
frame:FrameStrata(strata) → selfframe:OnClick(handler) → self
frame:OnEnter(handler) → self
frame:OnLeave(handler) → self
frame:OnShow(handler, skipFirstRun) → self
frame:OnHide(handler) → self
frame:OnUpdate(handler) → self
frame:OnMouseDown(handler) → self
frame:OnMouseUp(handler) → self
frame:OnMouseWheel(handler) → self
frame:OnDragStart(handler) → self
frame:OnDragStop(handler) → self
frame:OnEvent(handler) → self
frame:OnValueChanged(handler) → self
frame:OnTextChanged(handler) → self
frame:OnEnterPressed(handler) → self
frame:OnEscapePressed(handler) → selfframe:Tooltip(text) → self
frame:TooltipAnchor(anchor) → selfframe:Run(func, ...) → self
frame:EnableWidget() → self
frame:DisableWidget() → self
frame:SetEnabled(enabled) → self
frame:Text(text) → self
frame:Mouse(enable) → self
frame:MouseWheel(enable) → self
frame:Movable(button) → self
frame:ClampedToScreen(clamped) → self
frame:Parent(parent) → selfLoolibCreateEnhancedSlider(parent, name, template) → Sliderslider:Range(min, max) → self
slider:GetRange() → min, max
slider:Step(step) → self
slider:GetStep() → step
slider:SetTo(value) → self
slider:GetTo() → value
slider:OnChange(callback) → self
slider:ShowValue(formatString) → self
slider:HideValue() → self
slider:ShowLabels(minText, maxText) → self
slider:HideLabels() → self
slider:Title(title) → self
slider:HideTitle() → self
slider:ValueFormat(formatString) → self
slider:SetEnabled(enabled) → self
slider:Tooltip(text) → self
slider:TooltipAnchor(anchor) → self
slider:Font(font, size, flags) → self
slider:FontSize(size) → self
slider:TextColor(r, g, b, a) → self
slider:SetDefault(defaultValue) → self
slider:Orientation(orientation) → self
slider:ObeyStepOnDrag(obey) → self
slider:Run(func, ...) → selfLoolibCreatePopupMenu(parent, name) → Frame
LoolibGetSharedPopupMenu() → Frame
LoolibPopupMenu() → Buildermenu:SetOptions(options) → self
menu:AddOption(option) → self
menu:AddSeparator() → self
menu:AddTitle(text) → self
menu:OnSelect(callback) → self
menu:SetMenuWidth(width) → selfmenu:ShowAtCursor()
menu:ShowAt(anchorFrame, anchor, relativeAnchor, xOffset, yOffset)
menu:Close()LoolibCreateEnhancedDropdown(parent, name) → Buttondropdown:SetList(options) → self
dropdown:AddOption(option) → self
dropdown:ClearOptions() → self
dropdown:SetValue(value) → self
dropdown:GetValue() → value
dropdown:SetText(text) → self
dropdown:OnSelect(callback) → self
dropdown:SetMenuWidth(width) → self
dropdown:SetMaxLines(lines) → self
dropdown:SetAutoText(enabled) → self
dropdown:Tooltip(text) → self
dropdown:SetEnabled(enabled) → selfdropdown:OpenMenu()
dropdown:CloseMenu()
dropdown:Toggle()dropdown:Size(width, height) → self
dropdown:Point(...) → self- Config.md - Declarative configuration system
- WindowUtil.md - Window positioning and layout utilities
- SavedVariables.md - Data persistence