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 | 28 | Seerah-7 | reference = "MyAddonHeader" --(optional) unique global reference to control |
6 | 10 | Seerah-7 | } ]] |
7 | Seerah-7 | ||
8 | Seerah-7 | ||
9 | 32 | Seerah-7 | local widgetVersion = 2 |
10 | 10 | Seerah-7 | local LAM = LibStub("LibAddonMenu-2.0") |
11 | 14 | Seerah-7 | if not LAM:RegisterWidget("header", widgetVersion) then return end |
12 | 10 | Seerah-7 | |
13 | Seerah-7 | local wm = WINDOW_MANAGER |
|
14 | Seerah-7 | ||
15 | Seerah-7 | function LAMCreateControl.header(parent, headerData, controlName) |
|
16 | 28 | Seerah-7 | local control = wm:CreateTopLevelWindow(controlName or headerData.reference) |
17 | 11 | Seerah-7 | control:SetParent(parent.scroll) |
18 | 10 | Seerah-7 | local isHalfWidth = headerData.width == "half" |
19 | Seerah-7 | control:SetDimensions(isHalfWidth and 250 or 510, 30) |
|
20 | Seerah-7 | ||
21 | Seerah-7 | control.divider = wm:CreateControlFromVirtual(nil, control, "ZO_Options_Divider") |
|
22 | Seerah-7 | local divider = control.divider |
|
23 | Seerah-7 | divider:SetWidth(isHalfWidth and 250 or 510) |
|
24 | Seerah-7 | divider:SetAnchor(TOPLEFT) |
|
25 | Seerah-7 | ||
26 | Seerah-7 | control.header = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") |
|
27 | Seerah-7 | local header = control.header |
|
28 | Seerah-7 | header:SetAnchor(TOPLEFT, divider, BOTTOMLEFT) |
|
29 | Seerah-7 | header:SetAnchor(BOTTOMRIGHT) |
|
30 | Seerah-7 | header:SetText(headerData.name) |
|
31 | Seerah-7 | ||
32 | Seerah-7 | control.panel = parent.panel or parent --if this is in a submenu, panel is its parent |
|
33 | Seerah-7 | control.data = headerData |
|
34 | Seerah-7 | ||
35 | Seerah-7 | return control |
|
36 | Seerah-7 | end |