2009-08-14 05:09:03 +00:00
|
|
|
|
2016-09-11 10:12:42 +00:00
|
|
|
local myname, ns = ...
|
2009-08-14 05:09:03 +00:00
|
|
|
|
2016-09-11 10:12:42 +00:00
|
|
|
|
|
|
|
local BACKDROP = {
|
2009-08-14 05:09:03 +00:00
|
|
|
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
|
|
|
tile = true,
|
|
|
|
tileSize = 16,
|
|
|
|
edgeSize = 12,
|
|
|
|
insets = { left = 0, right = 0, top = 5, bottom = 5 }
|
|
|
|
}
|
|
|
|
|
2016-09-11 10:12:42 +00:00
|
|
|
|
|
|
|
local function Decrement(self)
|
|
|
|
self:SetValue(self:GetValue() - self:GetValueStep())
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function Increment(self)
|
|
|
|
self:SetValue(self:GetValue() + self:GetValueStep())
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function OnClickUp(self)
|
|
|
|
self:GetParent():Decrement()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function OnClickDown(self)
|
|
|
|
self:GetParent():Increment()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function Sound()
|
|
|
|
PlaySound("UChatScrollButton")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-08-14 05:09:03 +00:00
|
|
|
-- Creates a scrollbar
|
|
|
|
-- Parent is required, offset and step are optional
|
2016-09-11 10:12:42 +00:00
|
|
|
function ns.NewScrollBar(parent, offset, step)
|
2009-08-14 05:09:03 +00:00
|
|
|
local f = CreateFrame("Slider", nil, parent)
|
|
|
|
f:SetWidth(16)
|
|
|
|
|
2016-09-11 10:12:42 +00:00
|
|
|
f:SetPoint("TOP", 0, -16 - (offset or 0))
|
|
|
|
f:SetPoint("BOTTOM", 0, 16 + (offset or 0))
|
|
|
|
f:SetPoint("RIGHT", 0 - (offset or 0), 0)
|
|
|
|
|
|
|
|
f:SetValueStep(step or 1)
|
|
|
|
|
|
|
|
f.Decrement = Decrement
|
|
|
|
f.Increment = Increment
|
2009-08-14 05:09:03 +00:00
|
|
|
|
|
|
|
local up = CreateFrame("Button", nil, f)
|
|
|
|
up:SetPoint("BOTTOM", f, "TOP")
|
2016-09-11 10:12:42 +00:00
|
|
|
up:SetSize(16, 16)
|
2009-08-14 05:09:03 +00:00
|
|
|
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")
|
|
|
|
|
2016-09-11 10:12:42 +00:00
|
|
|
up:SetScript("OnClick", OnClickUp)
|
|
|
|
up:SetScript("PostClick", Sound)
|
2009-08-14 05:09:03 +00:00
|
|
|
|
|
|
|
local down = CreateFrame("Button", nil, f)
|
|
|
|
down:SetPoint("TOP", f, "BOTTOM")
|
2016-09-11 10:12:42 +00:00
|
|
|
down:SetSize(16, 16)
|
2009-08-14 05:09:03 +00:00
|
|
|
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")
|
|
|
|
|
2016-09-11 10:12:42 +00:00
|
|
|
down:SetScript("OnClick", OnClickDown)
|
|
|
|
down:SetScript("PostClick", Sound)
|
2009-08-14 05:09:03 +00:00
|
|
|
|
|
|
|
f:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
|
|
|
|
local thumb = f:GetThumbTexture()
|
2016-09-11 10:12:42 +00:00
|
|
|
thumb:SetSize(16, 24)
|
2009-08-14 05:09:03 +00:00
|
|
|
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
|
2016-09-11 10:12:42 +00:00
|
|
|
if self.Refresh then self:Refresh() end
|
2009-08-14 05:09:03 +00:00
|
|
|
end)
|
|
|
|
|
|
|
|
local border = CreateFrame("Frame", nil, f)
|
|
|
|
border:SetPoint("TOPLEFT", up, -5, 5)
|
|
|
|
border:SetPoint("BOTTOMRIGHT", down, 5, -3)
|
2016-09-11 10:12:42 +00:00
|
|
|
border:SetBackdrop(BACKDROP)
|
|
|
|
local r,g = TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g
|
|
|
|
local b,a = TOOLTIP_DEFAULT_COLOR.b, 0.5
|
|
|
|
border:SetBackdropBorderColor(r,g,b,a)
|
2009-08-14 05:09:03 +00:00
|
|
|
|
|
|
|
return f, up, down, border
|
|
|
|
end
|