Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 36 | Seerah-7 | --[[headerData = { |
2 | Seerah-7 | type = "header", |
|
3 | Seerah-7 | name = "My Header", |
|
4 | Seerah-7 | width = "full", --or "half" (optional) |
|
5 | Seerah-7 | reference = "MyAddonHeader" --(optional) unique global reference to control |
|
6 | Seerah-7 | } ]] |
|
7 | Seerah-7 | ||
8 | Seerah-7 | ||
9 | 48 | Seerah-7 | local widgetVersion = 4 |
10 | 36 | 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 | 49 | Seerah-7 | local tinsert = table.insert |
15 | 36 | Seerah-7 | |
16 | 48 | Seerah-7 | local function UpdateValue(control) |
17 | Seerah-7 | control.header:SetText(control.data.name) |
|
18 | Seerah-7 | end |
|
19 | Seerah-7 | ||
20 | 36 | Seerah-7 | function LAMCreateControl.header(parent, headerData, controlName) |
21 | Seerah-7 | local control = wm:CreateTopLevelWindow(controlName or headerData.reference) |
|
22 | 45 | Seerah-7 | control:SetParent(parent.scroll or parent) |
23 | 36 | 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 | 48 | 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 | 36 | Seerah-7 | return control |
47 | Seerah-7 | end |