annotate Libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua @ 1:6f17035de058

MO will now request a server refresh when mail opening has finished, ignoring the timer. (Collected Module) Fixed the time spent to only be displayed if it is being tracked. The inventory full sound will properly be played again when your bags change.
author Zerotorescue
date Sun, 05 Sep 2010 17:02:19 +0200
parents 823e33465b6e
children
rev   line source
Zerotorescue@0 1 --[[-----------------------------------------------------------------------------
Zerotorescue@0 2 InteractiveLabel Widget
Zerotorescue@0 3 -------------------------------------------------------------------------------]]
Zerotorescue@0 4 local Type, Version = "InteractiveLabel", 20
Zerotorescue@0 5 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
Zerotorescue@0 6 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
Zerotorescue@0 7
Zerotorescue@0 8 -- Lua APIs
Zerotorescue@0 9 local select, pairs = select, pairs
Zerotorescue@0 10
Zerotorescue@0 11 -- WoW APIs
Zerotorescue@0 12 local CreateFrame, UIParent = CreateFrame, UIParent
Zerotorescue@0 13
Zerotorescue@0 14 -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
Zerotorescue@0 15 -- List them here for Mikk's FindGlobals script
Zerotorescue@0 16 -- GLOBALS: GameFontHighlightSmall
Zerotorescue@0 17
Zerotorescue@0 18 --[[-----------------------------------------------------------------------------
Zerotorescue@0 19 Scripts
Zerotorescue@0 20 -------------------------------------------------------------------------------]]
Zerotorescue@0 21 local function Control_OnEnter(frame)
Zerotorescue@0 22 frame.obj:Fire("OnEnter")
Zerotorescue@0 23 end
Zerotorescue@0 24
Zerotorescue@0 25 local function Control_OnLeave(frame)
Zerotorescue@0 26 frame.obj:Fire("OnLeave")
Zerotorescue@0 27 end
Zerotorescue@0 28
Zerotorescue@0 29 local function Label_OnClick(frame, button)
Zerotorescue@0 30 frame.obj:Fire("OnClick", button)
Zerotorescue@0 31 AceGUI:ClearFocus()
Zerotorescue@0 32 end
Zerotorescue@0 33
Zerotorescue@0 34 --[[-----------------------------------------------------------------------------
Zerotorescue@0 35 Methods
Zerotorescue@0 36 -------------------------------------------------------------------------------]]
Zerotorescue@0 37 local methods = {
Zerotorescue@0 38 ["OnAcquire"] = function(self)
Zerotorescue@0 39 self:LabelOnAcquire()
Zerotorescue@0 40 self:SetHighlight()
Zerotorescue@0 41 self:SetHighlightTexCoord()
Zerotorescue@0 42 self:SetDisabled(false)
Zerotorescue@0 43 end,
Zerotorescue@0 44
Zerotorescue@0 45 -- ["OnRelease"] = nil,
Zerotorescue@0 46
Zerotorescue@0 47 ["SetHighlight"] = function(self, ...)
Zerotorescue@0 48 self.highlight:SetTexture(...)
Zerotorescue@0 49 end,
Zerotorescue@0 50
Zerotorescue@0 51 ["SetHighlightTexCoord"] = function(self, ...)
Zerotorescue@0 52 local c = select("#", ...)
Zerotorescue@0 53 if c == 4 or c == 8 then
Zerotorescue@0 54 self.highlight:SetTexCoord(...)
Zerotorescue@0 55 else
Zerotorescue@0 56 self.highlight:SetTexCoord(0, 1, 0, 1)
Zerotorescue@0 57 end
Zerotorescue@0 58 end,
Zerotorescue@0 59
Zerotorescue@0 60 ["SetDisabled"] = function(self,disabled)
Zerotorescue@0 61 self.disabled = disabled
Zerotorescue@0 62 if disabled then
Zerotorescue@0 63 self.frame:EnableMouse(false)
Zerotorescue@0 64 self.label:SetTextColor(0.5, 0.5, 0.5)
Zerotorescue@0 65 else
Zerotorescue@0 66 self.frame:EnableMouse(true)
Zerotorescue@0 67 self.label:SetTextColor(1, 1, 1)
Zerotorescue@0 68 end
Zerotorescue@0 69 end
Zerotorescue@0 70 }
Zerotorescue@0 71
Zerotorescue@0 72 --[[-----------------------------------------------------------------------------
Zerotorescue@0 73 Constructor
Zerotorescue@0 74 -------------------------------------------------------------------------------]]
Zerotorescue@0 75 local function Constructor()
Zerotorescue@0 76 -- create a Label type that we will hijack
Zerotorescue@0 77 local label = AceGUI:Create("Label")
Zerotorescue@0 78
Zerotorescue@0 79 local frame = label.frame
Zerotorescue@0 80 frame:EnableMouse(true)
Zerotorescue@0 81 frame:SetScript("OnEnter", Control_OnEnter)
Zerotorescue@0 82 frame:SetScript("OnLeave", Control_OnLeave)
Zerotorescue@0 83 frame:SetScript("OnMouseDown", Label_OnClick)
Zerotorescue@0 84
Zerotorescue@0 85 local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
Zerotorescue@0 86 highlight:SetTexture(nil)
Zerotorescue@0 87 highlight:SetAllPoints()
Zerotorescue@0 88 highlight:SetBlendMode("ADD")
Zerotorescue@0 89
Zerotorescue@0 90 label.highlight = highlight
Zerotorescue@0 91 label.type = Type
Zerotorescue@0 92 label.LabelOnAcquire = label.OnAcquire
Zerotorescue@0 93 for method, func in pairs(methods) do
Zerotorescue@0 94 label[method] = func
Zerotorescue@0 95 end
Zerotorescue@0 96
Zerotorescue@0 97 return label
Zerotorescue@0 98 end
Zerotorescue@0 99
Zerotorescue@0 100 AceGUI:RegisterWidgetType(Type, Constructor, Version)
Zerotorescue@0 101