This repository was archived by the owner on Jan 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathBarEditTab.lua
More file actions
147 lines (127 loc) · 5.19 KB
/
BarEditTab.lua
File metadata and controls
147 lines (127 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
-- Neuron is a World of Warcraft® user interface addon.
-- Copyright (c) 2017-2021 Britt W. Yazel
-- Copyright (c) 2006-2014 Connor H. Chenoweth
-- This code is licensed under the MIT license (see LICENSE for details)
local _, addonTable = ...
local Neuron = addonTable.Neuron
local NeuronGUI = Neuron.NeuronGUI
local L = LibStub("AceLocale-3.0"):GetLocale("Neuron")
local AceGUI = LibStub("AceGUI-3.0")
local currentTab = "general" --remember which tab we were using between refreshes
local selectedBarType --remember which bar type was selected for creating new bars between refreshes
-----------------------------------------------------------------------------
--------------------------Bar Editor-----------------------------------------
-----------------------------------------------------------------------------
---@param currentBar Bar
---@param tabFrame Frame
function NeuronGUI:BarEditPanel(currentBar, tabFrame)
-------------------------------
--Container for the top Row
local topRow = AceGUI:Create("SimpleGroup")
topRow:SetFullWidth(true)
topRow:SetHeight(50)
topRow:SetAutoAdjustHeight(false)
topRow:SetLayout("Flow")
tabFrame:AddChild(topRow)
-------------------------------
local spacer1 = AceGUI:Create("SimpleGroup")
spacer1:SetWidth(20)
spacer1:SetHeight(40)
spacer1:SetLayout("Fill")
topRow:AddChild(spacer1)
-------------------------------
local barList = {}
for _, bar in pairs(Neuron.bars) do
barList[bar] = bar:GetBarName()
end
--Scroll frame that will contain the Bar List
local barListDropdown = AceGUI:Create("Dropdown")
barListDropdown:SetWidth(180)
barListDropdown:SetLabel("Switch selected bar:")
barListDropdown:SetText(currentBar:GetBarName() or "")
barListDropdown:SetList(barList) --assign the bar type table to the dropdown menu
barListDropdown:SetCallback("OnValueChanged", function(_, _, key) Neuron.Bar.ChangeSelectedBar(key); NeuronGUI:RefreshEditor() end)
topRow:AddChild(barListDropdown)
-------------------------------
local spacer2 = AceGUI:Create("SimpleGroup")
spacer2:SetWidth(20)
spacer2:SetHeight(40)
spacer2:SetLayout("Fill")
topRow:AddChild(spacer2)
-------------------------------
--populate the dropdown menu with available bar types
local barTypes = {}
for class, info in pairs(Neuron.registeredBarData) do
barTypes[class] = info.barLabel
end
local newBarButton
--bar type list dropdown menu
local barTypeDropdown = AceGUI:Create("Dropdown")
barTypeDropdown:SetWidth(180)
barTypeDropdown:SetLabel("Create a new bar:")
if selectedBarType then
barTypeDropdown:SetText(selectedBarType)
else
barTypeDropdown:SetText("- select a bar type -")
end
barTypeDropdown:SetList(barTypes) --assign the bar type table to the dropdown menu
barTypeDropdown:SetCallback("OnValueChanged", function(_, _, key) selectedBarType = key; newBarButton:SetDisabled(false) end)
topRow:AddChild(barTypeDropdown)
-------------------------------
local spacer3 = AceGUI:Create("SimpleGroup")
spacer3:SetWidth(5)
spacer3:SetHeight(40)
spacer3:SetLayout("Fill")
topRow:AddChild(spacer3)
-------------------------------
--Create New Bar button
newBarButton = AceGUI:Create("Button")
newBarButton:SetWidth(120)
newBarButton:SetText("Create")
newBarButton:SetCallback("OnClick", function() if selectedBarType then Neuron.Bar:CreateNewBar(selectedBarType); NeuronGUI:RefreshEditor() end end)
if selectedBarType then
newBarButton:SetDisabled(false)
else
newBarButton:SetDisabled(true) --we want to disable it until they chose a bar type in the dropdown
end
topRow:AddChild(newBarButton)
---------------------------------
------ Settings Tab Group -------
---------------------------------
--Tab group that will contain all of our settings to configure
local innerTabFrame = AceGUI:Create("TabGroup")
innerTabFrame:SetLayout("Fill")
innerTabFrame:SetFullHeight(true)
innerTabFrame:SetFullWidth(true)
--only show the states tab if the bar is an ActionBar
if currentBar.class=="ActionBar" then
innerTabFrame:SetTabs({{text="General Configuration", value="general"}, {text="Bar States", value="states"}, {text="Bar Visibility", value="visibility"}})
else
innerTabFrame:SetTabs({{text="General Configuration", value="general"}, {text="Bar Visibility", value="visibility"}})
if currentTab == "states" then
currentTab = "general"
end
end
innerTabFrame:SetCallback("OnGroupSelected", function(callbackFrame, _, value) NeuronGUI:SelectInnerBarTab(currentBar, callbackFrame, value) end)
tabFrame:AddChild(innerTabFrame)
innerTabFrame:SelectTab(currentTab)
end
-----------------------------------------------------------------------------
----------------------Inner Tab Frame----------------------------------------
-----------------------------------------------------------------------------
---@param bar Bar
---@param tabFrame Frame
---@param value "general"|"states"|"visibility"
function NeuronGUI:SelectInnerBarTab(bar, tabFrame, value)
tabFrame:ReleaseChildren()
if value == "general" then
NeuronGUI:GeneralConfigPanel(bar, tabFrame)
currentTab = "general"
elseif value == "states" then
NeuronGUI:BarStatesPanel(bar, tabFrame)
currentTab = "states"
elseif value == "visibility" then
NeuronGUI:BarVisibilityPanel(bar, tabFrame)
currentTab = "visibility"
end
end