name/id refactoring, menu refactoring
This commit is contained in:
+14
-6
@@ -6,11 +6,11 @@ private.threads = {}
|
|||||||
public.thread_id = nil
|
public.thread_id = nil
|
||||||
|
|
||||||
function m.LOAD()
|
function m.LOAD()
|
||||||
m.event_frame:SetScript('OnUpdate', m.on_update)
|
m.event_frame:SetScript('OnUpdate', m.UPDATE)
|
||||||
m.event_frame:SetScript('OnEvent', m.on_event)
|
m.event_frame:SetScript('OnEvent', m.EVENT)
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.on_event()
|
function private.EVENT()
|
||||||
for _, listener in m.listeners do
|
for _, listener in m.listeners do
|
||||||
if event == listener.event and not listener.killed then
|
if event == listener.event and not listener.killed then
|
||||||
listener.cb(listener.kill)
|
listener.cb(listener.kill)
|
||||||
@@ -18,7 +18,7 @@ function private.on_event()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.on_update()
|
function private.UPDATE()
|
||||||
for _, listener in m.listeners do
|
for _, listener in m.listeners do
|
||||||
if not aux.util.any(m.listeners, function(l) return not l.killed and l.event == listener.event end) then
|
if not aux.util.any(m.listeners, function(l) return not l.killed and l.event == listener.event end) then
|
||||||
m.event_frame:UnregisterEvent(listener.event)
|
m.event_frame:UnregisterEvent(listener.event)
|
||||||
@@ -42,6 +42,14 @@ function private.on_update()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local id = 0
|
||||||
|
function private.id()
|
||||||
|
id = id + 1
|
||||||
|
return id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function public.kill_listener(listener_id)
|
function public.kill_listener(listener_id)
|
||||||
for _, listener in {m.listeners[listener_id]} do
|
for _, listener in {m.listeners[listener_id]} do
|
||||||
listener.killed = true
|
listener.killed = true
|
||||||
@@ -55,7 +63,7 @@ function public.kill_thread(thread_id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.event_listener(event, cb)
|
function public.event_listener(event, cb)
|
||||||
local listener_id = aux.id()
|
local listener_id = m.id()
|
||||||
m.listeners[listener_id] = { event=event, cb=cb, kill=function(...) if arg.n == 0 or arg[1] then m.kill_listener(listener_id) end end }
|
m.listeners[listener_id] = { event=event, cb=cb, kill=function(...) if arg.n == 0 or arg[1] then m.kill_listener(listener_id) end end }
|
||||||
m.event_frame:RegisterEvent(event)
|
m.event_frame:RegisterEvent(event)
|
||||||
return listener_id
|
return listener_id
|
||||||
@@ -69,7 +77,7 @@ function public.on_next_event(event, callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.thread(k, ...)
|
function public.thread(k, ...)
|
||||||
local thread_id = aux.id()
|
local thread_id = m.id()
|
||||||
m.threads[thread_id] = { k = aux._(k, unpack(arg)) }
|
m.threads[thread_id] = { k = aux._(k, unpack(arg)) }
|
||||||
return thread_id
|
return thread_id
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ end
|
|||||||
|
|
||||||
function public.VARIABLES_LOADED()
|
function public.VARIABLES_LOADED()
|
||||||
do
|
do
|
||||||
local frame = CreateFrame('Frame', 'AuxFrame', UIParent)
|
local frame = CreateFrame('Frame', aux.gui.name(), UIParent)
|
||||||
tinsert(UISpecialFrames, 'AuxFrame')
|
tinsert(UISpecialFrames, 'aux_frame1')
|
||||||
m.gui.set_window_style(frame)
|
m.gui.set_window_style(frame)
|
||||||
frame:SetWidth(768)
|
frame:SetWidth(768)
|
||||||
frame:SetHeight(447)
|
frame:SetHeight(447)
|
||||||
@@ -397,14 +397,6 @@ end
|
|||||||
|
|
||||||
public.huge = 2^100000
|
public.huge = 2^100000
|
||||||
|
|
||||||
do
|
|
||||||
local x = 0
|
|
||||||
function public.id()
|
|
||||||
x = x + 1
|
|
||||||
return x
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function public.log(...)
|
function public.log(...)
|
||||||
local msg = '[aux]'
|
local msg = '[aux]'
|
||||||
for i=1,arg.n do
|
for i=1,arg.n do
|
||||||
|
|||||||
@@ -45,13 +45,18 @@ public.inline_color = aux.index_function(function(self, key)
|
|||||||
return format('|c%02X%02X%02X%02X', unpack(color))
|
return format('|c%02X%02X%02X%02X', unpack(color))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--/run aux.gui.menu('kek', 'kuk', 'kok', function() end)
|
|
||||||
do
|
do
|
||||||
local dropdown
|
local id = 0
|
||||||
|
function public.name()
|
||||||
|
id = id + 1
|
||||||
|
return 'aux_frame'..id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local menu
|
||||||
|
|
||||||
function public.menu(...)
|
function public.menu(...)
|
||||||
local mythis = this
|
|
||||||
this = dropdown
|
|
||||||
UIMenu_Initialize()
|
UIMenu_Initialize()
|
||||||
for i=1,arg.n-1 do
|
for i=1,arg.n-1 do
|
||||||
UIMenu_AddButton(
|
UIMenu_AddButton(
|
||||||
@@ -62,36 +67,16 @@ do
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
dropdown:SetPoint('BOTTOMLEFT', GetCursorPosition())
|
menu:SetPoint('BOTTOMLEFT', GetCursorPosition())
|
||||||
dropdown:Show()
|
menu:Show()
|
||||||
this = mythis
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- function public.menu(...)
|
|
||||||
-- UIDropDownMenu_Initialize(dropdown, function()
|
|
||||||
-- for i=1,arg.n-1 do
|
|
||||||
-- UIDropDownMenu_AddButton{
|
|
||||||
-- text = arg[i],
|
|
||||||
-- value = i,
|
|
||||||
-- func = function()
|
|
||||||
-- return arg[arg.n](this.value)
|
|
||||||
-- end,
|
|
||||||
-- }
|
|
||||||
-- end
|
|
||||||
-- end, 'MENU')
|
|
||||||
-- dropdown:SetPoint('BOTTOMLEFT', GetCursorPosition())
|
|
||||||
-- ToggleDropDownMenu(nil, nil, dropdown, nil, 0, 0)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- function private.initialize_menu()
|
|
||||||
-- dropdown = CreateFrame('Frame', 'aux_frame'..aux.id(), UIParent, 'UIDropDownMenuTemplate')
|
|
||||||
-- dropdown:SetWidth(1)
|
|
||||||
-- dropdown:SetHeight(1)
|
|
||||||
-- dropdown:SetAlpha(0)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
function private.initialize_menu()
|
function private.initialize_menu()
|
||||||
dropdown = CreateFrame('Frame', 'aux_frame'..aux.id(), UIParent, 'UIMenuTemplate')
|
menu = CreateFrame('Frame', m.name(), UIParent, 'UIMenuTemplate')
|
||||||
|
local orig = menu:GetScript('OnShow')
|
||||||
|
menu:SetScript('OnShow', function()
|
||||||
|
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -259,7 +244,7 @@ function public.tab_group(parent, orientation)
|
|||||||
function self:create_tab(text)
|
function self:create_tab(text)
|
||||||
local id = getn(self.tabs) + 1
|
local id = getn(self.tabs) + 1
|
||||||
|
|
||||||
local tab = CreateFrame('Button', 'aux_tab_group'..self.id..'_tab'..id, self.frame)
|
local tab = CreateFrame('Button', m.name(), self.frame)
|
||||||
tab.id = id
|
tab.id = id
|
||||||
tab.group = self
|
tab.group = self
|
||||||
tab:SetHeight(24)
|
tab:SetHeight(24)
|
||||||
@@ -320,11 +305,11 @@ function public.tab_group(parent, orientation)
|
|||||||
|
|
||||||
function self:set_tab(id)
|
function self:set_tab(id)
|
||||||
self.selected = id
|
self.selected = id
|
||||||
self.update_tabs()
|
self:update_tabs()
|
||||||
aux.call(self.on_select, id)
|
aux.call(self.on_select, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.update_tabs()
|
function self:update_tabs()
|
||||||
for _, tab in self.tabs do
|
for _, tab in self.tabs do
|
||||||
if tab.group.selected == tab.id then
|
if tab.group.selected == tab.id then
|
||||||
tab.text:SetTextColor(unpack(m.color.label.enabled))
|
tab.text:SetTextColor(unpack(m.color.label.enabled))
|
||||||
@@ -450,7 +435,7 @@ function public.item(parent)
|
|||||||
local item = CreateFrame('Frame', nil, parent)
|
local item = CreateFrame('Frame', nil, parent)
|
||||||
item:SetWidth(260)
|
item:SetWidth(260)
|
||||||
item:SetHeight(40)
|
item:SetHeight(40)
|
||||||
local btn = CreateFrame('CheckButton', 'aux_frame'..aux.id(), item, 'ActionButtonTemplate')
|
local btn = CreateFrame('CheckButton', m.name(), item, 'ActionButtonTemplate')
|
||||||
item.button = btn
|
item.button = btn
|
||||||
btn:SetPoint('LEFT', 2, .5)
|
btn:SetPoint('LEFT', 2, .5)
|
||||||
btn:SetHighlightTexture(nil)
|
btn:SetHighlightTexture(nil)
|
||||||
@@ -501,7 +486,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function public.dropdown(parent)
|
function public.dropdown(parent)
|
||||||
local dropdown = CreateFrame('Frame', 'aux_frame'..aux.id(), parent, 'UIDropDownMenuTemplate')
|
local dropdown = CreateFrame('Frame', m.name(), parent, 'UIDropDownMenuTemplate')
|
||||||
m.set_content_style(dropdown, 0, 0, 2, 2)
|
m.set_content_style(dropdown, 0, 0, 2, 2)
|
||||||
|
|
||||||
getglobal(dropdown:GetName()..'Left'):Hide()
|
getglobal(dropdown:GetName()..'Left'):Hide()
|
||||||
|
|||||||
@@ -1005,9 +1005,8 @@ local methods = {
|
|||||||
|
|
||||||
function public.CreateAuctionResultsTable(parent, config)
|
function public.CreateAuctionResultsTable(parent, config)
|
||||||
|
|
||||||
local rtName = 'aux_frame'..aux.id()
|
|
||||||
RT_COUNT = RT_COUNT + 1
|
RT_COUNT = RT_COUNT + 1
|
||||||
local rt = CreateFrame('Frame', rtName, parent)
|
local rt = CreateFrame('Frame', nil, parent)
|
||||||
rt.config = config
|
rt.config = config
|
||||||
local numRows = 16
|
local numRows = 16
|
||||||
rt.ROW_HEIGHT = (parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / numRows
|
rt.ROW_HEIGHT = (parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / numRows
|
||||||
@@ -1030,14 +1029,14 @@ function public.CreateAuctionResultsTable(parent, config)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local contentFrame = CreateFrame('Frame', rtName..'Content', rt)
|
local contentFrame = CreateFrame('Frame', nil, rt)
|
||||||
contentFrame:SetPoint('TOPLEFT', 0, 0)
|
contentFrame:SetPoint('TOPLEFT', 0, 0)
|
||||||
contentFrame:SetPoint('BOTTOMRIGHT', -15, 0)
|
contentFrame:SetPoint('BOTTOMRIGHT', -15, 0)
|
||||||
-- contentFrame:SetScript('OnSizeChanged', rt.OnContentSizeChanged)
|
-- contentFrame:SetScript('OnSizeChanged', rt.OnContentSizeChanged)
|
||||||
rt.contentFrame = contentFrame
|
rt.contentFrame = contentFrame
|
||||||
|
|
||||||
-- frame to hold the header columns and the rows
|
-- frame to hold the header columns and the rows
|
||||||
local scrollFrame = CreateFrame('ScrollFrame', rtName..'ScrollFrame', rt, 'FauxScrollFrameTemplate')
|
local scrollFrame = CreateFrame('ScrollFrame', aux.gui.name(), rt, 'FauxScrollFrameTemplate')
|
||||||
scrollFrame:SetScript('OnVerticalScroll', function()
|
scrollFrame:SetScript('OnVerticalScroll', function()
|
||||||
if not rt.scrollDisabled then
|
if not rt.scrollDisabled then
|
||||||
FauxScrollFrame_OnVerticalScroll(rt.ROW_HEIGHT, function() rt:UpdateRows() end)
|
FauxScrollFrame_OnVerticalScroll(rt.ROW_HEIGHT, function() rt:UpdateRows() end)
|
||||||
@@ -1063,7 +1062,7 @@ function public.CreateAuctionResultsTable(parent, config)
|
|||||||
-- create the header cells
|
-- create the header cells
|
||||||
rt.headCells = {}
|
rt.headCells = {}
|
||||||
for i, column_config in rt.config do
|
for i, column_config in rt.config do
|
||||||
local cell = CreateFrame('Button', rtName..'HeadCol'..i, rt.contentFrame)
|
local cell = CreateFrame('Button', nil, rt.contentFrame)
|
||||||
cell:SetHeight(HEAD_HEIGHT)
|
cell:SetHeight(HEAD_HEIGHT)
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
cell:SetPoint('TOPLEFT', 0, 0)
|
cell:SetPoint('TOPLEFT', 0, 0)
|
||||||
@@ -1106,7 +1105,7 @@ function public.CreateAuctionResultsTable(parent, config)
|
|||||||
-- create the rows
|
-- create the rows
|
||||||
rt.rows = {}
|
rt.rows = {}
|
||||||
for i=1, numRows do
|
for i=1, numRows do
|
||||||
local row = CreateFrame('Frame', rtName..'Row'..i, rt.contentFrame)
|
local row = CreateFrame('Frame', nil, rt.contentFrame)
|
||||||
row:SetHeight(rt.ROW_HEIGHT)
|
row:SetHeight(rt.ROW_HEIGHT)
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
row:SetPoint('TOPLEFT', 0, -(HEAD_HEIGHT + HEAD_SPACE))
|
row:SetPoint('TOPLEFT', 0, -(HEAD_HEIGHT + HEAD_SPACE))
|
||||||
|
|||||||
Reference in New Issue
Block a user