Skip to content

Commit

Permalink
Update APIs, get rid of pixel dots
Browse files Browse the repository at this point in the history
  • Loading branch information
siweia committed Aug 6, 2020
1 parent a1edc78 commit 3538fbc
Showing 1 changed file with 34 additions and 63 deletions.
97 changes: 34 additions & 63 deletions Interface/AddOns/NDui/Core/Functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ do
local thumb = GrabScrollBarElement(self, "ThumbTexture") or GrabScrollBarElement(self, "thumbTexture") or self.GetThumbTexture and self:GetThumbTexture()
if thumb then
thumb:SetAlpha(0)
thumb:SetWidth(17)
thumb:SetWidth(16)
self.thumb = thumb

local bg = B.CreateBDFrame(self, 0, true)
Expand All @@ -904,24 +904,19 @@ do
local frameName = self.GetName and self:GetName()
local down = self.Button or frameName and (_G[frameName.."Button"] or _G[frameName.."_Button"])

down:ClearAllPoints()
down:SetPoint("RIGHT", -18, 2)
B.ReskinArrow(down, "down")
down:SetSize(20, 20)

local bg = B.CreateBDFrame(self, 0, true)
bg:SetPoint("TOPLEFT", 16, -4)
bg:SetPoint("BOTTOMRIGHT", -18, 8)

down:ClearAllPoints()
down:SetPoint("RIGHT", bg, -2, 0)
B.ReskinArrow(down, "down")
end

-- Handle close button
function B:Texture_OnEnter()
if self:IsEnabled() then
if self.pixels then
for _, pixel in pairs(self.pixels) do
pixel:SetVertexColor(cr, cg, cb)
end
elseif self.bg then
if self.bg then
self.bg:SetBackdropColor(cr, cg, cb, .25)
else
self.__texture:SetVertexColor(cr, cg, cb)
Expand All @@ -930,19 +925,15 @@ do
end

function B:Texture_OnLeave()
if self.pixels then
for _, pixel in pairs(self.pixels) do
pixel:SetVertexColor(1, 1, 1)
end
elseif self.bg then
if self.bg then
self.bg:SetBackdropColor(0, 0, 0, .25)
else
self.__texture:SetVertexColor(1, 1, 1)
end
end

function B:ReskinClose(a1, p, a2, x, y)
self:SetSize(17, 17)
self:SetSize(16, 16)

if not a1 then
self:SetPoint("TOPRIGHT", -6, -6)
Expand All @@ -961,15 +952,10 @@ do
dis:SetDrawLayer("OVERLAY")
dis:SetAllPoints()

self.pixels = {}
for i = 1, 2 do
local tex = self:CreateTexture()
tex:SetColorTexture(1, 1, 1)
tex:SetSize(11, 2)
tex:SetPoint("CENTER")
tex:SetRotation(rad((i-1/2)*90))
tinsert(self.pixels, tex)
end
local tex = self:CreateTexture()
tex:SetTexture(DB.closeTex)
tex:SetAllPoints()
self.__texture = tex

self:HookScript("OnEnter", B.Texture_OnEnter)
self:HookScript("OnLeave", B.Texture_OnLeave)
Expand All @@ -995,15 +981,19 @@ do
B.ReskinInput = B.ReskinEditBox -- Deprecated

-- Handle arrows
local direcIndex = {
["up"] = DB.arrowUp,
["down"] = DB.arrowDown,
["left"] = DB.arrowLeft,
["right"] = DB.arrowRight,
local arrowDegree = {
["up"] = 0,
["down"] = 180,
["left"] = 90,
["right"] = -90,
}
function B:SetupArrow(direction)
self:SetTexture(DB.ArrowUp)
self:SetRotation(rad(arrowDegree[direction]))
end

function B:ReskinArrow(direction)
self:SetSize(17, 17)
self:SetSize(16, 16)
B.Reskin(self, true)

self:SetDisabledTexture(DB.bdTex)
Expand All @@ -1013,9 +1003,8 @@ do
dis:SetAllPoints()

local tex = self:CreateTexture(nil, "ARTWORK")
tex:SetTexture(direcIndex[direction])
tex:SetSize(8, 8)
tex:SetPoint("CENTER")
tex:SetAllPoints()
B.SetupArrow(tex, direction)
self.__texture = tex

self:HookScript("OnEnter", B.Texture_OnEnter)
Expand All @@ -1026,9 +1015,9 @@ do
B.StripTextures(self)
B.Reskin(self)
self.Text:SetPoint("CENTER")
self.Icon:SetTexture(DB.arrowRight)
self.Icon:SetPoint("RIGHT", self, "RIGHT", -5, 0)
self.Icon:SetSize(8, 8)
B.SetupArrow(self.Icon, "right")
self.Icon:SetPoint("RIGHT")
self.Icon:SetSize(14, 14)
end

function B:ReskinNavBar()
Expand All @@ -1045,8 +1034,8 @@ do
B.Reskin(overflowButton, true)

local tex = overflowButton:CreateTexture(nil, "ARTWORK")
tex:SetTexture(DB.arrowLeft)
tex:SetSize(8, 8)
B.SetupArrow(tex, "left")
tex:SetSize(14, 14)
tex:SetPoint("CENTER")
overflowButton.__texture = tex

Expand Down Expand Up @@ -1167,37 +1156,19 @@ do
for _, name in next, buttonNames do
local button = self[name]
if button then
button:SetSize(17, 17)
button:SetSize(16, 16)
button:ClearAllPoints()
button:SetPoint("CENTER", -3, 0)
B.Reskin(button)

button.pixels = {}

local tex = button:CreateTexture()
tex:SetColorTexture(1, 1, 1)
tex:SetSize(11, 2)
tex:SetPoint("CENTER")
tex:SetRotation(math.rad(45))
tinsert(button.pixels, tex)

local hline = button:CreateTexture()
hline:SetColorTexture(1, 1, 1)
hline:SetSize(7, 2)
tinsert(button.pixels, hline)

local vline = button:CreateTexture()
vline:SetColorTexture(1, 1, 1)
vline:SetSize(2, 7)
tinsert(button.pixels, vline)

tex:SetAllPoints()
if name == "MaximizeButton" then
hline:Point("TOPRIGHT", -4, -4)
vline:Point("TOPRIGHT", -4, -4)
B.SetupArrow(tex, "up")
else
hline:Point("BOTTOMLEFT", 4, 4)
vline:Point("BOTTOMLEFT", 4, 4)
B.SetupArrow(tex, "down")
end
button.__texture = tex

button:SetScript("OnEnter", B.Texture_OnEnter)
button:SetScript("OnLeave", B.Texture_OnLeave)
Expand Down

0 comments on commit 3538fbc

Please sign in to comment.