From 77148b2c89ef39cc29ca4fbd963b67fbc4c88669 Mon Sep 17 00:00:00 2001 From: jeffi Date: Wed, 13 Mar 2024 10:47:29 -0500 Subject: [PATCH] Fix DropDown strata. --- DiesalGUI-2.0/Objects/DropDown.lua | 31 +++++++++++++++++++++----- DiesalGUI-2.0/Objects/DropDownItem.lua | 13 +++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/DiesalGUI-2.0/Objects/DropDown.lua b/DiesalGUI-2.0/Objects/DropDown.lua index 496af91..34e5793 100644 --- a/DiesalGUI-2.0/Objects/DropDown.lua +++ b/DiesalGUI-2.0/Objects/DropDown.lua @@ -128,7 +128,7 @@ local methods = { end, ---@param self Diesal.GUI.Object.DropDown - ---@param list table + ---@param list table 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) diff --git a/DiesalGUI-2.0/Objects/DropDownItem.lua b/DiesalGUI-2.0/Objects/DropDownItem.lua index 26bcedb..005fd0c 100644 --- a/DiesalGUI-2.0/Objects/DropDownItem.lua +++ b/DiesalGUI-2.0/Objects/DropDownItem.lua @@ -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