yellowfive@57
|
1 --[[-----------------------------------------------------------------------------
|
yellowfive@57
|
2 Panel Container
|
yellowfive@57
|
3 Simple container widget that is just a panel that can have a background color
|
yellowfive@57
|
4 and contains other widgets.
|
yellowfive@57
|
5 -------------------------------------------------------------------------------]]
|
yellowfive@57
|
6 local Type, Version = "AmrUiPanel", 1
|
yellowfive@57
|
7 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
yellowfive@57
|
8 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
yellowfive@57
|
9
|
yellowfive@57
|
10 local Amr = LibStub("AceAddon-3.0"):GetAddon("AskMrRobot")
|
yellowfive@57
|
11
|
yellowfive@57
|
12 -- Lua APIs
|
yellowfive@57
|
13 local pairs = pairs
|
yellowfive@57
|
14
|
yellowfive@57
|
15 -- WoW APIs
|
yellowfive@57
|
16 local CreateFrame, UIParent = CreateFrame, UIParent
|
yellowfive@57
|
17
|
yellowfive@57
|
18
|
yellowfive@57
|
19 --[[-----------------------------------------------------------------------------
|
yellowfive@57
|
20 Methods
|
yellowfive@57
|
21 -------------------------------------------------------------------------------]]
|
yellowfive@57
|
22 local methods = {
|
yellowfive@57
|
23 ["OnAcquire"] = function(self)
|
yellowfive@57
|
24 self:SetAutoAdjustHeight(false)
|
yellowfive@57
|
25 self:SetWidth(300)
|
yellowfive@57
|
26 self:SetHeight(100)
|
yellowfive@57
|
27 self:SetBackgroundColor(Amr.Colors.Black)
|
yellowfive@57
|
28 self:SetStrata("FULLSCREEN_DIALOG")
|
yellowfive@57
|
29 self:SetLevel(0)
|
yellowfive@57
|
30 self:SetAlpha(1)
|
yellowfive@57
|
31 self:SetVisible(true)
|
yellowfive@57
|
32 self:EnableMouse(false)
|
yellowfive@57
|
33 self.frame:ClearAllPoints()
|
yellowfive@57
|
34 end,
|
yellowfive@57
|
35
|
yellowfive@57
|
36 ["SetBackgroundColor"] = function(self, color, a)
|
yellowfive@57
|
37 self.bg:SetTexture(color.R, color.G, color.B, a or 1)
|
yellowfive@57
|
38 end,
|
yellowfive@57
|
39
|
yellowfive@57
|
40 -- set a transparent bg to make this panel invisible
|
yellowfive@57
|
41 ["SetTransparent"] = function(self)
|
yellowfive@57
|
42 self:SetBackgroundColor(Amr.Colors.Black, 0)
|
yellowfive@57
|
43 end,
|
yellowfive@57
|
44
|
yellowfive@57
|
45 ["SetStrata"] = function(self, strata)
|
yellowfive@57
|
46 self.frame:SetFrameStrata(strata)
|
yellowfive@57
|
47 end,
|
yellowfive@57
|
48
|
yellowfive@57
|
49 ["SetLevel"] = function(self, level)
|
yellowfive@57
|
50 self.frame:SetFrameLevel(level)
|
yellowfive@57
|
51 end,
|
yellowfive@57
|
52
|
yellowfive@57
|
53 ["SetAlpha"] = function(self, a)
|
yellowfive@57
|
54 self.frame:SetAlpha(a)
|
yellowfive@57
|
55 end,
|
yellowfive@57
|
56
|
yellowfive@57
|
57 ["EnableMouse"] = function(self, enable)
|
yellowfive@57
|
58 self.frame:EnableMouse(enable)
|
yellowfive@57
|
59 end,
|
yellowfive@57
|
60
|
yellowfive@57
|
61 ["SetVisible"] = function(self, visible)
|
yellowfive@57
|
62 if visible then
|
yellowfive@57
|
63 self.frame:Show()
|
yellowfive@57
|
64 else
|
yellowfive@57
|
65 self.frame:Hide()
|
yellowfive@57
|
66 end
|
yellowfive@57
|
67 end
|
yellowfive@57
|
68 }
|
yellowfive@57
|
69
|
yellowfive@57
|
70 --[[-----------------------------------------------------------------------------
|
yellowfive@57
|
71 Constructor
|
yellowfive@57
|
72 -------------------------------------------------------------------------------]]
|
yellowfive@57
|
73 local function Constructor()
|
yellowfive@57
|
74 local frame = CreateFrame("Frame", nil, UIParent)
|
yellowfive@57
|
75 frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
yellowfive@57
|
76
|
yellowfive@57
|
77 local bg = frame:CreateTexture(nil, "BACKGROUND")
|
yellowfive@57
|
78 bg:SetAllPoints()
|
yellowfive@57
|
79
|
yellowfive@57
|
80 local widget = {
|
yellowfive@57
|
81 bg = bg,
|
yellowfive@57
|
82 frame = frame,
|
yellowfive@57
|
83 content = frame,
|
yellowfive@57
|
84 type = Type
|
yellowfive@57
|
85 }
|
yellowfive@57
|
86 for method, func in pairs(methods) do
|
yellowfive@57
|
87 widget[method] = func
|
yellowfive@57
|
88 end
|
yellowfive@57
|
89
|
yellowfive@57
|
90 return AceGUI:RegisterAsContainer(widget)
|
yellowfive@57
|
91 end
|
yellowfive@57
|
92
|
yellowfive@57
|
93 AceGUI:RegisterWidgetType(Type, Constructor, Version)
|