WeakAuras

WeakAuras

206M Downloads

Dynamic resizing of Icons in a dynamic group to fit a fixed size defined for the group

psyquest opened this issue · 6 comments

commented

Is your feature request related to a problem? Please describe.
When adding icons to a dynamic group it is impossible to set a max lenght for the group so that adding icons does not enlarge the group. Since unit frames are in set places on the screen, players usully set their icons between the player and target unitframe. Unfortunately, there is no way to control the size of the dynamic group (depends on talents/spells selected) and thus we end up with not so nice UIs with varying lenght of dynamic groups.

Describe the solution you'd like
When creating a dynamic group, depending on talents choice there can be X icons or X+n icons
Ideally one would like to have all icons in a dynamic group fit a predefined maximum lenght of the dynamic group.
So that adding extra icons to a dynamic group, the lenght of the dynamic group does not change but the size of icons dynamically change to fit the predefined dynamic group lenght.

This makes for visually pleasing UI.

Describe alternatives you've considered
yes, tried using code such as the one used here https://wago.io/kib-dh-hud
But would rather have it done natively by weak aura, especially this would be used by many classes.

commented

It took quite some googling, but I finaly found a post on Reddit that suggesting using a custom grow function for the dynamic group. In the grow function one can change the width and/or height of the group's children. The following code reproduces the native "Centered Horizontal" placement and changes the width of the group's icon to perfectly fit 180 px horizontally:

-- https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Dynamic-Group#custom-grow

function(newPositions, activeRegions)
    local totalWidth = 180
    local width = totalWidth / #activeRegions
    
    for i = 1, #activeRegions do
        -- Changing only the icon width. I prefer to have constant height,
        -- which means that icons may not be square. To keep icons square,
        -- add `activeRegions[i].region:SetRegionHeight(width)`
        activeRegions[i].region:SetRegionWidth(width)
        
        newPositions[i] = {
            i*width - totalWidth/2 - width/2, -- x
            0                                 -- y
        }
    end
end

Here's part of my UI using the custom grow function above. Just so there's no confusion, the picture shows three distinct dynamic groups: one below the player unit frame, and two groups between the player and target frames.

wow-wa-dynamic-icon-size

commented

I dunno if I'll ever have an answer given the late comment, but how could I possibly change the spacing between icons/auras with that code?

commented

@gollumeo, I can't test right now, but something like this should work:

  • in SetRegionWidth(width) replace width with width-X,
  • in i*width - totalWidth/2 - width/2 replace width with (width+X);

where X is the desired spacing

        activeRegions[i].region:SetRegionWidth(width-2)
        
        newPositions[i] = {
            i*(width+2) - totalWidth/2 - (width+2)/2, -- x
            0                                         -- y
        }
commented

It works, ty! It asks to change some parameters (like the total width) to actually fit the initial pattern, but that's what I needed! Thanks a lot ♥

commented

Duplicate of #4057

commented

+1 I was coming here to submit this same feature request. Typically, my talent selections will give a UI looking something like this:
image

But worse case, with talent selections I can get this (soothe icon collides with barkskin icon):
image

If I could specify a max width (not simply an icon limit) for the the top row of icons, the dynamic group as a whole could scale down to fit within the max width (or even scale up to fit within a min width)