ESOUI SVN ZAMStats

[/] [trunk/] [ZAM_Stats/] [libs/] [LibAddonMenu-2.0/] [controls/] [header.lua] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 Seerah-7
--[[headerData = {
2 Seerah-7
        type = "header",
3 Seerah-7
        name = "My Header",
4 Seerah-7
        width = "full", --or "half" (optional)
5 11 Seerah-7
        reference = "MyAddonHeader"     --(optional) unique global reference to control
6 10 Seerah-7
}       ]]
7 Seerah-7
 
8 Seerah-7
 
9 14 Seerah-7
local widgetVersion = 4
10 10 Seerah-7
local LAM = LibStub("LibAddonMenu-2.0")
11 Seerah-7
if not LAM:RegisterWidget("header", widgetVersion) then return end
12 Seerah-7
 
13 Seerah-7
local wm = WINDOW_MANAGER
14 14 Seerah-7
local tinsert = table.insert
15 10 Seerah-7
 
16 14 Seerah-7
local function UpdateValue(control)
17 Seerah-7
        control.header:SetText(control.data.name)
18 Seerah-7
end
19 Seerah-7
 
20 10 Seerah-7
function LAMCreateControl.header(parent, headerData, controlName)
21 11 Seerah-7
        local control = wm:CreateTopLevelWindow(controlName or headerData.reference)
22 13 Seerah-7
        control:SetParent(parent.scroll or parent)
23 10 Seerah-7
        local isHalfWidth = headerData.width == "half"
24 Seerah-7
        control:SetDimensions(isHalfWidth and 250 or 510, 30)
25 Seerah-7
 
26 Seerah-7
        control.divider = wm:CreateControlFromVirtual(nil, control, "ZO_Options_Divider")
27 Seerah-7
        local divider = control.divider
28 Seerah-7
        divider:SetWidth(isHalfWidth and 250 or 510)
29 Seerah-7
        divider:SetAnchor(TOPLEFT)
30 Seerah-7
 
31 Seerah-7
        control.header = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel")
32 Seerah-7
        local header = control.header
33 Seerah-7
        header:SetAnchor(TOPLEFT, divider, BOTTOMLEFT)
34 Seerah-7
        header:SetAnchor(BOTTOMRIGHT)
35 Seerah-7
        header:SetText(headerData.name)
36 Seerah-7
 
37 Seerah-7
        control.panel = parent.panel or parent  --if this is in a submenu, panel is its parent
38 Seerah-7
        control.data = headerData
39 Seerah-7
 
40 14 Seerah-7
        control.UpdateValue = UpdateValue
41 Seerah-7
 
42 Seerah-7
        if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list
43 Seerah-7
                tinsert(control.panel.controlsToRefresh, control)
44 Seerah-7
        end
45 Seerah-7
 
46 10 Seerah-7
        return control
47 Seerah-7
end