Mercurial > wow > askmrrobot
comparison Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua @ 57:01b63b8ed811 v21
total rewrite to version 21
author | yellowfive |
---|---|
date | Fri, 05 Jun 2015 11:05:15 -0700 |
parents | |
children | e31b02b24488 |
comparison
equal
deleted
inserted
replaced
56:75431c084aa0 | 57:01b63b8ed811 |
---|---|
1 --[[ $Id: AceGUIWidget-DropDown.lua 1116 2014-10-12 08:15:46Z nevcairiel $ ]]-- | |
2 local AceGUI = LibStub("AceGUI-3.0") | |
3 | |
4 -- Lua APIs | |
5 local min, max, floor = math.min, math.max, math.floor | |
6 local select, pairs, ipairs, type = select, pairs, ipairs, type | |
7 local tsort = table.sort | |
8 | |
9 -- WoW APIs | |
10 local PlaySound = PlaySound | |
11 local UIParent, CreateFrame = UIParent, CreateFrame | |
12 local _G = _G | |
13 | |
14 -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded | |
15 -- List them here for Mikk's FindGlobals script | |
16 -- GLOBALS: CLOSE | |
17 | |
18 local function fixlevels(parent,...) | |
19 local i = 1 | |
20 local child = select(i, ...) | |
21 while child do | |
22 child:SetFrameLevel(parent:GetFrameLevel()+1) | |
23 fixlevels(child, child:GetChildren()) | |
24 i = i + 1 | |
25 child = select(i, ...) | |
26 end | |
27 end | |
28 | |
29 local function fixstrata(strata, parent, ...) | |
30 local i = 1 | |
31 local child = select(i, ...) | |
32 parent:SetFrameStrata(strata) | |
33 while child do | |
34 fixstrata(strata, child, child:GetChildren()) | |
35 i = i + 1 | |
36 child = select(i, ...) | |
37 end | |
38 end | |
39 | |
40 do | |
41 local widgetType = "Dropdown-Pullout" | |
42 local widgetVersion = 3 | |
43 | |
44 --[[ Static data ]]-- | |
45 | |
46 local backdrop = { | |
47 bgFile = "Interface\\ChatFrame\\ChatFrameBackground", | |
48 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", | |
49 edgeSize = 32, | |
50 tileSize = 32, | |
51 tile = true, | |
52 insets = { left = 11, right = 12, top = 12, bottom = 11 }, | |
53 } | |
54 local sliderBackdrop = { | |
55 bgFile = "Interface\\Buttons\\UI-SliderBar-Background", | |
56 edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", | |
57 tile = true, tileSize = 8, edgeSize = 8, | |
58 insets = { left = 3, right = 3, top = 3, bottom = 3 } | |
59 } | |
60 | |
61 local defaultWidth = 200 | |
62 local defaultMaxHeight = 600 | |
63 | |
64 --[[ UI Event Handlers ]]-- | |
65 | |
66 -- HACK: This should be no part of the pullout, but there | |
67 -- is no other 'clean' way to response to any item-OnEnter | |
68 -- Used to close Submenus when an other item is entered | |
69 local function OnEnter(item) | |
70 local self = item.pullout | |
71 for k, v in ipairs(self.items) do | |
72 if v.CloseMenu and v ~= item then | |
73 v:CloseMenu() | |
74 end | |
75 end | |
76 end | |
77 | |
78 -- See the note in Constructor() for each scroll related function | |
79 local function OnMouseWheel(this, value) | |
80 this.obj:MoveScroll(value) | |
81 end | |
82 | |
83 local function OnScrollValueChanged(this, value) | |
84 this.obj:SetScroll(value) | |
85 end | |
86 | |
87 local function OnSizeChanged(this) | |
88 this.obj:FixScroll() | |
89 end | |
90 | |
91 --[[ Exported methods ]]-- | |
92 | |
93 -- exported | |
94 local function SetScroll(self, value) | |
95 local status = self.scrollStatus | |
96 local frame, child = self.scrollFrame, self.itemFrame | |
97 local height, viewheight = frame:GetHeight(), child:GetHeight() | |
98 | |
99 local offset | |
100 if height > viewheight then | |
101 offset = 0 | |
102 else | |
103 offset = floor((viewheight - height) / 1000 * value) | |
104 end | |
105 child:ClearAllPoints() | |
106 child:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, offset) | |
107 child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", self.slider:IsShown() and -12 or 0, offset) | |
108 status.offset = offset | |
109 status.scrollvalue = value | |
110 end | |
111 | |
112 -- exported | |
113 local function MoveScroll(self, value) | |
114 local status = self.scrollStatus | |
115 local frame, child = self.scrollFrame, self.itemFrame | |
116 local height, viewheight = frame:GetHeight(), child:GetHeight() | |
117 | |
118 if height > viewheight then | |
119 self.slider:Hide() | |
120 else | |
121 self.slider:Show() | |
122 local diff = height - viewheight | |
123 local delta = 1 | |
124 if value < 0 then | |
125 delta = -1 | |
126 end | |
127 self.slider:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000)) | |
128 end | |
129 end | |
130 | |
131 -- exported | |
132 local function FixScroll(self) | |
133 local status = self.scrollStatus | |
134 local frame, child = self.scrollFrame, self.itemFrame | |
135 local height, viewheight = frame:GetHeight(), child:GetHeight() | |
136 local offset = status.offset or 0 | |
137 | |
138 if viewheight < height then | |
139 self.slider:Hide() | |
140 child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, offset) | |
141 self.slider:SetValue(0) | |
142 else | |
143 self.slider:Show() | |
144 local value = (offset / (viewheight - height) * 1000) | |
145 if value > 1000 then value = 1000 end | |
146 self.slider:SetValue(value) | |
147 self:SetScroll(value) | |
148 if value < 1000 then | |
149 child:ClearAllPoints() | |
150 child:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, offset) | |
151 child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -12, offset) | |
152 status.offset = offset | |
153 end | |
154 end | |
155 end | |
156 | |
157 -- exported, AceGUI callback | |
158 local function OnAcquire(self) | |
159 self.frame:SetParent(UIParent) | |
160 --self.itemFrame:SetToplevel(true) | |
161 end | |
162 | |
163 -- exported, AceGUI callback | |
164 local function OnRelease(self) | |
165 self:Clear() | |
166 self.frame:ClearAllPoints() | |
167 self.frame:Hide() | |
168 end | |
169 | |
170 -- exported | |
171 local function AddItem(self, item) | |
172 self.items[#self.items + 1] = item | |
173 | |
174 local h = #self.items * 16 | |
175 self.itemFrame:SetHeight(h) | |
176 self.frame:SetHeight(min(h + 34, self.maxHeight)) -- +34: 20 for scrollFrame placement (10 offset) and +14 for item placement | |
177 | |
178 item.frame:SetPoint("LEFT", self.itemFrame, "LEFT") | |
179 item.frame:SetPoint("RIGHT", self.itemFrame, "RIGHT") | |
180 | |
181 item:SetPullout(self) | |
182 item:SetOnEnter(OnEnter) | |
183 end | |
184 | |
185 -- exported | |
186 local function Open(self, point, relFrame, relPoint, x, y) | |
187 local items = self.items | |
188 local frame = self.frame | |
189 local itemFrame = self.itemFrame | |
190 | |
191 frame:SetPoint(point, relFrame, relPoint, x, y) | |
192 | |
193 | |
194 local height = 8 | |
195 for i, item in pairs(items) do | |
196 if i == 1 then | |
197 item:SetPoint("TOP", itemFrame, "TOP", 0, -2) | |
198 else | |
199 item:SetPoint("TOP", items[i-1].frame, "BOTTOM", 0, 1) | |
200 end | |
201 | |
202 item:Show() | |
203 | |
204 height = height + 16 | |
205 end | |
206 itemFrame:SetHeight(height) | |
207 fixstrata("TOOLTIP", frame, frame:GetChildren()) | |
208 frame:Show() | |
209 self:Fire("OnOpen") | |
210 end | |
211 | |
212 -- exported | |
213 local function Close(self) | |
214 self.frame:Hide() | |
215 self:Fire("OnClose") | |
216 end | |
217 | |
218 -- exported | |
219 local function Clear(self) | |
220 local items = self.items | |
221 for i, item in pairs(items) do | |
222 AceGUI:Release(item) | |
223 items[i] = nil | |
224 end | |
225 end | |
226 | |
227 -- exported | |
228 local function IterateItems(self) | |
229 return ipairs(self.items) | |
230 end | |
231 | |
232 -- exported | |
233 local function SetHideOnLeave(self, val) | |
234 self.hideOnLeave = val | |
235 end | |
236 | |
237 -- exported | |
238 local function SetMaxHeight(self, height) | |
239 self.maxHeight = height or defaultMaxHeight | |
240 if self.frame:GetHeight() > height then | |
241 self.frame:SetHeight(height) | |
242 elseif (self.itemFrame:GetHeight() + 34) < height then | |
243 self.frame:SetHeight(self.itemFrame:GetHeight() + 34) -- see :AddItem | |
244 end | |
245 end | |
246 | |
247 -- exported | |
248 local function GetRightBorderWidth(self) | |
249 return 6 + (self.slider:IsShown() and 12 or 0) | |
250 end | |
251 | |
252 -- exported | |
253 local function GetLeftBorderWidth(self) | |
254 return 6 | |
255 end | |
256 | |
257 --[[ Constructor ]]-- | |
258 | |
259 local function Constructor() | |
260 local count = AceGUI:GetNextWidgetNum(widgetType) | |
261 local frame = CreateFrame("Frame", "AceGUI30Pullout"..count, UIParent) | |
262 local self = {} | |
263 self.count = count | |
264 self.type = widgetType | |
265 self.frame = frame | |
266 frame.obj = self | |
267 | |
268 self.OnAcquire = OnAcquire | |
269 self.OnRelease = OnRelease | |
270 | |
271 self.AddItem = AddItem | |
272 self.Open = Open | |
273 self.Close = Close | |
274 self.Clear = Clear | |
275 self.IterateItems = IterateItems | |
276 self.SetHideOnLeave = SetHideOnLeave | |
277 | |
278 self.SetScroll = SetScroll | |
279 self.MoveScroll = MoveScroll | |
280 self.FixScroll = FixScroll | |
281 | |
282 self.SetMaxHeight = SetMaxHeight | |
283 self.GetRightBorderWidth = GetRightBorderWidth | |
284 self.GetLeftBorderWidth = GetLeftBorderWidth | |
285 | |
286 self.items = {} | |
287 | |
288 self.scrollStatus = { | |
289 scrollvalue = 0, | |
290 } | |
291 | |
292 self.maxHeight = defaultMaxHeight | |
293 | |
294 frame:SetBackdrop(backdrop) | |
295 frame:SetBackdropColor(0, 0, 0) | |
296 frame:SetFrameStrata("FULLSCREEN_DIALOG") | |
297 frame:SetClampedToScreen(true) | |
298 frame:SetWidth(defaultWidth) | |
299 frame:SetHeight(self.maxHeight) | |
300 --frame:SetToplevel(true) | |
301 | |
302 -- NOTE: The whole scroll frame code is copied from the AceGUI-3.0 widget ScrollFrame | |
303 local scrollFrame = CreateFrame("ScrollFrame", nil, frame) | |
304 local itemFrame = CreateFrame("Frame", nil, scrollFrame) | |
305 | |
306 self.scrollFrame = scrollFrame | |
307 self.itemFrame = itemFrame | |
308 | |
309 scrollFrame.obj = self | |
310 itemFrame.obj = self | |
311 | |
312 local slider = CreateFrame("Slider", "AceGUI30PulloutScrollbar"..count, scrollFrame) | |
313 slider:SetOrientation("VERTICAL") | |
314 slider:SetHitRectInsets(0, 0, -10, 0) | |
315 slider:SetBackdrop(sliderBackdrop) | |
316 slider:SetWidth(8) | |
317 slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical") | |
318 slider:SetFrameStrata("FULLSCREEN_DIALOG") | |
319 self.slider = slider | |
320 slider.obj = self | |
321 | |
322 scrollFrame:SetScrollChild(itemFrame) | |
323 scrollFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", 6, -12) | |
324 scrollFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -6, 12) | |
325 scrollFrame:EnableMouseWheel(true) | |
326 scrollFrame:SetScript("OnMouseWheel", OnMouseWheel) | |
327 scrollFrame:SetScript("OnSizeChanged", OnSizeChanged) | |
328 scrollFrame:SetToplevel(true) | |
329 scrollFrame:SetFrameStrata("FULLSCREEN_DIALOG") | |
330 | |
331 itemFrame:SetPoint("TOPLEFT", scrollFrame, "TOPLEFT", 0, 0) | |
332 itemFrame:SetPoint("TOPRIGHT", scrollFrame, "TOPRIGHT", -12, 0) | |
333 itemFrame:SetHeight(400) | |
334 itemFrame:SetToplevel(true) | |
335 itemFrame:SetFrameStrata("FULLSCREEN_DIALOG") | |
336 | |
337 slider:SetPoint("TOPLEFT", scrollFrame, "TOPRIGHT", -16, 0) | |
338 slider:SetPoint("BOTTOMLEFT", scrollFrame, "BOTTOMRIGHT", -16, 0) | |
339 slider:SetScript("OnValueChanged", OnScrollValueChanged) | |
340 slider:SetMinMaxValues(0, 1000) | |
341 slider:SetValueStep(1) | |
342 slider:SetValue(0) | |
343 | |
344 scrollFrame:Show() | |
345 itemFrame:Show() | |
346 slider:Hide() | |
347 | |
348 self:FixScroll() | |
349 | |
350 AceGUI:RegisterAsWidget(self) | |
351 return self | |
352 end | |
353 | |
354 AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion) | |
355 end | |
356 | |
357 do | |
358 local widgetType = "Dropdown" | |
359 local widgetVersion = 30 | |
360 | |
361 --[[ Static data ]]-- | |
362 | |
363 --[[ UI event handler ]]-- | |
364 | |
365 local function Control_OnEnter(this) | |
366 this.obj.button:LockHighlight() | |
367 this.obj:Fire("OnEnter") | |
368 end | |
369 | |
370 local function Control_OnLeave(this) | |
371 this.obj.button:UnlockHighlight() | |
372 this.obj:Fire("OnLeave") | |
373 end | |
374 | |
375 local function Dropdown_OnHide(this) | |
376 local self = this.obj | |
377 if self.open then | |
378 self.pullout:Close() | |
379 end | |
380 end | |
381 | |
382 local function Dropdown_TogglePullout(this) | |
383 local self = this.obj | |
384 PlaySound("igMainMenuOptionCheckBoxOn") -- missleading name, but the Blizzard code uses this sound | |
385 if self.open then | |
386 self.open = nil | |
387 self.pullout:Close() | |
388 AceGUI:ClearFocus() | |
389 else | |
390 self.open = true | |
391 self.pullout:SetWidth(self.pulloutWidth or self.frame:GetWidth()) | |
392 self.pullout:Open("TOPLEFT", self.frame, "BOTTOMLEFT", 0, self.label:IsShown() and -2 or 0) | |
393 AceGUI:SetFocus(self) | |
394 end | |
395 end | |
396 | |
397 local function OnPulloutOpen(this) | |
398 local self = this.userdata.obj | |
399 local value = self.value | |
400 | |
401 if not self.multiselect then | |
402 for i, item in this:IterateItems() do | |
403 item:SetValue(item.userdata.value == value) | |
404 end | |
405 end | |
406 | |
407 self.open = true | |
408 self:Fire("OnOpened") | |
409 end | |
410 | |
411 local function OnPulloutClose(this) | |
412 local self = this.userdata.obj | |
413 self.open = nil | |
414 self:Fire("OnClosed") | |
415 end | |
416 | |
417 local function ShowMultiText(self) | |
418 local text | |
419 for i, widget in self.pullout:IterateItems() do | |
420 if widget.type == "Dropdown-Item-Toggle" then | |
421 if widget:GetValue() then | |
422 if text then | |
423 text = text..", "..widget:GetText() | |
424 else | |
425 text = widget:GetText() | |
426 end | |
427 end | |
428 end | |
429 end | |
430 self:SetText(text) | |
431 end | |
432 | |
433 local function OnItemValueChanged(this, event, checked) | |
434 local self = this.userdata.obj | |
435 | |
436 if self.multiselect then | |
437 self:Fire("OnValueChanged", this.userdata.value, checked) | |
438 ShowMultiText(self) | |
439 else | |
440 if checked then | |
441 self:SetValue(this.userdata.value) | |
442 self:Fire("OnValueChanged", this.userdata.value) | |
443 else | |
444 this:SetValue(true) | |
445 end | |
446 if self.open then | |
447 self.pullout:Close() | |
448 end | |
449 end | |
450 end | |
451 | |
452 --[[ Exported methods ]]-- | |
453 | |
454 -- exported, AceGUI callback | |
455 local function OnAcquire(self) | |
456 local pullout = AceGUI:Create("Dropdown-Pullout") | |
457 self.pullout = pullout | |
458 pullout.userdata.obj = self | |
459 pullout:SetCallback("OnClose", OnPulloutClose) | |
460 pullout:SetCallback("OnOpen", OnPulloutOpen) | |
461 self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1) | |
462 fixlevels(self.pullout.frame, self.pullout.frame:GetChildren()) | |
463 | |
464 self:SetHeight(44) | |
465 self:SetWidth(200) | |
466 self:SetLabel() | |
467 self:SetPulloutWidth(nil) | |
468 end | |
469 | |
470 -- exported, AceGUI callback | |
471 local function OnRelease(self) | |
472 if self.open then | |
473 self.pullout:Close() | |
474 end | |
475 AceGUI:Release(self.pullout) | |
476 self.pullout = nil | |
477 | |
478 self:SetText("") | |
479 self:SetDisabled(false) | |
480 self:SetMultiselect(false) | |
481 | |
482 self.value = nil | |
483 self.list = nil | |
484 self.open = nil | |
485 self.hasClose = nil | |
486 | |
487 self.frame:ClearAllPoints() | |
488 self.frame:Hide() | |
489 end | |
490 | |
491 -- exported | |
492 local function SetDisabled(self, disabled) | |
493 self.disabled = disabled | |
494 if disabled then | |
495 self.text:SetTextColor(0.5,0.5,0.5) | |
496 self.button:Disable() | |
497 self.button_cover:Disable() | |
498 self.label:SetTextColor(0.5,0.5,0.5) | |
499 else | |
500 self.button:Enable() | |
501 self.button_cover:Enable() | |
502 self.label:SetTextColor(1,.82,0) | |
503 self.text:SetTextColor(1,1,1) | |
504 end | |
505 end | |
506 | |
507 -- exported | |
508 local function ClearFocus(self) | |
509 if self.open then | |
510 self.pullout:Close() | |
511 end | |
512 end | |
513 | |
514 -- exported | |
515 local function SetText(self, text) | |
516 self.text:SetText(text or "") | |
517 end | |
518 | |
519 -- exported | |
520 local function SetLabel(self, text) | |
521 if text and text ~= "" then | |
522 self.label:SetText(text) | |
523 self.label:Show() | |
524 self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,-14) | |
525 self:SetHeight(40) | |
526 self.alignoffset = 26 | |
527 else | |
528 self.label:SetText("") | |
529 self.label:Hide() | |
530 self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,0) | |
531 self:SetHeight(26) | |
532 self.alignoffset = 12 | |
533 end | |
534 end | |
535 | |
536 -- exported | |
537 local function SetValue(self, value) | |
538 if self.list then | |
539 self:SetText(self.list[value] or "") | |
540 end | |
541 self.value = value | |
542 end | |
543 | |
544 -- exported | |
545 local function GetValue(self) | |
546 return self.value | |
547 end | |
548 | |
549 -- exported | |
550 local function SetItemValue(self, item, value) | |
551 if not self.multiselect then return end | |
552 for i, widget in self.pullout:IterateItems() do | |
553 if widget.userdata.value == item then | |
554 if widget.SetValue then | |
555 widget:SetValue(value) | |
556 end | |
557 end | |
558 end | |
559 ShowMultiText(self) | |
560 end | |
561 | |
562 -- exported | |
563 local function SetItemDisabled(self, item, disabled) | |
564 for i, widget in self.pullout:IterateItems() do | |
565 if widget.userdata.value == item then | |
566 widget:SetDisabled(disabled) | |
567 end | |
568 end | |
569 end | |
570 | |
571 local function AddListItem(self, value, text, itemType) | |
572 if not itemType then itemType = "Dropdown-Item-Toggle" end | |
573 local exists = AceGUI:GetWidgetVersion(itemType) | |
574 if not exists then error(("The given item type, %q, does not exist within AceGUI-3.0"):format(tostring(itemType)), 2) end | |
575 | |
576 local item = AceGUI:Create(itemType) | |
577 item:SetText(text) | |
578 item.userdata.obj = self | |
579 item.userdata.value = value | |
580 item:SetCallback("OnValueChanged", OnItemValueChanged) | |
581 self.pullout:AddItem(item) | |
582 end | |
583 | |
584 local function AddCloseButton(self) | |
585 if not self.hasClose then | |
586 local close = AceGUI:Create("Dropdown-Item-Execute") | |
587 close:SetText(CLOSE) | |
588 self.pullout:AddItem(close) | |
589 self.hasClose = true | |
590 end | |
591 end | |
592 | |
593 -- exported | |
594 local sortlist = {} | |
595 local function SetList(self, list, order, itemType) | |
596 self.list = list | |
597 self.pullout:Clear() | |
598 self.hasClose = nil | |
599 if not list then return end | |
600 | |
601 if type(order) ~= "table" then | |
602 for v in pairs(list) do | |
603 sortlist[#sortlist + 1] = v | |
604 end | |
605 tsort(sortlist) | |
606 | |
607 for i, key in ipairs(sortlist) do | |
608 AddListItem(self, key, list[key], itemType) | |
609 sortlist[i] = nil | |
610 end | |
611 else | |
612 for i, key in ipairs(order) do | |
613 AddListItem(self, key, list[key], itemType) | |
614 end | |
615 end | |
616 if self.multiselect then | |
617 ShowMultiText(self) | |
618 AddCloseButton(self) | |
619 end | |
620 end | |
621 | |
622 -- exported | |
623 local function AddItem(self, value, text, itemType) | |
624 if self.list then | |
625 self.list[value] = text | |
626 AddListItem(self, value, text, itemType) | |
627 end | |
628 end | |
629 | |
630 -- exported | |
631 local function SetMultiselect(self, multi) | |
632 self.multiselect = multi | |
633 if multi then | |
634 ShowMultiText(self) | |
635 AddCloseButton(self) | |
636 end | |
637 end | |
638 | |
639 -- exported | |
640 local function GetMultiselect(self) | |
641 return self.multiselect | |
642 end | |
643 | |
644 local function SetPulloutWidth(self, width) | |
645 self.pulloutWidth = width | |
646 end | |
647 | |
648 --[[ Constructor ]]-- | |
649 | |
650 local function Constructor() | |
651 local count = AceGUI:GetNextWidgetNum(widgetType) | |
652 local frame = CreateFrame("Frame", nil, UIParent) | |
653 local dropdown = CreateFrame("Frame", "AceGUI30DropDown"..count, frame, "UIDropDownMenuTemplate") | |
654 | |
655 local self = {} | |
656 self.type = widgetType | |
657 self.frame = frame | |
658 self.dropdown = dropdown | |
659 self.count = count | |
660 frame.obj = self | |
661 dropdown.obj = self | |
662 | |
663 self.OnRelease = OnRelease | |
664 self.OnAcquire = OnAcquire | |
665 | |
666 self.ClearFocus = ClearFocus | |
667 | |
668 self.SetText = SetText | |
669 self.SetValue = SetValue | |
670 self.GetValue = GetValue | |
671 self.SetList = SetList | |
672 self.SetLabel = SetLabel | |
673 self.SetDisabled = SetDisabled | |
674 self.AddItem = AddItem | |
675 self.SetMultiselect = SetMultiselect | |
676 self.GetMultiselect = GetMultiselect | |
677 self.SetItemValue = SetItemValue | |
678 self.SetItemDisabled = SetItemDisabled | |
679 self.SetPulloutWidth = SetPulloutWidth | |
680 | |
681 self.alignoffset = 26 | |
682 | |
683 frame:SetScript("OnHide",Dropdown_OnHide) | |
684 | |
685 dropdown:ClearAllPoints() | |
686 dropdown:SetPoint("TOPLEFT",frame,"TOPLEFT",-15,0) | |
687 dropdown:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",17,0) | |
688 dropdown:SetScript("OnHide", nil) | |
689 | |
690 local left = _G[dropdown:GetName() .. "Left"] | |
691 local middle = _G[dropdown:GetName() .. "Middle"] | |
692 local right = _G[dropdown:GetName() .. "Right"] | |
693 | |
694 middle:ClearAllPoints() | |
695 right:ClearAllPoints() | |
696 | |
697 middle:SetPoint("LEFT", left, "RIGHT", 0, 0) | |
698 middle:SetPoint("RIGHT", right, "LEFT", 0, 0) | |
699 right:SetPoint("TOPRIGHT", dropdown, "TOPRIGHT", 0, 17) | |
700 | |
701 local button = _G[dropdown:GetName() .. "Button"] | |
702 self.button = button | |
703 button.obj = self | |
704 button:SetScript("OnEnter",Control_OnEnter) | |
705 button:SetScript("OnLeave",Control_OnLeave) | |
706 button:SetScript("OnClick",Dropdown_TogglePullout) | |
707 | |
708 local button_cover = CreateFrame("BUTTON",nil,self.frame) | |
709 self.button_cover = button_cover | |
710 button_cover.obj = self | |
711 button_cover:SetPoint("TOPLEFT",self.frame,"BOTTOMLEFT",0,25) | |
712 button_cover:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT") | |
713 button_cover:SetScript("OnEnter",Control_OnEnter) | |
714 button_cover:SetScript("OnLeave",Control_OnLeave) | |
715 button_cover:SetScript("OnClick",Dropdown_TogglePullout) | |
716 | |
717 local text = _G[dropdown:GetName() .. "Text"] | |
718 self.text = text | |
719 text.obj = self | |
720 text:ClearAllPoints() | |
721 text:SetPoint("RIGHT", right, "RIGHT" ,-43, 2) | |
722 text:SetPoint("LEFT", left, "LEFT", 25, 2) | |
723 | |
724 local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall") | |
725 label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) | |
726 label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) | |
727 label:SetJustifyH("LEFT") | |
728 label:SetHeight(18) | |
729 label:Hide() | |
730 self.label = label | |
731 | |
732 AceGUI:RegisterAsWidget(self) | |
733 return self | |
734 end | |
735 | |
736 AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion) | |
737 end |