|
|
@ -100,6 +100,7 @@ local methods = { |
|
|
|
self:SetStylesheet(Stylesheet) |
|
|
|
self:SetStylesheet(Stylesheet) |
|
|
|
-- self:SetStylesheet(wireFrameSheet) |
|
|
|
-- self:SetStylesheet(wireFrameSheet) |
|
|
|
self:Show() |
|
|
|
self:Show() |
|
|
|
|
|
|
|
self:SetFrameStrata("TOOLTIP") |
|
|
|
end, |
|
|
|
end, |
|
|
|
|
|
|
|
|
|
|
|
---@param self Diesal.GUI.Object.DropDown |
|
|
|
---@param self Diesal.GUI.Object.DropDown |
|
|
@ -135,8 +136,10 @@ local methods = { |
|
|
|
settings.list = list |
|
|
|
settings.list = list |
|
|
|
local foldColor = "353535" |
|
|
|
local foldColor = "353535" |
|
|
|
local expandColor = "5a5a5a" |
|
|
|
local expandColor = "5a5a5a" |
|
|
|
|
|
|
|
self.dropdown:SetFrameStrata("TOOLTIP") |
|
|
|
for position, item in ipairs(list) do |
|
|
|
for position, item in ipairs(list) do |
|
|
|
local dropdownItem = DiesalGUI:Create("DiesalDropDownItem") |
|
|
|
local dropdownItem = DiesalGUI:Create("DiesalDropDownItem") |
|
|
|
|
|
|
|
DiesalGUI:OnMouse(dropdownItem.frame, "LeftButton") |
|
|
|
self:AddChild(dropdownItem) |
|
|
|
self:AddChild(dropdownItem) |
|
|
|
dropdownItem:SetParentObject(self) |
|
|
|
dropdownItem:SetParentObject(self) |
|
|
|
dropdownItem:SetSettings({ |
|
|
|
dropdownItem:SetSettings({ |
|
|
@ -191,6 +194,7 @@ local methods = { |
|
|
|
SetValue = function(self, key) |
|
|
|
SetValue = function(self, key) |
|
|
|
local selectionTable = {} |
|
|
|
local selectionTable = {} |
|
|
|
local selectedKey, dropdownText, selectedValue |
|
|
|
local selectedKey, dropdownText, selectedValue |
|
|
|
|
|
|
|
local selectedCount = 0 |
|
|
|
|
|
|
|
|
|
|
|
if key ~= "CLEAR" then |
|
|
|
if key ~= "CLEAR" then |
|
|
|
if self.settings.multiSelect then |
|
|
|
if self.settings.multiSelect then |
|
|
@ -200,6 +204,7 @@ local methods = { |
|
|
|
self.children[i]:SetSelected(true) |
|
|
|
self.children[i]:SetSelected(true) |
|
|
|
end |
|
|
|
end |
|
|
|
if self.children[i].settings.selected then |
|
|
|
if self.children[i].settings.selected then |
|
|
|
|
|
|
|
selectedCount = selectedCount + 1 |
|
|
|
if dropdownText then |
|
|
|
if dropdownText then |
|
|
|
dropdownText = format("%s, %s", dropdownText, self.children[i].settings.value) |
|
|
|
dropdownText = format("%s, %s", dropdownText, self.children[i].settings.value) |
|
|
|
else |
|
|
|
else |
|
|
@ -225,6 +230,10 @@ local methods = { |
|
|
|
self:ClearSelection() |
|
|
|
self:ClearSelection() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.settings.multiSelect then |
|
|
|
|
|
|
|
dropdownText = string.format("+%d", selectedCount) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if selectedKey then |
|
|
|
if selectedKey then |
|
|
|
self:SetText(dropdownText) |
|
|
|
self:SetText(dropdownText) |
|
|
|
self:FireEvent("OnValueChanged", selectedKey, selectedValue, selectionTable) |
|
|
|
self:FireEvent("OnValueChanged", selectedKey, selectedValue, selectionTable) |
|
|
@ -251,6 +260,7 @@ local methods = { |
|
|
|
local selectionTable = {} |
|
|
|
local selectionTable = {} |
|
|
|
local selectedKey |
|
|
|
local selectedKey |
|
|
|
local dropdownText |
|
|
|
local dropdownText |
|
|
|
|
|
|
|
local selectedCount = 0 |
|
|
|
|
|
|
|
|
|
|
|
for i = 1, #dropdownItems do |
|
|
|
for i = 1, #dropdownItems do |
|
|
|
local dropdownItem = dropdownItems[i] |
|
|
|
local dropdownItem = dropdownItems[i] |
|
|
@ -258,12 +268,18 @@ local methods = { |
|
|
|
for _, key in ipairs(keyTable) do |
|
|
|
for _, key in ipairs(keyTable) do |
|
|
|
if dropdownItem.settings.key == key then |
|
|
|
if dropdownItem.settings.key == key then |
|
|
|
dropdownItem:SetSelected(true) |
|
|
|
dropdownItem:SetSelected(true) |
|
|
|
dropdownText = dropdownText and format("%s, %s", dropdownText, dropdownItem.settings.value) or dropdownItem.settings.value |
|
|
|
selectedCount = selectedCount + 1 |
|
|
|
|
|
|
|
if not self.settings.multiSelect then |
|
|
|
|
|
|
|
dropdownText = dropdownText and format("%s, %s", dropdownText, dropdownItem.settings.value) or dropdownItem.settings.value |
|
|
|
|
|
|
|
end |
|
|
|
selectionTable[#selectionTable + 1] = dropdownItem.settings.key |
|
|
|
selectionTable[#selectionTable + 1] = dropdownItem.settings.key |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
self:FireEvent("OnValueChanged", nil, nil, selectionTable) |
|
|
|
self:FireEvent("OnValueChanged", nil, nil, selectionTable) |
|
|
|
|
|
|
|
if self.settings.multiSelect then |
|
|
|
|
|
|
|
dropdownText = string.format("+%d", selectedCount) |
|
|
|
|
|
|
|
end |
|
|
|
self:SetText(dropdownText) |
|
|
|
self:SetText(dropdownText) |
|
|
|
end, |
|
|
|
end, |
|
|
|
|
|
|
|
|
|
|
@ -290,6 +306,7 @@ local methods = { |
|
|
|
|
|
|
|
|
|
|
|
---@param self Diesal.GUI.Object.DropDown |
|
|
|
---@param self Diesal.GUI.Object.DropDown |
|
|
|
ClearFocus = function(self) |
|
|
|
ClearFocus = function(self) |
|
|
|
|
|
|
|
self.dropdownShown = false |
|
|
|
self.dropdown:Hide() |
|
|
|
self.dropdown:Hide() |
|
|
|
end, |
|
|
|
end, |
|
|
|
|
|
|
|
|
|
|
@ -312,6 +329,27 @@ local methods = { |
|
|
|
SetJustifyH = function(self, justify) |
|
|
|
SetJustifyH = function(self, justify) |
|
|
|
self.text:SetJustifyH(justify) |
|
|
|
self.text:SetJustifyH(justify) |
|
|
|
end, |
|
|
|
end, |
|
|
|
|
|
|
|
---@param self Diesal.GUI.Object.DropDown |
|
|
|
|
|
|
|
ShowDropDown = function(self) |
|
|
|
|
|
|
|
self.dropdown:SetFrameStrata("TOOLTIP") |
|
|
|
|
|
|
|
self.dropdown:SetParent(self.frame) |
|
|
|
|
|
|
|
self.dropdown:Show() |
|
|
|
|
|
|
|
self.dropdownShown = true |
|
|
|
|
|
|
|
end, |
|
|
|
|
|
|
|
---@param self Diesal.GUI.Object.DropDown |
|
|
|
|
|
|
|
HideDropDown = function(self) |
|
|
|
|
|
|
|
self.dropdown:Hide() |
|
|
|
|
|
|
|
self.dropdownShown = false |
|
|
|
|
|
|
|
end, |
|
|
|
|
|
|
|
---@param self Diesal.GUI.Object.DropDown |
|
|
|
|
|
|
|
ToggleDropDown = function(self) |
|
|
|
|
|
|
|
print("ToggleDropDown", self.dropdown:IsShown()) |
|
|
|
|
|
|
|
if self.dropdownShown then |
|
|
|
|
|
|
|
self:HideDropDown() |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
self:ShowDropDown() |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
---@class Diesal.GUI.Obeject.DropDown.Settings |
|
|
|
---@class Diesal.GUI.Obeject.DropDown.Settings |
|
|
@ -327,6 +365,8 @@ local methods = { |
|
|
|
|
|
|
|
|
|
|
|
---@class DiesalDropDown : Diesal.GUI.Object.DropDown |
|
|
|
---@class DiesalDropDown : Diesal.GUI.Object.DropDown |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local f = CreateFrame("Button", nil, UIParent) |
|
|
|
|
|
|
|
|
|
|
|
-- ~~| Dropdown Constructor |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
|
-- ~~| Dropdown Constructor |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
|
local function Constructor() |
|
|
|
local function Constructor() |
|
|
|
---@class Diesal.GUI.Object.DropDown : Diesal.GUI.ObjectBase, Diesal.GUI.DropDown.Methods |
|
|
|
---@class Diesal.GUI.Object.DropDown : Diesal.GUI.ObjectBase, Diesal.GUI.DropDown.Methods |
|
|
@ -337,8 +377,11 @@ local function Constructor() |
|
|
|
---@field content Frame |
|
|
|
---@field content Frame |
|
|
|
---@field value string |
|
|
|
---@field value string |
|
|
|
local self = DiesalGUI:Create(Type, true) |
|
|
|
local self = DiesalGUI:Create(Type, true) |
|
|
|
|
|
|
|
self:SetMethods(methods) |
|
|
|
|
|
|
|
self.dropdownShown = true |
|
|
|
|
|
|
|
|
|
|
|
local frame = CreateFrame("Button", nil, UIParent) |
|
|
|
local frame = CreateFrame("Button", nil, UIParent) |
|
|
|
|
|
|
|
frame:SetFrameStrata("TOOLTIP") |
|
|
|
self.frame = frame |
|
|
|
self.frame = frame |
|
|
|
|
|
|
|
|
|
|
|
self.isContainer = true |
|
|
|
self.isContainer = true |
|
|
@ -356,16 +399,16 @@ local function Constructor() |
|
|
|
-- OnValueSelected(event,selectedKey,selectedValue,selectionTable) |
|
|
|
-- OnValueSelected(event,selectedKey,selectedValue,selectionTable) |
|
|
|
-- OnEnter, OnLeave |
|
|
|
-- OnEnter, OnLeave |
|
|
|
-- ~~ Construct ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
|
-- ~~ Construct ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
|
frame:SetScript("OnMouseUp", function(this, button) |
|
|
|
frame:SetScript("OnClick", function(this, button, down) |
|
|
|
if button == "LeftButton" then |
|
|
|
if button == "LeftButton" then |
|
|
|
local dropdown = self.dropdown |
|
|
|
if self.dropdown:IsVisible() then |
|
|
|
local visible = dropdown:IsVisible() |
|
|
|
self.dropdown:Hide() |
|
|
|
DiesalGUI:OnMouse(this, button) |
|
|
|
else |
|
|
|
dropdown[visible and "Hide" or "Show"](dropdown) |
|
|
|
DiesalGUI:OnMouse(this, button) |
|
|
|
|
|
|
|
self.dropdown:Show() |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end) |
|
|
|
self:FireEvent("OnClick", button, down) |
|
|
|
frame:SetScript("OnClick", function(this, ...) |
|
|
|
|
|
|
|
self:FireEvent("OnClick", ...) |
|
|
|
|
|
|
|
end) |
|
|
|
end) |
|
|
|
frame:SetScript("OnEnter", function(this, ...) |
|
|
|
frame:SetScript("OnEnter", function(this, ...) |
|
|
|
self:FireEvent("OnEnter", ...) |
|
|
|
self:FireEvent("OnEnter", ...) |
|
|
@ -382,18 +425,24 @@ local function Constructor() |
|
|
|
text:SetJustifyH("LEFT") |
|
|
|
text:SetJustifyH("LEFT") |
|
|
|
|
|
|
|
|
|
|
|
local dropdown = self:CreateRegion("Frame", "dropdown", frame) |
|
|
|
local dropdown = self:CreateRegion("Frame", "dropdown", frame) |
|
|
|
dropdown:SetFrameStrata("FULLSCREEN_DIALOG") |
|
|
|
dropdown:SetFrameStrata("TOOLTIP") |
|
|
|
|
|
|
|
dropdown:SetFrameLevel(998) |
|
|
|
|
|
|
|
dropdown:SetToplevel(true) |
|
|
|
dropdown:SetPoint("TOPRIGHT", frame, "BOTTOMRIGHT", 0, -2) |
|
|
|
dropdown:SetPoint("TOPRIGHT", frame, "BOTTOMRIGHT", 0, -2) |
|
|
|
dropdown:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, -2) |
|
|
|
dropdown:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, -2) |
|
|
|
dropdown:SetScript("OnShow", function(this) |
|
|
|
dropdown:SetScript("OnShow", function(this) |
|
|
|
self:SetFocus() |
|
|
|
self:SetFocus() |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
dropdown:SetScript("OnHide", function(this) |
|
|
|
|
|
|
|
self.dropdownShown = false |
|
|
|
|
|
|
|
end) |
|
|
|
dropdown:Hide() |
|
|
|
dropdown:Hide() |
|
|
|
|
|
|
|
self.dropdown = dropdown |
|
|
|
|
|
|
|
|
|
|
|
self:CreateRegion("Frame", "content", dropdown) |
|
|
|
self:CreateRegion("Frame", "content", dropdown) |
|
|
|
|
|
|
|
|
|
|
|
-- ~~ Methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
|
-- ~~ Methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
|
self:SetMethods(methods) |
|
|
|
--self:SetMethods(methods) |
|
|
|
--[[ for method, func in pairs(methods) do |
|
|
|
--[[ for method, func in pairs(methods) do |
|
|
|
self[method] = func |
|
|
|
self[method] = func |
|
|
|
end ]] |
|
|
|
end ]] |
|
|
|