Skip to content

Commit

Permalink
Add scaling to all action bars
Browse files Browse the repository at this point in the history
  • Loading branch information
ls- committed May 8, 2023
1 parent 38755e8 commit 39163a4
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 9 deletions.
13 changes: 13 additions & 0 deletions ls_UI/core/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,7 @@ D.profile = {
width = 32,
height = 0,
spacing = 4,
scale = 1,
visibility = "[petbattle] hide; show",
visible = true,
x_growth = "RIGHT",
Expand Down Expand Up @@ -2004,6 +2005,7 @@ D.profile = {
width = 32,
height = 0,
spacing = 4,
scale = 1,
visibility = "[vehicleui][petbattle][overridebar][possessbar] hide; show",
visible = true,
x_growth = "RIGHT",
Expand Down Expand Up @@ -2054,6 +2056,7 @@ D.profile = {
width = 32,
height = 0,
spacing = 4,
scale = 1,
visibility = "[vehicleui][petbattle][overridebar][possessbar] hide; show",
visible = true,
x_growth = "RIGHT",
Expand Down Expand Up @@ -2104,6 +2107,7 @@ D.profile = {
width = 32,
height = 0,
spacing = 4,
scale = 1,
visibility = "[vehicleui][petbattle][overridebar][possessbar] hide; show",
visible = true,
x_growth = "LEFT",
Expand Down Expand Up @@ -2154,6 +2158,7 @@ D.profile = {
width = 32,
height = 0,
spacing = 4,
scale = 1,
visibility = "[vehicleui][petbattle][overridebar][possessbar] hide; show",
visible = true,
x_growth = "LEFT",
Expand Down Expand Up @@ -2204,6 +2209,7 @@ D.profile = {
width = 32,
height = 0,
spacing = 4,
scale = 1,
visibility = "[vehicleui][petbattle][overridebar][possessbar] hide; show",
visible = false,
x_growth = "RIGHT",
Expand Down Expand Up @@ -2254,6 +2260,7 @@ D.profile = {
width = 32,
height = 0,
spacing = 4,
scale = 1,
visibility = "[vehicleui][petbattle][overridebar][possessbar] hide; show",
visible = false,
x_growth = "RIGHT",
Expand Down Expand Up @@ -2304,6 +2311,7 @@ D.profile = {
width = 32,
height = 0,
spacing = 4,
scale = 1,
visibility = "[vehicleui][petbattle][overridebar][possessbar] hide; show",
visible = false,
x_growth = "RIGHT",
Expand Down Expand Up @@ -2354,6 +2362,7 @@ D.profile = {
width = 24,
height = 0,
spacing = 4,
scale = 1,
visibility = "[pet,nopetbattle,novehicleui,nooverridebar,nopossessbar] show; hide",
visible = true,
x_growth = "RIGHT",
Expand Down Expand Up @@ -2390,6 +2399,7 @@ D.profile = {
width = 24,
height = 0,
spacing = 4,
scale = 1,
visibility = "[vehicleui][petbattle][overridebar][possessbar] hide; show",
visible = true,
x_growth = "RIGHT",
Expand Down Expand Up @@ -2425,6 +2435,7 @@ D.profile = {
width = 32,
height = 0,
spacing = 4,
scale = 1,
visibility = "[petbattle] show; hide",
visible = true,
x_growth = "RIGHT",
Expand All @@ -2451,6 +2462,7 @@ D.profile = {
extra = { -- ExtraAction
width = 40,
height = 0,
scale = 1,
visibility = "[vehicleui][petbattle][overridebar][possessbar] hide; show",
visible = true,
artwork = false,
Expand Down Expand Up @@ -2483,6 +2495,7 @@ D.profile = {
zone = { -- ZoneAbility
width = 40,
height = 0,
scale = 1,
visibility = "[vehicleui][petbattle][overridebar][possessbar] hide; show",
visible = true,
artwork = false,
Expand Down
2 changes: 2 additions & 0 deletions ls_UI/core/layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function E.Layout:Update(frame, config)
frame:SetSize(widthMult * width + (widthMult - 1) * config.spacing + 4,
heightMult * height + (heightMult - 1) * config.spacing + 4)

frame:SetScale(config.scale or 1)

local mover = E.Movers:Get(frame, true)
if mover then
mover:UpdateSize()
Expand Down
16 changes: 10 additions & 6 deletions ls_UI/core/mover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,6 @@ local function calculatePosition(self, xOffset, yOffset, forceUIParent)
end
end


return p, parent:GetName(), rP, x, y
end

Expand All @@ -643,10 +642,11 @@ local function resetObjectPoint(self, _, _, _, _, _, shouldIgnore)
local mover = E.Movers:Get(self)
if mover and not shouldIgnore then
if not InCombatLockdown() or not self:IsProtected() then
local scale = self:GetScale()
self:ClearAllPoints()

if mover.isSimple then
self:SetPoint("TOPRIGHT", mover, "TOPRIGHT", -mover.offsetX, -mover.offsetY, true)
self:SetPoint("TOPRIGHT", mover, "TOPRIGHT", E:Round(-mover.offsetX / scale), E:Round(-mover.offsetY / scale), true)
else
local p, anchor, rP, x, y = mover:GetCurrentPosition()
if anchor ~= "UIParent" then
Expand All @@ -656,15 +656,15 @@ local function resetObjectPoint(self, _, _, _, _, _, shouldIgnore)
if p then
dirtyObjects[self] = nil

self:SetPoint(p, anchor, rP, x - mover.offsetX, y - mover.offsetY, true)
self:SetPoint(p, anchor, rP, E:Round((x - mover.offsetX) / scale), E:Round((y - mover.offsetY) / scale), true)
else
-- I need to do this because some of the frames I move around are managed by Blizz
-- layout manager, so I can't have my movers as anchors since they're created after
-- their layout manager positions the frames, so I want all frames to be anchored to
-- UIParent
dirtyObjects[self] = true

self:SetPoint("TOPRIGHT", mover, "TOPRIGHT", -mover.offsetX, -mover.offsetY, true)
self:SetPoint("TOPRIGHT", mover, "TOPRIGHT", E:Round(-mover.offsetX / scale), E:Round(-mover.offsetY / scale), true)
end
end
else
Expand Down Expand Up @@ -969,8 +969,12 @@ function mover_proto:Disable()
end

function mover_proto:UpdateSize(width, height)
self:SetWidth(width or (self.object:GetWidth() + self.offsetX * 2))
self:SetHeight(height or (self.object:GetHeight() + self.offsetY * 2))
local newScale = self.object:GetScale()

self:SetWidth(E:Round((width or (self.object:GetWidth() + self.offsetX * 2)) * newScale))
self:SetHeight(E:Round((height or (self.object:GetHeight() + self.offsetY * 2)) * newScale))

resetObjectPoint(self.object)
end

function mover_proto:GetObject()
Expand Down
4 changes: 4 additions & 0 deletions ls_UI/modules/bars/actionbars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local CFG = {
width = 32,
height = 0,
spacing = 4,
-- scale = 1,
visibility = "[petbattle] hide; show",
visible = true,
x_growth = "RIGHT",
Expand Down Expand Up @@ -209,6 +210,9 @@ function bar1_proto:UpdateConfig()

self:SetAttribute("maxbuttons", self._config.num)
MODULE:UpdateMainBarMaxButtons(self._config.num)

self:SetAttribute("scale", C.db.profile.bars.bar1.scale)
MODULE:UpdateScale(C.db.profile.bars.bar1.scale)
end
end

Expand Down
7 changes: 4 additions & 3 deletions ls_UI/modules/bars/controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ function MODULE:SetupActionBarController()
anim:SetDuration(0.15)

self:UpdateEndcaps()
self:UpdateScale()

isInit = true
end
Expand Down Expand Up @@ -356,6 +355,7 @@ function MODULE:FinalizeActionBarController()
isFinilized = true

self:UpdateMainBarMaxButtons(LSActionBar1:GetAttribute("maxbuttons"))
self:UpdateScale(LSActionBar1:GetAttribute("scale"))
end
end

Expand All @@ -376,8 +376,9 @@ function MODULE:UpdateEndcaps()
end
end

function MODULE:UpdateScale()
local scale = C.db.profile.bars.scale
function MODULE:UpdateScale(scale)
if not isFinilized then return end
if not scale then return end

barController:SetScale(scale)
animController:SetScale(scale)
Expand Down
1 change: 1 addition & 0 deletions ls_UI/modules/bars/extra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function bar_proto:Update()

local width, height = ExtraActionButton1:GetSize()
self:SetSize((width > 0 and width or 52) + 4, (height > 0 and height or 52) + 4)
self:SetScale(self._config.scale)

local mover = E.Movers:Get(self)
if mover then
Expand Down
1 change: 1 addition & 0 deletions ls_UI/modules/bars/zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function bar_proto:Update()
end

self:SetSize(width + 4, height + 4)
self:SetScale(self._config.scale)

local mover = E.Movers:Get(self)
if mover then
Expand Down
7 changes: 7 additions & 0 deletions ls_UI_Options/bars/bar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ function CONFIG:CreateBarOptions(order, barID, name)
BARS:For(barID, "UpdateButtonConfig")
end,
},
scale = {
order = inc(1),
type = "range",
name = L["SCALE"],
isPercent = true,
min = 1, max = 2, step = 0.01, bigStep = 0.05,
},
num = {
order = inc(1),
type = "range",
Expand Down
7 changes: 7 additions & 0 deletions ls_UI_Options/bars/extra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ function CONFIG:CreateExtraBarOptions(order, barID, name)
BARS:For(barID, "UpdateArtwork")
end,
},
scale = {
order = inc(1),
type = "range",
name = L["SCALE"],
isPercent = true,
min = 0.5, max = 1.5, step = 0.01, bigStep = 0.05,
},
spacer_2 = {
order = inc(1),
type = "description",
Expand Down

0 comments on commit 39163a4

Please sign in to comment.