|
Tercio@11
|
1
|
|
Tercio@11
|
2 local DF = _G ["DetailsFramework"]
|
|
Tercio@20
|
3 if (not DF or not DetailsFrameworkCanLoad) then
|
|
Tercio@20
|
4 return
|
|
Tercio@20
|
5 end
|
|
Tercio@20
|
6
|
|
Tercio@11
|
7 local _
|
|
Tercio@11
|
8 local _rawset = rawset --> lua local
|
|
Tercio@11
|
9 local _rawget = rawget --> lua local
|
|
Tercio@11
|
10 local _setmetatable = setmetatable --> lua local
|
|
Tercio@11
|
11 local _unpack = unpack --> lua local
|
|
Tercio@11
|
12 local _type = type --> lua local
|
|
Tercio@11
|
13 local _math_floor = math.floor --> lua local
|
|
Tercio@11
|
14 local loadstring = loadstring --> lua local
|
|
Tercio@11
|
15 local _string_len = string.len --> lua local
|
|
Tercio@11
|
16
|
|
Tercio@11
|
17 local cleanfunction = function() end
|
|
Tercio@11
|
18 local APIDropDownFunctions = false
|
|
Tercio@39
|
19
|
|
Tercio@39
|
20 do
|
|
Tercio@39
|
21 local metaPrototype = {
|
|
Tercio@39
|
22 WidgetType = "dropdown",
|
|
Tercio@39
|
23 SetHook = DF.SetHook,
|
|
Tercio@39
|
24 RunHooksForWidget = DF.RunHooksForWidget,
|
|
Tercio@39
|
25 }
|
|
Tercio@39
|
26
|
|
Tercio@39
|
27 _G [DF.GlobalWidgetControlNames ["dropdown"]] = _G [DF.GlobalWidgetControlNames ["dropdown"]] or metaPrototype
|
|
Tercio@39
|
28 end
|
|
Tercio@39
|
29
|
|
Tercio@39
|
30 local DropDownMetaFunctions = _G [DF.GlobalWidgetControlNames ["dropdown"]]
|
|
Tercio@11
|
31
|
|
Tercio@11
|
32 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
33 --> metatables
|
|
Tercio@11
|
34
|
|
Tercio@11
|
35 DropDownMetaFunctions.__call = function (_table, value)
|
|
Tercio@11
|
36 --> unknow
|
|
Tercio@11
|
37 end
|
|
Tercio@11
|
38
|
|
Tercio@11
|
39 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
40 --> members
|
|
Tercio@11
|
41
|
|
Tercio@11
|
42 --> selected value
|
|
Tercio@11
|
43 local gmember_value = function (_object)
|
|
Tercio@11
|
44 return _object:GetValue()
|
|
Tercio@11
|
45 end
|
|
Tercio@11
|
46 --> tooltip
|
|
Tercio@11
|
47 local gmember_tooltip = function (_object)
|
|
Tercio@11
|
48 return _object:GetTooltip()
|
|
Tercio@11
|
49 end
|
|
Tercio@11
|
50 --> shown
|
|
Tercio@11
|
51 local gmember_shown = function (_object)
|
|
Tercio@11
|
52 return _object:IsShown()
|
|
Tercio@11
|
53 end
|
|
Tercio@11
|
54 --> frame width
|
|
Tercio@11
|
55 local gmember_width = function (_object)
|
|
Tercio@11
|
56 return _object.button:GetWidth()
|
|
Tercio@11
|
57 end
|
|
Tercio@11
|
58 --> frame height
|
|
Tercio@11
|
59 local gmember_height = function (_object)
|
|
Tercio@11
|
60 return _object.button:GetHeight()
|
|
Tercio@11
|
61 end
|
|
Tercio@11
|
62 --> current text
|
|
Tercio@11
|
63 local gmember_text = function (_object)
|
|
Tercio@11
|
64 return _object.label:GetText()
|
|
Tercio@11
|
65 end
|
|
Tercio@11
|
66 --> menu creation function
|
|
Tercio@11
|
67 local gmember_function = function (_object)
|
|
Tercio@11
|
68 return _object:GetFunction()
|
|
Tercio@11
|
69 end
|
|
Tercio@11
|
70 --> menu width
|
|
Tercio@11
|
71 local gmember_menuwidth = function (_object)
|
|
Tercio@11
|
72 return _rawget (self, "realsizeW")
|
|
Tercio@11
|
73 end
|
|
Tercio@11
|
74 --> menu height
|
|
Tercio@11
|
75 local gmember_menuheight = function (_object)
|
|
Tercio@11
|
76 return _rawget (self, "realsizeH")
|
|
Tercio@11
|
77 end
|
|
Tercio@11
|
78
|
|
Tercio@39
|
79 DropDownMetaFunctions.GetMembers = DropDownMetaFunctions.GetMembers or {}
|
|
Tercio@39
|
80 DropDownMetaFunctions.GetMembers ["value"] = gmember_value
|
|
Tercio@39
|
81 DropDownMetaFunctions.GetMembers ["text"] = gmember_text
|
|
Tercio@39
|
82 DropDownMetaFunctions.GetMembers ["shown"] = gmember_shown
|
|
Tercio@39
|
83 DropDownMetaFunctions.GetMembers ["width"] = gmember_width
|
|
Tercio@39
|
84 DropDownMetaFunctions.GetMembers ["menuwidth"] = gmember_menuwidth
|
|
Tercio@39
|
85 DropDownMetaFunctions.GetMembers ["height"] = gmember_height
|
|
Tercio@39
|
86 DropDownMetaFunctions.GetMembers ["menuheight"] = gmember_menuheight
|
|
Tercio@39
|
87 DropDownMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
|
|
Tercio@39
|
88 DropDownMetaFunctions.GetMembers ["func"] = gmember_function
|
|
Tercio@11
|
89
|
|
Tercio@11
|
90 DropDownMetaFunctions.__index = function (_table, _member_requested)
|
|
Tercio@11
|
91
|
|
Tercio@39
|
92 local func = DropDownMetaFunctions.GetMembers [_member_requested]
|
|
Tercio@11
|
93 if (func) then
|
|
Tercio@11
|
94 return func (_table, _member_requested)
|
|
Tercio@11
|
95 end
|
|
Tercio@11
|
96
|
|
Tercio@11
|
97 local fromMe = _rawget (_table, _member_requested)
|
|
Tercio@11
|
98 if (fromMe) then
|
|
Tercio@11
|
99 return fromMe
|
|
Tercio@11
|
100 end
|
|
Tercio@11
|
101
|
|
Tercio@11
|
102 return DropDownMetaFunctions [_member_requested]
|
|
Tercio@11
|
103 end
|
|
Tercio@11
|
104
|
|
Tercio@11
|
105 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
106
|
|
Tercio@11
|
107 --> tooltip
|
|
Tercio@11
|
108 local smember_tooltip = function (_object, _value)
|
|
Tercio@11
|
109 return _object:SetTooltip (_value)
|
|
Tercio@11
|
110 end
|
|
Tercio@11
|
111 --> show
|
|
Tercio@11
|
112 local smember_show = function (_object, _value)
|
|
Tercio@11
|
113 if (_value) then
|
|
Tercio@11
|
114 return _object:Show()
|
|
Tercio@11
|
115 else
|
|
Tercio@11
|
116 return _object:Hide()
|
|
Tercio@11
|
117 end
|
|
Tercio@11
|
118 end
|
|
Tercio@11
|
119 --> hide
|
|
Tercio@11
|
120 local smember_hide = function (_object, _value)
|
|
Tercio@11
|
121 if (not _value) then
|
|
Tercio@11
|
122 return _object:Show()
|
|
Tercio@11
|
123 else
|
|
Tercio@11
|
124 return _object:Hide()
|
|
Tercio@11
|
125 end
|
|
Tercio@11
|
126 end
|
|
Tercio@11
|
127 --> frame width
|
|
Tercio@11
|
128 local smember_width = function (_object, _value)
|
|
Tercio@11
|
129 return _object.dropdown:SetWidth (_value)
|
|
Tercio@11
|
130 end
|
|
Tercio@11
|
131 --> frame height
|
|
Tercio@11
|
132 local smember_height = function (_object, _value)
|
|
Tercio@11
|
133 return _object.dropdown:SetHeight (_value)
|
|
Tercio@11
|
134 end
|
|
Tercio@11
|
135 --> menu creation function
|
|
Tercio@11
|
136 local smember_function = function (_object, _value)
|
|
Tercio@11
|
137 return _object:SetFunction (_value)
|
|
Tercio@11
|
138 end
|
|
Tercio@11
|
139 --> menu width
|
|
Tercio@11
|
140 local smember_menuwidth = function (_object, _value)
|
|
Tercio@11
|
141 _object:SetMenuSize (_value, nil)
|
|
Tercio@11
|
142 end
|
|
Tercio@11
|
143 --> menu height
|
|
Tercio@11
|
144 local smember_menuheight = function (_object, _value)
|
|
Tercio@11
|
145 _object:SetMenuSize (nil, _value)
|
|
Tercio@11
|
146 end
|
|
Tercio@11
|
147
|
|
Tercio@39
|
148 DropDownMetaFunctions.SetMembers = DropDownMetaFunctions.SetMembers or {}
|
|
Tercio@39
|
149 DropDownMetaFunctions.SetMembers ["tooltip"] = smember_tooltip
|
|
Tercio@39
|
150 DropDownMetaFunctions.SetMembers ["show"] = smember_show
|
|
Tercio@39
|
151 DropDownMetaFunctions.SetMembers ["hide"] = smember_hide
|
|
Tercio@39
|
152 DropDownMetaFunctions.SetMembers ["width"] = smember_width
|
|
Tercio@39
|
153 DropDownMetaFunctions.SetMembers ["menuwidth"] = smember_menuwidth
|
|
Tercio@39
|
154 DropDownMetaFunctions.SetMembers ["height"] = smember_height
|
|
Tercio@39
|
155 DropDownMetaFunctions.SetMembers ["menuheight"] = smember_menuheight
|
|
Tercio@39
|
156 DropDownMetaFunctions.SetMembers ["func"] = smember_function
|
|
Tercio@11
|
157
|
|
Tercio@11
|
158 DropDownMetaFunctions.__newindex = function (_table, _key, _value)
|
|
Tercio@39
|
159 local func = DropDownMetaFunctions.SetMembers [_key]
|
|
Tercio@11
|
160 if (func) then
|
|
Tercio@11
|
161 return func (_table, _value)
|
|
Tercio@11
|
162 else
|
|
Tercio@11
|
163 return _rawset (_table, _key, _value)
|
|
Tercio@11
|
164 end
|
|
Tercio@11
|
165 end
|
|
Tercio@11
|
166
|
|
Tercio@11
|
167 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
168 --> methods
|
|
Tercio@11
|
169 function DropDownMetaFunctions:IsShown()
|
|
Tercio@11
|
170 return self.dropdown:IsShown()
|
|
Tercio@11
|
171 end
|
|
Tercio@11
|
172 function DropDownMetaFunctions:Show()
|
|
Tercio@11
|
173 return self.dropdown:Show()
|
|
Tercio@11
|
174 end
|
|
Tercio@11
|
175 function DropDownMetaFunctions:Hide()
|
|
Tercio@11
|
176 return self.dropdown:Hide()
|
|
Tercio@11
|
177 end
|
|
Tercio@11
|
178
|
|
Tercio@11
|
179 --> menu width and height
|
|
Tercio@11
|
180 function DropDownMetaFunctions:SetMenuSize (w, h)
|
|
Tercio@11
|
181 if (w) then
|
|
Tercio@11
|
182 return _rawset (self, "realsizeW", w)
|
|
Tercio@11
|
183 end
|
|
Tercio@11
|
184 if (h) then
|
|
Tercio@11
|
185 return _rawset (self, "realsizeH", h)
|
|
Tercio@11
|
186 end
|
|
Tercio@11
|
187 end
|
|
Tercio@11
|
188 function DropDownMetaFunctions:GetMenuSize()
|
|
Tercio@11
|
189 return _rawget (self, "realsizeW"), _rawget (self, "realsizeH")
|
|
Tercio@11
|
190 end
|
|
Tercio@11
|
191
|
|
Tercio@11
|
192 --> function
|
|
Tercio@11
|
193 function DropDownMetaFunctions:SetFunction (func)
|
|
Tercio@11
|
194 return _rawset (self, "func", func)
|
|
Tercio@11
|
195 end
|
|
Tercio@11
|
196 function DropDownMetaFunctions:GetFunction()
|
|
Tercio@11
|
197 return _rawget (self, "func")
|
|
Tercio@11
|
198 end
|
|
Tercio@11
|
199
|
|
Tercio@11
|
200 --> value
|
|
Tercio@11
|
201 function DropDownMetaFunctions:GetValue()
|
|
Tercio@11
|
202 return _rawget (self, "myvalue")
|
|
Tercio@11
|
203 end
|
|
Tercio@11
|
204 function DropDownMetaFunctions:SetValue (value)
|
|
Tercio@11
|
205 return _rawset (self, "myvalue", value)
|
|
Tercio@11
|
206 end
|
|
Tercio@11
|
207
|
|
Tercio@11
|
208 --> setpoint
|
|
Tercio@11
|
209 function DropDownMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
|
Tercio@11
|
210 v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
|
|
Tercio@11
|
211 if (not v1) then
|
|
Tercio@11
|
212 print ("Invalid parameter for SetPoint")
|
|
Tercio@11
|
213 return
|
|
Tercio@11
|
214 end
|
|
Tercio@11
|
215 return self.widget:SetPoint (v1, v2, v3, v4, v5)
|
|
Tercio@11
|
216 end
|
|
Tercio@11
|
217
|
|
Tercio@11
|
218 --> sizes
|
|
Tercio@11
|
219 function DropDownMetaFunctions:SetSize (w, h)
|
|
Tercio@11
|
220 if (w) then
|
|
Tercio@11
|
221 self.dropdown:SetWidth (w)
|
|
Tercio@11
|
222 end
|
|
Tercio@11
|
223 if (h) then
|
|
Tercio@11
|
224 return self.dropdown:SetHeight (h)
|
|
Tercio@11
|
225 end
|
|
Tercio@11
|
226 end
|
|
Tercio@11
|
227
|
|
Tercio@11
|
228 --> tooltip
|
|
Tercio@11
|
229 function DropDownMetaFunctions:SetTooltip (tooltip)
|
|
Tercio@11
|
230 if (tooltip) then
|
|
Tercio@11
|
231 return _rawset (self, "have_tooltip", tooltip)
|
|
Tercio@11
|
232 else
|
|
Tercio@11
|
233 return _rawset (self, "have_tooltip", nil)
|
|
Tercio@11
|
234 end
|
|
Tercio@11
|
235 end
|
|
Tercio@11
|
236 function DropDownMetaFunctions:GetTooltip()
|
|
Tercio@11
|
237 return _rawget (self, "have_tooltip")
|
|
Tercio@11
|
238 end
|
|
Tercio@11
|
239
|
|
Tercio@11
|
240 --> frame levels
|
|
Tercio@11
|
241 function DropDownMetaFunctions:GetFrameLevel()
|
|
Tercio@11
|
242 return self.dropdown:GetFrameLevel()
|
|
Tercio@11
|
243 end
|
|
Tercio@11
|
244 function DropDownMetaFunctions:SetFrameLevel (level, frame)
|
|
Tercio@11
|
245 if (not frame) then
|
|
Tercio@11
|
246 return self.dropdown:SetFrameLevel (level)
|
|
Tercio@11
|
247 else
|
|
Tercio@11
|
248 local framelevel = frame:GetFrameLevel (frame) + level
|
|
Tercio@11
|
249 return self.dropdown:SetFrameLevel (framelevel)
|
|
Tercio@11
|
250 end
|
|
Tercio@11
|
251 end
|
|
Tercio@11
|
252
|
|
Tercio@11
|
253 --> frame stratas
|
|
Tercio@11
|
254 function DropDownMetaFunctions:GetFrameStrata()
|
|
Tercio@11
|
255 return self.dropdown:GetFrameStrata()
|
|
Tercio@11
|
256 end
|
|
Tercio@11
|
257 function DropDownMetaFunctions:SetFrameStrata (strata)
|
|
Tercio@11
|
258 if (_type (strata) == "table") then
|
|
Tercio@11
|
259 self.dropdown:SetFrameStrata (strata:GetFrameStrata())
|
|
Tercio@11
|
260 else
|
|
Tercio@11
|
261 self.dropdown:SetFrameStrata (strata)
|
|
Tercio@11
|
262 end
|
|
Tercio@11
|
263 end
|
|
Tercio@11
|
264
|
|
Tercio@11
|
265 --> enabled
|
|
Tercio@11
|
266 function DropDownMetaFunctions:IsEnabled()
|
|
Tercio@11
|
267 return self.dropdown:IsEnabled()
|
|
Tercio@11
|
268 end
|
|
Tercio@11
|
269
|
|
Tercio@11
|
270 function DropDownMetaFunctions:Enable()
|
|
Tercio@11
|
271
|
|
Tercio@11
|
272 self:SetAlpha (1)
|
|
Tercio@11
|
273 _rawset (self, "lockdown", false)
|
|
Tercio@11
|
274
|
|
Tercio@11
|
275 if (self.OnEnable) then
|
|
Tercio@11
|
276 self.OnEnable (self)
|
|
Tercio@11
|
277 end
|
|
Tercio@11
|
278 --return self.dropdown:Enable()
|
|
Tercio@11
|
279 end
|
|
Tercio@11
|
280
|
|
Tercio@11
|
281 function DropDownMetaFunctions:Disable()
|
|
Tercio@11
|
282
|
|
Tercio@11
|
283 self:SetAlpha (.4)
|
|
Tercio@11
|
284 _rawset (self, "lockdown", true)
|
|
Tercio@11
|
285
|
|
Tercio@11
|
286 if (self.OnDisable) then
|
|
Tercio@11
|
287 self.OnDisable (self)
|
|
Tercio@11
|
288 end
|
|
Tercio@11
|
289 --return self.dropdown:Disable()
|
|
Tercio@11
|
290 end
|
|
Tercio@11
|
291
|
|
Tercio@11
|
292 --> fixed value
|
|
Tercio@11
|
293 function DropDownMetaFunctions:SetFixedParameter (value)
|
|
Tercio@11
|
294 _rawset (self, "FixedValue", value)
|
|
Tercio@11
|
295 end
|
|
Tercio@11
|
296
|
|
Tercio@11
|
297 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
298 --> scripts
|
|
Tercio@11
|
299
|
|
Tercio@11
|
300 local last_opened = false
|
|
Tercio@11
|
301
|
|
Tercio@11
|
302 local function isOptionVisible (thisOption)
|
|
Tercio@11
|
303 if (_type (thisOption.shown) == "boolean" or _type (thisOption.shown) == "function") then
|
|
Tercio@11
|
304 if (not thisOption.shown) then
|
|
Tercio@11
|
305 return false
|
|
Tercio@11
|
306 elseif (not thisOption.shown()) then
|
|
Tercio@11
|
307 return false
|
|
Tercio@11
|
308 end
|
|
Tercio@11
|
309 end
|
|
Tercio@11
|
310 return true
|
|
Tercio@11
|
311 end
|
|
Tercio@11
|
312
|
|
Tercio@11
|
313 function DropDownMetaFunctions:Refresh()
|
|
Tercio@11
|
314 local menu = self.func()
|
|
Tercio@11
|
315
|
|
Tercio@11
|
316 if (#menu == 0) then
|
|
Tercio@11
|
317 self:NoOption (true)
|
|
Tercio@11
|
318 self.no_options = true
|
|
Tercio@11
|
319 return false
|
|
Tercio@11
|
320
|
|
Tercio@11
|
321 elseif (self.no_options) then
|
|
Tercio@11
|
322 self.no_options = false
|
|
Tercio@11
|
323 self:NoOption (false)
|
|
Tercio@11
|
324 self:NoOptionSelected()
|
|
Tercio@11
|
325 return true
|
|
Tercio@11
|
326 end
|
|
Tercio@11
|
327
|
|
Tercio@11
|
328 return true
|
|
Tercio@11
|
329 end
|
|
Tercio@11
|
330
|
|
Tercio@11
|
331 function DropDownMetaFunctions:NoOptionSelected()
|
|
Tercio@22
|
332 if (self.no_options) then
|
|
Tercio@22
|
333 return
|
|
Tercio@22
|
334 end
|
|
Tercio@11
|
335 self.label:SetText (self.empty_text or "no option selected")
|
|
Tercio@22
|
336 self.label:SetPoint ("left", self.icon, "right", 2, 0)
|
|
Tercio@11
|
337 self.label:SetTextColor (1, 1, 1, 0.4)
|
|
Tercio@11
|
338 if (self.empty_icon) then
|
|
Tercio@11
|
339 self.icon:SetTexture (self.empty_icon)
|
|
Tercio@11
|
340 else
|
|
Tercio@11
|
341 self.icon:SetTexture ([[Interface\COMMON\UI-ModelControlPanel]])
|
|
Tercio@11
|
342 self.icon:SetTexCoord (0.625, 0.78125, 0.328125, 0.390625)
|
|
Tercio@11
|
343 end
|
|
Tercio@11
|
344 self.icon:SetVertexColor (1, 1, 1, 0.4)
|
|
Tercio@11
|
345
|
|
Tercio@11
|
346 self.last_select = nil
|
|
Tercio@11
|
347 end
|
|
Tercio@11
|
348
|
|
Tercio@11
|
349 function DropDownMetaFunctions:NoOption (state)
|
|
Tercio@11
|
350 if (state) then
|
|
Tercio@11
|
351 self:Disable()
|
|
Tercio@11
|
352 self:SetAlpha (0.5)
|
|
Tercio@11
|
353 self.no_options = true
|
|
Tercio@11
|
354 self.label:SetText ("no options")
|
|
Tercio@22
|
355 self.label:SetPoint ("left", self.icon, "right", 2, 0)
|
|
Tercio@11
|
356 self.label:SetTextColor (1, 1, 1, 0.4)
|
|
Tercio@11
|
357 self.icon:SetTexture ([[Interface\CHARACTERFRAME\UI-Player-PlayTimeUnhealthy]])
|
|
Tercio@11
|
358 self.icon:SetTexCoord (0, 1, 0, 1)
|
|
Tercio@11
|
359 self.icon:SetVertexColor (1, 1, 1, 0.4)
|
|
Tercio@11
|
360 else
|
|
Tercio@11
|
361 self.no_options = false
|
|
Tercio@11
|
362 self:Enable()
|
|
Tercio@11
|
363 self:SetAlpha (1)
|
|
Tercio@11
|
364 end
|
|
Tercio@11
|
365 end
|
|
Tercio@11
|
366
|
|
Tercio@11
|
367 function DropDownMetaFunctions:Select (optionName, byOptionNumber)
|
|
Tercio@11
|
368
|
|
Tercio@11
|
369 if (type (optionName) == "boolean" and not optionName) then
|
|
Tercio@11
|
370 self:NoOptionSelected()
|
|
Tercio@11
|
371 return false
|
|
Tercio@11
|
372 end
|
|
Tercio@11
|
373
|
|
Tercio@11
|
374 local menu = self.func()
|
|
Tercio@11
|
375
|
|
Tercio@11
|
376 if (#menu == 0) then
|
|
Tercio@11
|
377 self:NoOption (true)
|
|
Tercio@11
|
378 return true
|
|
Tercio@11
|
379 else
|
|
Tercio@11
|
380 self:NoOption (false)
|
|
Tercio@11
|
381 end
|
|
Tercio@11
|
382
|
|
Tercio@11
|
383 if (byOptionNumber and type (optionName) == "number") then
|
|
Tercio@11
|
384 if (not menu [optionName]) then --> invalid index
|
|
Tercio@11
|
385 self:NoOptionSelected()
|
|
Tercio@11
|
386 return false
|
|
Tercio@11
|
387 end
|
|
Tercio@11
|
388 self:Selected (menu [optionName])
|
|
Tercio@11
|
389 return true
|
|
Tercio@11
|
390 end
|
|
Tercio@11
|
391
|
|
Tercio@11
|
392 for _, thisMenu in ipairs (menu) do
|
|
Tercio@11
|
393 if ( ( thisMenu.label == optionName or thisMenu.value == optionName ) and isOptionVisible (thisMenu)) then
|
|
Tercio@11
|
394 self:Selected (thisMenu)
|
|
Tercio@11
|
395 return true
|
|
Tercio@11
|
396 end
|
|
Tercio@11
|
397 end
|
|
Tercio@11
|
398
|
|
Tercio@11
|
399 return false
|
|
Tercio@11
|
400 end
|
|
Tercio@11
|
401
|
|
Tercio@11
|
402 function DropDownMetaFunctions:SetEmptyTextAndIcon (text, icon)
|
|
Tercio@11
|
403 if (text) then
|
|
Tercio@11
|
404 self.empty_text = text
|
|
Tercio@11
|
405 end
|
|
Tercio@11
|
406 if (icon) then
|
|
Tercio@11
|
407 self.empty_icon = icon
|
|
Tercio@11
|
408 end
|
|
Tercio@11
|
409
|
|
Tercio@11
|
410 self:Selected (self.last_select)
|
|
Tercio@11
|
411 end
|
|
Tercio@11
|
412
|
|
Tercio@11
|
413 function DropDownMetaFunctions:Selected (_table)
|
|
Tercio@11
|
414
|
|
Tercio@11
|
415 if (not _table) then
|
|
Tercio@11
|
416
|
|
Tercio@11
|
417 --> there is any options?
|
|
Tercio@11
|
418 if (not self:Refresh()) then
|
|
Tercio@11
|
419 self.last_select = nil
|
|
Tercio@11
|
420 return
|
|
Tercio@11
|
421 end
|
|
Tercio@11
|
422
|
|
Tercio@11
|
423 --> exists options but none selected
|
|
Tercio@11
|
424 self:NoOptionSelected()
|
|
Tercio@11
|
425 return
|
|
Tercio@11
|
426 end
|
|
Tercio@11
|
427
|
|
Tercio@11
|
428 self.last_select = _table
|
|
Tercio@11
|
429 self:NoOption (false)
|
|
Tercio@11
|
430
|
|
Tercio@11
|
431 self.label:SetText (_table.label)
|
|
Tercio@11
|
432 self.icon:SetTexture (_table.icon)
|
|
Tercio@11
|
433
|
|
Tercio@11
|
434 if (_table.icon) then
|
|
Tercio@11
|
435 self.label:SetPoint ("left", self.icon, "right", 2, 0)
|
|
Tercio@11
|
436 if (_table.texcoord) then
|
|
Tercio@11
|
437 self.icon:SetTexCoord (unpack (_table.texcoord))
|
|
Tercio@11
|
438 else
|
|
Tercio@11
|
439 self.icon:SetTexCoord (0, 1, 0, 1)
|
|
Tercio@11
|
440 end
|
|
Tercio@11
|
441
|
|
Tercio@11
|
442 if (_table.iconcolor) then
|
|
Tercio@11
|
443 if (type (_table.iconcolor) == "string") then
|
|
Tercio@11
|
444 self.icon:SetVertexColor (DF:ParseColors (_table.iconcolor))
|
|
Tercio@11
|
445 else
|
|
Tercio@11
|
446 self.icon:SetVertexColor (unpack (_table.iconcolor))
|
|
Tercio@11
|
447 end
|
|
Tercio@11
|
448 else
|
|
Tercio@11
|
449 self.icon:SetVertexColor (1, 1, 1, 1)
|
|
Tercio@11
|
450 end
|
|
Tercio@11
|
451
|
|
Tercio@22
|
452 self.icon:SetSize (self:GetHeight()-2, self:GetHeight()-2)
|
|
Tercio@11
|
453 else
|
|
Tercio@11
|
454 self.label:SetPoint ("left", self.label:GetParent(), "left", 4, 0)
|
|
Tercio@11
|
455 end
|
|
Tercio@11
|
456
|
|
Tercio@11
|
457 self.statusbar:SetTexture (_table.statusbar)
|
|
Tercio@11
|
458
|
|
Tercio@11
|
459 if (_table.color) then
|
|
Tercio@11
|
460 local _value1, _value2, _value3, _value4 = DF:ParseColors (_table.color)
|
|
Tercio@11
|
461 self.label:SetTextColor (_value1, _value2, _value3, _value4)
|
|
Tercio@11
|
462 else
|
|
Tercio@11
|
463 self.label:SetTextColor (1, 1, 1, 1)
|
|
Tercio@11
|
464 end
|
|
Tercio@11
|
465
|
|
Tercio@11
|
466 if (_table.font) then
|
|
Tercio@11
|
467 self.label:SetFont (_table.font, 10)
|
|
Tercio@11
|
468 else
|
|
Tercio@11
|
469 self.label:SetFont ("GameFontHighlightSmall", 10)
|
|
Tercio@11
|
470 end
|
|
Tercio@11
|
471
|
|
Tercio@11
|
472 self:SetValue (_table.value)
|
|
Tercio@11
|
473
|
|
Tercio@11
|
474 end
|
|
Tercio@11
|
475
|
|
Tercio@11
|
476 function DetailsFrameworkDropDownOptionClick (button)
|
|
Tercio@11
|
477
|
|
Tercio@11
|
478 --> update name and icon on main frame
|
|
Tercio@11
|
479 button.object:Selected (button.table)
|
|
Tercio@11
|
480
|
|
Tercio@11
|
481 --> close menu frame
|
|
Tercio@11
|
482 button.object:Close()
|
|
Tercio@11
|
483
|
|
Tercio@11
|
484 --> exec function if any
|
|
Tercio@11
|
485 if (button.table.onclick) then
|
|
Tercio@55
|
486
|
|
Tercio@55
|
487 local success, errorText = pcall (button.table.onclick, button:GetParent():GetParent():GetParent().MyObject, button.object.FixedValue, button.table.value)
|
|
Tercio@55
|
488 if (not success) then
|
|
Tercio@55
|
489 error ("Details! Framework: dropdown " .. button:GetParent():GetParent():GetParent().MyObject:GetName() .. " error: " .. errorText)
|
|
Tercio@55
|
490 end
|
|
Tercio@55
|
491
|
|
Tercio@55
|
492 --button.table.onclick (button:GetParent():GetParent():GetParent().MyObject, button.object.FixedValue, button.table.value)
|
|
Tercio@11
|
493 end
|
|
Tercio@11
|
494
|
|
Tercio@11
|
495 --> set the value of selected option in main object
|
|
Tercio@11
|
496 button.object.myvalue = button.table.value
|
|
Tercio@22
|
497 button.object.myvaluelabel = button.table.label
|
|
Tercio@11
|
498 end
|
|
Tercio@11
|
499
|
|
Tercio@11
|
500 function DropDownMetaFunctions:Open()
|
|
Tercio@11
|
501 self.dropdown.dropdownframe:Show()
|
|
Tercio@11
|
502 self.dropdown.dropdownborder:Show()
|
|
Tercio@11
|
503 self.dropdown.arrowTexture:SetTexture ("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Down")
|
|
Tercio@11
|
504 self.opened = true
|
|
Tercio@11
|
505 if (last_opened) then
|
|
Tercio@11
|
506 last_opened:Close()
|
|
Tercio@11
|
507 end
|
|
Tercio@11
|
508 last_opened = self
|
|
Tercio@11
|
509 end
|
|
Tercio@11
|
510
|
|
Tercio@11
|
511 function DropDownMetaFunctions:Close()
|
|
Tercio@11
|
512 --> when menu is being close, just hide the border and the script will call back this again
|
|
Tercio@11
|
513 if (self.dropdown.dropdownborder:IsShown()) then
|
|
Tercio@11
|
514 self.dropdown.dropdownborder:Hide()
|
|
Tercio@11
|
515 return
|
|
Tercio@11
|
516 end
|
|
Tercio@11
|
517 self.dropdown.dropdownframe:Hide()
|
|
Tercio@11
|
518 self.dropdown.arrowTexture:SetTexture ("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Up")
|
|
Tercio@11
|
519
|
|
Tercio@11
|
520 local selectedTexture = _G [self:GetName() .. "_ScrollFrame_ScrollChild_SelectedTexture"]
|
|
Tercio@11
|
521 selectedTexture:Hide()
|
|
Tercio@11
|
522
|
|
Tercio@11
|
523 self.opened = false
|
|
Tercio@11
|
524 last_opened = false
|
|
Tercio@11
|
525 end
|
|
Tercio@11
|
526
|
|
Tercio@11
|
527 --> close by escape key
|
|
Tercio@11
|
528 function DetailsFrameworkDropDownOptionsFrameOnHide (frame)
|
|
Tercio@11
|
529 frame:GetParent().MyObject:Close()
|
|
Tercio@11
|
530 end
|
|
Tercio@11
|
531
|
|
Tercio@11
|
532 function DetailsFrameworkDropDownOptionOnEnter (frame)
|
|
Tercio@11
|
533 if (frame.table.desc) then
|
|
Tercio@17
|
534 GameCooltip2:Preset (2)
|
|
Tercio@11
|
535 GameCooltip2:AddLine (frame.table.desc)
|
|
Tercio@11
|
536 if (frame.table.descfont) then
|
|
Tercio@11
|
537 GameCooltip2:SetOption ("TextFont", frame.table.descfont)
|
|
Tercio@11
|
538 end
|
|
Tercio@11
|
539
|
|
Tercio@58
|
540 if (frame.table.tooltipwidth) then
|
|
Tercio@58
|
541 GameCooltip2:SetOption ("FixedWidth", frame.table.tooltipwidth)
|
|
Tercio@58
|
542 end
|
|
Tercio@58
|
543
|
|
Tercio@11
|
544 GameCooltip2:SetHost (frame, "topleft", "topright", 10, 0)
|
|
Tercio@11
|
545
|
|
Tercio@11
|
546 GameCooltip2:ShowCooltip (nil, "tooltip")
|
|
Tercio@11
|
547 frame.tooltip = true
|
|
Tercio@11
|
548 end
|
|
Tercio@11
|
549 frame:GetParent().mouseover:SetPoint ("left", frame)
|
|
Tercio@11
|
550 frame:GetParent().mouseover:Show()
|
|
Tercio@11
|
551 end
|
|
Tercio@11
|
552
|
|
Tercio@11
|
553 function DetailsFrameworkDropDownOptionOnLeave (frame)
|
|
Tercio@11
|
554 if (frame.table.desc) then
|
|
Tercio@11
|
555 GameCooltip2:ShowMe (false)
|
|
Tercio@11
|
556 end
|
|
Tercio@11
|
557 frame:GetParent().mouseover:Hide()
|
|
Tercio@11
|
558 end
|
|
Tercio@11
|
559
|
|
Tercio@11
|
560 function DetailsFrameworkDropDownOnMouseDown (button)
|
|
Tercio@11
|
561
|
|
Tercio@11
|
562 local object = button.MyObject
|
|
Tercio@11
|
563
|
|
Tercio@11
|
564 if (not object.opened and not _rawget (object, "lockdown")) then --> click to open
|
|
Tercio@11
|
565
|
|
Tercio@11
|
566 local menu = object:func()
|
|
Tercio@11
|
567 object.builtMenu = menu
|
|
Tercio@11
|
568
|
|
Tercio@11
|
569 local frame_witdh = object.realsizeW
|
|
Tercio@11
|
570
|
|
Tercio@11
|
571 if (menu [1]) then
|
|
Tercio@11
|
572 --> build menu
|
|
Tercio@11
|
573
|
|
Tercio@11
|
574 local scrollFrame = _G [button:GetName() .. "_ScrollFrame"]
|
|
Tercio@11
|
575 local scrollChild = _G [button:GetName() .. "_ScrollFrame_ScrollChild"]
|
|
Tercio@11
|
576 local scrollBorder = _G [button:GetName() .. "_Border"]
|
|
Tercio@11
|
577 local selectedTexture = _G [button:GetName() .. "_ScrollFrame_ScrollChild_SelectedTexture"]
|
|
Tercio@11
|
578 local mouseOverTexture = _G [button:GetName() .. "_ScrollFrame_ScrollChild_MouseOverTexture"]
|
|
Tercio@11
|
579
|
|
Tercio@11
|
580 local i = 1
|
|
Tercio@11
|
581 local showing = 0
|
|
Tercio@11
|
582 local currentText = button.text:GetText() or ""
|
|
Tercio@22
|
583 local currentIndex
|
|
Tercio@11
|
584
|
|
Tercio@11
|
585 if (object.OnMouseDownHook) then
|
|
Tercio@11
|
586 local interrupt = object.OnMouseDownHook (button, buttontype, menu, scrollFrame, scrollChild, selectedTexture)
|
|
Tercio@11
|
587 if (interrupt) then
|
|
Tercio@11
|
588 return
|
|
Tercio@11
|
589 end
|
|
Tercio@11
|
590 end
|
|
Tercio@11
|
591
|
|
Tercio@22
|
592 for tindex, _table in ipairs (menu) do
|
|
Tercio@11
|
593
|
|
Tercio@11
|
594 local show = isOptionVisible (_table)
|
|
Tercio@11
|
595
|
|
Tercio@11
|
596 if (show) then
|
|
Tercio@11
|
597 local _this_row = object.menus [i]
|
|
Tercio@11
|
598 showing = showing + 1
|
|
Tercio@11
|
599
|
|
Tercio@11
|
600 if (not _this_row) then
|
|
Tercio@11
|
601
|
|
Tercio@11
|
602 local name = button:GetName() .. "Row" .. i
|
|
Tercio@11
|
603 local parent = scrollChild
|
|
Tercio@11
|
604
|
|
Tercio@40
|
605 --_this_row = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownOptionTemplate")
|
|
Tercio@40
|
606 _this_row = DF:CreateDropdownButton (parent, name)
|
|
Tercio@11
|
607 local anchor_i = i-1
|
|
Tercio@11
|
608 _this_row:SetPoint ("topleft", parent, "topleft", 5, (-anchor_i*20)-5)
|
|
Tercio@11
|
609 _this_row:SetPoint ("topright", parent, "topright", -5, (-anchor_i*20)-5)
|
|
Tercio@11
|
610 _this_row.object = object
|
|
Tercio@11
|
611 object.menus [i] = _this_row
|
|
Tercio@11
|
612 end
|
|
Tercio@11
|
613
|
|
Tercio@40
|
614 _this_row:SetFrameStrata (_this_row:GetParent():GetFrameStrata())
|
|
Tercio@40
|
615 _this_row:SetFrameLevel (_this_row:GetParent():GetFrameLevel()+10)
|
|
Tercio@40
|
616
|
|
Tercio@11
|
617 _this_row.icon:SetTexture (_table.icon)
|
|
Tercio@11
|
618 if (_table.icon) then
|
|
Tercio@11
|
619
|
|
Tercio@11
|
620 _this_row.label:SetPoint ("left", _this_row.icon, "right", 5, 0)
|
|
Tercio@11
|
621
|
|
Tercio@11
|
622 if (_table.texcoord) then
|
|
Tercio@11
|
623 _this_row.icon:SetTexCoord (unpack (_table.texcoord))
|
|
Tercio@11
|
624 else
|
|
Tercio@11
|
625 _this_row.icon:SetTexCoord (0, 1, 0, 1)
|
|
Tercio@11
|
626 end
|
|
Tercio@11
|
627
|
|
Tercio@11
|
628 if (_table.iconcolor) then
|
|
Tercio@11
|
629 if (type (_table.iconcolor) == "string") then
|
|
Tercio@11
|
630 _this_row.icon:SetVertexColor (DF:ParseColors (_table.iconcolor))
|
|
Tercio@11
|
631 else
|
|
Tercio@11
|
632 _this_row.icon:SetVertexColor (unpack (_table.iconcolor))
|
|
Tercio@11
|
633 end
|
|
Tercio@11
|
634 else
|
|
Tercio@11
|
635 _this_row.icon:SetVertexColor (1, 1, 1, 1)
|
|
Tercio@11
|
636 end
|
|
Tercio@11
|
637 else
|
|
Tercio@11
|
638 _this_row.label:SetPoint ("left", _this_row.statusbar, "left", 2, 0)
|
|
Tercio@11
|
639 end
|
|
Tercio@11
|
640
|
|
Tercio@11
|
641 if (_table.iconsize) then
|
|
Tercio@11
|
642 _this_row.icon:SetSize (_table.iconsize[1], _table.iconsize[2])
|
|
Tercio@11
|
643 else
|
|
Tercio@11
|
644 _this_row.icon:SetSize (20, 20)
|
|
Tercio@11
|
645 end
|
|
Tercio@11
|
646
|
|
Tercio@11
|
647 if (_table.font) then
|
|
Tercio@11
|
648 _this_row.label:SetFont (_table.font, 10.5)
|
|
Tercio@11
|
649 else
|
|
Tercio@11
|
650 _this_row.label:SetFont ("GameFontHighlightSmall", 10.5)
|
|
Tercio@11
|
651 end
|
|
Tercio@11
|
652
|
|
Tercio@11
|
653 _this_row.statusbar:SetTexture (_table.statusbar)
|
|
Tercio@11
|
654 _this_row.label:SetText (_table.label)
|
|
Tercio@11
|
655
|
|
Tercio@11
|
656 if (currentText and currentText == _table.label) then
|
|
Tercio@11
|
657 if (_table.icon) then
|
|
Tercio@11
|
658 selectedTexture:SetPoint ("left", _this_row.icon, "left", -3, 0)
|
|
Tercio@11
|
659 else
|
|
Tercio@11
|
660 selectedTexture:SetPoint ("left", _this_row.statusbar, "left", 0, 0)
|
|
Tercio@11
|
661 end
|
|
Tercio@11
|
662
|
|
Tercio@11
|
663 selectedTexture:Show()
|
|
Tercio@22
|
664 selectedTexture:SetVertexColor (1, 1, 1, .3)
|
|
Tercio@22
|
665 selectedTexture:SetTexCoord (0, 29/32, 5/32, 27/32)
|
|
Tercio@22
|
666
|
|
Tercio@22
|
667 currentIndex = tindex
|
|
Tercio@11
|
668 currentText = nil
|
|
Tercio@11
|
669 end
|
|
Tercio@11
|
670
|
|
Tercio@11
|
671 if (_table.color) then
|
|
Tercio@11
|
672 local _value1, _value2, _value3, _value4 = DF:ParseColors (_table.color)
|
|
Tercio@11
|
673 _this_row.label:SetTextColor (_value1, _value2, _value3, _value4)
|
|
Tercio@11
|
674 else
|
|
Tercio@11
|
675 _this_row.label:SetTextColor (1, 1, 1, 1)
|
|
Tercio@11
|
676 end
|
|
Tercio@11
|
677
|
|
Tercio@11
|
678 _this_row.table = _table
|
|
Tercio@11
|
679
|
|
Tercio@11
|
680 local labelwitdh = _this_row.label:GetStringWidth()
|
|
Tercio@11
|
681 if (labelwitdh+40 > frame_witdh) then
|
|
Tercio@11
|
682 frame_witdh = labelwitdh+40
|
|
Tercio@11
|
683 end
|
|
Tercio@11
|
684 _this_row:Show()
|
|
Tercio@11
|
685
|
|
Tercio@11
|
686 i = i + 1
|
|
Tercio@11
|
687 end
|
|
Tercio@11
|
688
|
|
Tercio@11
|
689 end
|
|
Tercio@11
|
690
|
|
Tercio@11
|
691 if (currentText) then
|
|
Tercio@11
|
692 selectedTexture:Hide()
|
|
Tercio@11
|
693 else
|
|
Tercio@11
|
694 selectedTexture:SetWidth (frame_witdh-20)
|
|
Tercio@11
|
695 end
|
|
Tercio@11
|
696
|
|
Tercio@11
|
697 for i = showing+1, #object.menus do
|
|
Tercio@11
|
698 object.menus [i]:Hide()
|
|
Tercio@11
|
699 end
|
|
Tercio@11
|
700
|
|
Tercio@11
|
701 local size = object.realsizeH
|
|
Tercio@11
|
702
|
|
Tercio@11
|
703 if (showing*20 > size) then
|
|
Tercio@11
|
704 --show scrollbar and setup scroll
|
|
Tercio@11
|
705 object:ShowScroll()
|
|
Tercio@11
|
706 scrollFrame:EnableMouseWheel (true)
|
|
Tercio@11
|
707 object.scroll:Altura (size-35)
|
|
Tercio@11
|
708 object.scroll:SetMinMaxValues (0, (showing*20) - size + 20)
|
|
Tercio@11
|
709 --width
|
|
Tercio@11
|
710 scrollBorder:SetWidth (frame_witdh+20)
|
|
Tercio@11
|
711 scrollFrame:SetWidth (frame_witdh+20)
|
|
Tercio@11
|
712 scrollChild:SetWidth (frame_witdh+20)
|
|
Tercio@11
|
713 --height
|
|
Tercio@40
|
714 scrollBorder:SetHeight (size+2)
|
|
Tercio@40
|
715 scrollFrame:SetHeight (size+2)
|
|
Tercio@11
|
716 scrollChild:SetHeight ((showing*20)+20)
|
|
Tercio@11
|
717 --mouse over texture
|
|
Tercio@11
|
718 mouseOverTexture:SetWidth (frame_witdh-7)
|
|
Tercio@11
|
719 --selected
|
|
Tercio@11
|
720 selectedTexture:SetWidth (frame_witdh - 9)
|
|
Tercio@11
|
721
|
|
Tercio@11
|
722 for index, row in ipairs (object.menus) do
|
|
Tercio@11
|
723 row:SetPoint ("topright", scrollChild, "topright", -22, ((-index-1)*20)-5)
|
|
Tercio@11
|
724 end
|
|
Tercio@11
|
725
|
|
Tercio@11
|
726 else
|
|
Tercio@11
|
727 --hide scrollbar and disable wheel
|
|
Tercio@11
|
728 object:HideScroll()
|
|
Tercio@11
|
729 scrollFrame:EnableMouseWheel (false)
|
|
Tercio@11
|
730 --width
|
|
Tercio@11
|
731 scrollBorder:SetWidth (frame_witdh)
|
|
Tercio@11
|
732 scrollFrame:SetWidth (frame_witdh)
|
|
Tercio@11
|
733 scrollChild:SetWidth (frame_witdh)
|
|
Tercio@11
|
734 --height
|
|
Tercio@40
|
735 scrollBorder:SetHeight ((showing*20) + 10)
|
|
Tercio@40
|
736 scrollFrame:SetHeight ((showing*20) + 10)
|
|
Tercio@11
|
737 --mouse over texture
|
|
Tercio@11
|
738 mouseOverTexture:SetWidth (frame_witdh-10)
|
|
Tercio@11
|
739 --selected
|
|
Tercio@11
|
740 selectedTexture:SetWidth (frame_witdh - 9)
|
|
Tercio@11
|
741
|
|
Tercio@11
|
742 for index, row in ipairs (object.menus) do
|
|
Tercio@11
|
743 row:SetPoint ("topright", scrollChild, "topright", -5, ((-index-1)*20)-5)
|
|
Tercio@11
|
744 end
|
|
Tercio@11
|
745 end
|
|
Tercio@11
|
746
|
|
Tercio@22
|
747 if (object.myvaluelabel and currentIndex and scrollFrame.slider:IsShown()) then
|
|
Tercio@22
|
748 object.scroll:SetValue (max ((currentIndex*20) - 80, 0))
|
|
Tercio@22
|
749 else
|
|
Tercio@22
|
750 object.scroll:SetValue (0)
|
|
Tercio@22
|
751 end
|
|
Tercio@22
|
752
|
|
Tercio@11
|
753 object:Open()
|
|
Tercio@11
|
754
|
|
Tercio@11
|
755 else
|
|
Tercio@11
|
756 --> clear menu
|
|
Tercio@11
|
757
|
|
Tercio@11
|
758 end
|
|
Tercio@11
|
759
|
|
Tercio@11
|
760 else --> click to close
|
|
Tercio@11
|
761
|
|
Tercio@11
|
762 object:Close()
|
|
Tercio@11
|
763 end
|
|
Tercio@11
|
764
|
|
Tercio@11
|
765 end
|
|
Tercio@11
|
766
|
|
Tercio@11
|
767 function DetailsFrameworkDropDownOnEnter (self)
|
|
Tercio@11
|
768
|
|
Tercio@39
|
769 local capsule = self.MyObject
|
|
Tercio@39
|
770 local kill = capsule:RunHooksForWidget ("OnEnter", self, capsule)
|
|
Tercio@39
|
771 if (kill) then
|
|
Tercio@39
|
772 return
|
|
Tercio@11
|
773 end
|
|
Tercio@11
|
774
|
|
Tercio@11
|
775 if (self.MyObject.onenter_backdrop) then
|
|
Tercio@11
|
776 self:SetBackdropColor (unpack (self.MyObject.onenter_backdrop))
|
|
Tercio@11
|
777 else
|
|
Tercio@11
|
778 self:SetBackdropColor (.2, .2, .2, .2)
|
|
Tercio@11
|
779 end
|
|
Tercio@11
|
780
|
|
Tercio@22
|
781 if (self.MyObject.onenter_backdrop_border_color) then
|
|
Tercio@22
|
782 self:SetBackdropBorderColor (unpack (self.MyObject.onenter_backdrop_border_color))
|
|
Tercio@22
|
783 end
|
|
Tercio@22
|
784
|
|
Tercio@11
|
785 self.arrowTexture2:Show()
|
|
Tercio@11
|
786
|
|
Tercio@11
|
787 if (self.MyObject.have_tooltip) then
|
|
Tercio@17
|
788 GameCooltip2:Preset (2)
|
|
Tercio@17
|
789
|
|
Tercio@17
|
790 if (type (self.MyObject.have_tooltip) == "function") then
|
|
Tercio@17
|
791 GameCooltip2:AddLine (self.MyObject.have_tooltip() or "")
|
|
Tercio@17
|
792 else
|
|
Tercio@17
|
793 GameCooltip2:AddLine (self.MyObject.have_tooltip)
|
|
Tercio@17
|
794 end
|
|
Tercio@17
|
795
|
|
Tercio@11
|
796 GameCooltip2:SetOwner (self)
|
|
Tercio@11
|
797 GameCooltip2:ShowCooltip()
|
|
Tercio@11
|
798 end
|
|
Tercio@22
|
799
|
|
Tercio@11
|
800 end
|
|
Tercio@11
|
801
|
|
Tercio@11
|
802 function DetailsFrameworkDropDownOnLeave (self)
|
|
Tercio@39
|
803 local capsule = self.MyObject
|
|
Tercio@39
|
804 local kill = capsule:RunHooksForWidget ("OnLeave", self, capsule)
|
|
Tercio@39
|
805 if (kill) then
|
|
Tercio@39
|
806 return
|
|
Tercio@11
|
807 end
|
|
Tercio@11
|
808
|
|
Tercio@11
|
809 if (self.MyObject.onleave_backdrop) then
|
|
Tercio@11
|
810 self:SetBackdropColor (unpack (self.MyObject.onleave_backdrop))
|
|
Tercio@11
|
811 else
|
|
Tercio@11
|
812 self:SetBackdropColor (1, 1, 1, .5)
|
|
Tercio@11
|
813 end
|
|
Tercio@11
|
814
|
|
Tercio@22
|
815 if (self.MyObject.onleave_backdrop_border_color) then
|
|
Tercio@22
|
816 self:SetBackdropBorderColor (unpack (self.MyObject.onleave_backdrop_border_color))
|
|
Tercio@22
|
817 end
|
|
Tercio@22
|
818
|
|
Tercio@11
|
819 self.arrowTexture2:Hide()
|
|
Tercio@11
|
820
|
|
Tercio@11
|
821 if (self.MyObject.have_tooltip) then
|
|
Tercio@11
|
822 GameCooltip2:ShowMe (false)
|
|
Tercio@11
|
823 end
|
|
Tercio@11
|
824 end
|
|
Tercio@11
|
825
|
|
Tercio@11
|
826 function DetailsFrameworkDropDownOnSizeChanged (self, w, h)
|
|
Tercio@11
|
827 self.MyObject.label:SetSize (self:GetWidth()-40, 10)
|
|
Tercio@11
|
828 end
|
|
Tercio@11
|
829
|
|
Tercio@11
|
830 function DetailsFrameworkDropDownOnShow (self)
|
|
Tercio@39
|
831 local capsule = self.MyObject
|
|
Tercio@39
|
832 local kill = capsule:RunHooksForWidget ("OnShow", self, capsule)
|
|
Tercio@39
|
833 if (kill) then
|
|
Tercio@39
|
834 return
|
|
Tercio@11
|
835 end
|
|
Tercio@11
|
836 end
|
|
Tercio@11
|
837
|
|
Tercio@11
|
838 function DetailsFrameworkDropDownOnHide (self)
|
|
Tercio@39
|
839 local capsule = self.MyObject
|
|
Tercio@39
|
840 local kill = capsule:RunHooksForWidget ("OnHide", self, capsule)
|
|
Tercio@39
|
841 if (kill) then
|
|
Tercio@39
|
842 return
|
|
Tercio@11
|
843 end
|
|
Tercio@11
|
844
|
|
Tercio@11
|
845 self.MyObject:Close()
|
|
Tercio@11
|
846 end
|
|
Tercio@11
|
847
|
|
Tercio@20
|
848 function DF:BuildDropDownFontList (on_click, icon, icon_texcoord, icon_size)
|
|
Tercio@20
|
849 local t = {}
|
|
Tercio@20
|
850 local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
|
|
Tercio@20
|
851 for name, fontPath in pairs (SharedMedia:HashTable ("font")) do
|
|
Tercio@20
|
852 t[#t+1] = {value = name, label = name, onclick = on_click, icon = icon, iconsize = icon_size, texcoord = icon_texcoord, font = fontPath, descfont = "abcdefg ABCDEFG"}
|
|
Tercio@20
|
853 end
|
|
Tercio@20
|
854 table.sort (t, function (t1, t2) return t1.label < t2.label end)
|
|
Tercio@20
|
855 return t
|
|
Tercio@20
|
856 end
|
|
Tercio@11
|
857
|
|
Tercio@11
|
858 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@22
|
859 function DropDownMetaFunctions:SetTemplate (template)
|
|
Tercio@22
|
860
|
|
Tercio@22
|
861 if (template.width) then
|
|
Tercio@22
|
862 self:SetWidth (template.width)
|
|
Tercio@22
|
863 end
|
|
Tercio@22
|
864 if (template.height) then
|
|
Tercio@22
|
865 self:SetHeight (template.height)
|
|
Tercio@22
|
866 end
|
|
Tercio@22
|
867
|
|
Tercio@22
|
868 if (template.backdrop) then
|
|
Tercio@22
|
869 self:SetBackdrop (template.backdrop)
|
|
Tercio@22
|
870 end
|
|
Tercio@22
|
871 if (template.backdropcolor) then
|
|
Tercio@22
|
872 local r, g, b, a = DF:ParseColors (template.backdropcolor)
|
|
Tercio@22
|
873 self:SetBackdropColor (r, g, b, a)
|
|
Tercio@22
|
874 self.onleave_backdrop = {r, g, b, a}
|
|
Tercio@22
|
875 end
|
|
Tercio@22
|
876 if (template.backdropbordercolor) then
|
|
Tercio@22
|
877 local r, g, b, a = DF:ParseColors (template.backdropbordercolor)
|
|
Tercio@22
|
878 self:SetBackdropBorderColor (r, g, b, a)
|
|
Tercio@22
|
879 self.onleave_backdrop_border_color = {r, g, b, a}
|
|
Tercio@22
|
880 end
|
|
Tercio@22
|
881
|
|
Tercio@22
|
882 if (template.onentercolor) then
|
|
Tercio@22
|
883 local r, g, b, a = DF:ParseColors (template.onentercolor)
|
|
Tercio@22
|
884 self.onenter_backdrop = {r, g, b, a}
|
|
Tercio@22
|
885 end
|
|
Tercio@22
|
886
|
|
Tercio@22
|
887 if (template.onleavecolor) then
|
|
Tercio@22
|
888 local r, g, b, a = DF:ParseColors (template.onleavecolor)
|
|
Tercio@22
|
889 self.onleave_backdrop = {r, g, b, a}
|
|
Tercio@22
|
890 end
|
|
Tercio@22
|
891
|
|
Tercio@22
|
892 if (template.onenterbordercolor) then
|
|
Tercio@22
|
893 local r, g, b, a = DF:ParseColors (template.onenterbordercolor)
|
|
Tercio@22
|
894 self.onenter_backdrop_border_color = {r, g, b, a}
|
|
Tercio@22
|
895 end
|
|
Tercio@22
|
896
|
|
Tercio@22
|
897 if (template.onleavebordercolor) then
|
|
Tercio@22
|
898 local r, g, b, a = DF:ParseColors (template.onleavebordercolor)
|
|
Tercio@22
|
899 self.onleave_backdrop_border_color = {r, g, b, a}
|
|
Tercio@22
|
900 end
|
|
Tercio@22
|
901
|
|
Tercio@22
|
902 end
|
|
Tercio@22
|
903
|
|
Tercio@22
|
904 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
905 --> object constructor
|
|
Tercio@11
|
906
|
|
Tercio@22
|
907 function DF:CreateDropDown (parent, func, default, w, h, member, name, template)
|
|
Tercio@22
|
908 return DF:NewDropDown (parent, parent, name, member, w, h, func, default, template)
|
|
Tercio@11
|
909 end
|
|
Tercio@11
|
910
|
|
Tercio@22
|
911 function DF:NewDropDown (parent, container, name, member, w, h, func, default, template)
|
|
Tercio@11
|
912
|
|
Tercio@11
|
913 if (not name) then
|
|
Tercio@11
|
914 name = "DetailsFrameworkDropDownNumber" .. DF.DropDownCounter
|
|
Tercio@11
|
915 DF.DropDownCounter = DF.DropDownCounter + 1
|
|
Tercio@11
|
916
|
|
Tercio@11
|
917 elseif (not parent) then
|
|
Tercioo@29
|
918 return error ("Details! FrameWork: parent not found.", 2)
|
|
Tercio@11
|
919 end
|
|
Tercio@11
|
920 if (not container) then
|
|
Tercio@11
|
921 container = parent
|
|
Tercio@11
|
922 end
|
|
Tercio@11
|
923
|
|
Tercio@11
|
924 if (name:find ("$parent")) then
|
|
Tercioo@29
|
925 local parentName = DF.GetParentName (parent)
|
|
Tercioo@29
|
926 name = name:gsub ("$parent", parentName)
|
|
Tercio@11
|
927 end
|
|
Tercio@11
|
928
|
|
Tercio@11
|
929 local DropDownObject = {type = "dropdown", dframework = true}
|
|
Tercio@11
|
930
|
|
Tercio@11
|
931 if (member) then
|
|
Tercio@11
|
932 parent [member] = DropDownObject
|
|
Tercio@11
|
933 end
|
|
Tercio@11
|
934
|
|
Tercio@11
|
935 if (parent.dframework) then
|
|
Tercio@11
|
936 parent = parent.widget
|
|
Tercio@11
|
937 end
|
|
Tercio@11
|
938 if (container.dframework) then
|
|
Tercio@11
|
939 container = container.widget
|
|
Tercio@11
|
940 end
|
|
Tercio@11
|
941
|
|
Tercio@11
|
942 if (default == nil) then
|
|
Tercio@11
|
943 default = 1
|
|
Tercio@11
|
944 end
|
|
Tercio@11
|
945
|
|
Tercio@11
|
946 --> default members:
|
|
Tercio@11
|
947 --> misc
|
|
Tercio@11
|
948 DropDownObject.container = container
|
|
Tercio@11
|
949
|
|
Tercio@40
|
950 --DropDownObject.dropdown = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownTemplate")
|
|
Tercio@40
|
951 DropDownObject.dropdown = DF:CreateNewDropdownFrame (parent, name)
|
|
Tercio@40
|
952
|
|
Tercio@11
|
953 DropDownObject.widget = DropDownObject.dropdown
|
|
Tercio@11
|
954
|
|
Tercio@11
|
955 DropDownObject.__it = {nil, nil}
|
|
Tercio@11
|
956 --_G [name] = DropDownObject
|
|
Tercio@11
|
957
|
|
Tercio@11
|
958 if (not APIDropDownFunctions) then
|
|
Tercio@11
|
959 APIDropDownFunctions = true
|
|
Tercio@11
|
960 local idx = getmetatable (DropDownObject.dropdown).__index
|
|
Tercio@11
|
961 for funcName, funcAddress in pairs (idx) do
|
|
Tercio@11
|
962 if (not DropDownMetaFunctions [funcName]) then
|
|
Tercio@11
|
963 DropDownMetaFunctions [funcName] = function (object, ...)
|
|
Tercio@20
|
964 local x = loadstring ( "return _G['"..object.dropdown:GetName().."']:"..funcName.."(...)")
|
|
Tercio@11
|
965 return x (...)
|
|
Tercio@11
|
966 end
|
|
Tercio@11
|
967 end
|
|
Tercio@11
|
968 end
|
|
Tercio@11
|
969 end
|
|
Tercio@11
|
970
|
|
Tercio@11
|
971 DropDownObject.dropdown.MyObject = DropDownObject
|
|
Tercio@11
|
972
|
|
Tercio@11
|
973 DropDownObject.dropdown:SetWidth (w)
|
|
Tercio@11
|
974 DropDownObject.dropdown:SetHeight (h)
|
|
Tercio@11
|
975
|
|
Tercio@11
|
976 DropDownObject.func = func
|
|
Tercio@11
|
977 DropDownObject.realsizeW = 150
|
|
Tercio@11
|
978 DropDownObject.realsizeH = 150
|
|
Tercio@11
|
979 DropDownObject.FixedValue = nil
|
|
Tercio@11
|
980 DropDownObject.opened = false
|
|
Tercio@11
|
981 DropDownObject.menus = {}
|
|
Tercio@11
|
982 DropDownObject.myvalue = nil
|
|
Tercio@11
|
983
|
|
Tercio@11
|
984 DropDownObject.label = _G [name .. "_Text"]
|
|
Tercio@11
|
985
|
|
Tercio@11
|
986 DropDownObject.icon = _G [name .. "_IconTexture"]
|
|
Tercio@11
|
987 DropDownObject.statusbar = _G [name .. "_StatusBarTexture"]
|
|
Tercio@11
|
988 DropDownObject.select = _G [name .. "_SelectedTexture"]
|
|
Tercio@11
|
989
|
|
Tercio@11
|
990 local scroll = _G [DropDownObject.dropdown:GetName() .. "_ScrollFrame"]
|
|
Tercio@11
|
991
|
|
Tercio@11
|
992 DropDownObject.scroll = DF:NewScrollBar (scroll, _G [DropDownObject.dropdown:GetName() .. "_ScrollFrame".."_ScrollChild"], -25, -18)
|
|
Tercio@11
|
993
|
|
Tercio@11
|
994 function DropDownObject:HideScroll()
|
|
Tercio@11
|
995 scroll.baixo:Hide()
|
|
Tercio@11
|
996 scroll.cima:Hide()
|
|
Tercio@11
|
997 scroll.slider:Hide()
|
|
Tercio@11
|
998 end
|
|
Tercio@11
|
999 function DropDownObject:ShowScroll()
|
|
Tercio@11
|
1000 scroll.baixo:Show()
|
|
Tercio@11
|
1001 scroll.cima:Show()
|
|
Tercio@11
|
1002 scroll.slider:Show()
|
|
Tercio@11
|
1003 end
|
|
Tercio@11
|
1004
|
|
Tercio@11
|
1005 --button_down_scripts (DropDownObject, scroll.slider, scroll.baixo)
|
|
Tercio@11
|
1006
|
|
Tercio@11
|
1007 DropDownObject:HideScroll()
|
|
Tercio@11
|
1008 DropDownObject.label:SetSize (DropDownObject.dropdown:GetWidth()-40, 10)
|
|
Tercio@11
|
1009
|
|
Tercio@39
|
1010 DropDownObject.HookList = {
|
|
Tercio@39
|
1011 OnEnter = {},
|
|
Tercio@39
|
1012 OnLeave = {},
|
|
Tercio@39
|
1013 OnHide = {},
|
|
Tercio@39
|
1014 OnShow = {},
|
|
Tercio@39
|
1015 }
|
|
Tercio@39
|
1016
|
|
Tercio@39
|
1017 DropDownObject.dropdown:SetScript ("OnShow", DetailsFrameworkDropDownOnShow)
|
|
Tercio@39
|
1018 DropDownObject.dropdown:SetScript ("OnHide", DetailsFrameworkDropDownOnHide)
|
|
Tercio@39
|
1019 DropDownObject.dropdown:SetScript ("OnEnter", DetailsFrameworkDropDownOnEnter)
|
|
Tercio@39
|
1020 DropDownObject.dropdown:SetScript ("OnLeave", DetailsFrameworkDropDownOnLeave)
|
|
Tercio@39
|
1021
|
|
Tercio@11
|
1022 --> setup class
|
|
Tercio@11
|
1023 _setmetatable (DropDownObject, DropDownMetaFunctions)
|
|
Tercio@39
|
1024
|
|
Tercio@11
|
1025 --> initialize first menu selected
|
|
Tercio@11
|
1026 if (type (default) == "string") then
|
|
Tercio@11
|
1027 DropDownObject:Select (default)
|
|
Tercio@11
|
1028
|
|
Tercio@11
|
1029 elseif (type (default) == "number") then
|
|
Tercio@11
|
1030 if (not DropDownObject:Select (default)) then
|
|
Tercio@11
|
1031 DropDownObject:Select (default, true)
|
|
Tercio@11
|
1032 end
|
|
Tercio@11
|
1033 end
|
|
Tercio@11
|
1034
|
|
Tercio@22
|
1035 if (template) then
|
|
Tercio@22
|
1036 DropDownObject:SetTemplate (template)
|
|
Tercio@22
|
1037 end
|
|
Tercio@22
|
1038
|
|
Tercio@39
|
1039 return DropDownObject
|
|
Tercio@11
|
1040
|
|
Tercio@40
|
1041 end
|
|
Tercio@40
|
1042
|
|
Tercio@40
|
1043 local default_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
|
|
Tercio@40
|
1044 edgeSize = 1, tile = true, tileSize = 16, insets = {left = 1, right = 1, top = 0, bottom = 1}}
|
|
Tercio@40
|
1045 local border_backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, insets = {left = 0, right = 0, top = 0, bottom = 0}}
|
|
Tercio@40
|
1046 local child_backdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 256, insets = {left = 0, right = 0, top = 0, bottom = 0}}
|
|
Tercio@40
|
1047
|
|
Tercio@40
|
1048 function DF:CreateNewDropdownFrame (parent, name)
|
|
Tercio@40
|
1049 local f = CreateFrame ("button", name, parent)
|
|
Tercio@40
|
1050 f:SetBackdrop (default_backdrop)
|
|
Tercio@40
|
1051 f:SetSize (150, 20)
|
|
Tercio@40
|
1052
|
|
Tercio@40
|
1053 local statusbar = f:CreateTexture ("$parent_StatusBarTexture", "BACKGROUND")
|
|
Tercio@40
|
1054 statusbar:SetPoint ("topleft", f, "topleft", 3, -3)
|
|
Tercio@40
|
1055 statusbar:SetPoint ("bottomright", f, "bottomright", -3, 3)
|
|
Tercio@40
|
1056 f.statusbar = statusbar
|
|
Tercio@40
|
1057
|
|
Tercio@40
|
1058 local icon = f:CreateTexture ("$parent_IconTexture", "ARTWORK")
|
|
Tercio@40
|
1059 icon:SetPoint ("left", f, "left", 2, 0)
|
|
Tercio@40
|
1060 icon:SetSize (20, 20)
|
|
Tercio@40
|
1061 icon:SetTexture ([[Interface\COMMON\UI-ModelControlPanel]])
|
|
Tercio@40
|
1062 icon:SetTexCoord (0.625, 0.78125, 0.328125, 0.390625)
|
|
Tercio@40
|
1063 icon:SetVertexColor (1, 1, 1, 0.4)
|
|
Tercio@40
|
1064 f.icon = icon
|
|
Tercio@40
|
1065
|
|
Tercio@40
|
1066 local text = f:CreateFontString ("$parent_Text", "ARTWORK", "GameFontHighlightSmall")
|
|
Tercio@40
|
1067 text:SetPoint ("left", icon, "right", 5, 0)
|
|
Tercio@40
|
1068 text:SetJustifyH ("left")
|
|
Tercio@40
|
1069 text:SetText ("no option selected")
|
|
Tercio@40
|
1070 text:SetTextColor (1, 1, 1, 0.4)
|
|
Tercio@40
|
1071 DF:SetFontSize (text, 10)
|
|
Tercio@40
|
1072 f.text = text
|
|
Tercio@40
|
1073
|
|
Tercio@40
|
1074 local arrow = f:CreateTexture ("$parent_ArrowTexture2", "OVERLAY")
|
|
Tercio@40
|
1075 arrow:SetPoint ("right", f, "right", 5, -1)
|
|
Tercio@40
|
1076 arrow:SetBlendMode ("ADD")
|
|
Tercio@40
|
1077 arrow:SetTexture ([[Interface\Buttons\UI-ScrollBar-ScrollDownButton-Highlight]])
|
|
Tercio@40
|
1078 arrow:Hide()
|
|
Tercio@40
|
1079 arrow:SetSize (32, 28)
|
|
Tercio@40
|
1080 f.arrowTexture2 = arrow
|
|
Tercio@40
|
1081
|
|
Tercio@40
|
1082 local buttonTexture = f:CreateTexture ("$parent_ArrowTexture", "OVERLAY")
|
|
Tercio@40
|
1083 buttonTexture:SetPoint ("right", f, "right", 5, -1)
|
|
Tercio@40
|
1084 buttonTexture:SetTexture ([[Interface\Buttons\UI-ScrollBar-ScrollDownButton-Up]])
|
|
Tercio@40
|
1085 buttonTexture:SetSize (32, 28)
|
|
Tercio@40
|
1086 f.arrowTexture = buttonTexture
|
|
Tercio@40
|
1087
|
|
Tercio@40
|
1088 --scripts
|
|
Tercio@40
|
1089 f:SetScript ("OnSizeChanged", DetailsFrameworkDropDownOnSizeChanged)
|
|
Tercio@40
|
1090 f:SetScript ("OnMouseDown", DetailsFrameworkDropDownOnMouseDown)
|
|
Tercio@40
|
1091
|
|
Tercio@40
|
1092 --on load
|
|
Tercio@40
|
1093 f:SetBackdropColor (1, 1, 1, .5)
|
|
Tercio@40
|
1094 f.arrowTexture:SetDrawLayer ("OVERLAY", 1)
|
|
Tercio@40
|
1095 f.arrowTexture2:SetDrawLayer ("OVERLAY", 2)
|
|
Tercio@40
|
1096
|
|
Tercio@40
|
1097 --dropdown
|
|
Tercio@40
|
1098 local border = CreateFrame ("frame", "$Parent_Border", f)
|
|
Tercio@40
|
1099 border:Hide()
|
|
Tercio@40
|
1100 border:SetFrameStrata ("FULLSCREEN")
|
|
Tercio@40
|
1101 border:SetSize (150, 150)
|
|
Tercio@40
|
1102 border:SetPoint ("topleft", f, "bottomleft")
|
|
Tercio@40
|
1103 border:SetBackdrop (border_backdrop)
|
|
Tercio@40
|
1104 border:SetScript ("OnHide", DetailsFrameworkDropDownOptionsFrameOnHide)
|
|
Tercio@40
|
1105 border:SetBackdropColor (0, 0, 0, 0.92)
|
|
Tercio@40
|
1106 border:SetBackdropBorderColor (0, 0, 0, 1)
|
|
Tercio@40
|
1107 f.dropdownborder = border
|
|
Tercio@40
|
1108
|
|
Tercio@40
|
1109 local scroll = CreateFrame ("ScrollFrame", "$Parent_ScrollFrame", f)
|
|
Tercio@40
|
1110 scroll:Hide()
|
|
Tercio@40
|
1111 scroll:SetFrameStrata ("FULLSCREEN")
|
|
Tercio@40
|
1112 scroll:SetSize (150, 150)
|
|
Tercio@40
|
1113 scroll:SetPoint ("topleft", f, "bottomleft", 0, 0)
|
|
Tercio@40
|
1114 f.dropdownframe = scroll
|
|
Tercio@40
|
1115
|
|
Tercio@40
|
1116 local child = CreateFrame ("frame", "$Parent_ScrollChild", scroll)
|
|
Tercio@40
|
1117 child:SetSize (150, 150)
|
|
Tercio@40
|
1118 child:SetPoint ("topleft", scroll, "topleft", 0, 0)
|
|
Tercio@40
|
1119 child:SetBackdrop (child_backdrop)
|
|
Tercio@40
|
1120 child:SetBackdropColor (0, 0, 0, 1)
|
|
Tercio@40
|
1121
|
|
Tercio@40
|
1122 local selected = child:CreateTexture ("$parent_SelectedTexture", "BACKGROUND")
|
|
Tercio@40
|
1123 selected:SetSize (150, 16)
|
|
Tercio@40
|
1124 selected:Hide()
|
|
Tercio@40
|
1125 selected:SetPoint ("left", child, "left", 2, 0)
|
|
Tercio@40
|
1126 selected:SetTexture ([[Interface\RAIDFRAME\Raid-Bar-Hp-Fill]])
|
|
Tercio@40
|
1127 child.selected = selected
|
|
Tercio@40
|
1128
|
|
Tercio@40
|
1129 local mouseover = child:CreateTexture ("$parent_MouseOverTexture", "ARTWORK")
|
|
Tercio@40
|
1130 mouseover:SetBlendMode ("ADD")
|
|
Tercio@40
|
1131 mouseover:Hide()
|
|
Tercio@40
|
1132 mouseover:SetTexture ([[Interface\Buttons\UI-Listbox-Highlight]])
|
|
Tercio@40
|
1133 mouseover:SetSize (150, 15)
|
|
Tercio@40
|
1134 mouseover:SetPoint ("left", child, "left", 2, 0)
|
|
Tercio@40
|
1135 child.mouseover = mouseover
|
|
Tercio@40
|
1136
|
|
Tercio@40
|
1137 scroll:SetScrollChild (child)
|
|
Tercio@40
|
1138 tinsert (UISpecialFrames, f.dropdownborder:GetName())
|
|
Tercio@40
|
1139 tinsert (UISpecialFrames, f.dropdownframe:GetName())
|
|
Tercio@40
|
1140
|
|
Tercio@40
|
1141 return f
|
|
Tercio@40
|
1142 end
|
|
Tercio@40
|
1143
|
|
Tercio@40
|
1144 function DF:CreateDropdownButton (parent, name)
|
|
Tercio@40
|
1145
|
|
Tercio@40
|
1146 local f = CreateFrame ("button", name, parent)
|
|
Tercio@40
|
1147 f:SetSize (150, 20)
|
|
Tercio@40
|
1148
|
|
Tercio@40
|
1149 local statusbar = f:CreateTexture ("$parent_StatusBarTexture", "ARTWORK")
|
|
Tercio@40
|
1150 statusbar:SetPoint ("left", f, "left", 1, 0)
|
|
Tercio@40
|
1151 statusbar:SetPoint ("right", f, "right", -10, 0)
|
|
Tercio@40
|
1152 statusbar:SetSize (150, 20)
|
|
Tercio@40
|
1153 f.statusbar = statusbar
|
|
Tercio@40
|
1154
|
|
Tercio@40
|
1155 local icon = f:CreateTexture ("$parent_IconTexture", "OVERLAY")
|
|
Tercio@40
|
1156 icon:SetPoint ("left", f, "left", 2, 0)
|
|
Tercio@40
|
1157 icon:SetSize (20, 20)
|
|
Tercio@40
|
1158 icon:SetTexture ([[Interface\ICONS\Spell_ChargePositive]])
|
|
Tercio@40
|
1159 f.icon = icon
|
|
Tercio@40
|
1160
|
|
Tercio@40
|
1161 local text = f:CreateFontString ("$parent_Text", "OVERLAY", "GameFontHighlightSmall")
|
|
Tercio@40
|
1162 text:SetPoint ("left", icon, "right", 5, 0)
|
|
Tercio@40
|
1163 text:SetJustifyH ("left")
|
|
Tercio@40
|
1164 DF:SetFontSize (text, 10)
|
|
Tercio@40
|
1165 f.label = text
|
|
Tercio@40
|
1166
|
|
Tercio@40
|
1167 f:SetScript ("OnMouseDown", DetailsFrameworkDropDownOptionClick)
|
|
Tercio@40
|
1168 f:SetScript ("OnEnter", DetailsFrameworkDropDownOptionOnEnter)
|
|
Tercio@40
|
1169 f:SetScript ("OnLeave", DetailsFrameworkDropDownOptionOnLeave)
|
|
Tercio@40
|
1170
|
|
Tercio@40
|
1171 return f
|
|
Tercio@40
|
1172 end
|