from retail
This commit is contained in:
@@ -26,6 +26,7 @@ local default = {
|
||||
local function create(parent)
|
||||
-- Main region
|
||||
local region = CreateFrame("FRAME", nil, parent);
|
||||
region.regionType = "group"
|
||||
region:SetMovable(true);
|
||||
region:SetWidth(2);
|
||||
region:SetHeight(2);
|
||||
@@ -36,6 +37,12 @@ local function create(parent)
|
||||
|
||||
WeakAuras.regionPrototype.create(region);
|
||||
|
||||
local oldSetFrameLevel = region.SetFrameLevel
|
||||
region.SetFrameLevel = function(self, level)
|
||||
oldSetFrameLevel(self, level)
|
||||
self.border:SetFrameLevel(level)
|
||||
end
|
||||
|
||||
return region;
|
||||
end
|
||||
|
||||
@@ -92,20 +99,14 @@ local function modify(parent, region, data)
|
||||
|
||||
-- Get overall bounding box
|
||||
local leftest, rightest, lowest, highest = 0, 0, 0, 0;
|
||||
local minLevel
|
||||
for index, childId in ipairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
local childRegion = WeakAuras.GetRegion(childId)
|
||||
if(childData) then
|
||||
local blx, bly, trx, try = getRect(childData, childRegion);
|
||||
for child in Private.TraverseLeafs(data) do
|
||||
local childRegion = WeakAuras.GetRegion(child.id)
|
||||
if(child) then
|
||||
local blx, bly, trx, try = getRect(child, childRegion);
|
||||
leftest = math.min(leftest, blx);
|
||||
rightest = math.max(rightest, trx);
|
||||
lowest = math.min(lowest, bly);
|
||||
highest = math.max(highest, try);
|
||||
local frameLevel = childRegion and childRegion:GetFrameLevel()
|
||||
if frameLevel then
|
||||
minLevel = minLevel and math.min(minLevel, frameLevel) or frameLevel
|
||||
end
|
||||
end
|
||||
end
|
||||
region.blx = leftest;
|
||||
@@ -116,56 +117,67 @@ local function modify(parent, region, data)
|
||||
-- Adjust frame-level sorting
|
||||
Private.FixGroupChildrenOrderForGroup(data);
|
||||
|
||||
-- Control children (does not happen with "group")
|
||||
function region:UpdateBorder(childRegion)
|
||||
local border = region.border;
|
||||
-- Apply border settings
|
||||
if data.border then
|
||||
-- Initial visibility (of child that originated UpdateBorder(...))
|
||||
local childVisible = childRegion and childRegion.toShow or false;
|
||||
local hasDynamicSubGroups = false
|
||||
for index, childId in pairs(data.controlledChildren) do
|
||||
local childData = WeakAuras.GetData(childId);
|
||||
if childData.regionType == "dynamicgroup" then
|
||||
hasDynamicSubGroups = true
|
||||
break;
|
||||
end
|
||||
end
|
||||
|
||||
-- Scan children for visibility
|
||||
if not childVisible then
|
||||
for index, childId in ipairs(data.controlledChildren) do
|
||||
local childRegion = WeakAuras.regions[childId] and WeakAuras.regions[childId].region;
|
||||
if childRegion and childRegion.toShow then
|
||||
childVisible = true;
|
||||
break;
|
||||
if not hasDynamicSubGroups then
|
||||
-- Control children (does not happen with "group")
|
||||
function region:UpdateBorder(childRegion)
|
||||
local border = region.border;
|
||||
-- Apply border settings
|
||||
if data.border then
|
||||
-- Initial visibility (of child that originated UpdateBorder(...))
|
||||
local childVisible = childRegion and childRegion.toShow or false;
|
||||
|
||||
-- Scan children for visibility
|
||||
if not childVisible then
|
||||
for child in Private.TraverseLeafs(data) do
|
||||
local childRegion = WeakAuras.regions[child.id] and WeakAuras.regions[child.id].region;
|
||||
if childRegion and childRegion.toShow then
|
||||
childVisible = true;
|
||||
break;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Show border if child is visible
|
||||
if childVisible then
|
||||
border:SetBackdrop({
|
||||
edgeFile = data.borderEdge ~= "None" and SharedMedia:Fetch("border", data.borderEdge) or "",
|
||||
edgeSize = data.borderSize,
|
||||
bgFile = data.borderBackdrop ~= "None" and SharedMedia:Fetch("background", data.borderBackdrop) or "",
|
||||
insets = {
|
||||
left = data.borderInset,
|
||||
right = data.borderInset,
|
||||
top = data.borderInset,
|
||||
bottom = data.borderInset,
|
||||
},
|
||||
});
|
||||
border:SetBackdropBorderColor(data.borderColor[1], data.borderColor[2], data.borderColor[3], data.borderColor[4]);
|
||||
border:SetBackdropColor(data.backdropColor[1], data.backdropColor[2], data.backdropColor[3], data.backdropColor[4]);
|
||||
-- Show border if child is visible
|
||||
if childVisible then
|
||||
border:SetBackdrop({
|
||||
edgeFile = data.borderEdge ~= "None" and SharedMedia:Fetch("border", data.borderEdge) or "",
|
||||
edgeSize = data.borderSize,
|
||||
bgFile = data.borderBackdrop ~= "None" and SharedMedia:Fetch("background", data.borderBackdrop) or "",
|
||||
insets = {
|
||||
left = data.borderInset,
|
||||
right = data.borderInset,
|
||||
top = data.borderInset,
|
||||
bottom = data.borderInset,
|
||||
},
|
||||
});
|
||||
border:SetBackdropBorderColor(data.borderColor[1], data.borderColor[2], data.borderColor[3], data.borderColor[4]);
|
||||
border:SetBackdropColor(data.backdropColor[1], data.backdropColor[2], data.backdropColor[3], data.backdropColor[4]);
|
||||
|
||||
border:ClearAllPoints();
|
||||
border:SetPoint("bottomleft", region, "bottomleft", leftest-data.borderOffset, lowest-data.borderOffset);
|
||||
border:SetPoint("topright", region, "topright", rightest+data.borderOffset, highest+data.borderOffset);
|
||||
if minLevel then
|
||||
border:SetFrameLevel(minLevel - 1)
|
||||
border:ClearAllPoints();
|
||||
border:SetPoint("bottomleft", region, "bottomleft", leftest-data.borderOffset, lowest-data.borderOffset);
|
||||
border:SetPoint("topright", region, "topright", rightest+data.borderOffset, highest+data.borderOffset);
|
||||
border:Show();
|
||||
else
|
||||
border:Hide();
|
||||
end
|
||||
border:Show();
|
||||
else
|
||||
border:Hide();
|
||||
end
|
||||
else
|
||||
border:Hide();
|
||||
end
|
||||
region:UpdateBorder()
|
||||
else
|
||||
region.UpdateBorder = function() end
|
||||
region.border:Hide()
|
||||
end
|
||||
region:UpdateBorder()
|
||||
|
||||
WeakAuras.regionPrototype.modifyFinish(parent, region, data);
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user