module refactoring

This commit is contained in:
Simon Hirsig
2017-11-01 15:01:41 +01:00
parent 9989ceb42f
commit 8823b34904
36 changed files with 669 additions and 646 deletions
+17 -16
View File
@@ -1,8 +1,9 @@
module 'aux.gui'
include 'T'
include 'aux'
local T = require 'T'
M.font = [[Fonts\ARIALN.TTF]]
M.font_size = immutable-{
@@ -11,7 +12,7 @@ M.font_size = immutable-{
large = 18,
}
--function LOAD()
--function handle.LOAD()
-- do
-- local blizzard_backdrop, aux_background, aux_border
--
@@ -25,8 +26,8 @@ M.font_size = immutable-{
-- aux_background:SetAllPoints(DropDownList1Backdrop)
-- blizzard_backdrop = DropDownList1Backdrop:GetBackdrop()
-- hook('ToggleDropDownMenu', function(...)
-- temp(arg)
-- local ret = temp-A(orig.ToggleDropDownMenu(unpack(arg)))
-- T.temp(arg)
-- local ret = T.temp-T.list(orig.ToggleDropDownMenu(unpack(arg)))
-- local dropdown = _G[arg[4] or ''] or this:GetParent()
-- if strfind(dropdown:GetName() or '', '^AuxFrame%d+$') then
-- set_aux_dropdown_style(dropdown)
@@ -37,7 +38,7 @@ M.font_size = immutable-{
-- end)
--
-- function set_aux_dropdown_style(dropdown)
-- DropDownList1Backdrop:SetBackdrop(empty)
-- DropDownList1Backdrop:SetBackdrop(T.empty)
-- aux_border:Show()
-- aux_background:Show()
-- DropDownList1:SetWidth(dropdown:GetWidth() * .9)
@@ -88,19 +89,19 @@ M.font_size = immutable-{
do
local id = 1
function M.get.unique_name()
function M.unique_name()
id = id + 1
return 'AuxFrame' .. id
end
end
do
local menu = CreateFrame('Frame', unique_name, UIParent, 'UIDropDownMenuTemplate')
M.menu = vararg-function(arg)
local menu = CreateFrame('Frame', unique_name(), UIParent, 'UIDropDownMenuTemplate')
M.menu = T.vararg-function(arg)
HideDropDownMenu(1)
UIDropDownMenu_Initialize(menu, function()
for i = 1, getn(arg), 2 do
UIDropDownMenu_AddButton(O('text', arg[i], 'notCheckable', true, 'func', arg[i + 1]))
UIDropDownMenu_AddButton(T.map('text', arg[i], 'notCheckable', true, 'func', arg[i + 1]))
end
end, 'MENU')
ToggleDropDownMenu(1, nil, menu, 'cursor')
@@ -190,11 +191,11 @@ function M.button(parent, text_height)
end
do
local mt = {__index=T}
local mt = {__index=T.acquire()}
function mt.__index:create_tab(text)
local id = getn(self._tabs) + 1
local tab = CreateFrame('Button', unique_name, self._frame)
local tab = CreateFrame('Button', unique_name(), self._frame)
tab.id = id
tab.group = self
tab:SetHeight(24)
@@ -275,7 +276,7 @@ do
local self = {
_frame = parent,
_orientation = orientation,
_tabs = T,
_tabs = T.acquire(),
}
return setmetatable(self, mt)
end
@@ -320,7 +321,7 @@ function M.editbox(parent)
end)
editbox:SetScript('OnChar', function() (this.char or nop)() end)
do
local last_click = O('t', 0)
local last_click = T.map('t', 0)
editbox:SetScript('OnMouseDown', function()
if arg1 == 'RightButton' then
this:SetText('')
@@ -333,7 +334,7 @@ function M.editbox(parent)
if GetTime() - last_click.t < .5 and x == last_click.x and y == last_click.y then
thread(function() editbox:HighlightText() end)
end
wipe(last_click)
T.wipe(last_click)
last_click.t = GetTime()
last_click.x = x
last_click.y = y
@@ -419,7 +420,7 @@ end
function M.item(parent)
local item = CreateFrame('Frame', nil, parent)
set_size(item, 260, 40)
local btn = CreateFrame('CheckButton', unique_name, item, 'ActionButtonTemplate')
local btn = CreateFrame('CheckButton', unique_name(), item, 'ActionButtonTemplate')
item.button = btn
btn:SetPoint('LEFT', 2, .5)
btn:SetHighlightTexture(nil)
@@ -469,7 +470,7 @@ function M.vertical_line(parent, x_offset, top_offset, bottom_offset, inverted_c
end
function M.dropdown(parent)
local dropdown = CreateFrame('Frame', unique_name, parent, 'UIDropDownMenuTemplate')
local dropdown = CreateFrame('Frame', unique_name(), parent, 'UIDropDownMenuTemplate')
set_content_style(dropdown, 0, 0, 4, 4)
_G[dropdown:GetName() .. 'Left']:Hide()