Mercurial > wow > hansgar_and_franzok_assist
diff Libs/DF/dropdown.lua @ 22:dbd417f413a8
- framework update.
| author | Tercio |
|---|---|
| date | Tue, 08 Sep 2015 13:16:49 -0300 |
| parents | dc1c77254f80 |
| children | 5da06cb420d4 |
line wrap: on
line diff
--- a/Libs/DF/dropdown.lua Tue Aug 25 14:09:54 2015 -0300 +++ b/Libs/DF/dropdown.lua Tue Sep 08 13:16:49 2015 -0300 @@ -329,7 +329,11 @@ end function DropDownMetaFunctions:NoOptionSelected() + if (self.no_options) then + return + end self.label:SetText (self.empty_text or "no option selected") + self.label:SetPoint ("left", self.icon, "right", 2, 0) self.label:SetTextColor (1, 1, 1, 0.4) if (self.empty_icon) then self.icon:SetTexture (self.empty_icon) @@ -348,6 +352,7 @@ self:SetAlpha (0.5) self.no_options = true self.label:SetText ("no options") + self.label:SetPoint ("left", self.icon, "right", 2, 0) self.label:SetTextColor (1, 1, 1, 0.4) self.icon:SetTexture ([[Interface\CHARACTERFRAME\UI-Player-PlayTimeUnhealthy]]) self.icon:SetTexCoord (0, 1, 0, 1) @@ -444,6 +449,7 @@ self.icon:SetVertexColor (1, 1, 1, 1) end + self.icon:SetSize (self:GetHeight()-2, self:GetHeight()-2) else self.label:SetPoint ("left", self.label:GetParent(), "left", 4, 0) end @@ -482,6 +488,7 @@ --> set the value of selected option in main object button.object.myvalue = button.table.value + button.object.myvaluelabel = button.table.label end function DropDownMetaFunctions:Open() @@ -563,6 +570,7 @@ local i = 1 local showing = 0 local currentText = button.text:GetText() or "" + local currentIndex if (object.OnMouseDownHook) then local interrupt = object.OnMouseDownHook (button, buttontype, menu, scrollFrame, scrollChild, selectedTexture) @@ -571,7 +579,7 @@ end end - for _, _table in ipairs (menu) do + for tindex, _table in ipairs (menu) do local show = isOptionVisible (_table) @@ -639,7 +647,10 @@ end selectedTexture:Show() - selectedTexture:SetVertexColor (1, 1, 1, .3); + selectedTexture:SetVertexColor (1, 1, 1, .3) + selectedTexture:SetTexCoord (0, 29/32, 5/32, 27/32) + + currentIndex = tindex currentText = nil end @@ -719,7 +730,12 @@ end end - object.scroll:SetValue (0) + if (object.myvaluelabel and currentIndex and scrollFrame.slider:IsShown()) then + object.scroll:SetValue (max ((currentIndex*20) - 80, 0)) + else + object.scroll:SetValue (0) + end + object:Open() else @@ -749,6 +765,10 @@ self:SetBackdropColor (.2, .2, .2, .2) end + if (self.MyObject.onenter_backdrop_border_color) then + self:SetBackdropBorderColor (unpack (self.MyObject.onenter_backdrop_border_color)) + end + self.arrowTexture2:Show() if (self.MyObject.have_tooltip) then @@ -763,14 +783,7 @@ GameCooltip2:SetOwner (self) GameCooltip2:ShowCooltip() end - - local parent = self:GetParent().MyObject - if (parent and parent.type == "panel") then - if (parent.GradientEnabled) then - parent:RunGradient() - end - end - + end function DetailsFrameworkDropDownOnLeave (self) @@ -787,18 +800,15 @@ self:SetBackdropColor (1, 1, 1, .5) end + if (self.MyObject.onleave_backdrop_border_color) then + self:SetBackdropBorderColor (unpack (self.MyObject.onleave_backdrop_border_color)) + end + self.arrowTexture2:Hide() if (self.MyObject.have_tooltip) then GameCooltip2:ShowMe (false) end - - local parent = self:GetParent().MyObject - if (parent and parent.type == "panel") then - if (parent.GradientEnabled) then - parent:RunGradient (false) - end - end end function DetailsFrameworkDropDownOnSizeChanged (self, w, h) @@ -836,13 +846,59 @@ end ------------------------------------------------------------------------------------------------------------ +function DropDownMetaFunctions: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 + +end + +------------------------------------------------------------------------------------------------------------ --> object constructor -function DF:CreateDropDown (parent, func, default, w, h, member, name) - return DF:NewDropDown (parent, parent, name, member, w, h, func, default) +function DF:CreateDropDown (parent, func, default, w, h, member, name, template) + return DF:NewDropDown (parent, parent, name, member, w, h, func, default, template) end -function DF:NewDropDown (parent, container, name, member, w, h, func, default) +function DF:NewDropDown (parent, container, name, member, w, h, func, default, template) if (not name) then name = "DetailsFrameworkDropDownNumber" .. DF.DropDownCounter @@ -959,6 +1015,10 @@ end end + if (template) then + DropDownObject:SetTemplate (template) + end + return DropDownObject end \ No newline at end of file
