replace Ace3v with Ace3 ElvUI-TBC version

or easy tracking of code difference
This commit is contained in:
Pinya
2018-07-21 13:20:39 +03:00
parent bb867629d5
commit 332d53e7f6
59 changed files with 1975 additions and 2496 deletions
@@ -2,92 +2,32 @@
Button Widget (Modified to change text color on SetDisabled method)
Graphical Button.
-------------------------------------------------------------------------------]]
local Type, Version = "Button-ElvUI", 2
local Type, Version = "Button-ElvUI", 23
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs, unpack = pairs, unpack
local pairs = pairs
-- WoW APIs
local _G = _G
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
local IsShiftKeyDown = IsShiftKeyDown
-- GLOBALS: GameTooltip, ElvUI
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local dragdropButton
local function lockTooltip()
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
GameTooltip:SetText(" ")
GameTooltip:Show()
end
local function dragdrop_OnMouseDown(...)
if this.obj.dragOnMouseDown then
dragdropButton.mouseDownFrame = this
dragdropButton:SetText(this.obj.value or "Unknown")
dragdropButton:SetWidth(this:GetWidth())
dragdropButton:SetHeight(this:SetHeight())
this.obj.dragOnMouseDown(this, unpack(arg))
end
end
local function dragdrop_OnMouseUp(...)
if this.obj.dragOnMouseUp then
this:SetAlpha(1)
GameTooltip:Hide()
dragdropButton:Hide()
if dragdropButton.enteredFrame and dragdropButton.enteredFrame ~= this and dragdropButton.enteredFrame:IsMouseOver() then
this.obj.dragOnMouseUp(this, unpack(arg))
this.obj.ActivateMultiControl(this.obj, unpack(arg))
end
dragdropButton.enteredFrame = nil
dragdropButton.mouseDownFrame = nil
end
end
local function dragdrop_OnLeave(...)
if this.obj.dragOnLeave then
if dragdropButton.mouseDownFrame then
lockTooltip()
end
if this == dragdropButton.mouseDownFrame then
this:SetAlpha(0)
dragdropButton:Show()
this.obj.dragOnLeave(this, unpack(arg))
end
end
end
local function dragdrop_OnEnter(...)
if this.obj.dragOnEnter and dragdropButton:IsShown() then
dragdropButton.enteredFrame = this
lockTooltip()
this.obj.dragOnEnter(this, unpack(arg))
end
end
local function dragdrop_OnClick()
local button = arg1
if this.obj.dragOnClick and button == "RightButton" then
this.obj.dragOnClick(this, button)
this.obj.ActivateMultiControl(this.obj, button)
elseif this.obj.stateSwitchOnClick and (button == "LeftButton") and IsShiftKeyDown() then
this.obj.stateSwitchOnClick(this, button)
this.obj.ActivateMultiControl(this.obj, button)
end
end
local function Button_OnClick()
local function Button_OnClick(frame, ...)
AceGUI:ClearFocus()
PlaySound("igMainMenuOption")
this.obj:Fire("OnClick", 2, arg1)
frame.obj:Fire("OnClick", ...)
end
local function Control_OnEnter()
this.obj:Fire("OnEnter")
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
end
local function Control_OnLeave()
this.obj:Fire("OnLeave")
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
end
--[[-----------------------------------------------------------------------------
@@ -136,28 +76,14 @@ Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate2")
frame:Hide()
frame:EnableMouse(true)
frame:SetScript("OnClick", Button_OnClick)
frame:SetScript("OnEnter", Control_OnEnter)
frame:SetScript("OnLeave", Control_OnLeave)
-- dragdrop
if not dragdropButton then
dragdropButton = CreateFrame("Button", "ElvUIAceGUI30DragDropButton", UIParent, "UIPanelButtonTemplate")
dragdropButton:SetFrameStrata("TOOLTIP")
dragdropButton:SetFrameLevel(5)
dragdropButton:SetPoint('BOTTOM', GameTooltip, "BOTTOM", 0, 10)
dragdropButton:Hide()
ElvUI[1]:GetModule('Skins'):HandleButton(dragdropButton)
end
HookScript(frame, "OnClick", dragdrop_OnClick)
HookScript(frame, "OnEnter", dragdrop_OnEnter)
HookScript(frame, "OnLeave", dragdrop_OnLeave)
HookScript(frame, "OnMouseUp", dragdrop_OnMouseUp)
HookScript(frame, "OnMouseDown", dragdrop_OnMouseDown)
local text = frame:GetFontString()
text:ClearAllPoints()
text:SetPoint("TOPLEFT", 15, -1)