comparison Libs/DF/button.lua @ 20:dc1c77254f80

- added close button to users panel. - framework update.
author Tercio
date Tue, 11 Aug 2015 12:46:46 -0300
parents 215f0dd37a6c
children dbd417f413a8
comparison
equal deleted inserted replaced
19:215f0dd37a6c 20:dc1c77254f80
1 1
2 local DF = _G ["DetailsFramework"] 2 local DF = _G ["DetailsFramework"]
3
4 if (not DF or not DetailsFrameworkCanLoad) then
5 return
6 end
3 7
4 local _ 8 local _
5 local _rawset = rawset --> lua local 9 local _rawset = rawset --> lua local
6 local _rawget = rawget --> lua local 10 local _rawget = rawget --> lua local
7 local _setmetatable = setmetatable --> lua local 11 local _setmetatable = setmetatable --> lua local
858 end 862 end
859 863
860 ------------------------------------------------------------------------------------------------------------ 864 ------------------------------------------------------------------------------------------------------------
861 --> object constructor 865 --> object constructor
862 866
863 function DF:CreateButton (parent, func, w, h, text, param1, param2, texture, member, name, short_method) 867 function DF:CreateButton (parent, func, w, h, text, param1, param2, texture, member, name, short_method, text_template)
864 return DF:NewButton (parent, parent, name, member, w, h, func, param1, param2, texture, text, short_method) 868 return DF:NewButton (parent, parent, name, member, w, h, func, param1, param2, texture, text, short_method, text_template)
865 end 869 end
866 870
867 function DF:NewButton (parent, container, name, member, w, h, func, param1, param2, texture, text, short_method) 871 function DF:NewButton (parent, container, name, member, w, h, func, param1, param2, texture, text, short_method, template)
868 872
869 if (not name) then 873 if (not name) then
870 name = "DetailsFrameworkButtonNumber" .. DF.ButtonCounter 874 name = "DetailsFrameworkButtonNumber" .. DF.ButtonCounter
871 DF.ButtonCounter = DF.ButtonCounter + 1 875 DF.ButtonCounter = DF.ButtonCounter + 1
872 876
921 APIButtonFunctions = true 925 APIButtonFunctions = true
922 local idx = getmetatable (ButtonObject.button).__index 926 local idx = getmetatable (ButtonObject.button).__index
923 for funcName, funcAddress in pairs (idx) do 927 for funcName, funcAddress in pairs (idx) do
924 if (not ButtonMetaFunctions [funcName]) then 928 if (not ButtonMetaFunctions [funcName]) then
925 ButtonMetaFunctions [funcName] = function (object, ...) 929 ButtonMetaFunctions [funcName] = function (object, ...)
926 local x = loadstring ( "return _G."..object.button:GetName()..":"..funcName.."(...)") 930 local x = loadstring ( "return _G['"..object.button:GetName().."']:"..funcName.."(...)")
927 return x (...) 931 return x (...)
928 end 932 end
929 end 933 end
930 end 934 end
931 end 935 end
971 ButtonObject.param1 = param1 975 ButtonObject.param1 = param1
972 ButtonObject.param2 = param2 976 ButtonObject.param2 = param2
973 977
974 ButtonObject.short_method = short_method 978 ButtonObject.short_method = short_method
975 979
980 if (template) then
981 if (template.size) then
982 DF:SetFontSize (ButtonObject.button.text, template.size)
983 end
984 if (template.color) then
985 local r, g, b, a = DF:ParseColors (template.color)
986 ButtonObject.button.text:SetTextColor (r, g, b, a)
987 end
988 if (template.font) then
989 local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
990 local font = SharedMedia:Fetch ("font", template.font)
991 DF:SetFontFace (ButtonObject.button.text, font)
992 end
993 end
994
976 --> hooks 995 --> hooks
977 ButtonObject.button:SetScript ("OnEnter", OnEnter) 996 ButtonObject.button:SetScript ("OnEnter", OnEnter)
978 ButtonObject.button:SetScript ("OnLeave", OnLeave) 997 ButtonObject.button:SetScript ("OnLeave", OnLeave)
979 ButtonObject.button:SetScript ("OnHide", OnHide) 998 ButtonObject.button:SetScript ("OnHide", OnHide)
980 ButtonObject.button:SetScript ("OnShow", OnShow) 999 ButtonObject.button:SetScript ("OnShow", OnShow)