Redesigned dropdowns
This commit is contained in:
parent
9423171d54
commit
cfdef3cc26
2 changed files with 36 additions and 24 deletions
|
|
@ -44,8 +44,9 @@ local function CreateFlatEditBox(name, parent, width)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ─── Helper: Create a flat dark dropdown button matching the blocky design ──
|
-- ─── Helper: Create a flat dark dropdown button matching the blocky design ──
|
||||||
|
-- Shared globally so other files (UI.lua) can reuse it.
|
||||||
|
|
||||||
local function CreateFlatDropdown(name, parent, width)
|
function AltSystem.CreateFlatDropdown(name, parent, width)
|
||||||
local btn = CreateFrame("Button", name, parent, "BackdropTemplate")
|
local btn = CreateFrame("Button", name, parent, "BackdropTemplate")
|
||||||
btn:SetSize(width, 28)
|
btn:SetSize(width, 28)
|
||||||
btn:SetBackdrop({
|
btn:SetBackdrop({
|
||||||
|
|
@ -107,12 +108,12 @@ local function CreateSkillRowFrame(index)
|
||||||
row.nameContainer = nameContainer
|
row.nameContainer = nameContainer
|
||||||
|
|
||||||
-- Level Dropdown (flat dark style)
|
-- Level Dropdown (flat dark style)
|
||||||
local levelDropdown = CreateFlatDropdown("AltSystemSkillLevel" .. index, row, LEVEL_WIDTH)
|
local levelDropdown = AltSystem.CreateFlatDropdown("AltSystemSkillLevel" .. index, row, LEVEL_WIDTH)
|
||||||
levelDropdown:SetPoint("LEFT", nameContainer, "RIGHT", 12, 0)
|
levelDropdown:SetPoint("LEFT", nameContainer, "RIGHT", 12, 0)
|
||||||
row.levelDropdown = levelDropdown
|
row.levelDropdown = levelDropdown
|
||||||
|
|
||||||
-- Value Dropdown (flat dark style)
|
-- Value Dropdown (flat dark style)
|
||||||
local valueDropdown = CreateFlatDropdown("AltSystemSkillValue" .. index, row, VALUE_WIDTH)
|
local valueDropdown = AltSystem.CreateFlatDropdown("AltSystemSkillValue" .. index, row, VALUE_WIDTH)
|
||||||
valueDropdown:SetPoint("LEFT", levelDropdown, "RIGHT", 8, 0)
|
valueDropdown:SetPoint("LEFT", levelDropdown, "RIGHT", 8, 0)
|
||||||
row.valueDropdown = valueDropdown
|
row.valueDropdown = valueDropdown
|
||||||
|
|
||||||
|
|
|
||||||
53
UI.lua
53
UI.lua
|
|
@ -29,7 +29,7 @@ local function BuildSkillOptions()
|
||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Helper: Create a modern dropdown (WowStyle1DropdownTemplate)
|
-- Helper: Create a flat dark dropdown with optional label (reuses shared CreateFlatDropdown)
|
||||||
local function CreateDropdown(parent, name, labelText, options, defaultIndex, onSelect, labelFont)
|
local function CreateDropdown(parent, name, labelText, options, defaultIndex, onSelect, labelFont)
|
||||||
local container = CreateFrame("Frame", nil, parent)
|
local container = CreateFrame("Frame", nil, parent)
|
||||||
container:SetHeight(ROW_HEIGHT)
|
container:SetHeight(ROW_HEIGHT)
|
||||||
|
|
@ -44,28 +44,32 @@ local function CreateDropdown(parent, name, labelText, options, defaultIndex, on
|
||||||
|
|
||||||
local selectedIndex = defaultIndex or 1
|
local selectedIndex = defaultIndex or 1
|
||||||
|
|
||||||
local dropdown = CreateFrame("DropdownButton", name, container, "WowStyle1DropdownTemplate")
|
local dropdown = AltSystem.CreateFlatDropdown(name, container, 190)
|
||||||
if label then
|
if label then
|
||||||
dropdown:SetPoint("RIGHT", container, "RIGHT", 0, 0)
|
dropdown:SetPoint("RIGHT", container, "RIGHT", 0, 0)
|
||||||
else
|
else
|
||||||
dropdown:SetPoint("LEFT", container, "LEFT", 0, 0)
|
dropdown:SetPoint("LEFT", container, "LEFT", 0, 0)
|
||||||
end
|
end
|
||||||
dropdown:SetWidth(190)
|
|
||||||
|
|
||||||
dropdown:SetupMenu(function(dropdown, rootDescription)
|
-- Set initial label text
|
||||||
|
if options[selectedIndex] then
|
||||||
|
dropdown.label:SetText(options[selectedIndex].text)
|
||||||
|
end
|
||||||
|
|
||||||
|
dropdown:SetupMenu(function(owner, rootDescription)
|
||||||
for i, option in ipairs(options) do
|
for i, option in ipairs(options) do
|
||||||
rootDescription:CreateRadio(
|
rootDescription:CreateRadio(
|
||||||
option.text,
|
option.text,
|
||||||
function(data)
|
function()
|
||||||
return data == selectedIndex
|
return i == selectedIndex
|
||||||
end,
|
end,
|
||||||
function(data)
|
function()
|
||||||
selectedIndex = data
|
selectedIndex = i
|
||||||
|
dropdown.label:SetText(option.text)
|
||||||
if onSelect then
|
if onSelect then
|
||||||
onSelect(data, options[data])
|
onSelect(i, option)
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
i
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
@ -74,6 +78,9 @@ local function CreateDropdown(parent, name, labelText, options, defaultIndex, on
|
||||||
return selectedIndex
|
return selectedIndex
|
||||||
end, function(idx)
|
end, function(idx)
|
||||||
selectedIndex = idx
|
selectedIndex = idx
|
||||||
|
if options[idx] then
|
||||||
|
dropdown.label:SetText(options[idx].text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -573,24 +580,28 @@ function AltSystem:RefreshSkillDropdown()
|
||||||
-- Rebuild the dropdown menu with the new skill list
|
-- Rebuild the dropdown menu with the new skill list
|
||||||
if AltSystem.SkillDropdown then
|
if AltSystem.SkillDropdown then
|
||||||
local skillOptions = BuildSkillOptions()
|
local skillOptions = BuildSkillOptions()
|
||||||
AltSystem.SkillDropdown:SetupMenu(function(dropdown, rootDescription)
|
-- Update the displayed label text
|
||||||
|
if skillOptions[newIndex] then
|
||||||
|
AltSystem.SkillDropdown.label:SetText(skillOptions[newIndex].text)
|
||||||
|
end
|
||||||
|
AltSystem.SkillDropdown:SetupMenu(function(owner, rootDescription)
|
||||||
for i, option in ipairs(skillOptions) do
|
for i, option in ipairs(skillOptions) do
|
||||||
rootDescription:CreateRadio(
|
rootDescription:CreateRadio(
|
||||||
option.text,
|
option.text,
|
||||||
function(data)
|
function()
|
||||||
return data == AltSystem.State.selectedSkillIndex
|
return i == AltSystem.State.selectedSkillIndex
|
||||||
end,
|
end,
|
||||||
function(data)
|
function()
|
||||||
AltSystem.State.selectedSkillIndex = data
|
AltSystem.State.selectedSkillIndex = i
|
||||||
AltSystem.State.selectedSkillName = AltSystem.Data.Skills[data] and AltSystem.Data.Skills[data].name or nil
|
AltSystem.State.selectedSkillName = AltSystem.Data.Skills[i] and AltSystem.Data.Skills[i].name or nil
|
||||||
|
AltSystem.SkillDropdown.label:SetText(option.text)
|
||||||
if AltSystem.SetSkillIndex then
|
if AltSystem.SetSkillIndex then
|
||||||
AltSystem.SetSkillIndex(data)
|
AltSystem.SetSkillIndex(i)
|
||||||
end
|
end
|
||||||
if AltSystem.UpdateSkillWarning then
|
if AltSystem.UpdateSkillWarning then
|
||||||
AltSystem.UpdateSkillWarning(data)
|
AltSystem.UpdateSkillWarning(i)
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
i
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue