ESOUI SVN LibAddonMenu

[/] [branches/] [LibAddonMenu-2.0/] [LibAddonMenu-2.0/] [controls/] [custom.lua] - Blame information for rev 32

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 Seerah-7
--[[customData = {
2 Seerah-7
        type = "custom",
3 Seerah-7
        reference = "MyAddonCustomControl",     --unique name for your control to use as reference
4 Seerah-7
        width = "full", --or "half" (optional)
5 Seerah-7
}       ]]
6 Seerah-7
 
7 32 Seerah-7
local widgetVersion = 2
8 22 Seerah-7
local LAM = LibStub("LibAddonMenu-2.0")
9 Seerah-7
if not LAM:RegisterWidget("custom", widgetVersion) then return end
10 Seerah-7
 
11 Seerah-7
local wm = WINDOW_MANAGER
12 Seerah-7
 
13 Seerah-7
function LAMCreateControl.custom(parent, customData, controlName)
14 Seerah-7
        local control = wm:CreateTopLevelWindow(controlName or customData.reference)
15 Seerah-7
        control:SetResizeToFitDescendents(true)
16 Seerah-7
        control:SetParent(parent.scroll)
17 Seerah-7
 
18 Seerah-7
        local isHalfWidth = customData.width == "half"
19 Seerah-7
        if isHalfWidth then     --note these restrictions
20 Seerah-7
                control:SetDimensionConstraints(250, 55, 250, 100)
21 Seerah-7
                control:SetDimensions(250, 55)
22 Seerah-7
        else
23 Seerah-7
                control:SetDimensionConstraints(510, 30, 510, 100)
24 Seerah-7
                control:SetDimensions(510, 30)
25 Seerah-7
        end
26 Seerah-7
 
27 Seerah-7
        control.panel = parent.panel or parent  --if this is in a submenu, panel is its parent
28 Seerah-7
        control.data = customData
29 Seerah-7
 
30 Seerah-7
        return control
31 Seerah-7
end