Fix DropDown strata.

main
jeffi 10 months ago
parent 2ee8f47827
commit 77148b2c89
  1. 31
      DiesalGUI-2.0/Objects/DropDown.lua
  2. 13
      DiesalGUI-2.0/Objects/DropDownItem.lua

@ -128,7 +128,7 @@ local methods = {
end,
---@param self Diesal.GUI.Object.DropDown
---@param list table
---@param list table<integer, Diesal.GUI.DropDownItem.Settings>
SetList = function(self, list)
self:ReleaseChildren()
self:SetText("")
@ -148,6 +148,7 @@ local methods = {
position = position,
clickable = item.clickable,
indent = item.indent or 0,
icon2 = item.icon2,
}, true)
dropdownItem.text:SetPoint("TOPLEFT", 12 + (item.indent * 6), -2)
if item.indent and item.indent > 0 then
@ -205,6 +206,11 @@ local methods = {
for i = 1, #self.children do
local child = self.children[i]
child:SetSelected(false)
if child.settings.icon2 then
child.icon2:Show()
else
child.icon2:Hide()
end
if child.settings.key == key then
child:SetSelected(true)
dropdownText = child.settings.value
@ -337,9 +343,21 @@ local methods = {
self:ShowDropDown()
end
end,
---@param self Diesal.GUI.Object.DropDown
---@param strata FrameStrata
---@param parent Frame
---@param children Frame[]
FixStrata = function(self, strata, parent, children)
parent:SetFrameStrata(strata)
for i, child in ipairs(children) do
self:FixStrata(strata, child, {
child:GetChildren() --[[@as Frame]],
})
end
end,
}
---@class Diesal.GUI.Object.DropDown.Settings
---@class Diesal.GUI.Object.DropDown.Settings : Diesal.GUI.ObjectBase.Settings
---@field dropdownPadLeft number
---@field dropdownPadRight number
---@field dropdownPadTop number
@ -369,6 +387,7 @@ local function Constructor()
local frame = CreateFrame("Button", nil, UIParent)
frame:SetFrameStrata("TOOLTIP")
frame:SetClampedToScreen(true)
self.frame = frame
self.isContainer = true
@ -391,7 +410,10 @@ local function Constructor()
if self.dropdown:IsVisible() then
self.dropdown:Hide()
else
DiesalGUI:OnMouse(this, button)
DiesalGUI:OnMouse(self.dropdown, button)
self:FixStrata("TOOLTIP", self.dropdown, {
self.dropdown:GetChildren() --[[@as Frame]],
})
self.dropdown:Show()
end
end
@ -413,8 +435,7 @@ local function Constructor()
local dropdown = self:CreateRegion("Frame", "dropdown", frame)
dropdown:SetFrameStrata("TOOLTIP")
dropdown:SetFrameLevel(998)
dropdown:SetToplevel(true)
dropdown:SetFrameLevel(dropdown:GetFrameLevel() + 2)
dropdown:SetPoint("TOPRIGHT", frame, "BOTTOMRIGHT", 0, -2)
dropdown:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, -2)
dropdown:SetScript("OnShow", function(this)

@ -61,6 +61,11 @@ local methods = {
alpha = 0.0,
})
end
if self.settings.icon2 then
self.icon2:Show()
else
self.icon2:Hide()
end
end,
---@param self Diesal.GUI.Object.DropDown.Item
["SetText"] = function(self, text)
@ -131,6 +136,7 @@ local methods = {
---@field clickable boolean
---@field indent number
---@field header boolean
---@field icon2 boolean
---@field parentObject Diesal.GUI.Object.DropDown
---@class DiesalDropDownItem : Diesal.GUI.Object.DropDown.Item
@ -139,6 +145,7 @@ local methods = {
local function Constructor()
---@class Diesal.GUI.Object.DropDown.Item : Diesal.GUI.ObjectBase, Diesal.GUI.DropDownItem.Methods
---@field check Texture
---@field icon2 Texture
---@field text FontString
---@field settings Diesal.GUI.DropDownItem.Settings
local self = DiesalGUI:Create(Type, true)
@ -172,6 +179,12 @@ local function Constructor()
image = { "DiesalGUIcons", { 10, 5, 16, 256, 128 }, "FFFF00" },
})
check:Hide()
local icon2 = self:CreateRegion("Texture", "icon2", frame)
icon2:SetTexture(130775)
icon2:SetSize(16, 16)
icon2:SetAlpha(0.5)
icon2:SetPoint("RIGHT", -2, 0)
icon2:Hide()
-- ~~ Methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
self:SetMethods(methods)
--[[ for method, func in pairs(methods) do

Loading…
Cancel
Save