comparison ui/AmrUiPanel.lua @ 57:01b63b8ed811 v21

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