forked from phuein/UserScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdescription.lua
More file actions
64 lines (52 loc) · 1.94 KB
/
Copy pathdescription.lua
File metadata and controls
64 lines (52 loc) · 1.94 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--[[descriptionData = {
type = "description",
title = "My Title", --(optional)
text = "My description text to display.",
width = "full", --or "half" (optional)
reference = "MyAddonDescription" --(optional) unique global reference to control
} ]]
local widgetVersion = 6
local LAM = LibStub("LibAddonMenu-2.0")
if not LAM:RegisterWidget("description", widgetVersion) then return end
local wm = WINDOW_MANAGER
local tinsert = table.insert
local function UpdateValue(control)
if control.title then
control.title:SetText(control.data.title)
end
control.desc:SetText(control.data.text)
end
local MIN_HEIGHT = 26
function LAMCreateControl.description(parent, descriptionData, controlName)
local control = LAM.util.CreateBaseControl(parent, descriptionData, controlName)
local isHalfWidth = control.isHalfWidth
local width = control:GetWidth()
control:SetResizeToFitDescendents(true)
if isHalfWidth then
control:SetDimensionConstraints(width / 2, MIN_HEIGHT, width / 2, MIN_HEIGHT * 4)
else
control:SetDimensionConstraints(width, MIN_HEIGHT, width, MIN_HEIGHT * 4)
end
control.desc = wm:CreateControl(nil, control, CT_LABEL)
local desc = control.desc
desc:SetVerticalAlignment(TEXT_ALIGN_TOP)
desc:SetFont("ZoFontGame")
desc:SetText(descriptionData.text)
desc:SetWidth(isHalfWidth and width / 2 or width)
if descriptionData.title then
control.title = wm:CreateControl(nil, control, CT_LABEL)
local title = control.title
title:SetWidth(isHalfWidth and width / 2 or width)
title:SetAnchor(TOPLEFT, control, TOPLEFT)
title:SetFont("ZoFontWinH4")
title:SetText(descriptionData.title)
desc:SetAnchor(TOPLEFT, title, BOTTOMLEFT)
else
desc:SetAnchor(TOPLEFT)
end
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