WoWInterface SVN PhanxConfigWidgets

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 38 to Rev 39
    Reverse comparison

Rev 38 → Rev 39

PhanxConfig-Button/PhanxConfig-Button.lua New file
0,0 → 1,54
--[[--------------------------------------------------------------------
PhanxConfig-Button
Simple button widget generator.
Requires LibStub.
 
This library is not intended for use by other authors. Absolutely no
support of any kind will be provided for other authors using it, and
its internals may change at any time without notice.
----------------------------------------------------------------------]]
 
local MINOR_VERSION = tonumber( string.match( "$Revision: 28 $", "%d+" ) )
 
local lib, oldminor = LibStub:NewLibrary( "PhanxConfig-Button", MINOR_VERSION )
if not lib then return end
 
local function OnEnter( self )
local text = self.desc
if text then
GameTooltip:SetOwner( self, "ANCHOR_RIGHT" )
GameTooltip:SetText( text, nil, nil, nil, nil, true )
end
end
 
local function OnLeave()
GameTooltip:Hide()
end
 
function lib.CreateButton( parent, name )
local button = CreateFrame( "Button", nil, parent )
button:SetWidth( 44 )
button:SetHeight( 19 )
 
button:SetNormalFontObject( GameFontNormalSmall )
button:SetDisabledFontObject( GameFontDisable )
button:SetHighlightFontObject( GameFontHighlightSmall )
 
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: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 )
 
return button
end
\ No newline at end of file Property changes : Added: svn:eol-style + native
PhanxConfigWidgets.toc
1,5 → 1,5
## Interface: 40000
## Version: 4.0.1.wowi:revision
## Version: 4.0.3.wowi:revision
 
## Title: |cffffcc00Lib:|r PhanxConfigWidgets
## Notes: Simple GUI configuration widgets.
8,9 → 8,11
 
## Dependencies: LibStub
 
PhanxConfig-Button\PhanxConfig-Button.lua
PhanxConfig-Checkbox\PhanxConfig-Checkbox.lua
PhanxConfig-ColorPicker\PhanxConfig-ColorPicker.lua
PhanxConfig-Dropdown\PhanxConfig-Dropdown.lua
PhanxConfig-EditBox\PhanxConfig-EditBox.lua
PhanxConfig-Panel\PhanxConfig-Panel.lua
PhanxConfig-ScrollingDropdown\PhanxConfig-ScrollingDropdown.lua
PhanxConfig-Slider\PhanxConfig-Slider.lua
\ No newline at end of file
PhanxConfig-EditBox/PhanxConfig-EditBox.lua New file
0,0 → 1,167
--[[--------------------------------------------------------------------
PhanxConfig-EditBox
Simple text input widget generator.
Requires LibStub.
 
This library is not intended for use by other authors. Absolutely no
support of any kind will be provided for other authors using it, and
its internals may change at any time without notice.
----------------------------------------------------------------------]]
 
local CreateButton = LibStub( "PhanxConfig-Button", true ) and LibStub( "PhanxConfig-Button" ).CreateButton
assert( CreateButton, "PhanxConfig-EditBox requires PhanxConfig-Button!" )
 
local MINOR_VERSION = tonumber( string.match( "$Revision: 28 $", "%d+" ) )
 
local lib, oldminor = LibStub:NewLibrary( "PhanxConfig-EditBox", MINOR_VERSION )
if not lib then return end
 
lib.editboxes = lib.editboxes or { }
 
if not PhanxConfigEditBoxInsertLink then
hooksecurefunc( "ChatEdit_InsertLink", function( ... ) return _G.PhanxConfigEditBoxInsertLink( ... ) end )
end
 
function PhanxConfigEditBoxInsertLink( link )
for i = 1, #lib.editboxes do
local editbox = lib.editboxes[ i ]
if editbox and editbox:IsVisible() and editbox:HasFocus() then
editbox:Insert( link )
return true
end
end
end
 
local function OnEnter( self )
local text = self:GetParent().desc
if text then
GameTooltip:SetOwner( self, "ANCHOR_RIGHT" )
GameTooltip:SetText( text, nil, nil, nil, nil, true )
end
end
 
local function OnLeave()
GameTooltip:Hide()
end
 
local function OnEditFocusGained( self )
self.currText = self:GetText()
self:HighlightText()
end
 
local function OnTextChanged( self )
local text = self:GetText()
local parent = self:GetParent()
if parent.OnTextChanged and text ~= self.currText then
parent:OnTextChanged( text )
self.currText = text
end
self.button:Enable()
end
 
