-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui_utility.lua
66 lines (53 loc) · 1.63 KB
/
ui_utility.lua
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
-- Helper functions to make UI code less verbose
local OUR_NAME, profiler = ...
if not profiler.ui then
profiler.ui = {}
end
local ui = profiler.ui
if not ui.utility then
ui.utility = {}
end
-- Colors and texture
function ui.utility.edgecolor(frame, color)
-- ...yeah. Switch to file edge textures at some point.
local left = frame:CreateTexture(nil)
left:SetPoint("topleft", -1, 1)
left:SetPoint("bottomleft", -1, -1)
left:SetWidth(1)
left:SetTexture(unpack(color))
frame.borderleft = left
local top = frame:CreateTexture(nil)
top:SetPoint("topleft", -1, 1)
top:SetPoint("topright", 1, 1)
top:SetHeight(1)
top:SetTexture(unpack(color))
frame.bordertop = top
local right = frame:CreateTexture(nil)
right:SetPoint("topright", 1, 1)
right:SetPoint("bottomright", 1, -1)
right:SetWidth(1)
right:SetTexture(unpack(color))
frame.borderright = right
local bottom = frame:CreateTexture(nil)
bottom:SetPoint("bottomleft", -1, -1)
bottom:SetPoint("bottomright", 1, -1)
bottom:SetHeight(1)
bottom:SetTexture(unpack(color))
frame.borderbottom = bottom
end
local edgecolor = ui.utility.edgecolor
function ui.utility.bgcolor(frame, bg, edge)
local texture = frame:CreateTexture(nil, "MEDIUM")
texture:SetAllPoints(true)
texture:SetTexture(unpack(bg))
frame.texture = texture
if edge then edgecolor(frame, edge) end
return texture
end
local bgcolor = ui.utility.bgcolor
-- Elements
function ui.utility.box(parent, bg, name)
local frame = CreateFrame("Frame", name, parent)
if bg then bgcolor(frame, bg) end
return frame
end