|
Tercio@11
|
1
|
|
Tercio@11
|
2 local DF = _G ["DetailsFramework"]
|
|
Tercio@11
|
3 local _
|
|
Tercio@11
|
4
|
|
Tercio@11
|
5 local _rawset = rawset --> lua local
|
|
Tercio@11
|
6 local _rawget = rawget --> lua local
|
|
Tercio@11
|
7 local _setmetatable = setmetatable --> lua local
|
|
Tercio@11
|
8 local _unpack = unpack --> lua local
|
|
Tercio@11
|
9 local _type = type --> lua local
|
|
Tercio@11
|
10 local _math_floor = math.floor --> lua local
|
|
Tercio@11
|
11 local loadstring = loadstring --> lua local
|
|
Tercio@11
|
12 local _string_len = string.len --> lua local
|
|
Tercio@11
|
13
|
|
Tercio@11
|
14 local cleanfunction = function() end
|
|
Tercio@11
|
15 local APIDropDownFunctions = false
|
|
Tercio@11
|
16 local DropDownMetaFunctions = {}
|
|
Tercio@11
|
17
|
|
Tercio@11
|
18 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
19 --> metatables
|
|
Tercio@11
|
20
|
|
Tercio@11
|
21 DropDownMetaFunctions.__call = function (_table, value)
|
|
Tercio@11
|
22 --> unknow
|
|
Tercio@11
|
23 end
|
|
Tercio@11
|
24
|
|
Tercio@11
|
25 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
26 --> members
|
|
Tercio@11
|
27
|
|
Tercio@11
|
28 --> selected value
|
|
Tercio@11
|
29 local gmember_value = function (_object)
|
|
Tercio@11
|
30 return _object:GetValue()
|
|
Tercio@11
|
31 end
|
|
Tercio@11
|
32 --> tooltip
|
|
Tercio@11
|
33 local gmember_tooltip = function (_object)
|
|
Tercio@11
|
34 return _object:GetTooltip()
|
|
Tercio@11
|
35 end
|
|
Tercio@11
|
36 --> shown
|
|
Tercio@11
|
37 local gmember_shown = function (_object)
|
|
Tercio@11
|
38 return _object:IsShown()
|
|
Tercio@11
|
39 end
|
|
Tercio@11
|
40 --> frame width
|
|
Tercio@11
|
41 local gmember_width = function (_object)
|
|
Tercio@11
|
42 return _object.button:GetWidth()
|
|
Tercio@11
|
43 end
|
|
Tercio@11
|
44 --> frame height
|
|
Tercio@11
|
45 local gmember_height = function (_object)
|
|
Tercio@11
|
46 return _object.button:GetHeight()
|
|
Tercio@11
|
47 end
|
|
Tercio@11
|
48 --> current text
|
|
Tercio@11
|
49 local gmember_text = function (_object)
|
|
Tercio@11
|
50 return _object.label:GetText()
|
|
Tercio@11
|
51 end
|
|
Tercio@11
|
52 --> menu creation function
|
|
Tercio@11
|
53 local gmember_function = function (_object)
|
|
Tercio@11
|
54 return _object:GetFunction()
|
|
Tercio@11
|
55 end
|
|
Tercio@11
|
56 --> menu width
|
|
Tercio@11
|
57 local gmember_menuwidth = function (_object)
|
|
Tercio@11
|
58 return _rawget (self, "realsizeW")
|
|
Tercio@11
|
59 end
|
|
Tercio@11
|
60 --> menu height
|
|
Tercio@11
|
61 local gmember_menuheight = function (_object)
|
|
Tercio@11
|
62 return _rawget (self, "realsizeH")
|
|
Tercio@11
|
63 end
|
|
Tercio@11
|
64
|
|
Tercio@11
|
65 local get_members_function_index = {
|
|
Tercio@11
|
66 ["value"] = gmember_value,
|
|
Tercio@11
|
67 ["text"] = gmember_text,
|
|
Tercio@11
|
68 ["shown"] = gmember_shown,
|
|
Tercio@11
|
69 ["width"] = gmember_width,
|
|
Tercio@11
|
70 ["menuwidth"] = gmember_menuwidth,
|
|
Tercio@11
|
71 ["height"] = gmember_height,
|
|
Tercio@11
|
72 ["menuheight"] = gmember_menuheight,
|
|
Tercio@11
|
73 ["tooltip"] = gmember_tooltip,
|
|
Tercio@11
|
74 ["func"] = gmember_function,
|
|
Tercio@11
|
75 }
|
|
Tercio@11
|
76
|
|
Tercio@11
|
77 DropDownMetaFunctions.__index = function (_table, _member_requested)
|
|
Tercio@11
|
78
|
|
Tercio@11
|
79 local func = get_members_function_index [_member_requested]
|
|
Tercio@11
|
80 if (func) then
|
|
Tercio@11
|
81 return func (_table, _member_requested)
|
|
Tercio@11
|
82 end
|
|
Tercio@11
|
83
|
|
Tercio@11
|
84 local fromMe = _rawget (_table, _member_requested)
|
|
Tercio@11
|
85 if (fromMe) then
|
|
Tercio@11
|
86 return fromMe
|
|
Tercio@11
|
87 end
|
|
Tercio@11
|
88
|
|
Tercio@11
|
89 return DropDownMetaFunctions [_member_requested]
|
|
Tercio@11
|
90 end
|
|
Tercio@11
|
91
|
|
Tercio@11
|
92 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
93
|
|
Tercio@11
|
94 --> tooltip
|
|
Tercio@11
|
95 local smember_tooltip = function (_object, _value)
|
|
Tercio@11
|
96 return _object:SetTooltip (_value)
|
|
Tercio@11
|
97 end
|
|
Tercio@11
|
98 --> show
|
|
Tercio@11
|
99 local smember_show = function (_object, _value)
|
|
Tercio@11
|
100 if (_value) then
|
|
Tercio@11
|
101 return _object:Show()
|
|
Tercio@11
|
102 else
|
|
Tercio@11
|
103 return _object:Hide()
|
|
Tercio@11
|
104 end
|
|
Tercio@11
|
105 end
|
|
Tercio@11
|
106 --> hide
|
|
Tercio@11
|
107 local smember_hide = function (_object, _value)
|
|
Tercio@11
|
108 if (not _value) then
|
|
Tercio@11
|
109 return _object:Show()
|
|
Tercio@11
|
110 else
|
|
Tercio@11
|
111 return _object:Hide()
|
|
Tercio@11
|
112 end
|
|
Tercio@11
|
113 end
|
|
Tercio@11
|
114 --> frame width
|
|
Tercio@11
|
115 local smember_width = function (_object, _value)
|
|
Tercio@11
|
116 return _object.dropdown:SetWidth (_value)
|
|
Tercio@11
|
117 end
|
|
Tercio@11
|
118 --> frame height
|
|
Tercio@11
|
119 local smember_height = function (_object, _value)
|
|
Tercio@11
|
120 return _object.dropdown:SetHeight (_value)
|
|
Tercio@11
|
121 end
|
|
Tercio@11
|
122 --> menu creation function
|
|
Tercio@11
|
123 local smember_function = function (_object, _value)
|
|
Tercio@11
|
124 return _object:SetFunction (_value)
|
|
Tercio@11
|
125 end
|
|
Tercio@11
|
126 --> menu width
|
|
Tercio@11
|
127 local smember_menuwidth = function (_object, _value)
|
|
Tercio@11
|
128 _object:SetMenuSize (_value, nil)
|
|
Tercio@11
|
129 end
|
|
Tercio@11
|
130 --> menu height
|
|
Tercio@11
|
131 local smember_menuheight = function (_object, _value)
|
|
Tercio@11
|
132 _object:SetMenuSize (nil, _value)
|
|
Tercio@11
|
133 end
|
|
Tercio@11
|
134
|
|
Tercio@11
|
135 local set_members_function_index = {
|
|
Tercio@11
|
136 ["tooltip"] = smember_tooltip,
|
|
Tercio@11
|
137 ["show"] = smember_show,
|
|
Tercio@11
|
138 ["hide"] = smember_hide,
|
|
Tercio@11
|
139 ["width"] = smember_width,
|
|
Tercio@11
|
140 ["menuwidth"] = smember_menuwidth,
|
|
Tercio@11
|
141 ["height"] = smember_height,
|
|
Tercio@11
|
142 ["menuheight"] = smember_menuheight,
|
|
Tercio@11
|
143 ["func"] = smember_function,
|
|
Tercio@11
|
144 }
|
|
Tercio@11
|
145
|
|
Tercio@11
|
146 DropDownMetaFunctions.__newindex = function (_table, _key, _value)
|
|
Tercio@11
|
147 local func = set_members_function_index [_key]
|
|
Tercio@11
|
148 if (func) then
|
|
Tercio@11
|
149 return func (_table, _value)
|
|
Tercio@11
|
150 else
|
|
Tercio@11
|
151 return _rawset (_table, _key, _value)
|
|
Tercio@11
|
152 end
|
|
Tercio@11
|
153 end
|
|
Tercio@11
|
154
|
|
Tercio@11
|
155 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
156 --> methods
|
|
Tercio@11
|
157 function DropDownMetaFunctions:IsShown()
|
|
Tercio@11
|
158 return self.dropdown:IsShown()
|
|
Tercio@11
|
159 end
|
|
Tercio@11
|
160 function DropDownMetaFunctions:Show()
|
|
Tercio@11
|
161 return self.dropdown:Show()
|
|
Tercio@11
|
162 end
|
|
Tercio@11
|
163 function DropDownMetaFunctions:Hide()
|
|
Tercio@11
|
164 return self.dropdown:Hide()
|
|
Tercio@11
|
165 end
|
|
Tercio@11
|
166
|
|
Tercio@11
|
167 --> menu width and height
|
|
Tercio@11
|
168 function DropDownMetaFunctions:SetMenuSize (w, h)
|
|
Tercio@11
|
169 if (w) then
|
|
Tercio@11
|
170 return _rawset (self, "realsizeW", w)
|
|
Tercio@11
|
171 end
|
|
Tercio@11
|
172 if (h) then
|
|
Tercio@11
|
173 return _rawset (self, "realsizeH", h)
|
|
Tercio@11
|
174 end
|
|
Tercio@11
|
175 end
|
|
Tercio@11
|
176 function DropDownMetaFunctions:GetMenuSize()
|
|
Tercio@11
|
177 return _rawget (self, "realsizeW"), _rawget (self, "realsizeH")
|
|
Tercio@11
|
178 end
|
|
Tercio@11
|
179
|
|
Tercio@11
|
180 --> function
|
|
Tercio@11
|
181 function DropDownMetaFunctions:SetFunction (func)
|
|
Tercio@11
|
182 return _rawset (self, "func", func)
|
|
Tercio@11
|
183 end
|
|
Tercio@11
|
184 function DropDownMetaFunctions:GetFunction()
|
|
Tercio@11
|
185 return _rawget (self, "func")
|
|
Tercio@11
|
186 end
|
|
Tercio@11
|
187
|
|
Tercio@11
|
188 --> value
|
|
Tercio@11
|
189 function DropDownMetaFunctions:GetValue()
|
|
Tercio@11
|
190 return _rawget (self, "myvalue")
|
|
Tercio@11
|
191 end
|
|
Tercio@11
|
192 function DropDownMetaFunctions:SetValue (value)
|
|
Tercio@11
|
193 return _rawset (self, "myvalue", value)
|
|
Tercio@11
|
194 end
|
|
Tercio@11
|
195
|
|
Tercio@11
|
196 --> setpoint
|
|
Tercio@11
|
197 function DropDownMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
|
Tercio@11
|
198 v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
|
|
Tercio@11
|
199 if (not v1) then
|
|
Tercio@11
|
200 print ("Invalid parameter for SetPoint")
|
|
Tercio@11
|
201 return
|
|
Tercio@11
|
202 end
|
|
Tercio@11
|
203 return self.widget:SetPoint (v1, v2, v3, v4, v5)
|
|
Tercio@11
|
204 end
|
|
Tercio@11
|
205
|
|
Tercio@11
|
206 --> sizes
|
|
Tercio@11
|
207 function DropDownMetaFunctions:SetSize (w, h)
|
|
Tercio@11
|
208 if (w) then
|
|
Tercio@11
|
209 self.dropdown:SetWidth (w)
|
|
Tercio@11
|
210 end
|
|
Tercio@11
|
211 if (h) then
|
|
Tercio@11
|
212 return self.dropdown:SetHeight (h)
|
|
Tercio@11
|
213 end
|
|
Tercio@11
|
214 end
|
|
Tercio@11
|
215
|
|
Tercio@11
|
216 --> tooltip
|
|
Tercio@11
|
217 function DropDownMetaFunctions:SetTooltip (tooltip)
|
|
Tercio@11
|
218 if (tooltip) then
|
|
Tercio@11
|
219 return _rawset (self, "have_tooltip", tooltip)
|
|
Tercio@11
|
220 else
|
|
Tercio@11
|
221 return _rawset (self, "have_tooltip", nil)
|
|
Tercio@11
|
222 end
|
|
Tercio@11
|
223 end
|
|
Tercio@11
|
224 function DropDownMetaFunctions:GetTooltip()
|
|
Tercio@11
|
225 return _rawget (self, "have_tooltip")
|
|
Tercio@11
|
226 end
|
|
Tercio@11
|
227
|
|
Tercio@11
|
228 --> frame levels
|
|
Tercio@11
|
229 function DropDownMetaFunctions:GetFrameLevel()
|
|
Tercio@11
|
230 return self.dropdown:GetFrameLevel()
|
|
Tercio@11
|
231 end
|
|
Tercio@11
|
232 function DropDownMetaFunctions:SetFrameLevel (level, frame)
|
|
Tercio@11
|
233 if (not frame) then
|
|
Tercio@11
|
234 return self.dropdown:SetFrameLevel (level)
|
|
Tercio@11
|
235 else
|
|
Tercio@11
|
236 local framelevel = frame:GetFrameLevel (frame) + level
|
|
Tercio@11
|
237 return self.dropdown:SetFrameLevel (framelevel)
|
|
Tercio@11
|
238 end
|
|
Tercio@11
|
239 end
|
|
Tercio@11
|
240
|
|
Tercio@11
|
241 --> frame stratas
|
|
Tercio@11
|
242 function DropDownMetaFunctions:GetFrameStrata()
|
|
Tercio@11
|
243 return self.dropdown:GetFrameStrata()
|
|
Tercio@11
|
244 end
|
|
Tercio@11
|
245 function DropDownMetaFunctions:SetFrameStrata (strata)
|
|
Tercio@11
|
246 if (_type (strata) == "table") then
|
|
Tercio@11
|
247 self.dropdown:SetFrameStrata (strata:GetFrameStrata())
|
|
Tercio@11
|
248 else
|
|
Tercio@11
|
249 self.dropdown:SetFrameStrata (strata)
|
|
Tercio@11
|
250 end
|
|
Tercio@11
|
251 end
|
|
Tercio@11
|
252
|
|
Tercio@11
|
253 --> enabled
|
|
Tercio@11
|
254 function DropDownMetaFunctions:IsEnabled()
|
|
Tercio@11
|
255 return self.dropdown:IsEnabled()
|
|
Tercio@11
|
256 end
|
|
Tercio@11
|
257
|
|
Tercio@11
|
258 function DropDownMetaFunctions:Enable()
|
|
Tercio@11
|
259
|
|
Tercio@11
|
260 self:SetAlpha (1)
|
|
Tercio@11
|
261 _rawset (self, "lockdown", false)
|
|
Tercio@11
|
262
|
|
Tercio@11
|
263 if (self.OnEnable) then
|
|
Tercio@11
|
264 self.OnEnable (self)
|
|
Tercio@11
|
265 end
|
|
Tercio@11
|
266 --return self.dropdown:Enable()
|
|
Tercio@11
|
267 end
|
|
Tercio@11
|
268
|
|
Tercio@11
|
269 function DropDownMetaFunctions:Disable()
|
|
Tercio@11
|
270
|
|
Tercio@11
|
271 self:SetAlpha (.4)
|
|
Tercio@11
|
272 _rawset (self, "lockdown", true)
|
|
Tercio@11
|
273
|
|
Tercio@11
|
274 if (self.OnDisable) then
|
|
Tercio@11
|
275 self.OnDisable (self)
|
|
Tercio@11
|
276 end
|
|
Tercio@11
|
277 --return self.dropdown:Disable()
|
|
Tercio@11
|
278 end
|
|
Tercio@11
|
279
|
|
Tercio@11
|
280 --> fixed value
|
|
Tercio@11
|
281 function DropDownMetaFunctions:SetFixedParameter (value)
|
|
Tercio@11
|
282 _rawset (self, "FixedValue", value)
|
|
Tercio@11
|
283 end
|
|
Tercio@11
|
284
|
|
Tercio@11
|
285 --> hooks
|
|
Tercio@11
|
286 function DropDownMetaFunctions:SetHook (hookType, func)
|
|
Tercio@11
|
287 if (func) then
|
|
Tercio@11
|
288 _rawset (self, hookType.."Hook", func)
|
|
Tercio@11
|
289 else
|
|
Tercio@11
|
290 _rawset (self, hookType.."Hook", nil)
|
|
Tercio@11
|
291 end
|
|
Tercio@11
|
292 end
|
|
Tercio@11
|
293
|
|
Tercio@11
|
294 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
295 --> scripts
|
|
Tercio@11
|
296
|
|
Tercio@11
|
297 local last_opened = false
|
|
Tercio@11
|
298
|
|
Tercio@11
|
299 local function isOptionVisible (thisOption)
|
|
Tercio@11
|
300 if (_type (thisOption.shown) == "boolean" or _type (thisOption.shown) == "function") then
|
|
Tercio@11
|
301 if (not thisOption.shown) then
|
|
Tercio@11
|
302 return false
|
|
Tercio@11
|
303 elseif (not thisOption.shown()) then
|
|
Tercio@11
|
304 return false
|
|
Tercio@11
|
305 end
|
|
Tercio@11
|
306 end
|
|
Tercio@11
|
307 return true
|
|
Tercio@11
|
308 end
|
|
Tercio@11
|
309
|
|
Tercio@11
|
310 function DropDownMetaFunctions:Refresh()
|
|
Tercio@11
|
311 local menu = self.func()
|
|
Tercio@11
|
312
|
|
Tercio@11
|
313 if (#menu == 0) then
|
|
Tercio@11
|
314 self:NoOption (true)
|
|
Tercio@11
|
315 self.no_options = true
|
|
Tercio@11
|
316 return false
|
|
Tercio@11
|
317
|
|
Tercio@11
|
318 elseif (self.no_options) then
|
|
Tercio@11
|
319 self.no_options = false
|
|
Tercio@11
|
320 self:NoOption (false)
|
|
Tercio@11
|
321 self:NoOptionSelected()
|
|
Tercio@11
|
322 return true
|
|
Tercio@11
|
323 end
|
|
Tercio@11
|
324
|
|
Tercio@11
|
325 return true
|
|
Tercio@11
|
326 end
|
|
Tercio@11
|
327
|
|
Tercio@11
|
328 function DropDownMetaFunctions:NoOptionSelected()
|
|
Tercio@11
|
329 self.label:SetText (self.empty_text or "no option selected")
|
|
Tercio@11
|
330 self.label:SetTextColor (1, 1, 1, 0.4)
|
|
Tercio@11
|
331 if (self.empty_icon) then
|
|
Tercio@11
|
332 self.icon:SetTexture (self.empty_icon)
|
|
Tercio@11
|
333 else
|
|
Tercio@11
|
334 self.icon:SetTexture ([[Interface\COMMON\UI-ModelControlPanel]])
|
|
Tercio@11
|
335 self.icon:SetTexCoord (0.625, 0.78125, 0.328125, 0.390625)
|
|
Tercio@11
|
336 end
|
|
Tercio@11
|
337 self.icon:SetVertexColor (1, 1, 1, 0.4)
|
|
Tercio@11
|
338
|
|
Tercio@11
|
339 self.last_select = nil
|
|
Tercio@11
|
340 end
|
|
Tercio@11
|
341
|
|
Tercio@11
|
342 function DropDownMetaFunctions:NoOption (state)
|
|
Tercio@11
|
343 if (state) then
|
|
Tercio@11
|
344 self:Disable()
|
|
Tercio@11
|
345 self:SetAlpha (0.5)
|
|
Tercio@11
|
346 self.no_options = true
|
|
Tercio@11
|
347 self.label:SetText ("no options")
|
|
Tercio@11
|
348 self.label:SetTextColor (1, 1, 1, 0.4)
|
|
Tercio@11
|
349 self.icon:SetTexture ([[Interface\CHARACTERFRAME\UI-Player-PlayTimeUnhealthy]])
|
|
Tercio@11
|
350 self.icon:SetTexCoord (0, 1, 0, 1)
|
|
Tercio@11
|
351 self.icon:SetVertexColor (1, 1, 1, 0.4)
|
|
Tercio@11
|
352 else
|
|
Tercio@11
|
353 self.no_options = false
|
|
Tercio@11
|
354 self:Enable()
|
|
Tercio@11
|
355 self:SetAlpha (1)
|
|
Tercio@11
|
356 end
|
|
Tercio@11
|
357 end
|
|
Tercio@11
|
358
|
|
Tercio@11
|
359 function DropDownMetaFunctions:Select (optionName, byOptionNumber)
|
|
Tercio@11
|
360
|
|
Tercio@11
|
361 if (type (optionName) == "boolean" and not optionName) then
|
|
Tercio@11
|
362 self:NoOptionSelected()
|
|
Tercio@11
|
363 return false
|
|
Tercio@11
|
364 end
|
|
Tercio@11
|
365
|
|
Tercio@11
|
366 local menu = self.func()
|
|
Tercio@11
|
367
|
|
Tercio@11
|
368 if (#menu == 0) then
|
|
Tercio@11
|
369 self:NoOption (true)
|
|
Tercio@11
|
370 return true
|
|
Tercio@11
|
371 else
|
|
Tercio@11
|
372 self:NoOption (false)
|
|
Tercio@11
|
373 end
|
|
Tercio@11
|
374
|
|
Tercio@11
|
375 if (byOptionNumber and type (optionName) == "number") then
|
|
Tercio@11
|
376 if (not menu [optionName]) then --> invalid index
|
|
Tercio@11
|
377 self:NoOptionSelected()
|
|
Tercio@11
|
378 return false
|
|
Tercio@11
|
379 end
|
|
Tercio@11
|
380 self:Selected (menu [optionName])
|
|
Tercio@11
|
381 return true
|
|
Tercio@11
|
382 end
|
|
Tercio@11
|
383
|
|
Tercio@11
|
384 for _, thisMenu in ipairs (menu) do
|
|
Tercio@11
|
385 if ( ( thisMenu.label == optionName or thisMenu.value == optionName ) and isOptionVisible (thisMenu)) then
|
|
Tercio@11
|
386 self:Selected (thisMenu)
|
|
Tercio@11
|
387 return true
|
|
Tercio@11
|
388 end
|
|
Tercio@11
|
389 end
|
|
Tercio@11
|
390
|
|
Tercio@11
|
391 return false
|
|
Tercio@11
|
392 end
|
|
Tercio@11
|
393
|
|
Tercio@11
|
394 function DropDownMetaFunctions:SetEmptyTextAndIcon (text, icon)
|
|
Tercio@11
|
395 if (text) then
|
|
Tercio@11
|
396 self.empty_text = text
|
|
Tercio@11
|
397 end
|
|
Tercio@11
|
398 if (icon) then
|
|
Tercio@11
|
399 self.empty_icon = icon
|
|
Tercio@11
|
400 end
|
|
Tercio@11
|
401
|
|
Tercio@11
|
402 self:Selected (self.last_select)
|
|
Tercio@11
|
403 end
|
|
Tercio@11
|
404
|
|
Tercio@11
|
405 function DropDownMetaFunctions:Selected (_table)
|
|
Tercio@11
|
406
|
|
Tercio@11
|
407 if (not _table) then
|
|
Tercio@11
|
408
|
|
Tercio@11
|
409 --> there is any options?
|
|
Tercio@11
|
410 if (not self:Refresh()) then
|
|
Tercio@11
|
411 self.last_select = nil
|
|
Tercio@11
|
412 return
|
|
Tercio@11
|
413 end
|
|
Tercio@11
|
414
|
|
Tercio@11
|
415 --> exists options but none selected
|
|
Tercio@11
|
416 self:NoOptionSelected()
|
|
Tercio@11
|
417 return
|
|
Tercio@11
|
418 end
|
|
Tercio@11
|
419
|
|
Tercio@11
|
420 self.last_select = _table
|
|
Tercio@11
|
421 self:NoOption (false)
|
|
Tercio@11
|
422
|
|
Tercio@11
|
423 self.label:SetText (_table.label)
|
|
Tercio@11
|
424 self.icon:SetTexture (_table.icon)
|
|
Tercio@11
|
425
|
|
Tercio@11
|
426 if (_table.icon) then
|
|
Tercio@11
|
427 self.label:SetPoint ("left", self.icon, "right", 2, 0)
|
|
Tercio@11
|
428 if (_table.texcoord) then
|
|
Tercio@11
|
429 self.icon:SetTexCoord (unpack (_table.texcoord))
|
|
Tercio@11
|
430 else
|
|
Tercio@11
|
431 self.icon:SetTexCoord (0, 1, 0, 1)
|
|
Tercio@11
|
432 end
|
|
Tercio@11
|
433
|
|
Tercio@11
|
434 if (_table.iconcolor) then
|
|
Tercio@11
|
435 if (type (_table.iconcolor) == "string") then
|
|
Tercio@11
|
436 self.icon:SetVertexColor (DF:ParseColors (_table.iconcolor))
|
|
Tercio@11
|
437 else
|
|
Tercio@11
|
438 self.icon:SetVertexColor (unpack (_table.iconcolor))
|
|
Tercio@11
|
439 end
|
|
Tercio@11
|
440 else
|
|
Tercio@11
|
441 self.icon:SetVertexColor (1, 1, 1, 1)
|
|
Tercio@11
|
442 end
|
|
Tercio@11
|
443
|
|
Tercio@11
|
444 else
|
|
Tercio@11
|
445 self.label:SetPoint ("left", self.label:GetParent(), "left", 4, 0)
|
|
Tercio@11
|
446 end
|
|
Tercio@11
|
447
|
|
Tercio@11
|
448 self.statusbar:SetTexture (_table.statusbar)
|
|
Tercio@11
|
449
|
|
Tercio@11
|
450 if (_table.color) then
|
|
Tercio@11
|
451 local _value1, _value2, _value3, _value4 = DF:ParseColors (_table.color)
|
|
Tercio@11
|
452 self.label:SetTextColor (_value1, _value2, _value3, _value4)
|
|
Tercio@11
|
453 else
|
|
Tercio@11
|
454 self.label:SetTextColor (1, 1, 1, 1)
|
|
Tercio@11
|
455 end
|
|
Tercio@11
|
456
|
|
Tercio@11
|
457 if (_table.font) then
|
|
Tercio@11
|
458 self.label:SetFont (_table.font, 10)
|
|
Tercio@11
|
459 else
|
|
Tercio@11
|
460 self.label:SetFont ("GameFontHighlightSmall", 10)
|
|
Tercio@11
|
461 end
|
|
Tercio@11
|
462
|
|
Tercio@11
|
463 self:SetValue (_table.value)
|
|
Tercio@11
|
464
|
|
Tercio@11
|
465 end
|
|
Tercio@11
|
466
|
|
Tercio@11
|
467 function DetailsFrameworkDropDownOptionClick (button)
|
|
Tercio@11
|
468
|
|
Tercio@11
|
469 --> update name and icon on main frame
|
|
Tercio@11
|
470 button.object:Selected (button.table)
|
|
Tercio@11
|
471
|
|
Tercio@11
|
472 --> close menu frame
|
|
Tercio@11
|
473 button.object:Close()
|
|
Tercio@11
|
474
|
|
Tercio@11
|
475 --> exec function if any
|
|
Tercio@11
|
476 if (button.table.onclick) then
|
|
Tercio@11
|
477 button.table.onclick (button:GetParent():GetParent():GetParent().MyObject, button.object.FixedValue, button.table.value)
|
|
Tercio@11
|
478 end
|
|
Tercio@11
|
479
|
|
Tercio@11
|
480 --> set the value of selected option in main object
|
|
Tercio@11
|
481 button.object.myvalue = button.table.value
|
|
Tercio@11
|
482 end
|
|
Tercio@11
|
483
|
|
Tercio@11
|
484 function DropDownMetaFunctions:Open()
|
|
Tercio@11
|
485 self.dropdown.dropdownframe:Show()
|
|
Tercio@11
|
486 self.dropdown.dropdownborder:Show()
|
|
Tercio@11
|
487 self.dropdown.arrowTexture:SetTexture ("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Down")
|
|
Tercio@11
|
488 self.opened = true
|
|
Tercio@11
|
489 if (last_opened) then
|
|
Tercio@11
|
490 last_opened:Close()
|
|
Tercio@11
|
491 end
|
|
Tercio@11
|
492 last_opened = self
|
|
Tercio@11
|
493 end
|
|
Tercio@11
|
494
|
|
Tercio@11
|
495 function DropDownMetaFunctions:Close()
|
|
Tercio@11
|
496 --> when menu is being close, just hide the border and the script will call back this again
|
|
Tercio@11
|
497 if (self.dropdown.dropdownborder:IsShown()) then
|
|
Tercio@11
|
498 self.dropdown.dropdownborder:Hide()
|
|
Tercio@11
|
499 return
|
|
Tercio@11
|
500 end
|
|
Tercio@11
|
501 self.dropdown.dropdownframe:Hide()
|
|
Tercio@11
|
502 self.dropdown.arrowTexture:SetTexture ("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Up")
|
|
Tercio@11
|
503
|
|
Tercio@11
|
504 local selectedTexture = _G [self:GetName() .. "_ScrollFrame_ScrollChild_SelectedTexture"]
|
|
Tercio@11
|
505 selectedTexture:Hide()
|
|
Tercio@11
|
506
|
|
Tercio@11
|
507 self.opened = false
|
|
Tercio@11
|
508 last_opened = false
|
|
Tercio@11
|
509 end
|
|
Tercio@11
|
510
|
|
Tercio@11
|
511 --> close by escape key
|
|
Tercio@11
|
512 function DetailsFrameworkDropDownOptionsFrameOnHide (frame)
|
|
Tercio@11
|
513 frame:GetParent().MyObject:Close()
|
|
Tercio@11
|
514 end
|
|
Tercio@11
|
515
|
|
Tercio@11
|
516 function DetailsFrameworkDropDownOptionOnEnter (frame)
|
|
Tercio@11
|
517 if (frame.table.desc) then
|
|
Tercio@17
|
518 GameCooltip2:Preset (2)
|
|
Tercio@11
|
519 GameCooltip2:AddLine (frame.table.desc)
|
|
Tercio@11
|
520 if (frame.table.descfont) then
|
|
Tercio@11
|
521 GameCooltip2:SetOption ("TextFont", frame.table.descfont)
|
|
Tercio@11
|
522 end
|
|
Tercio@11
|
523
|
|
Tercio@11
|
524 GameCooltip2:SetHost (frame, "topleft", "topright", 10, 0)
|
|
Tercio@11
|
525
|
|
Tercio@11
|
526 GameCooltip2:ShowCooltip (nil, "tooltip")
|
|
Tercio@11
|
527 frame.tooltip = true
|
|
Tercio@11
|
528 end
|
|
Tercio@11
|
529 frame:GetParent().mouseover:SetPoint ("left", frame)
|
|
Tercio@11
|
530 frame:GetParent().mouseover:Show()
|
|
Tercio@11
|
531 end
|
|
Tercio@11
|
532
|
|
Tercio@11
|
533 function DetailsFrameworkDropDownOptionOnLeave (frame)
|
|
Tercio@11
|
534 if (frame.table.desc) then
|
|
Tercio@11
|
535 GameCooltip2:ShowMe (false)
|
|
Tercio@11
|
536 end
|
|
Tercio@11
|
537 frame:GetParent().mouseover:Hide()
|
|
Tercio@11
|
538 end
|
|
Tercio@11
|
539
|
|
Tercio@11
|
540 function DetailsFrameworkDropDownOnMouseDown (button)
|
|
Tercio@11
|
541
|
|
Tercio@11
|
542 local object = button.MyObject
|
|
Tercio@11
|
543
|
|
Tercio@11
|
544 if (not object.opened and not _rawget (object, "lockdown")) then --> click to open
|
|
Tercio@11
|
545
|
|
Tercio@11
|
546 local menu = object:func()
|
|
Tercio@11
|
547 object.builtMenu = menu
|
|
Tercio@11
|
548
|
|
Tercio@11
|
549 local frame_witdh = object.realsizeW
|
|
Tercio@11
|
550
|
|
Tercio@11
|
551 if (menu [1]) then
|
|
Tercio@11
|
552 --> build menu
|
|
Tercio@11
|
553
|
|
Tercio@11
|
554 local scrollFrame = _G [button:GetName() .. "_ScrollFrame"]
|
|
Tercio@11
|
555 local scrollChild = _G [button:GetName() .. "_ScrollFrame_ScrollChild"]
|
|
Tercio@11
|
556 local scrollBorder = _G [button:GetName() .. "_Border"]
|
|
Tercio@11
|
557 local selectedTexture = _G [button:GetName() .. "_ScrollFrame_ScrollChild_SelectedTexture"]
|
|
Tercio@11
|
558 local mouseOverTexture = _G [button:GetName() .. "_ScrollFrame_ScrollChild_MouseOverTexture"]
|
|
Tercio@11
|
559
|
|
Tercio@11
|
560 local i = 1
|
|
Tercio@11
|
561 local showing = 0
|
|
Tercio@11
|
562 local currentText = button.text:GetText() or ""
|
|
Tercio@11
|
563
|
|
Tercio@11
|
564 if (object.OnMouseDownHook) then
|
|
Tercio@11
|
565 local interrupt = object.OnMouseDownHook (button, buttontype, menu, scrollFrame, scrollChild, selectedTexture)
|
|
Tercio@11
|
566 if (interrupt) then
|
|
Tercio@11
|
567 return
|
|
Tercio@11
|
568 end
|
|
Tercio@11
|
569 end
|
|
Tercio@11
|
570
|
|
Tercio@11
|
571 for _, _table in ipairs (menu) do
|
|
Tercio@11
|
572
|
|
Tercio@11
|
573 local show = isOptionVisible (_table)
|
|
Tercio@11
|
574
|
|
Tercio@11
|
575 if (show) then
|
|
Tercio@11
|
576 local _this_row = object.menus [i]
|
|
Tercio@11
|
577 showing = showing + 1
|
|
Tercio@11
|
578
|
|
Tercio@11
|
579 if (not _this_row) then
|
|
Tercio@11
|
580
|
|
Tercio@11
|
581 local name = button:GetName() .. "Row" .. i
|
|
Tercio@11
|
582 local parent = scrollChild
|
|
Tercio@11
|
583
|
|
Tercio@11
|
584 _this_row = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownOptionTemplate")
|
|
Tercio@11
|
585 local anchor_i = i-1
|
|
Tercio@11
|
586 _this_row:SetPoint ("topleft", parent, "topleft", 5, (-anchor_i*20)-5)
|
|
Tercio@11
|
587 _this_row:SetPoint ("topright", parent, "topright", -5, (-anchor_i*20)-5)
|
|
Tercio@11
|
588 _this_row.object = object
|
|
Tercio@11
|
589 object.menus [i] = _this_row
|
|
Tercio@11
|
590 end
|
|
Tercio@11
|
591
|
|
Tercio@11
|
592 _this_row.icon:SetTexture (_table.icon)
|
|
Tercio@11
|
593 if (_table.icon) then
|
|
Tercio@11
|
594
|
|
Tercio@11
|
595 _this_row.label:SetPoint ("left", _this_row.icon, "right", 5, 0)
|
|
Tercio@11
|
596
|
|
Tercio@11
|
597 if (_table.texcoord) then
|
|
Tercio@11
|
598 _this_row.icon:SetTexCoord (unpack (_table.texcoord))
|
|
Tercio@11
|
599 else
|
|
Tercio@11
|
600 _this_row.icon:SetTexCoord (0, 1, 0, 1)
|
|
Tercio@11
|
601 end
|
|
Tercio@11
|
602
|
|
Tercio@11
|
603 if (_table.iconcolor) then
|
|
Tercio@11
|
604 if (type (_table.iconcolor) == "string") then
|
|
Tercio@11
|
605 _this_row.icon:SetVertexColor (DF:ParseColors (_table.iconcolor))
|
|
Tercio@11
|
606 else
|
|
Tercio@11
|
607 _this_row.icon:SetVertexColor (unpack (_table.iconcolor))
|
|
Tercio@11
|
608 end
|
|
Tercio@11
|
609 else
|
|
Tercio@11
|
610 _this_row.icon:SetVertexColor (1, 1, 1, 1)
|
|
Tercio@11
|
611 end
|
|
Tercio@11
|
612 else
|
|
Tercio@11
|
613 _this_row.label:SetPoint ("left", _this_row.statusbar, "left", 2, 0)
|
|
Tercio@11
|
614 end
|
|
Tercio@11
|
615
|
|
Tercio@11
|
616 if (_table.iconsize) then
|
|
Tercio@11
|
617 _this_row.icon:SetSize (_table.iconsize[1], _table.iconsize[2])
|
|
Tercio@11
|
618 else
|
|
Tercio@11
|
619 _this_row.icon:SetSize (20, 20)
|
|
Tercio@11
|
620 end
|
|
Tercio@11
|
621
|
|
Tercio@11
|
622 if (_table.font) then
|
|
Tercio@11
|
623 _this_row.label:SetFont (_table.font, 10.5)
|
|
Tercio@11
|
624 else
|
|
Tercio@11
|
625 _this_row.label:SetFont ("GameFontHighlightSmall", 10.5)
|
|
Tercio@11
|
626 end
|
|
Tercio@11
|
627
|
|
Tercio@11
|
628 _this_row.statusbar:SetTexture (_table.statusbar)
|
|
Tercio@11
|
629 _this_row.label:SetText (_table.label)
|
|
Tercio@11
|
630
|
|
Tercio@11
|
631 if (currentText and currentText == _table.label) then
|
|
Tercio@11
|
632 if (_table.icon) then
|
|
Tercio@11
|
633 selectedTexture:SetPoint ("left", _this_row.icon, "left", -3, 0)
|
|
Tercio@11
|
634 else
|
|
Tercio@11
|
635 selectedTexture:SetPoint ("left", _this_row.statusbar, "left", 0, 0)
|
|
Tercio@11
|
636 end
|
|
Tercio@11
|
637
|
|
Tercio@11
|
638 selectedTexture:Show()
|
|
Tercio@11
|
639 selectedTexture:SetVertexColor (1, 1, 1, .3);
|
|
Tercio@11
|
640 currentText = nil
|
|
Tercio@11
|
641 end
|
|
Tercio@11
|
642
|
|
Tercio@11
|
643 if (_table.color) then
|
|
Tercio@11
|
644 local _value1, _value2, _value3, _value4 = DF:ParseColors (_table.color)
|
|
Tercio@11
|
645 _this_row.label:SetTextColor (_value1, _value2, _value3, _value4)
|
|
Tercio@11
|
646 else
|
|
Tercio@11
|
647 _this_row.label:SetTextColor (1, 1, 1, 1)
|
|
Tercio@11
|
648 end
|
|
Tercio@11
|
649
|
|
Tercio@11
|
650 _this_row.table = _table
|
|
Tercio@11
|
651
|
|
Tercio@11
|
652 local labelwitdh = _this_row.label:GetStringWidth()
|
|
Tercio@11
|
653 if (labelwitdh+40 > frame_witdh) then
|
|
Tercio@11
|
654 frame_witdh = labelwitdh+40
|
|
Tercio@11
|
655 end
|
|
Tercio@11
|
656 _this_row:Show()
|
|
Tercio@11
|
657
|
|
Tercio@11
|
658 i = i + 1
|
|
Tercio@11
|
659 end
|
|
Tercio@11
|
660
|
|
Tercio@11
|
661 end
|
|
Tercio@11
|
662
|
|
Tercio@11
|
663 if (currentText) then
|
|
Tercio@11
|
664 selectedTexture:Hide()
|
|
Tercio@11
|
665 else
|
|
Tercio@11
|
666 selectedTexture:SetWidth (frame_witdh-20)
|
|
Tercio@11
|
667 end
|
|
Tercio@11
|
668
|
|
Tercio@11
|
669 for i = showing+1, #object.menus do
|
|
Tercio@11
|
670 object.menus [i]:Hide()
|
|
Tercio@11
|
671 end
|
|
Tercio@11
|
672
|
|
Tercio@11
|
673 local size = object.realsizeH
|
|
Tercio@11
|
674
|
|
Tercio@11
|
675 if (showing*20 > size) then
|
|
Tercio@11
|
676 --show scrollbar and setup scroll
|
|
Tercio@11
|
677 object:ShowScroll()
|
|
Tercio@11
|
678 scrollFrame:EnableMouseWheel (true)
|
|
Tercio@11
|
679 object.scroll:Altura (size-35)
|
|
Tercio@11
|
680 object.scroll:SetMinMaxValues (0, (showing*20) - size + 20)
|
|
Tercio@11
|
681 --width
|
|
Tercio@11
|
682 scrollBorder:SetWidth (frame_witdh+20)
|
|
Tercio@11
|
683 scrollFrame:SetWidth (frame_witdh+20)
|
|
Tercio@11
|
684 scrollChild:SetWidth (frame_witdh+20)
|
|
Tercio@11
|
685 --height
|
|
Tercio@11
|
686 scrollBorder:SetHeight (size+20)
|
|
Tercio@11
|
687 scrollFrame:SetHeight (size)
|
|
Tercio@11
|
688 scrollChild:SetHeight ((showing*20)+20)
|
|
Tercio@11
|
689 --mouse over texture
|
|
Tercio@11
|
690 mouseOverTexture:SetWidth (frame_witdh-7)
|
|
Tercio@11
|
691 --selected
|
|
Tercio@11
|
692 selectedTexture:SetWidth (frame_witdh - 9)
|
|
Tercio@11
|
693
|
|
Tercio@11
|
694 for index, row in ipairs (object.menus) do
|
|
Tercio@11
|
695 row:SetPoint ("topright", scrollChild, "topright", -22, ((-index-1)*20)-5)
|
|
Tercio@11
|
696 end
|
|
Tercio@11
|
697
|
|
Tercio@11
|
698 else
|
|
Tercio@11
|
699 --hide scrollbar and disable wheel
|
|
Tercio@11
|
700 object:HideScroll()
|
|
Tercio@11
|
701 scrollFrame:EnableMouseWheel (false)
|
|
Tercio@11
|
702 --width
|
|
Tercio@11
|
703 scrollBorder:SetWidth (frame_witdh)
|
|
Tercio@11
|
704 scrollFrame:SetWidth (frame_witdh)
|
|
Tercio@11
|
705 scrollChild:SetWidth (frame_witdh)
|
|
Tercio@11
|
706 --height
|
|
Tercio@11
|
707 scrollBorder:SetHeight ((showing*20) + 25)
|
|
Tercio@11
|
708 scrollFrame:SetHeight ((showing*20) + 25)
|
|
Tercio@11
|
709 --mouse over texture
|
|
Tercio@11
|
710 mouseOverTexture:SetWidth (frame_witdh-10)
|
|
Tercio@11
|
711 --selected
|
|
Tercio@11
|
712 selectedTexture:SetWidth (frame_witdh - 9)
|
|
Tercio@11
|
713
|
|
Tercio@11
|
714 for index, row in ipairs (object.menus) do
|
|
Tercio@11
|
715 row:SetPoint ("topright", scrollChild, "topright", -5, ((-index-1)*20)-5)
|
|
Tercio@11
|
716 end
|
|
Tercio@11
|
717 end
|
|
Tercio@11
|
718
|
|
Tercio@11
|
719 object.scroll:SetValue (0)
|
|
Tercio@11
|
720 object:Open()
|
|
Tercio@11
|
721
|
|
Tercio@11
|
722 else
|
|
Tercio@11
|
723 --> clear menu
|
|
Tercio@11
|
724
|
|
Tercio@11
|
725 end
|
|
Tercio@11
|
726
|
|
Tercio@11
|
727 else --> click to close
|
|
Tercio@11
|
728
|
|
Tercio@11
|
729 object:Close()
|
|
Tercio@11
|
730 end
|
|
Tercio@11
|
731
|
|
Tercio@11
|
732 end
|
|
Tercio@11
|
733
|
|
Tercio@11
|
734 function DetailsFrameworkDropDownOnEnter (self)
|
|
Tercio@11
|
735
|
|
Tercio@11
|
736 if (self.MyObject.OnEnterHook) then
|
|
Tercio@11
|
737 local interrupt = self.MyObject.OnEnterHook (self)
|
|
Tercio@11
|
738 if (interrupt) then
|
|
Tercio@11
|
739 return
|
|
Tercio@11
|
740 end
|
|
Tercio@11
|
741 end
|
|
Tercio@11
|
742
|
|
Tercio@11
|
743 if (self.MyObject.onenter_backdrop) then
|
|
Tercio@11
|
744 self:SetBackdropColor (unpack (self.MyObject.onenter_backdrop))
|
|
Tercio@11
|
745 else
|
|
Tercio@11
|
746 self:SetBackdropColor (.2, .2, .2, .2)
|
|
Tercio@11
|
747 end
|
|
Tercio@11
|
748
|
|
Tercio@11
|
749 self.arrowTexture2:Show()
|
|
Tercio@11
|
750
|
|
Tercio@11
|
751 if (self.MyObject.have_tooltip) then
|
|
Tercio@17
|
752 GameCooltip2:Preset (2)
|
|
Tercio@17
|
753
|
|
Tercio@17
|
754 if (type (self.MyObject.have_tooltip) == "function") then
|
|
Tercio@17
|
755 GameCooltip2:AddLine (self.MyObject.have_tooltip() or "")
|
|
Tercio@17
|
756 else
|
|
Tercio@17
|
757 GameCooltip2:AddLine (self.MyObject.have_tooltip)
|
|
Tercio@17
|
758 end
|
|
Tercio@17
|
759
|
|
Tercio@11
|
760 GameCooltip2:SetOwner (self)
|
|
Tercio@11
|
761 GameCooltip2:ShowCooltip()
|
|
Tercio@11
|
762 end
|
|
Tercio@11
|
763
|
|
Tercio@11
|
764 local parent = self:GetParent().MyObject
|
|
Tercio@11
|
765 if (parent and parent.type == "panel") then
|
|
Tercio@11
|
766 if (parent.GradientEnabled) then
|
|
Tercio@11
|
767 parent:RunGradient()
|
|
Tercio@11
|
768 end
|
|
Tercio@11
|
769 end
|
|
Tercio@11
|
770
|
|
Tercio@11
|
771 end
|
|
Tercio@11
|
772
|
|
Tercio@11
|
773 function DetailsFrameworkDropDownOnLeave (self)
|
|
Tercio@11
|
774 if (self.MyObject.OnLeaveHook) then
|
|
Tercio@11
|
775 local interrupt = self.MyObject.OnLeaveHook (self)
|
|
Tercio@11
|
776 if (interrupt) then
|
|
Tercio@11
|
777 return
|
|
Tercio@11
|
778 end
|
|
Tercio@11
|
779 end
|
|
Tercio@11
|
780
|
|
Tercio@11
|
781 if (self.MyObject.onleave_backdrop) then
|
|
Tercio@11
|
782 self:SetBackdropColor (unpack (self.MyObject.onleave_backdrop))
|
|
Tercio@11
|
783 else
|
|
Tercio@11
|
784 self:SetBackdropColor (1, 1, 1, .5)
|
|
Tercio@11
|
785 end
|
|
Tercio@11
|
786
|
|
Tercio@11
|
787 self.arrowTexture2:Hide()
|
|
Tercio@11
|
788
|
|
Tercio@11
|
789 if (self.MyObject.have_tooltip) then
|
|
Tercio@11
|
790 GameCooltip2:ShowMe (false)
|
|
Tercio@11
|
791 end
|
|
Tercio@11
|
792
|
|
Tercio@11
|
793 local parent = self:GetParent().MyObject
|
|
Tercio@11
|
794 if (parent and parent.type == "panel") then
|
|
Tercio@11
|
795 if (parent.GradientEnabled) then
|
|
Tercio@11
|
796 parent:RunGradient (false)
|
|
Tercio@11
|
797 end
|
|
Tercio@11
|
798 end
|
|
Tercio@11
|
799 end
|
|
Tercio@11
|
800
|
|
Tercio@11
|
801 function DetailsFrameworkDropDownOnSizeChanged (self, w, h)
|
|
Tercio@11
|
802 self.MyObject.label:SetSize (self:GetWidth()-40, 10)
|
|
Tercio@11
|
803 end
|
|
Tercio@11
|
804
|
|
Tercio@11
|
805 function DetailsFrameworkDropDownOnShow (self)
|
|
Tercio@11
|
806 if (self.MyObject and self.MyObject.OnShowHook) then
|
|
Tercio@11
|
807 local interrupt = self.MyObject.OnShowHook (self)
|
|
Tercio@11
|
808 if (interrupt) then
|
|
Tercio@11
|
809 return
|
|
Tercio@11
|
810 end
|
|
Tercio@11
|
811 end
|
|
Tercio@11
|
812 end
|
|
Tercio@11
|
813
|
|
Tercio@11
|
814 function DetailsFrameworkDropDownOnHide (self)
|
|
Tercio@11
|
815 if (self.MyObject and self.MyObject.OnHideHook) then
|
|
Tercio@11
|
816 local interrupt = self.MyObject.OnHideHook (self)
|
|
Tercio@11
|
817 if (interrupt) then
|
|
Tercio@11
|
818 return
|
|
Tercio@11
|
819 end
|
|
Tercio@11
|
820 end
|
|
Tercio@11
|
821
|
|
Tercio@11
|
822 self.MyObject:Close()
|
|
Tercio@11
|
823 end
|
|
Tercio@11
|
824
|
|
Tercio@11
|
825
|
|
Tercio@11
|
826
|
|
Tercio@11
|
827 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
828 --> object constructor
|
|
Tercio@11
|
829
|
|
Tercio@11
|
830 function DF:CreateDropDown (parent, func, default, w, h, member, name)
|
|
Tercio@11
|
831 return DF:NewDropDown (parent, parent, name, member, w, h, func, default)
|
|
Tercio@11
|
832 end
|
|
Tercio@11
|
833
|
|
Tercio@11
|
834 function DF:NewDropDown (parent, container, name, member, w, h, func, default)
|
|
Tercio@11
|
835
|
|
Tercio@11
|
836 if (not name) then
|
|
Tercio@11
|
837 name = "DetailsFrameworkDropDownNumber" .. DF.DropDownCounter
|
|
Tercio@11
|
838 DF.DropDownCounter = DF.DropDownCounter + 1
|
|
Tercio@11
|
839
|
|
Tercio@11
|
840 elseif (not parent) then
|
|
Tercio@11
|
841 return nil
|
|
Tercio@11
|
842 end
|
|
Tercio@11
|
843 if (not container) then
|
|
Tercio@11
|
844 container = parent
|
|
Tercio@11
|
845 end
|
|
Tercio@11
|
846
|
|
Tercio@11
|
847 if (name:find ("$parent")) then
|
|
Tercio@11
|
848 name = name:gsub ("$parent", parent:GetName())
|
|
Tercio@11
|
849 end
|
|
Tercio@11
|
850
|
|
Tercio@11
|
851 local DropDownObject = {type = "dropdown", dframework = true}
|
|
Tercio@11
|
852
|
|
Tercio@11
|
853 if (member) then
|
|
Tercio@11
|
854 parent [member] = DropDownObject
|
|
Tercio@11
|
855 end
|
|
Tercio@11
|
856
|
|
Tercio@11
|
857 if (parent.dframework) then
|
|
Tercio@11
|
858 parent = parent.widget
|
|
Tercio@11
|
859 end
|
|
Tercio@11
|
860 if (container.dframework) then
|
|
Tercio@11
|
861 container = container.widget
|
|
Tercio@11
|
862 end
|
|
Tercio@11
|
863
|
|
Tercio@11
|
864 if (default == nil) then
|
|
Tercio@11
|
865 default = 1
|
|
Tercio@11
|
866 end
|
|
Tercio@11
|
867
|
|
Tercio@11
|
868 --> default members:
|
|
Tercio@11
|
869 --> hooks
|
|
Tercio@11
|
870 DropDownObject.OnEnterHook = nil
|
|
Tercio@11
|
871 DropDownObject.OnLeaveHook = nil
|
|
Tercio@11
|
872 DropDownObject.OnHideHook = nil
|
|
Tercio@11
|
873 DropDownObject.OnShowHook = nil
|
|
Tercio@11
|
874 DropDownObject.OnMouseDownHook = nil
|
|
Tercio@11
|
875 --> misc
|
|
Tercio@11
|
876 DropDownObject.container = container
|
|
Tercio@11
|
877 DropDownObject.have_tooltip = nil
|
|
Tercio@11
|
878
|
|
Tercio@11
|
879 DropDownObject.dropdown = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownTemplate")
|
|
Tercio@11
|
880 DropDownObject.widget = DropDownObject.dropdown
|
|
Tercio@11
|
881
|
|
Tercio@11
|
882 DropDownObject.__it = {nil, nil}
|
|
Tercio@11
|
883 --_G [name] = DropDownObject
|
|
Tercio@11
|
884
|
|
Tercio@11
|
885 if (not APIDropDownFunctions) then
|
|
Tercio@11
|
886 APIDropDownFunctions = true
|
|
Tercio@11
|
887 local idx = getmetatable (DropDownObject.dropdown).__index
|
|
Tercio@11
|
888 for funcName, funcAddress in pairs (idx) do
|
|
Tercio@11
|
889 if (not DropDownMetaFunctions [funcName]) then
|
|
Tercio@11
|
890 DropDownMetaFunctions [funcName] = function (object, ...)
|
|
Tercio@11
|
891 local x = loadstring ( "return _G."..object.dropdown:GetName()..":"..funcName.."(...)")
|
|
Tercio@11
|
892 return x (...)
|
|
Tercio@11
|
893 end
|
|
Tercio@11
|
894 end
|
|
Tercio@11
|
895 end
|
|
Tercio@11
|
896 end
|
|
Tercio@11
|
897
|
|
Tercio@11
|
898 DropDownObject.dropdown.MyObject = DropDownObject
|
|
Tercio@11
|
899
|
|
Tercio@11
|
900 DropDownObject.dropdown:SetWidth (w)
|
|
Tercio@11
|
901 DropDownObject.dropdown:SetHeight (h)
|
|
Tercio@11
|
902
|
|
Tercio@11
|
903 DropDownObject.func = func
|
|
Tercio@11
|
904 DropDownObject.realsizeW = 150
|
|
Tercio@11
|
905 DropDownObject.realsizeH = 150
|
|
Tercio@11
|
906 DropDownObject.FixedValue = nil
|
|
Tercio@11
|
907 DropDownObject.opened = false
|
|
Tercio@11
|
908 DropDownObject.menus = {}
|
|
Tercio@11
|
909 DropDownObject.myvalue = nil
|
|
Tercio@11
|
910
|
|
Tercio@11
|
911 DropDownObject.label = _G [name .. "_Text"]
|
|
Tercio@11
|
912
|
|
Tercio@11
|
913 DropDownObject.icon = _G [name .. "_IconTexture"]
|
|
Tercio@11
|
914 DropDownObject.statusbar = _G [name .. "_StatusBarTexture"]
|
|
Tercio@11
|
915 DropDownObject.select = _G [name .. "_SelectedTexture"]
|
|
Tercio@11
|
916
|
|
Tercio@11
|
917 local scroll = _G [DropDownObject.dropdown:GetName() .. "_ScrollFrame"]
|
|
Tercio@11
|
918
|
|
Tercio@11
|
919 DropDownObject.scroll = DF:NewScrollBar (scroll, _G [DropDownObject.dropdown:GetName() .. "_ScrollFrame".."_ScrollChild"], -25, -18)
|
|
Tercio@11
|
920
|
|
Tercio@11
|
921 function DropDownObject:HideScroll()
|
|
Tercio@11
|
922 scroll.baixo:Hide()
|
|
Tercio@11
|
923 scroll.cima:Hide()
|
|
Tercio@11
|
924 scroll.slider:Hide()
|
|
Tercio@11
|
925 end
|
|
Tercio@11
|
926 function DropDownObject:ShowScroll()
|
|
Tercio@11
|
927 scroll.baixo:Show()
|
|
Tercio@11
|
928 scroll.cima:Show()
|
|
Tercio@11
|
929 scroll.slider:Show()
|
|
Tercio@11
|
930 end
|
|
Tercio@11
|
931
|
|
Tercio@11
|
932 --button_down_scripts (DropDownObject, scroll.slider, scroll.baixo)
|
|
Tercio@11
|
933
|
|
Tercio@11
|
934 DropDownObject:HideScroll()
|
|
Tercio@11
|
935 DropDownObject.label:SetSize (DropDownObject.dropdown:GetWidth()-40, 10)
|
|
Tercio@11
|
936
|
|
Tercio@11
|
937 --> setup class
|
|
Tercio@11
|
938 _setmetatable (DropDownObject, DropDownMetaFunctions)
|
|
Tercio@11
|
939
|
|
Tercio@11
|
940 --> initialize first menu selected
|
|
Tercio@11
|
941
|
|
Tercio@11
|
942 if (type (default) == "string") then
|
|
Tercio@11
|
943 DropDownObject:Select (default)
|
|
Tercio@11
|
944
|
|
Tercio@11
|
945 elseif (type (default) == "number") then
|
|
Tercio@11
|
946 if (not DropDownObject:Select (default)) then
|
|
Tercio@11
|
947 DropDownObject:Select (default, true)
|
|
Tercio@11
|
948 end
|
|
Tercio@11
|
949 end
|
|
Tercio@11
|
950
|
|
Tercio@11
|
951 return DropDownObject
|
|
Tercio@11
|
952
|
|
Tercio@11
|
953 end |