From 4fa2aea86f5ad43c47472e0eb184caf8ad3c5f88 Mon Sep 17 00:00:00 2001 From: Artur Morozov Date: Thu, 2 May 2019 19:41:07 +0300 Subject: [PATCH] skin: fix dropdown menu backdrop and orientation --- api/ui-widgets.lua | 3 --- modules/skin.lua | 35 +++++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/api/ui-widgets.lua b/api/ui-widgets.lua index c6571f65..9535d7c9 100644 --- a/api/ui-widgets.lua +++ b/api/ui-widgets.lua @@ -552,8 +552,6 @@ function pfUI.api.SkinDropDown(frame, cr, cg, cb) local funcc = button:GetScript("OnClick") button:SetScript("OnClick", function() if funcc then funcc() end - UIDropDownMenu_JustifyText("RIGHT", this:GetParent()) - DropDownList1:SetPoint("TOPLEFT", this:GetParent().backdrop, "BOTTOMLEFT", 0, -4) local DropDownListWidth = DropDownList1:GetWidth() local DropDownFrameWidth = this:GetParent().backdrop:GetWidth() @@ -564,7 +562,6 @@ function pfUI.api.SkinDropDown(frame, cr, cg, cb) _G["DropDownList1Button" .. i]:SetWidth(_G["DropDownList1Button" .. i]:GetWidth() + diff) end end - CreateBackdrop(DropDownList1Backdrop, nil, true, .8) end) frame.button = button diff --git a/modules/skin.lua b/modules/skin.lua index 8b8316af..b9b80302 100644 --- a/modules/skin.lua +++ b/modules/skin.lua @@ -56,18 +56,33 @@ pfUI:RegisterModule("skin", 20400, function () end) end - local boxes = { - "DropDownList1MenuBackdrop", - "DropDownList2MenuBackdrop", - "DropDownList1Backdrop", - "DropDownList2Backdrop", - } - - for _, box in pairs(boxes) do - local b = _G[box] - CreateBackdrop(b, nil, true, .8) + for i = 1, UIDROPDOWNMENU_MAXLEVELS do + CreateBackdrop(_G["DropDownList"..i.."MenuBackdrop"], nil, true, .8) + CreateBackdrop(_G["DropDownList"..i.."Backdrop"], nil, true, .8) end + hooksecurefunc("ToggleDropDownMenu", function(level, value, dropDownFrame, anchorName, xOffset, yOffset) + if not dropDownFrame then dropDownFrame = this end + if not level then level = 1 end + local listFrame = _G["DropDownList"..level] + local point, relativeTo, relativePoint, xOffset, yOffset = listFrame:GetPoint() + + if level == 1 then + if dropDownFrame.displayMode == "MENU" then return end + if point == "TOPLEFT" then + listFrame:SetPoint(point, this:GetParent().backdrop, relativePoint, 0, -4) + elseif point == "BOTTOMLEFT" then + listFrame:SetPoint(point, this:GetParent().backdrop, relativePoint, 0, 4) + end + else + if point == "TOPLEFT" then + listFrame:SetPoint(point, relativeTo, relativePoint, xOffset + 8, 0) + else + listFrame:SetPoint(point, relativeTo, relativePoint, xOffset - 4, 0) + end + end + end, 1) + if C.global.errors_limit == "1" then UIErrorsFrame:SetHeight(25) end