Skip to content

Commit

Permalink
fix(theme): finish widget highlight by class color
Browse files Browse the repository at this point in the history
  • Loading branch information
ffainy committed Jun 10, 2022
1 parent d1ad15e commit c4e3989
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
43 changes: 28 additions & 15 deletions core/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,18 @@ do
end

local function Option_OnClick(self)
local classColor = _G.FREE_ADB.WidgetHighlightClassColor
local newColor = _G.FREE_ADB.WidgetHighlightColor

PlaySound(_G.SOUNDKIT.GS_TITLE_OPTION_OK)
local opt = self.__owner.options
for i = 1, #opt do
if self == opt[i] then
opt[i]:SetBackdropColor(C.r, C.g, C.b, 0.25)
if classColor then
opt[i]:SetBackdropColor(C.r, C.g, C.b, 0.25)
else
opt[i]:SetBackdropColor(newColor.r, newColor.g, newColor.b, 0.25)
end
opt[i].selected = true
else
opt[i]:SetBackdropColor(0.1, 0.1, 0.1, 0.25)
Expand Down Expand Up @@ -1138,10 +1145,6 @@ do
return
end

local gradStyle = _G.FREE_ADB.GradientStyle
local color = _G.FREE_ADB.ButtonBackdropColor
local alpha = _G.FREE_ADB.ButtonBackdropAlpha

local classColor = _G.FREE_ADB.WidgetHighlightClassColor
local newColor = _G.FREE_ADB.WidgetHighlightColor

Expand All @@ -1161,11 +1164,6 @@ do
end

local function Button_OnLeave(self)
local gradStyle = _G.FREE_ADB.GradientStyle
local color = _G.FREE_ADB.ButtonBackdropColor
local alpha = _G.FREE_ADB.ButtonBackdropAlpha


self.__bg:SetBackdropColor(0, 0, 0, 0.25)
F.SetBorderColor(self.__bg)

Expand Down Expand Up @@ -1274,11 +1272,19 @@ do
F.CreateSD(bg)
self.bg = bg

local classColor = _G.FREE_ADB.WidgetHighlightClassColor
local newColor = _G.FREE_ADB.WidgetHighlightColor

self:SetHighlightTexture(C.Assets.Texture.Backdrop)
local hl = self:GetHighlightTexture()
hl:ClearAllPoints()
hl:SetInside(bg)
hl:SetVertexColor(C.r, C.g, C.b, 0.25)

if classColor then
hl:SetVertexColor(C.r, C.g, C.b, 0.25)
else
hl:SetVertexColor(newColor.r, newColor.g, newColor.b, 0.25)
end
end

function F:ResetTabAnchor()
Expand Down Expand Up @@ -1421,7 +1427,14 @@ do
function F:Texture_OnEnter()
if self:IsEnabled() then
if self.__texture then
self.__texture:SetVertexColor(C.r, C.g, C.b)
local classColor = _G.FREE_ADB.WidgetHighlightClassColor
local newColor = _G.FREE_ADB.WidgetHighlightColor

if classColor then
self.__texture:SetVertexColor(C.r, C.g, C.b)
else
self.__texture:SetVertexColor(newColor.r, newColor.g, newColor.b)
end
end
end
end
Expand Down Expand Up @@ -1688,7 +1701,7 @@ do
self:SetBackdrop(nil)
F.StripTextures(self)

local bg = F.CreateBDFrame(self, 0.25)
local bg = F.CreateBDFrame(self, 0.25, true)
bg:SetPoint('TOPLEFT', 14, -2)
bg:SetPoint('BOTTOMRIGHT', -15, 3)
F.SetBorderColor(bg)
Expand All @@ -1712,9 +1725,9 @@ do
bar:SetStatusBarTexture(gradStyle and gradTex or normTex)

if classColor then
bar:SetStatusBarColor(C.r, C.g, C.b, 0.45)
bar:SetStatusBarColor(C.r, C.g, C.b, 0.85)
else
bar:SetStatusBarColor(newColor.r, newColor.g, newColor.b, 0.45)
bar:SetStatusBarColor(newColor.r, newColor.g, newColor.b, 0.85)
end

if vertical then
Expand Down
6 changes: 4 additions & 2 deletions gui/extra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ end

local function CreateCheckbox(parent, offset, key, value, text, func, tip)
local box = F.CreateCheckbox(parent.child, true)
box:SetSize(20, 20)
box:SetSize(18, 18)
box:SetHitRectInsets(-5, -5, -5, -5)
box:SetPoint('TOPLEFT', 10, offset)
F.CreateFS(box, C.Assets.Font.Regular, 12, nil, text, nil, true, 'LEFT', 22, 0)
box.label = F.CreateFS(box, C.Assets.Font.Regular, 12, nil, text, nil, true)
box.label:SetPoint('LEFT', box, 'RIGHT', 4, 0)

box:SetChecked(C.DB[key][value])
box.__value = value
Expand All @@ -234,6 +235,7 @@ end

local function CreateColorSwatch(parent, value, text, defaultV, offset, x, y)
local swatch = F.CreateColorSwatch(parent, text, value)
swatch:SetSize(22, 14)
swatch.__default = defaultV

if x and y then
Expand Down
8 changes: 7 additions & 1 deletion gui/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,17 @@ local function Slider_OnValueChanged(self, v)
end

local function updateDropdownSelection(self)
local classColor = _G.FREE_ADB.WidgetHighlightClassColor
local newColor = _G.FREE_ADB.WidgetHighlightColor
local dd = self.__owner
for i = 1, #dd.__options do
local option = dd.options[i]
if i == UpdateValue(dd.__key, dd.__value) then
option:SetBackdropColor(C.r, C.g, C.b, 0.25)
if classColor then
option:SetBackdropColor(C.r, C.g, C.b, 0.25)
else
option:SetBackdropColor(newColor.r, newColor.g, newColor.b, 0.25)
end
option.selected = true
else
option:SetBackdropColor(0.1, 0.1, 0.1, 0.25)
Expand Down

0 comments on commit c4e3989

Please sign in to comment.