Created
September 25, 2017 11:41
-
-
Save Road-block/40293af698261a202f311f398eccbef2 to your computer and use it in GitHub Desktop.
pfUI scrollbuttons patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
child.deco_up = CreateFrame("Button", nil, child) | |
child.deco_up:SetPoint("TOPLEFT", child, "TOPLEFT", -4, 4) | |
child.deco_up:SetPoint("BOTTOMRIGHT", child, "TOPRIGHT", 4, -spacing) | |
child.deco_up:SetFrameStrata("DIALOG") | |
child.deco_up:SetFrameLevel(128) | |
child.deco_up:SetScript("OnClick", function() | |
local scroll = this:GetParent() | |
local current = scroll:GetVerticalScroll() | |
local new = current - 25 | |
local max = scroll:GetVerticalScrollRange() + spacing | |
if max > spacing then | |
if new < 0 then | |
scroll:SetVerticalScroll(0) | |
elseif new > max then | |
scroll:SetVerticalScroll(max) | |
else | |
scroll:SetVerticalScroll(new) | |
end | |
end | |
scroll:UpdateScrollState() | |
end) | |
child.deco_up.fader = child.deco_up:CreateTexture("OVERLAY") | |
child.deco_up.fader:SetTexture(1,1,1,1) | |
child.deco_up.fader:SetGradientAlpha("VERTICAL", 0, 0, 0, 0, 0, 0, 0, 1) | |
child.deco_up.fader:SetAllPoints(child.deco_up) | |
child.deco_up_indicator = CreateFrame("Frame", nil, child.deco_up) | |
child.deco_up_indicator:Hide() | |
child.deco_up_indicator:SetPoint("TOP", child.deco_up, "TOP", 0, -6) | |
child.deco_up_indicator:SetHeight(12) | |
child.deco_up_indicator:SetWidth(12) | |
child.deco_up_indicator.modifier = 0.03 | |
child.deco_up_indicator:SetScript("OnUpdate", function() | |
local alpha = this:GetAlpha() | |
if alpha >= .75 then | |
this.modifier = -0.03 | |
elseif alpha <= .25 then | |
this.modifier = 0.03 | |
end | |
this:SetAlpha(alpha + this.modifier) | |
end) | |
child.deco_up_indicator.tex = child.deco_up_indicator:CreateTexture("OVERLAY") | |
child.deco_up_indicator.tex:SetTexture("Interface\\AddOns\\pfUI\\img\\up") | |
child.deco_up_indicator.tex:SetAllPoints(child.deco_up_indicator) | |
child.deco_down = CreateFrame("Button", nil, child) | |
child.deco_down:SetPoint("BOTTOMLEFT", child, "BOTTOMLEFT", -4, -4) | |
child.deco_down:SetPoint("TOPRIGHT", child, "BOTTOMRIGHT", 4, spacing) | |
child.deco_down:SetFrameStrata("DIALOG") | |
child.deco_down:SetFrameLevel(128) | |
child.deco_down:SetScript("OnClick", function() | |
local scroll = this:GetParent() | |
local current = scroll:GetVerticalScroll() | |
local new = current + 25 | |
local max = scroll:GetVerticalScrollRange() + spacing | |
if max > spacing then | |
if new < 0 then | |
scroll:SetVerticalScroll(0) | |
elseif new > max then | |
scroll:SetVerticalScroll(max) | |
else | |
scroll:SetVerticalScroll(new) | |
end | |
end | |
scroll:UpdateScrollState() | |
end) | |
child.deco_down.fader = child.deco_down:CreateTexture("OVERLAY") | |
child.deco_down.fader:SetTexture(1,1,1,1) | |
child.deco_down.fader:SetGradientAlpha("VERTICAL", 0, 0, 0, 1, 0, 0, 0, 0) | |
child.deco_down.fader:SetAllPoints(child.deco_down) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment