Mercurial > wow > hansgar_and_franzok_assist
diff Libs/DF/button.lua @ 22:dbd417f413a8
- framework update.
| author | Tercio |
|---|---|
| date | Tue, 08 Sep 2015 13:16:49 -0300 |
| parents | dc1c77254f80 |
| children | 7523376ecaa3 |
line wrap: on
line diff
--- a/Libs/DF/button.lua Tue Aug 25 14:09:54 2015 -0300 +++ b/Libs/DF/button.lua Tue Sep 08 13:16:49 2015 -0300 @@ -616,6 +616,14 @@ end end + if (button.MyObject.onenter_backdrop_border_color) then + button:SetBackdropBorderColor (unpack (button.MyObject.onenter_backdrop_border_color)) + end + + if (button.MyObject.onenter_backdrop) then + button:SetBackdropColor (unpack (button.MyObject.onenter_backdrop)) + end + if (button.MyObject.have_tooltip) then GameCooltip2:Preset (2) if (type (button.MyObject.have_tooltip) == "function") then @@ -625,13 +633,6 @@ end GameCooltip2:ShowCooltip (button, "tooltip") end - - local parent = button:GetParent().MyObject - if (parent and parent.type == "panel") then - if (parent.GradientEnabled) then - parent:RunGradient() - end - end end local OnLeave = function (button) @@ -665,18 +666,19 @@ end end + if (button.MyObject.onleave_backdrop_border_color) then + button:SetBackdropBorderColor (unpack (button.MyObject.onleave_backdrop_border_color)) + end + + if (button.MyObject.onleave_backdrop) then + button:SetBackdropColor (unpack (button.MyObject.onleave_backdrop)) + end + if (button.MyObject.have_tooltip) then if (GameCooltip2:GetText (1) == button.MyObject.have_tooltip or type (button.MyObject.have_tooltip) == "function") then GameCooltip2:Hide() end end - - local parent = button:GetParent().MyObject - if (parent and parent.type == "panel") then - if (parent.GradientEnabled) then - parent:RunGradient (false) - end - end end local OnHide = function (button) @@ -862,13 +864,65 @@ end ------------------------------------------------------------------------------------------------------------ + +function ButtonMetaFunctions:SetTemplate (template) + + if (template.width) then + self:SetWidth (template.width) + end + if (template.height) then + self:SetHeight (template.height) + end + + if (template.backdrop) then + self:SetBackdrop (template.backdrop) + end + if (template.backdropcolor) then + local r, g, b, a = DF:ParseColors (template.backdropcolor) + self:SetBackdropColor (r, g, b, a) + self.onleave_backdrop = {r, g, b, a} + end + if (template.backdropbordercolor) then + local r, g, b, a = DF:ParseColors (template.backdropbordercolor) + self:SetBackdropBorderColor (r, g, b, a) + self.onleave_backdrop_border_color = {r, g, b, a} + end + + if (template.onentercolor) then + local r, g, b, a = DF:ParseColors (template.onentercolor) + self.onenter_backdrop = {r, g, b, a} + end + + if (template.onleavecolor) then + local r, g, b, a = DF:ParseColors (template.onleavecolor) + self.onleave_backdrop = {r, g, b, a} + end + + if (template.onenterbordercolor) then + local r, g, b, a = DF:ParseColors (template.onenterbordercolor) + self.onenter_backdrop_border_color = {r, g, b, a} + end + + if (template.onleavebordercolor) then + local r, g, b, a = DF:ParseColors (template.onleavebordercolor) + self.onleave_backdrop_border_color = {r, g, b, a} + end + + if (template.icon) then + local i = template.icon + self:SetIcon (i.texture, i.width, i.height, i.layout, i.texcoord, i.color, i.textdistance, i.leftpadding) + end + +end + +------------------------------------------------------------------------------------------------------------ --> object constructor -function DF:CreateButton (parent, func, w, h, text, param1, param2, texture, member, name, short_method, text_template) - return DF:NewButton (parent, parent, name, member, w, h, func, param1, param2, texture, text, short_method, text_template) +function DF:CreateButton (parent, func, w, h, text, param1, param2, texture, member, name, short_method, button_template, text_template) + return DF:NewButton (parent, parent, name, member, w, h, func, param1, param2, texture, text, short_method, button_template, text_template) end -function DF:NewButton (parent, container, name, member, w, h, func, param1, param2, texture, text, short_method, template) +function DF:NewButton (parent, container, name, member, w, h, func, param1, param2, texture, text, short_method, button_template, text_template) if (not name) then name = "DetailsFrameworkButtonNumber" .. DF.ButtonCounter @@ -884,8 +938,7 @@ if (name:find ("$parent")) then name = name:gsub ("$parent", parent:GetName()) end - - + local ButtonObject = {type = "button", dframework = true} if (member) then @@ -917,7 +970,7 @@ ButtonObject.button = CreateFrame ("button", name, parent, "DetailsFrameworkButtonTemplate") ButtonObject.widget = ButtonObject.button - ButtonObject.button:SetBackdrop ({bgFile = DF.folder .. "background", tileSize = 64, edgeFile = DF.folder .. "border_2", edgeSize = 10, insets = {left = 1, right = 1, top = 1, bottom = 1}}) + --ButtonObject.button:SetBackdrop ({bgFile = DF.folder .. "background", tileSize = 64, edgeFile = DF.folder .. "border_2", edgeSize = 10, insets = {left = 1, right = 1, top = 1, bottom = 1}}) ButtonObject.button:SetBackdropColor (0, 0, 0, 0.4) ButtonObject.button:SetBackdropBorderColor (1, 1, 1, 1) @@ -934,6 +987,7 @@ end end + ButtonObject.button:SetWidth (w or 100) ButtonObject.button:SetHeight (h or 20) ButtonObject.button.MyObject = ButtonObject @@ -977,17 +1031,17 @@ ButtonObject.short_method = short_method - if (template) then - if (template.size) then - DF:SetFontSize (ButtonObject.button.text, template.size) + if (text_template) then + if (text_template.size) then + DF:SetFontSize (ButtonObject.button.text, text_template.size) end - if (template.color) then - local r, g, b, a = DF:ParseColors (template.color) + if (text_template.color) then + local r, g, b, a = DF:ParseColors (text_template.color) ButtonObject.button.text:SetTextColor (r, g, b, a) end - if (template.font) then + if (text_template.font) then local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0") - local font = SharedMedia:Fetch ("font", template.font) + local font = SharedMedia:Fetch ("font", text_template.font) DF:SetFontFace (ButtonObject.button.text, font) end end @@ -1002,6 +1056,10 @@ _setmetatable (ButtonObject, ButtonMetaFunctions) + if (button_template) then + ButtonObject:SetTemplate (button_template) + end + return ButtonObject end @@ -1029,21 +1087,23 @@ ColorPickerFrame:Hide() end -function DF:CreateColorPickButton (parent, name, member, callback, alpha) - return DF:NewColorPickButton (parent, name, member, callback, alpha) +function DF:CreateColorPickButton (parent, name, member, callback, alpha, button_template) + return DF:NewColorPickButton (parent, name, member, callback, alpha, button_template) end -function DF:NewColorPickButton (parent, name, member, callback, alpha) +function DF:NewColorPickButton (parent, name, member, callback, alpha, button_template) --button - local button = DF:NewButton (parent, _, name, member, color_button_width, color_button_height, pickcolor, alpha, "param2") - button:InstallCustomTexture() + local button = DF:NewButton (parent, _, name, member, color_button_width, color_button_height, pickcolor, alpha, "param2", nil, nil, nil, button_template) button.color_callback = callback button.Cancel = colorpick_cancel button.SetColor = set_colorpick_color - button:SetBackdrop ({edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 6, - bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], insets = {left = 0, right = 0, top = 0, bottom = 0}}) + if (not button_template) then + button:InstallCustomTexture() + button:SetBackdrop ({edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 6, + bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], insets = {left = 0, right = 0, top = 0, bottom = 0}}) + end --textura do fundo local background = DF:NewImage (button, nil, color_button_width, color_button_height, nil, nil, nil, "$parentBck")
