yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: InteractiveLabel Widget yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@106: local Type, Version = "InteractiveLabel", 21 yellowfive@57: local AceGUI = LibStub and LibStub("AceGUI-3.0", true) yellowfive@57: if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end yellowfive@57: yellowfive@57: -- Lua APIs yellowfive@57: local select, pairs = select, pairs yellowfive@57: yellowfive@57: -- WoW APIs yellowfive@57: local CreateFrame, UIParent = CreateFrame, UIParent yellowfive@57: yellowfive@57: -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded yellowfive@57: -- List them here for Mikk's FindGlobals script yellowfive@57: -- GLOBALS: GameFontHighlightSmall yellowfive@57: yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Scripts yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local function Control_OnEnter(frame) yellowfive@57: frame.obj:Fire("OnEnter") yellowfive@57: end yellowfive@57: yellowfive@57: local function Control_OnLeave(frame) yellowfive@57: frame.obj:Fire("OnLeave") yellowfive@57: end yellowfive@57: yellowfive@57: local function Label_OnClick(frame, button) yellowfive@57: frame.obj:Fire("OnClick", button) yellowfive@57: AceGUI:ClearFocus() yellowfive@57: end yellowfive@57: yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Methods yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local methods = { yellowfive@57: ["OnAcquire"] = function(self) yellowfive@57: self:LabelOnAcquire() yellowfive@57: self:SetHighlight() yellowfive@57: self:SetHighlightTexCoord() yellowfive@57: self:SetDisabled(false) yellowfive@57: end, yellowfive@57: yellowfive@57: -- ["OnRelease"] = nil, yellowfive@57: yellowfive@57: ["SetHighlight"] = function(self, ...) yellowfive@57: self.highlight:SetTexture(...) yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetHighlightTexCoord"] = function(self, ...) yellowfive@57: local c = select("#", ...) yellowfive@57: if c == 4 or c == 8 then yellowfive@57: self.highlight:SetTexCoord(...) yellowfive@57: else yellowfive@57: self.highlight:SetTexCoord(0, 1, 0, 1) yellowfive@57: end yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetDisabled"] = function(self,disabled) yellowfive@57: self.disabled = disabled yellowfive@57: if disabled then yellowfive@57: self.frame:EnableMouse(false) yellowfive@57: self.label:SetTextColor(0.5, 0.5, 0.5) yellowfive@57: else yellowfive@57: self.frame:EnableMouse(true) yellowfive@57: self.label:SetTextColor(1, 1, 1) yellowfive@57: end yellowfive@57: end yellowfive@57: } yellowfive@57: yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Constructor yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local function Constructor() yellowfive@57: -- create a Label type that we will hijack yellowfive@57: local label = AceGUI:Create("Label") yellowfive@57: yellowfive@57: local frame = label.frame yellowfive@57: frame:EnableMouse(true) yellowfive@57: frame:SetScript("OnEnter", Control_OnEnter) yellowfive@57: frame:SetScript("OnLeave", Control_OnLeave) yellowfive@57: frame:SetScript("OnMouseDown", Label_OnClick) yellowfive@57: yellowfive@57: local highlight = frame:CreateTexture(nil, "HIGHLIGHT") yellowfive@57: highlight:SetTexture(nil) yellowfive@57: highlight:SetAllPoints() yellowfive@57: highlight:SetBlendMode("ADD") yellowfive@57: yellowfive@57: label.highlight = highlight yellowfive@57: label.type = Type yellowfive@57: label.LabelOnAcquire = label.OnAcquire yellowfive@57: for method, func in pairs(methods) do yellowfive@57: label[method] = func yellowfive@57: end yellowfive@57: yellowfive@57: return label yellowfive@57: end yellowfive@57: yellowfive@57: AceGUI:RegisterWidgetType(Type, Constructor, Version) yellowfive@57: