#How to use a group's grow function to trigger another group's grow function?

4 messages · Page 1 of 1 (latest)

boreal sage
#

trying to create a group that scales based off antoher group's total width:

``function(newPositions, activeRegions)
local space = 1
local count = #activeRegions
local sourceGroup = WeakAuras.GetRegion("Warlock Main Row")
local sourceWidth = sourceGroup.currentWidth
local width = (sourceWidth / count) - space

local totalWidth = sourceWidth
local start = - (totalWidth / 2) + (width / 2)
for i = 1, #activeRegions do
    newPositions[i] = {
        start + (i - 1) * (width + space),
        0,
    }
end
WeakAuras.ScanEvents("WARLOCK_CD_ROW_GROW", totalWidth)

end``

I seem to be running into a race condition and sourceWidth is returning just the size of 1 icon. the math to determine the new icon width is also a little off

boreal sage
#

hmm found a really hacky way to do it

main row is the source and CD row is the group getting resized:

main row grow function broadcasts a GROW_EVENT

I made a single empty icon aura within CD row to listen for the event and simply trigger true when it's heard. CD Row is then forced to run its grow function:

    local count = #activeRegions
    local space = 1
    local width
    local totalWidth
    local usableWidth
    
    local mainRow = WeakAuras.GetRegion("Warlock Main Row")
    local cdRow = aura_env.region
    if not mainRow.sourceWidth then
        for i = 1, count do
            if activeRegions[i].dimensions and activeRegions[i].dimensions.width then
                width = activeRegions[i].dimensions.width
                break
            end
        end
        if not width then 
            return 
        end
        totalWidth = count * width + ((count - 1) * space)     
    else
        totalWidth = mainRow.sourceWidth
        usableWidth = totalWidth - (count * space)
        width = usableWidth / count
    end
    
    local start = - (totalWidth / 2) + (width / 2)
    for i = 1, count do
        cdRow.sortedChildren[i].region:SetRegionWidth(width)
        newPositions[i] = {
            start + (i - 1) * (width + space),
            0,
        }
    end
    WeakAuras.ScanEvents("WARLOCK_CD_ROW_GROW", totalWidth)
end```
#

there's got to be a better way to do it but it's getting the job done for now lol

hybrid ether
#

There isn’t, as far a I am aware, a "good" way to do it as of right now. As a side note however I’d suggest going into display settings of the icon auras and clicking the ⚙️ and check the Keep Aspect Ratio option to make them look less stretched out (it will zoom the image slightly however so it might just not be to your liking)