Skip to content

Commit

Permalink
added working CURVE grow type
Browse files Browse the repository at this point in the history
  • Loading branch information
wtodom committed Oct 9, 2023
1 parent 46ab420 commit f208d8e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
40 changes: 40 additions & 0 deletions WeakAuras/RegionTypes/DynamicGroup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,46 @@ local growers = {
end
end, anchorOn
end,
CURVE = function(data)
local oX, oY = 0, 0
local radius = data.radius or 0
local limit = data.useLimit and data.limit or math.huge
local sAngle = (data.rotation or 0) * math.pi / 180
local arc = (data.fullCircle and 360 or data.arcLength or 0) * math.pi / 180
local anchorPerUnitFunc, anchorOn
if data.useAnchorPerUnit then
anchorPerUnitFunc, anchorOn = createAnchorPerUnitFunc(data)
end
return function(newPositions, activeRegions)
local frames = {}
if anchorPerUnitFunc then
anchorPerUnitFunc(frames, activeRegions)
else
frames[""] = activeRegions
end
for frame, regionDatas in pairs(frames) do
local maxVisible = min(limit, #data.controlledChildren)
local r = radius
local theta = sAngle
local dAngle
if maxVisible == 1 then
dAngle = 0
elseif not data.fullCircle then
dAngle = arc / (maxVisible - 1)
else
dAngle = arc / maxVisible
end
newPositions[frame] = {}
for i, regionData in ipairs(regionDatas) do
if i <= maxVisible then
local x, y = polarToRect(r, theta)
newPositions[frame][regionData] = { x, y, true }
theta = theta + dAngle
end
end
end
end, anchorOn
end,
GRID = function(data)
local gridType = data.gridType
local gridWidth = data.gridWidth
Expand Down
1 change: 1 addition & 0 deletions WeakAuras/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,7 @@ Private.grow_types = {
["VERTICAL"] = L["Centered Vertical"],
["CIRCLE"] = L["Counter Clockwise"],
["COUNTERCIRCLE"] = L["Clockwise"],
["CURVE"] = L["Curve"],
["GRID"] = L["Grid"],
["CUSTOM"] = L["Custom"],
}
Expand Down
17 changes: 10 additions & 7 deletions WeakAurasOptions/RegionOptions/DynamicGroup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ local selfPoints = {
end,
CIRCLE = "CENTER",
COUNTERCIRCLE = "CENTER",
CURVE = "CENTER",
}

local gridSelfPoints = {
Expand Down Expand Up @@ -214,16 +215,16 @@ local function createOptions(id, data)
WeakAuras.ClearAndUpdateOptions(data.id)
OptionsPrivate.ResetMoverSizer()
end,
hidden = function() return (data.grow == "CUSTOM" or data.grow == "LEFT" or data.grow == "RIGHT" or data.grow == "HORIZONTAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "GRID") end,
disabled = function() return data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" end
hidden = function() return (data.grow == "CUSTOM" or data.grow == "LEFT" or data.grow == "RIGHT" or data.grow == "HORIZONTAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "CURVE" or data.grow == "GRID") end,
disabled = function() return data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "CURVE" end
},
rotated_align = {
type = "select",
width = WeakAuras.normalWidth,
name = L["Align"],
order = 3,
values = OptionsPrivate.Private.rotated_align_types,
hidden = function() return (data.grow == "CUSTOM" or data.grow == "UP" or data.grow == "DOWN" or data.grow == "VERTICAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "GRID") end,
hidden = function() return (data.grow == "CUSTOM" or data.grow == "UP" or data.grow == "DOWN" or data.grow == "VERTICAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "CURVE" or data.grow == "GRID") end,
get = function() return data.align; end,
set = function(info, v)
data.align = v
Expand Down Expand Up @@ -269,14 +270,14 @@ local function createOptions(id, data)
min = 0,
max = 360,
bigStep = 3,
hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" end
hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" and data.grow ~= "CURVE" end
},
fullCircle = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Full Circle"],
order = 7,
hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" end
hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" and data.grow ~= "CURVE" end
},
arcLength = {
type = "range",
Expand All @@ -288,7 +289,7 @@ local function createOptions(id, data)
max = 360,
bigStep = 3,
disabled = function() return data.fullCircle end,
hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" end
hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" and data.grow ~= "CURVE" end
},
radius = {
type = "range",
Expand All @@ -299,7 +300,7 @@ local function createOptions(id, data)
softMin = 0,
softMax = 500,
bigStep = 1,
hidden = function() return data.grow == "CUSTOM" or not((data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE") and data.constantFactor == "RADIUS") end
hidden = function() return data.grow == "CUSTOM" or not((data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "CURVE") and data.constantFactor == "RADIUS") end
},
-- grid grow options
gridType = {
Expand Down Expand Up @@ -369,6 +370,7 @@ local function createOptions(id, data)
hidden = function()
return data.grow == "CUSTOM"
or data.grow == "GRID"
or data.grow == "CURVE"
or ((data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE") and data.constantFactor == "RADIUS")
end
},
Expand All @@ -386,6 +388,7 @@ local function createOptions(id, data)
return data.grow == "CUSTOM"
or data.grow == "CIRCLE"
or data.grow == "COUNTERCIRCLE"
or data.grow == "CURVE"
or data.grow == "GRID"
end
},
Expand Down

0 comments on commit f208d8e

Please sign in to comment.