Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 10 | Seerah-7 | --[[descriptionData = { |
2 | Seerah-7 | type = "description", |
|
3 | Seerah-7 | title = "My Title", --(optional) |
|
4 | 16 | Seerah-7 | text = "My description text to display.", |
5 | 10 | Seerah-7 | width = "full", --or "half" (optional) |
6 | 28 | Seerah-7 | reference = "MyAddonDescription" --(optional) unique global reference to control |
7 | 10 | Seerah-7 | } ]] |
8 | Seerah-7 | ||
9 | Seerah-7 | ||
10 | 32 | Seerah-7 | local widgetVersion = 2 |
11 | 10 | Seerah-7 | local LAM = LibStub("LibAddonMenu-2.0") |
12 | 14 | Seerah-7 | if not LAM:RegisterWidget("description", widgetVersion) then return end |
13 | 10 | Seerah-7 | |
14 | Seerah-7 | local wm = WINDOW_MANAGER |
|
15 | Seerah-7 | ||
16 | Seerah-7 | function LAMCreateControl.description(parent, descriptionData, controlName) |
|
17 | 28 | Seerah-7 | local control = wm:CreateTopLevelWindow(controlName or descriptionData.reference) |
18 | 10 | Seerah-7 | control:SetResizeToFitDescendents(true) |
19 | 11 | Seerah-7 | control:SetParent(parent.scroll) |
20 | 16 | Seerah-7 | local isHalfWidth = descriptionData.width == "half" |
21 | 10 | Seerah-7 | if isHalfWidth then |
22 | Seerah-7 | control:SetDimensionConstraints(250, 55, 250, 100) |
|
23 | Seerah-7 | control:SetDimensions(250, 55) |
|
24 | Seerah-7 | else |
|
25 | 16 | Seerah-7 | control:SetDimensionConstraints(510, 40, 510, 100) |
26 | 10 | Seerah-7 | control:SetDimensions(510, 30) |
27 | Seerah-7 | end |
|
28 | Seerah-7 | ||
29 | Seerah-7 | control.desc = wm:CreateControl(nil, control, CT_LABEL) |
|
30 | Seerah-7 | local desc = control.desc |
|
31 | Seerah-7 | desc:SetVerticalAlignment(TEXT_ALIGN_TOP) |
|
32 | Seerah-7 | desc:SetFont("ZoFontGame") |
|
33 | Seerah-7 | desc:SetText(descriptionData.text) |
|
34 | 18 | Seerah-7 | desc:SetWidth(isHalfWidth and 250 or 510) |
35 | Seerah-7 | ||
36 | 10 | Seerah-7 | if descriptionData.title then |
37 | Seerah-7 | control.title = wm:CreateControl(nil, control, CT_LABEL) |
|
38 | Seerah-7 | local title = control.title |
|
39 | Seerah-7 | title:SetWidth(isHalfWidth and 250 or 510) |
|
40 | Seerah-7 | title:SetAnchor(TOPLEFT, control, TOPLEFT) |
|
41 | Seerah-7 | title:SetFont("ZoFontWinH4") |
|
42 | Seerah-7 | title:SetText(descriptionData.title) |
|
43 | Seerah-7 | desc:SetAnchor(TOPLEFT, title, BOTTOMLEFT) |
|
44 | Seerah-7 | else |
|
45 | 25 | Seerah-7 | desc:SetAnchor(TOPLEFT) |
46 | 10 | Seerah-7 | end |
47 | Seerah-7 | ||
48 | Seerah-7 | control.panel = parent.panel or parent --if this is in a submenu, panel is its parent |
|
49 | Seerah-7 | control.data = descriptionData |
|
50 | Seerah-7 | ||
51 | Seerah-7 | return control |
|
52 | Seerah-7 | ||
53 | Seerah-7 | end |