local function OnEnterPressed( self )
local parent = self:GetParent()
if parent.OnValueChanged then
parent:OnValueChanged( self:GetText() )
end
self:ClearFocus()
self.currText = nil
parent.button:Disable()
end
 
local function OnEscapePressed( self )
self:ClearFocus()
self.currText = nil
self:GetParent().button:Disable()
end
 
local function OnReceiveDrag( self )
local type, id, info = GetCursorInfo()
if type == "item" then
self:SetText( info )
OnEnterPressed( self )
ClearCursor()
elseif type == "spell" then
local name = GetSpellInfo( id, info )
self:SetText( name )
OnEnterPressed( self )
ClearCursor()
end
end
 
local function OnClick( self )
return OnEnterPressed( self:GetParent().editbox )
end
 
local function SetValue( self, text )
return self.editbox:SetText( text )
end
 
function lib.CreateEditBox( parent, name, maxLetters, noButton )
local frame = CreateFrame( "Frame", nil, parent )
frame:SetWidth( 144 )
frame:SetHeight( 42 )
 
-- local bg = frame:CreateTexture(nil, "BACKGROUND")
-- bg:SetAllPoints(frame)
-- bg:SetTexture(0, 0, 0)
-- frame.bg = bg
 
local button = CreateButton( frame, OKAY )
button:SetWidth( 24 )
button:SetScript( "OnClick", OnClick )
button:Disable()
if noButton then button:Hide() end
frame.button = button
 
local editbox = CreateFrame( "EditBox", nil, frame )
editbox:SetPoint( "LEFT", 5, 0 )
editbox:SetPoint( "RIGHT", button, "LEFT", -5, 0 )
editbox:SetHeight( 19 )
editbox:EnableMouse( true )
editbox:SetAutoFocus( false )
editbox:SetFontObject( ChatFontNormal )
editbox:SetMaxLetters( maxLetters or 256 )
editbox:SetTextInsets( 0, 0, 3, 3 )
editbox:SetScript( "OnEnter", OnEnter )
editbox:SetScript( "OnLeave", OnLeave )
editbox:SetScript( "OnEditFocusGained", OnEditFocusGained )
editbox:SetScript( "OnTextChanged", OnTextChanged )
editbox:SetScript( "OnEnterPressed", OnEnterPressed )
editbox:SetScript( "OnEscapePressed", OnEscapePressed )
editbox:SetScript( "OnReceiveDrag", OnReceiveDrag )
lib.editboxes[ #lib.editboxes + 1 ] = editbox
frame.editbox = editbox
 
editbox.bgLeft = editbox:CreateTexture( nil, "BACKGROUND" )
editbox.bgLeft:SetPoint( "LEFT", -5, 0 )
editbox.bgLeft:SetSize( 8, 20 )
editbox.bgLeft:SetTexture( [[Interface\Common\Common-Input-Border]] )
editbox.bgLeft:SetTexCoord( 0, 0.0625, 0, 0.625 )
 
editbox.bgRight = editbox:CreateTexture( nil, "BACKGROUND" )
editbox.bgRight:SetPoint( "RIGHT", 0, 0 )
editbox.bgRight:SetSize( 8, 20 )
editbox.bgRight:SetTexture( [[Interface\Common\Common-Input-Border]] )
editbox.bgRight:SetTexCoord( 0.9375, 1, 0, 0.625 )
 
editbox.bgMiddle = editbox:CreateTexture( nil, "BACKGROUND" )
editbox.bgMiddle:SetPoint( "LEFT", editbox.bgLeft, "RIGHT" )
editbox.bgMiddle:SetPoint( "RIGHT", editbox.bgRight, "LEFT" )
editbox.bgMiddle:SetSize( 10, 20 )
editbox.bgMiddle:SetTexture( [[Interface\Common\Common-Input-Border]] )
editbox.bgMiddle:SetTexCoord( 0.0625, 0.9375, 0, 0.625 )
 
local label = slider:CreateFontString( nil, "ARTWORK", "GameFontNormal" )
label:SetPoint( "BOTTOMLEFT", slider, "TOPLEFT" )
label:SetPoint( "BOTTOMRIGHT", slider, "TOPRIGHT" )
label:SetJustifyH( "LEFT" )
label:SetText( name )
frame.label = label
 
frame.noButton = noButton
 
frame.SetValue = SetValue
 
return frame
end
\ No newline at end of file Property changes : Added: svn:eol-style + native