diff --git a/api/api.lua b/api/api.lua index 2d70f34d..74d4904b 100644 --- a/api/api.lua +++ b/api/api.lua @@ -1277,7 +1277,7 @@ end -- 'barsize' integer number of buttons, -- 'formfactor' string formfactor in cols x rows, -- 'padding' the spacing between buttons -function pfUI.api.BarLayoutSize(bar,barsize,formfactor,iconsize,bordersize,padding,uneven) +function pfUI.api.BarLayoutSize(bar,barsize,formfactor,iconsize,bordersize,padding,uneven,fillmode) assert(barsize > 0 and barsize <= NUM_ACTIONBAR_BUTTONS,"BarLayoutSize: barsize "..tostring(barsize).." is invalid") local cols, rows = ResolveBarLayout(barsize, formfactor, uneven) if not cols or not rows then cols, rows = unpack(pfGridmath[barsize][1]) end @@ -1295,21 +1295,53 @@ end -- 'iconsize' size of the button -- 'bordersize' default bordersize -- 'padding' the spacing between buttons -function pfUI.api.BarButtonAnchor(button,basename,buttonindex,barsize,formfactor,iconsize,bordersize,padding,uneven) +function pfUI.api.BarButtonAnchor(button,basename,buttonindex,barsize,formfactor,iconsize,bordersize,padding,uneven,fillmode) assert(barsize > 0 and barsize <= NUM_ACTIONBAR_BUTTONS,"BarButtonAnchor: barsize "..tostring(barsize).." is invalid") local cols, rows, mode, orientation = ResolveBarLayout(barsize, formfactor, uneven) if not cols or not rows then cols, rows, mode, orientation = unpack(pfGridmath[barsize][1]), "rows", "DOWN" end + + -- fillmode: remap buttonindex to slotindex (grid position in native fill order) + -- only needed when fill direction differs from layout mode + local slotindex = buttonindex + if fillmode == "row" and mode == "cols" then + local full = math.floor(barsize / rows) + local rem = barsize - full * rows + local n = 0 + for r = 1, rows do + local w = full + ((r <= rem) and 1 or 0) + if n + w >= buttonindex then + local c = buttonindex - n + slotindex = (c - 1) * rows + r + break + end + n = n + w + end + elseif fillmode == "col" and mode == "rows" then + local full = math.floor(barsize / cols) + local rem = barsize - full * cols + local n = 0 + for c = 1, cols do + local h = full + ((c <= rem) and 1 or 0) + if n + h >= buttonindex then + local r = buttonindex - n + slotindex = (r - 1) * cols + c + break + end + n = n + h + end + end + local parent = button:GetParent() local step = iconsize + bordersize*2 + padding local row, col if mode == "cols" then - col = math.ceil(buttonindex / rows) - row = buttonindex - ((col-1) * rows) + col = math.ceil(slotindex / rows) + row = slotindex - ((col-1) * rows) else - row = math.ceil(buttonindex / cols) - col = buttonindex - ((row-1) * cols) + row = math.ceil(slotindex / cols) + col = slotindex - ((row-1) * cols) end if mode == "cols" and orientation == "LEFT" then local final_col = math.ceil(barsize / rows) @@ -1326,7 +1358,7 @@ function pfUI.api.BarButtonAnchor(button,basename,buttonindex,barsize,formfactor end local x = bordersize + padding + (col - 1) * step local y = -bordersize - padding - (row - 1) * step - if buttonindex == 1 then + if slotindex == 1 then button._anchor = {"TOPLEFT", parent, "TOPLEFT", x, y} else button._anchor = {"TOPLEFT", parent, "TOPLEFT", x, y} diff --git a/modules/actionbar.lua b/modules/actionbar.lua index 7656e130..2e10f490 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -1277,6 +1277,7 @@ pfUI:RegisterModule("actionbar", "vanilla", function () local background = C.bars["bar"..i].background local formfactor = C.bars["bar"..i].formfactor local uneven = C.bars["bar"..i].uneven or "Down" + local fillmode = C.bars["bar"..i].fillmode or "auto" -- validate uneven against bar shape and reset if incompatible local _, _, fcols2, frows2 = string.find(tostring(formfactor or ""), "(%d+)%s*x%s*(%d+)") fcols2, frows2 = tonumber(fcols2), tonumber(frows2) @@ -1421,7 +1422,7 @@ pfUI:RegisterModule("actionbar", "vanilla", function () bars[i][j] = CreateActionButton(bars[i], i, j) bars[i][j].bar = i - BarButtonAnchor(bars[i][j], buttonbasename, j, buttons, formfactor, size, border, spacing, uneven) + BarButtonAnchor(bars[i][j], buttonbasename, j, buttons, formfactor, size, border, spacing, uneven, fillmode) bars[i][j]:ClearAllPoints() bars[i][j]:SetPoint(unpack(bars[i][j]._anchor)) bars[i][j]:Show() @@ -1452,7 +1453,7 @@ pfUI:RegisterModule("actionbar", "vanilla", function () end -- adjust actionbar size - BarLayoutSize(bars[i], buttons, formfactor, size, border, spacing, uneven) + BarLayoutSize(bars[i], buttons, formfactor, size, border, spacing, uneven, fillmode) bars[i]:SetWidth(bars[i]._size[1]) bars[i]:SetHeight(bars[i]._size[2]) bars[i]:ClearAllPoints() diff --git a/modules/gui.lua b/modules/gui.lua index 8a930355..4186e2bb 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -2662,6 +2662,9 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () end CreateConfig(layout_ufunc, T["Layout"], C.bars["bar"..id], "formfactor", "dropdown", formfactors) uneven_frame = CreateConfig(U["bars"], T["Layout Uneven Orientation"], C.bars["bar"..id], "uneven", "dropdown", uneven_options) + CreateConfig(U["bars"], T["Fill Order"], C.bars["bar"..id], "fillmode", "dropdown", function() + return {"auto:Auto", "row:Row-first (1,2,3 / 4,5,6)", "col:Column-first (1,3,5 / 2,4,6)"} + end) CreateConfig(U["bars"], T["Bar Background"], C.bars["bar"..id], "background", "checkbox") CreateConfig(U["bars"], T["Show Hotkey Text"], C.bars["bar"..id], "showkeybind", "checkbox")