Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 10 | Seerah-7 | --[[submenuData = { |
2 | Seerah-7 | type = "submenu", |
|
3 | Seerah-7 | name = "Submenu Title", |
|
4 | Seerah-7 | tooltip = "My submenu tooltip", --(optional) |
|
5 | Seerah-7 | controls = {sliderData, buttonData} --(optional) used by LAM |
|
6 | 28 | Seerah-7 | reference = "MyAddonSubmenu" --(optional) unique global reference to control |
7 | 10 | 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("submenu", widgetVersion) then return end |
12 | 10 | Seerah-7 | |
13 | 16 | Seerah-7 | local wm = WINDOW_MANAGER |
14 | 10 | Seerah-7 | local am = ANIMATION_MANAGER |
15 | Seerah-7 | ||
16 | Seerah-7 | ||
17 | 17 | Seerah-7 | local function AnimateSubmenu(label) |
18 | Seerah-7 | local control = label:GetParent() |
|
19 | 10 | Seerah-7 | control.open = not control.open |
20 | Seerah-7 | ||
21 | Seerah-7 | if control.open then |
|
22 | Seerah-7 | control.animation:PlayFromStart() |
|
23 | Seerah-7 | else |
|
24 | Seerah-7 | control.animation:PlayFromEnd() |
|
25 | Seerah-7 | end |
|
26 | Seerah-7 | end |
|
27 | Seerah-7 | ||
28 | Seerah-7 | ||
29 | Seerah-7 | function LAMCreateControl.submenu(parent, submenuData, controlName) |
|
30 | 28 | Seerah-7 | local control = wm:CreateTopLevelWindow(controlName or submenuData.reference) |
31 | 11 | Seerah-7 | control:SetParent(parent.scroll) |
32 | 10 | Seerah-7 | control.panel = parent |
33 | 17 | Seerah-7 | control:SetDimensions(523, 40) |
34 | Seerah-7 | ||
35 | Seerah-7 | control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") |
|
36 | Seerah-7 | local label = control.label |
|
37 | Seerah-7 | label:SetAnchor(TOPLEFT, control, TOPLEFT, 5, 5) |
|
38 | Seerah-7 | label:SetDimensions(520, 30) |
|
39 | Seerah-7 | label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) |
|
40 | Seerah-7 | label:SetText(submenuData.name) |
|
41 | Seerah-7 | label:SetMouseEnabled(true) |
|
42 | 10 | Seerah-7 | if submenuData.tooltip then |
43 | 17 | Seerah-7 | label.tooltipText = submenuData.tooltip |
44 | Seerah-7 | label:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) |
|
45 | Seerah-7 | label:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) |
|
46 | 10 | Seerah-7 | end |
47 | Seerah-7 | ||
48 | 17 | Seerah-7 | control.scroll = wm:CreateControl(nil, control, CT_SCROLL) |
49 | Seerah-7 | local scroll = control.scroll |
|
50 | Seerah-7 | scroll:SetParent(control) |
|
51 | Seerah-7 | scroll:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 10) |
|
52 | Seerah-7 | scroll:SetDimensionConstraints(525, 0, 525, 1500) |
|
53 | Seerah-7 | ||
54 | Seerah-7 | control.bg = wm:CreateControl(nil, label, CT_BACKDROP) |
|
55 | 10 | Seerah-7 | local bg = control.bg |
56 | 17 | Seerah-7 | bg:SetAnchor(TOPLEFT, label, TOPLEFT, -5, -5) |
57 | Seerah-7 | bg:SetAnchor(BOTTOMRIGHT, scroll, BOTTOMRIGHT, -7, 0) |
|
58 | 10 | Seerah-7 | bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-Border.dds", 128, 16) |
59 | Seerah-7 | bg:SetCenterTexture("EsoUI\\Art\\Tooltips\\UI-TooltipCenter.dds") |
|
60 | Seerah-7 | bg:SetInsets(16, 16, -16, -16) |
|
61 | Seerah-7 | ||
62 | 17 | Seerah-7 | control.arrow = wm:CreateControl(nil, bg, CT_TEXTURE) |
63 | 10 | Seerah-7 | local arrow = control.arrow |
64 | 17 | Seerah-7 | arrow:SetDimensions(28, 28) |
65 | 10 | Seerah-7 | arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") --list_sortup for the other way |
66 | 17 | Seerah-7 | arrow:SetAnchor(TOPRIGHT, bg, TOPRIGHT, -5, 5) |
67 | 10 | Seerah-7 | |
68 | 17 | Seerah-7 | --figure out the cool animation later... |
69 | 10 | Seerah-7 | control.animation = am:CreateTimeline() |
70 | Seerah-7 | local animation = control.animation |
|
71 | Seerah-7 | animation:SetPlaybackType(ANIMATION_SIZE, 0) --2nd arg = loop count |
|
72 | 16 | Seerah-7 | --animation:SetDuration(1) |
73 | Seerah-7 | --animation:SetEasingFunction(ZO_LinearEase) --is this needed? |
|
74 | 17 | Seerah-7 | --animation:SetHeightStartAndEnd(40, 80) --SetStartAndEndHeight |
75 | Seerah-7 | --animation:SetStartAndEndHeight(40, 80) --SetStartAndEndHeight |
|
76 | 16 | Seerah-7 | --animation:SetAnimatedControl(control) |
77 | 10 | Seerah-7 | |
78 | 17 | Seerah-7 | control:SetResizeToFitDescendents(true) |
79 | 10 | Seerah-7 | control.open = false |
80 | 17 | Seerah-7 | label:SetHandler("OnMouseUp", AnimateSubmenu) |
81 | 10 | Seerah-7 | animation:SetHandler("OnStop", function(self, completedPlaying) |
82 | 17 | Seerah-7 | scroll:SetResizeToFitDescendents(control.open) |
83 | 10 | Seerah-7 | if control.open then |
84 | 17 | Seerah-7 | control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortup.dds") |
85 | Seerah-7 | scroll:SetResizeToFitPadding(5, 20) |
|
86 | 10 | Seerah-7 | else |
87 | Seerah-7 | control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") |
|
88 | 17 | Seerah-7 | scroll:SetResizeToFitPadding(5, 0) |
89 | Seerah-7 | scroll:SetHeight(0) |
|
90 | 10 | Seerah-7 | end |
91 | Seerah-7 | end) |
|
92 | Seerah-7 | ||
93 | Seerah-7 | control.data = submenuData |
|
94 | Seerah-7 | ||
95 | 11 | Seerah-7 | return control |
96 | 10 | Seerah-7 | end |
97 | Seerah-7 |