forked from ZMOT7S/Spy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWidgets.lua
More file actions
87 lines (79 loc) · 2.8 KB
/
Widgets.lua
File metadata and controls
87 lines (79 loc) · 2.8 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
function Spy:CreateFrame(Name, Title, Height, Width, ShowFunc, HideFunc)
local theFrame = CreateFrame("Frame", Name, UIParent)
theFrame:ClearAllPoints()
theFrame:SetPoint("TOPLEFT", UIParent)
theFrame:SetHeight(Height)
theFrame:SetWidth(Width)
theFrame:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
edgeFile = "Interface\\AddOns\\Spy\\Textures\\title-industrial.tga", edgeSize = 32,
insets = {left = 0, right = 0, top = 31, bottom = 0},
})
if Name == "Spy_MainWindow" then
Spy.Colors:RegisterBorder("Window", "Title", theFrame)
Spy.Colors:RegisterBackground("Window", "Background", theFrame)
else
Spy.Colors:RegisterBorder("Other Windows", "Title", theFrame)
Spy.Colors:RegisterBackground("Other Windows", "Background", theFrame)
end
theFrame:EnableMouse(true)
theFrame:SetMovable(true)
theFrame:SetScript("OnMouseDown",
function()
if (((not this.isLocked) or (this.isLocked == 0)) and (arg1 == "LeftButton")) then
Spy:SetWindowTop(this)
this:StartMoving();
this.isMoving = true;
end
end)
theFrame:SetScript("OnMouseUp",
function()
if (this.isMoving) then
this:StopMovingOrSizing();
this.isMoving = false;
Spy:SaveMainWindowPosition()
end
end)
theFrame.ShowFunc = ShowFunc
theFrame:SetScript("OnShow",
function()
Spy:SetWindowTop(this)
if (this.ShowFunc) then
this:ShowFunc()
end
end)
theFrame.HideFunc = HideFunc
theFrame:SetScript("OnHide",
function()
if (this.isMoving) then
this:StopMovingOrSizing();
this.isMoving = false;
end
if (this.HideFunc) then
this:HideFunc()
end
end)
theFrame.Title = theFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
theFrame.Title:SetPoint("TOPLEFT", theFrame, "TOPLEFT", 8, -16)
theFrame.Title:SetJustifyH("LEFT")
theFrame.Title:SetTextColor(1.0, 1.0, 1.0, 1.0)
theFrame.Title:SetText(Title)
theFrame.Title:SetHeight(Spy.db.profile.MainWindow.TextHeight)
Spy:AddFontString(theFrame.Title)
if Name == "Spy_MainWindow" then
Spy.Colors:UnregisterItem(theFrame.Title)
Spy.Colors:RegisterFont("Window", "Title Text", theFrame.Title)
else
Spy.Colors:UnregisterItem(theFrame.Title)
Spy.Colors:RegisterFont("Other Windows", "Title Text", theFrame.Title)
end
theFrame.CloseButton = CreateFrame("Button", nil, theFrame)
theFrame.CloseButton:SetNormalTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Up.blp")
theFrame.CloseButton:SetPushedTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Down.blp")
theFrame.CloseButton:SetHighlightTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Highlight.blp")
theFrame.CloseButton:SetWidth(20)
theFrame.CloseButton:SetHeight(20)
theFrame.CloseButton:SetPoint("TOPRIGHT", theFrame, "TOPRIGHT", -4, -12)
theFrame.CloseButton:SetScript("OnClick", function() this:GetParent():Hide() end)
return theFrame
end