Skip to content

Commit

Permalink
Add Scale option to groups
Browse files Browse the repository at this point in the history
Ticket-Nr: 827
  • Loading branch information
sragia authored and InfusOnWoW committed Jul 13, 2018
1 parent ab44440 commit 9b8f96a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 4 deletions.
9 changes: 8 additions & 1 deletion WeakAuras/RegionTypes/DynamicGroup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ local default = {
radius = 200,
rotation = 0,
constantFactor = "RADIUS",
frameStrata = 1
frameStrata = 1,
scale = 1,
};

local function create(parent)
Expand Down Expand Up @@ -48,6 +49,9 @@ function WeakAuras.GetPolarCoordinates(x, y, originX, originY)
end

local function modify(parent, region, data)
-- Scale
region:SetScale(data.scale and data.scale > 0 and data.scale or 1)

local selfPoint;
if(data.grow == "RIGHT") then
selfPoint = "LEFT";
Expand Down Expand Up @@ -275,6 +279,9 @@ local function modify(parent, region, data)
for index, regionData in ipairs(region.controlledRegions) do
if not(region.trays[regionData.key]) then
region.trays[regionData.key] = CreateFrame("Frame", nil, region);
regionData.region:SetParent(region.trays[regionData.key])
else
regionData.region:SetParent(region.trays[regionData.key]) -- removing and adding aura back doesnt delete tray, so need to reparent it
end
if(regionData.data and regionData.region) then
local tray = region.trays[regionData.key];
Expand Down
4 changes: 4 additions & 0 deletions WeakAuras/RegionTypes/Group.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local default = {
borderInset = 11,
borderSize = 16,
borderBackdrop = "Blizzard Tooltip",
scale = 1,
};

-- Called when first creating a new region/display
Expand Down Expand Up @@ -76,6 +77,9 @@ local function modify(parent, region, data)
-- Localize
local border = region.border;

-- Scale
region:SetScale(data.scale and data.scale > 0 and data.scale or 1)

-- Get overall bounding box
local leftest, rightest, lowest, highest = 0, 0, 0, 0;
for index, childId in ipairs(data.controlledChildren) do
Expand Down
4 changes: 2 additions & 2 deletions WeakAurasOptions/OptionsFrames/MoverSizer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ local function ConstructMoverSizer(parent)
self.interims[i]:SetPoint("CENTER", self.anchorPointIcon, "CENTER", x, y);
self.interims[i]:Show();
end

self.text:SetText(("(%.2f, %.2f)"):format(dX, dY));
local regionScale = self.moving.region:GetScale()
self.text:SetText(("(%.2f, %.2f)"):format(dX*1/regionScale, dY*1/regionScale));
local midx = (distance / 2) * cos(angle);
local midy = (distance / 2) * sin(angle);
self.text:SetPoint("CENTER", self.anchorPointIcon, "CENTER", midx, midy);
Expand Down
23 changes: 22 additions & 1 deletion WeakAurasOptions/RegionOptions/DynamicGroup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,31 @@ local function createOptions(id, data)
data.sortHybridTable[id] = not(cur);
end,
},
scale = {
type = "range",
name = L["Group Scale"],
order = 50,
min = 0.05,
softMax = 2,
bigStep = 0.05,
get = function()
return data.scale or 1
end,
set = function(info, v)
data.scale = data.scale or 1
local change = 1 - (v/data.scale)
data.xOffset = data.xOffset/(1-change)
data.yOffset = data.yOffset/(1-change)
data.scale = v
WeakAuras.Add(data);
WeakAuras.SetThumbnail(data);
WeakAuras.ResetMoverSizer();
end
},
spacer = {
type = "header",
name = "",
order = 50
order = 51
}
};

Expand Down
21 changes: 21 additions & 0 deletions WeakAurasOptions/RegionOptions/Group.lua
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,27 @@ local function createOptions(id, data)
WeakAuras.ResetMoverSizer();
end
},
scale = {
type = "range",
name = L["Group Scale"],
order = 45,
min = 0.05,
softMax = 2,
bigStep = 0.05,
get = function()
return data.scale or 1
end,
set = function(info, v)
data.scale = data.scale or 1
local change = 1 - (v/data.scale)
data.xOffset = data.xOffset/(1-change)
data.yOffset = data.yOffset/(1-change)
data.scale = v
WeakAuras.Add(data);
WeakAuras.SetThumbnail(data);
WeakAuras.ResetMoverSizer();
end
},
};

return {
Expand Down

0 comments on commit 9b8f96a

Please sign in to comment.