-
Notifications
You must be signed in to change notification settings - Fork 6
/
tekKonfigScroll.lua
80 lines (66 loc) · 2.97 KB
/
tekKonfigScroll.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
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Scroll", 1)
if not lib then return end
lib.bg = {
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true,
tileSize = 16,
edgeSize = 12,
insets = { left = 0, right = 0, top = 5, bottom = 5 }
}
-- Creates a scrollbar
-- Parent is required, offset is optional
function lib.new(parent, offset)
local f = CreateFrame("Slider", nil, parent)
f:SetWidth(16)
f:SetPoint("TOPRIGHT", 0 - (offset or 0), -16 - (offset or 0))
f:SetPoint("BOTTOMRIGHT", 0 - (offset or 0), 16 + (offset or 0))
local up = CreateFrame("Button", nil, f)
up:SetPoint("BOTTOM", f, "TOP")
up:SetWidth(16) up:SetHeight(16)
up:SetNormalTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Up")
up:SetPushedTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Down")
up:SetDisabledTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Disabled")
up:SetHighlightTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Highlight")
up:GetNormalTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
up:GetPushedTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
up:GetDisabledTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
up:GetHighlightTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
up:GetHighlightTexture():SetBlendMode("ADD")
up:SetScript("OnClick", function(self)
local parent = self:GetParent()
parent:SetValue(parent:GetValue() - parent:GetHeight()/2)
PlaySound("UChatScrollButton")
end)
local down = CreateFrame("Button", nil, f)
down:SetPoint("TOP", f, "BOTTOM")
down:SetWidth(16) down:SetHeight(16)
down:SetNormalTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Up")
down:SetPushedTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Down")
down:SetDisabledTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Disabled")
down:SetHighlightTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Highlight")
down:GetNormalTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
down:GetPushedTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
down:GetDisabledTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
down:GetHighlightTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4)
down:GetHighlightTexture():SetBlendMode("ADD")
down:SetScript("OnClick", function(self)
local parent = self:GetParent()
parent:SetValue(parent:GetValue() + parent:GetHeight()/2)
PlaySound("UChatScrollButton")
end)
f:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
local thumb = f:GetThumbTexture()
thumb:SetWidth(16) thumb:SetHeight(24)
thumb:SetTexCoord(1/4, 3/4, 1/8, 7/8)
f:SetScript("OnValueChanged", function(self, value)
local min, max = self:GetMinMaxValues()
if value == min then up:Disable() else up:Enable() end
if value == max then down:Disable() else down:Enable() end
end)
local border = CreateFrame("Frame", nil, f)
border:SetPoint("TOPLEFT", up, -5, 5)
border:SetPoint("BOTTOMRIGHT", down, 5, -3)
border:SetBackdrop(lib.bg)
border:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b, 0.5)
return f, up, down, border
end