-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathWidgets.lua
186 lines (160 loc) · 6.09 KB
/
Widgets.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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
local Recount = _G.Recount
local revision = tonumber(string.sub("$Revision: 1563 $", 12, -3))
if Recount.Version < revision then
Recount.Version = revision
end
local _G = _G
local CreateFrame = CreateFrame
local UIParent = UIParent
function Recount:CreateFrame(Name, Title, Height, Width, ShowFunc, HideFunc)
local theFrame = CreateFrame("Frame", Name, UIParent, BackdropTemplateMixin and "BackdropTemplate")
theFrame:ClearAllPoints()
theFrame:SetPoint("CENTER",UIParent)
theFrame:SetHeight(Height)
theFrame:SetWidth(Width)
theFrame:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
tile = true,
tileSize = 16,
edgeFile = "Interface\\AddOns\\Recount\\textures\\otravi-semi-full-border",
edgeSize = 32,
insets = {left = 1, right = 1, top = 20, bottom = 1},
})
theFrame:SetBackdropBorderColor(1.0, 0.0, 0.0)
theFrame:SetBackdropColor(24 / 255, 24 / 255, 24 / 255)
if Name == "Recount_MainWindow" then
Recount.Colors:RegisterBorder("Window", "Title", theFrame)
Recount.Colors:RegisterBackground("Window", "Background", theFrame)
else
Recount.Colors:RegisterBorder("Other Windows", "Title", theFrame)
Recount.Colors:RegisterBackground("Other Windows", "Background", theFrame)
end
theFrame:EnableMouse(true)
theFrame:SetMovable(true)
theFrame:SetScript("OnMouseDown", function(this, button)
if (not this.isLocked or this.isLocked == 0) and button == "LeftButton" then
Recount:SetWindowTop(this)
this:StartMoving()
this.isMoving = true
end
end)
theFrame:SetScript("OnMouseUp", function(this)
if this.isMoving then
this:StopMovingOrSizing()
this.isMoving = false
if this.SavePosition then
this:SavePosition()
end
end
end)
theFrame.ShowFunc = ShowFunc
theFrame:SetScript("OnShow", function(this)
Recount:SetWindowTop(this)
if this.ShowFunc then
this:ShowFunc()
end
end)
theFrame.HideFunc = HideFunc
theFrame:SetScript("OnHide", function(this)
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", 6, -15)
theFrame.Title:SetTextColor(1.0, 1.0, 1.0, 1.0)
theFrame.Title:SetText(Title)
Recount:AddFontString(theFrame.Title)
if Name == "Recount_MainWindow" then
Recount.Colors:UnregisterItem(theFrame.Title)
Recount.Colors:RegisterFont("Window", "Title Text", theFrame.Title)
else
Recount.Colors:UnregisterItem(theFrame.Title)
Recount.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)
this:GetParent():Hide()
end)
return theFrame
end
function Recount:SetupScrollbar(name)
local Thumb = _G[name.."ScrollBarThumbTexture"]
Thumb:SetTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-Knob")
Thumb:SetVertexColor(1, 0, 0)
Recount.Colors:RegisterTexture("Window", "Title", Thumb)
local Up = _G[name.."ScrollBarScrollUpButton"]
Up:SetNormalTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-ScrollUpButton-Up")
Up:SetPushedTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-ScrollUpButton-Up")
Up:SetDisabledTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-ScrollUpButton-Disabled")
Up:SetHighlightTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-ScrollUpButton-Highlight")
if not Up.Overlay then
Up.Overlay = Up:CreateTexture(nil, "OVERLAY")
Up.Overlay:SetAllPoints(Up)
Up.Overlay:SetTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-ScrollUpButton-Overlay")
Up.Overlay:SetVertexColor(1, 0, 0)
Up.Overlay:SetTexCoord(0.25, 0.75, 0.25, 0.75)
Up.Overlay:SetBlendMode("MOD")
Recount.Colors:RegisterTexture("Window", "Title", Up.Overlay)
end
local Down = _G[name.."ScrollBarScrollDownButton"]
Down:SetNormalTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-ScrollDownButton-Up")
Down:SetPushedTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-ScrollDownButton-Up")
Down:SetDisabledTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-ScrollDownButton-Disabled")
Down:SetHighlightTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-ScrollDownButton-Highlight")
if not Down.Overlay then
Down.Overlay = Up:CreateTexture(nil, "OVERLAY")
Down.Overlay:SetAllPoints(Down)
Down.Overlay:SetTexture("Interface\\AddOns\\Recount\\textures\\scrollbar\\UI-ScrollBar-ScrollDownButton-Overlay")
Down.Overlay:SetVertexColor(1, 0, 0)
Down.Overlay:SetTexCoord(0.25, 0.75, 0.25, 0.75)
Down.Overlay:SetBlendMode("MOD")
Recount.Colors:RegisterTexture("Window", "Title", Down.Overlay)
end
end
function Recount:HideScrollbarElements(name)
local Thumb = _G[name.."ScrollBarThumbTexture"]
local Up = _G[name.."ScrollBarScrollUpButton"]
local Down = _G[name.."ScrollBarScrollDownButton"]
Thumb:Hide()
Up:Hide()
Up:EnableMouse(false)
if Up.Overlay then
Up.Overlay:Hide()
end
Down:Hide()
Down:EnableMouse(false)
if Down.Overlay then
Down.Overlay:Hide()
end
local scrollbar = _G[name.."ScrollBar"]
scrollbar:EnableMouse(false)
end
function Recount:ShowScrollbarElements(name)
local Thumb = _G[name.."ScrollBarThumbTexture"]
local Up = _G[name.."ScrollBarScrollUpButton"]
local Down = _G[name.."ScrollBarScrollDownButton"]
Thumb:Show()
Up:EnableMouse(true)
Up:Show()
if Up.Overlay then
Up.Overlay:Show()
end
Down:EnableMouse(true)
Down:Show()
if Down.Overlay then
Down.Overlay:Show()
end
local scrollbar = _G[name.."ScrollBar"]
scrollbar:EnableMouse(true)
end