forked from phuein/UserScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.lua
More file actions
45 lines (35 loc) · 1.44 KB
/
Copy pathheader.lua
File metadata and controls
45 lines (35 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--[[headerData = {
type = "header",
name = "My Header",
width = "full", --or "half" (optional)
reference = "MyAddonHeader" --(optional) unique global reference to control
} ]]
local widgetVersion = 6
local LAM = LibStub("LibAddonMenu-2.0")
if not LAM:RegisterWidget("header", widgetVersion) then return end
local wm = WINDOW_MANAGER
local tinsert = table.insert
local function UpdateValue(control)
control.header:SetText(control.data.name)
end
local MIN_HEIGHT = 30
function LAMCreateControl.header(parent, headerData, controlName)
local control = LAM.util.CreateBaseControl(parent, headerData, controlName)
local isHalfWidth = control.isHalfWidth
local width = control:GetWidth()
control:SetDimensions(isHalfWidth and width / 2 or width, MIN_HEIGHT)
control.divider = wm:CreateControlFromVirtual(nil, control, "ZO_Options_Divider")
local divider = control.divider
divider:SetWidth(isHalfWidth and width / 2 or width)
divider:SetAnchor(TOPLEFT)
control.header = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel")
local header = control.header
header:SetAnchor(TOPLEFT, divider, BOTTOMLEFT)
header:SetAnchor(BOTTOMRIGHT)
header:SetText(headerData.name)
control.UpdateValue = UpdateValue
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
tinsert(control.panel.controlsToRefresh, control)
end
return control
end