Mercurial > wow > icu
comparison Libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua @ 0:98c6f55e6619
First commit
| author | Xiiph |
|---|---|
| date | Sat, 05 Feb 2011 16:45:02 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:98c6f55e6619 |
|---|---|
| 1 --[[----------------------------------------------------------------------------- | |
| 2 InlineGroup Container | |
| 3 Simple container widget that creates a visible "box" with an optional title. | |
| 4 -------------------------------------------------------------------------------]] | |
| 5 local Type, Version = "InlineGroup", 20 | |
| 6 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) | |
| 7 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end | |
| 8 | |
| 9 -- Lua APIs | |
| 10 local pairs = pairs | |
| 11 | |
| 12 -- WoW APIs | |
| 13 local CreateFrame, UIParent = CreateFrame, UIParent | |
| 14 | |
| 15 --[[----------------------------------------------------------------------------- | |
| 16 Methods | |
| 17 -------------------------------------------------------------------------------]] | |
| 18 local methods = { | |
| 19 ["OnAcquire"] = function(self) | |
| 20 self:SetWidth(300) | |
| 21 self:SetHeight(100) | |
| 22 end, | |
| 23 | |
| 24 -- ["OnRelease"] = nil, | |
| 25 | |
| 26 ["SetTitle"] = function(self,title) | |
| 27 self.titletext:SetText(title) | |
| 28 end, | |
| 29 | |
| 30 | |
| 31 ["LayoutFinished"] = function(self, width, height) | |
| 32 if self.noAutoHeight then return end | |
| 33 self:SetHeight((height or 0) + 40) | |
| 34 end, | |
| 35 | |
| 36 ["OnWidthSet"] = function(self, width) | |
| 37 local content = self.content | |
| 38 local contentwidth = width - 20 | |
| 39 if contentwidth < 0 then | |
| 40 contentwidth = 0 | |
| 41 end | |
| 42 content:SetWidth(contentwidth) | |
| 43 content.width = contentwidth | |
| 44 end, | |
| 45 | |
| 46 ["OnHeightSet"] = function(self, height) | |
| 47 local content = self.content | |
| 48 local contentheight = height - 20 | |
| 49 if contentheight < 0 then | |
| 50 contentheight = 0 | |
| 51 end | |
| 52 content:SetHeight(contentheight) | |
| 53 content.height = contentheight | |
| 54 end | |
| 55 } | |
| 56 | |
| 57 --[[----------------------------------------------------------------------------- | |
| 58 Constructor | |
| 59 -------------------------------------------------------------------------------]] | |
| 60 local PaneBackdrop = { | |
| 61 bgFile = "Interface\\ChatFrame\\ChatFrameBackground", | |
| 62 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", | |
| 63 tile = true, tileSize = 16, edgeSize = 16, | |
| 64 insets = { left = 3, right = 3, top = 5, bottom = 3 } | |
| 65 } | |
| 66 | |
| 67 local function Constructor() | |
| 68 local frame = CreateFrame("Frame", nil, UIParent) | |
| 69 frame:SetFrameStrata("FULLSCREEN_DIALOG") | |
| 70 | |
| 71 local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") | |
| 72 titletext:SetPoint("TOPLEFT", 14, 0) | |
| 73 titletext:SetPoint("TOPRIGHT", -14, 0) | |
| 74 titletext:SetJustifyH("LEFT") | |
| 75 titletext:SetHeight(18) | |
| 76 | |
| 77 local border = CreateFrame("Frame", nil, frame) | |
| 78 border:SetPoint("TOPLEFT", 0, -17) | |
| 79 border:SetPoint("BOTTOMRIGHT", -1, 3) | |
| 80 border:SetBackdrop(PaneBackdrop) | |
| 81 border:SetBackdropColor(0.1, 0.1, 0.1, 0.5) | |
| 82 border:SetBackdropBorderColor(0.4, 0.4, 0.4) | |
| 83 | |
| 84 --Container Support | |
| 85 local content = CreateFrame("Frame", nil, border) | |
| 86 content:SetPoint("TOPLEFT", 10, -10) | |
| 87 content:SetPoint("BOTTOMRIGHT", -10, 10) | |
| 88 | |
| 89 local widget = { | |
| 90 frame = frame, | |
| 91 content = content, | |
| 92 titletext = titletext, | |
| 93 type = Type | |
| 94 } | |
| 95 for method, func in pairs(methods) do | |
| 96 widget[method] = func | |
| 97 end | |
| 98 | |
| 99 return AceGUI:RegisterAsContainer(widget) | |
| 100 end | |
| 101 | |
| 102 AceGUI:RegisterWidgetType(Type, Constructor, Version) |
