annotate Libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua @ 63:3552946c0b9a tip

Added tag v8.2.0.062 for changeset d6704922ef5d
author Tercioo
date Fri, 28 Jun 2019 20:06:18 -0300
parents 52973d00a183
children
rev   line source
Tercio@23 1 --[[-----------------------------------------------------------------------------
Tercio@23 2 BlizOptionsGroup Container
Tercio@23 3 Simple container widget for the integration of AceGUI into the Blizzard Interface Options
Tercio@23 4 -------------------------------------------------------------------------------]]
Tercio@23 5 local Type, Version = "BlizOptionsGroup", 21
Tercio@23 6 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
Tercio@23 7 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
Tercio@23 8
Tercio@23 9 -- Lua APIs
Tercio@23 10 local pairs = pairs
Tercio@23 11
Tercio@23 12 -- WoW APIs
Tercio@23 13 local CreateFrame = CreateFrame
Tercio@23 14
Tercio@23 15 --[[-----------------------------------------------------------------------------
Tercio@23 16 Scripts
Tercio@23 17 -------------------------------------------------------------------------------]]
Tercio@23 18
Tercio@23 19 local function OnShow(frame)
Tercio@23 20 frame.obj:Fire("OnShow")
Tercio@23 21 end
Tercio@23 22
Tercio@23 23 local function OnHide(frame)
Tercio@23 24 frame.obj:Fire("OnHide")
Tercio@23 25 end
Tercio@23 26
Tercio@23 27 --[[-----------------------------------------------------------------------------
Tercio@23 28 Support functions
Tercio@23 29 -------------------------------------------------------------------------------]]
Tercio@23 30
Tercio@23 31 local function okay(frame)
Tercio@23 32 frame.obj:Fire("okay")
Tercio@23 33 end
Tercio@23 34
Tercio@23 35 local function cancel(frame)
Tercio@23 36 frame.obj:Fire("cancel")
Tercio@23 37 end
Tercio@23 38
Tercio@23 39 local function default(frame)
Tercio@23 40 frame.obj:Fire("default")
Tercio@23 41 end
Tercio@23 42
Tercio@23 43 local function refresh(frame)
Tercio@23 44 frame.obj:Fire("refresh")
Tercio@23 45 end
Tercio@23 46
Tercio@23 47 --[[-----------------------------------------------------------------------------
Tercio@23 48 Methods
Tercio@23 49 -------------------------------------------------------------------------------]]
Tercio@23 50
Tercio@23 51 local methods = {
Tercio@23 52 ["OnAcquire"] = function(self)
Tercio@23 53 self:SetName()
Tercio@23 54 self:SetTitle()
Tercio@23 55 end,
Tercio@23 56
Tercio@23 57 -- ["OnRelease"] = nil,
Tercio@23 58
Tercio@23 59 ["OnWidthSet"] = function(self, width)
Tercio@23 60 local content = self.content
Tercio@23 61 local contentwidth = width - 63
Tercio@23 62 if contentwidth < 0 then
Tercio@23 63 contentwidth = 0
Tercio@23 64 end
Tercio@23 65 content:SetWidth(contentwidth)
Tercio@23 66 content.width = contentwidth
Tercio@23 67 end,
Tercio@23 68
Tercio@23 69 ["OnHeightSet"] = function(self, height)
Tercio@23 70 local content = self.content
Tercio@23 71 local contentheight = height - 26
Tercio@23 72 if contentheight < 0 then
Tercio@23 73 contentheight = 0
Tercio@23 74 end
Tercio@23 75 content:SetHeight(contentheight)
Tercio@23 76 content.height = contentheight
Tercio@23 77 end,
Tercio@23 78
Tercio@23 79 ["SetName"] = function(self, name, parent)
Tercio@23 80 self.frame.name = name
Tercio@23 81 self.frame.parent = parent
Tercio@23 82 end,
Tercio@23 83
Tercio@23 84 ["SetTitle"] = function(self, title)
Tercio@23 85 local content = self.content
Tercio@23 86 content:ClearAllPoints()
Tercio@23 87 if not title or title == "" then
Tercio@23 88 content:SetPoint("TOPLEFT", 10, -10)
Tercio@23 89 self.label:SetText("")
Tercio@23 90 else
Tercio@23 91 content:SetPoint("TOPLEFT", 10, -40)
Tercio@23 92 self.label:SetText(title)
Tercio@23 93 end
Tercio@23 94 content:SetPoint("BOTTOMRIGHT", -10, 10)
Tercio@23 95 end
Tercio@23 96 }
Tercio@23 97
Tercio@23 98 --[[-----------------------------------------------------------------------------
Tercio@23 99 Constructor
Tercio@23 100 -------------------------------------------------------------------------------]]
Tercio@23 101 local function Constructor()
Tercio@23 102 local frame = CreateFrame("Frame")
Tercio@23 103 frame:Hide()
Tercio@23 104
Tercio@23 105 -- support functions for the Blizzard Interface Options
Tercio@23 106 frame.okay = okay
Tercio@23 107 frame.cancel = cancel
Tercio@23 108 frame.default = default
Tercio@23 109 frame.refresh = refresh
Tercio@23 110
Tercio@23 111 frame:SetScript("OnHide", OnHide)
Tercio@23 112 frame:SetScript("OnShow", OnShow)
Tercio@23 113
Tercio@23 114 local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
Tercio@23 115 label:SetPoint("TOPLEFT", 10, -15)
Tercio@23 116 label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
Tercio@23 117 label:SetJustifyH("LEFT")
Tercio@23 118 label:SetJustifyV("TOP")
Tercio@23 119
Tercio@23 120 --Container Support
Tercio@23 121 local content = CreateFrame("Frame", nil, frame)
Tercio@23 122 content:SetPoint("TOPLEFT", 10, -10)
Tercio@23 123 content:SetPoint("BOTTOMRIGHT", -10, 10)
Tercio@23 124
Tercio@23 125 local widget = {
Tercio@23 126 label = label,
Tercio@23 127 frame = frame,
Tercio@23 128 content = content,
Tercio@23 129 type = Type
Tercio@23 130 }
Tercio@23 131 for method, func in pairs(methods) do
Tercio@23 132 widget[method] = func
Tercio@23 133 end
Tercio@23 134
Tercio@23 135 return AceGUI:RegisterAsContainer(widget)
Tercio@23 136 end
Tercio@23 137
Tercio@23 138 AceGUI:RegisterWidgetType(Type, Constructor, Version)