WoWInterface SVN PhanxConfigWidgets

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk/PhanxConfig-Button
    from Rev 87 to Rev 112
    Reverse comparison

Rev 87 → Rev 112

PhanxConfig-Button.lua
8,7 → 8,7
its internals may change at any time without notice.
----------------------------------------------------------------------]]
 
local MINOR_VERSION = tonumber( string.match( "$Revision: 29 $", "%d+" ) )
local MINOR_VERSION = tonumber( string.match( "$Revision: 30000 $", "%d+" ) )
 
local lib, oldminor = LibStub:NewLibrary( "PhanxConfig-Button", MINOR_VERSION )
if not lib then return end
33,6 → 33,34
end
end
 
local function OnMouseDown( self )
if self:IsEnabled() then
self.Left:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down")
self.Middle:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down")
self.Right:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down")
end
end
 
local function OnMouseUp( self )
if self:IsEnabled() then
self.Left:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up")
self.Middle:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up")
self.Right:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up")
end
end
 
local function OnDisable( self )
self.Left:SetTexture("Interface\\Buttons\\UI-Panel-Button-Disabled")
self.Middle:SetTexture("Interface\\Buttons\\UI-Panel-Button-Disabled")
self.Right:SetTexture("Interface\\Buttons\\UI-Panel-Button-Disabled")
end
 
local function OnEnable( self )
self.Left:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up")
self.Middle:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up")
self.Right:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up")
end
 
function lib.CreateButton( parent, name, desc )
assert( type(parent) == "table" and parent.CreateFontString, "PhanxConfig-Button: Parent is not a valid frame!" )
if type(name) ~= "string" then name = nil end
44,22 → 72,50
button:SetDisabledFontObject( GameFontDisable )
button:SetHighlightFontObject( GameFontHighlightSmall )
 
local left = button:CreateTexture( nil, "BACKGROUND" )
left:SetPoint( "TOPLEFT" )
left:SetPoint( "BOTTOMLEFT" )
left:SetWidth( 12 )
left:SetTexture( [[Interface\Buttons\UI-Panel-Button-Up]] )
left:SetTexCoord( 0, 0.09375, 0, 0.6875 )
button.Left = left
 
local right = button:CreateTexture( nil, "BACKGROUND" )
right:SetPoint( "TOPRIGHT" )
right:SetPoint( "BOTTOMRIGHT" )
right:SetWidth( 12 )
right:SetTexture( [[Interface\Buttons\UI-Panel-Button-Up]] )
right:SetTexCoord( 0.53125, 0.625, 0, 0.6875 )
button.Right = right
 
local mid = button:CreateTexture( nil, "BACKGROUND" )
mid:SetPoint( "BOTTOMLEFT", left, "BOTTOMRIGHT" )
mid:SetPoint( "TOPRIGHT", right, "TOPLEFT" )
mid:SetTexture( [[Interface\Buttons\UI-Panel-Button-Up]] )
mid:SetTexCoord( 0.09375, 0.53125, 0, 0.6875 )
button.Middle = mid
--[=[
button:SetNormalTexture( [[Interface\Buttons\UI-Panel-Button-Up]] )
button:GetNormalTexture():SetTexCoord( 0, 0.625, 0, 0.6875 )
 
button:SetPushedTexture( [[Interface\Buttons\UI-Panel-Button-Down]] )
button:GetPushedTexture():SetTexCoord( 0, 0.625, 0, 0.6875 )
 
button:SetDisabledTexture( [[Interface\Buttons\UI-Panel-Button-Disabled]] )
button:GetDisabledTexture():SetTexCoord( 0, 0.625, 0, 0.6875 )
]=]
button:SetHighlightTexture( [[Interface\Buttons\UI-Panel-Button-Highlight]] )
button:GetHighlightTexture():SetTexCoord( 0, 0.625, 0, 0.6875 )
button:GetHighlightTexture():SetBlendMode( "ADD" )
 
button:SetDisabledTexture( [[Interface\Buttons\UI-Panel-Button-Disabled]] )
button:GetDisabledTexture():SetTexCoord( 0, 0.625, 0, 0.6875 )
 
button:SetScript( "OnEnter", OnEnter )
button:SetScript( "OnLeave", OnLeave )
button:SetScript( "OnClick", OnClick )
button:SetScript( "OnMouseDown", OnMouseDown )
button:SetScript( "OnMouseUp", OnMouseUp )
button:SetScript( "OnShow", OnMouseUp )
button:SetScript( "OnDisable", OnDisable )
button:SetScript( "OnEnable", OnEnable )
 
button:SetText( name )
button:SetWidth( math.min( 44, button:GetTextWidth() + 8 ) )