From 0838c6ec3aed850527273a70ec57f322c299ec82 Mon Sep 17 00:00:00 2001 From: Meow <30401521+me0wg4ming@users.noreply.github.com> Date: Fri, 10 Apr 2026 15:24:39 +0200 Subject: [PATCH] Added a fillmode variant to actionbars --- api/api.lua | 53 ++++++++++++++++++++++++++++++++----------- modules/actionbar.lua | 5 ++-- modules/gui.lua | 3 +++ 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/api/api.lua b/api/api.lua index 2d70f34d..ff46ac61 100644 --- a/api/api.lua +++ b/api/api.lua @@ -1248,7 +1248,7 @@ function pfUI.api.BarLayoutFormfactor(option) end end -local function ResolveBarLayout(barsize, formfactor, uneven) +local function ResolveBarLayout(barsize, formfactor, uneven, fillmode) local layout = tostring(formfactor or "") local _, _, a, b = string.find(layout, "(%d+)%s*x%s*(%d+)") if a and b then @@ -1256,13 +1256,28 @@ local function ResolveBarLayout(barsize, formfactor, uneven) cols = math.min(NUM_ACTIONBAR_BUTTONS, math.max(1, cols)) rows = math.min(NUM_ACTIONBAR_BUTTONS, math.max(1, rows)) local orientation = string.upper(uneven or "DOWN") - local mode = (orientation == "LEFT" or orientation == "RIGHT") and "cols" or "rows" - if mode == "rows" then - cols = math.max(1, math.min(cols, barsize)) - rows = math.max(1, math.ceil(barsize / cols)) - else + local mode + if fillmode == "col" then + -- spaltenweise: rows aus formfactor fix, cols berechnen + mode = "cols" rows = math.max(1, math.min(rows, barsize)) cols = math.max(1, math.ceil(barsize / rows)) + elseif fillmode == "row" then + -- zeilenweise: rows aus formfactor fix, cols berechnen + mode = "rows" + rows = math.max(1, math.min(rows, barsize)) + cols = math.max(1, math.ceil(barsize / rows)) + else + mode = (orientation == "LEFT" or orientation == "RIGHT") and "cols" or "rows" + if mode == "rows" then + -- rows aus formfactor fix, cols berechnen + rows = math.max(1, math.min(rows, barsize)) + cols = math.max(1, math.ceil(barsize / rows)) + else + -- cols aus formfactor fix, rows berechnen + cols = math.max(1, math.min(cols, barsize)) + rows = math.max(1, math.ceil(barsize / cols)) + end end return cols, rows, mode, orientation end @@ -1277,9 +1292,9 @@ 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) + local cols, rows = ResolveBarLayout(barsize, formfactor, uneven, fillmode) if not cols or not rows then cols, rows = unpack(pfGridmath[barsize][1]) end local width = (iconsize + bordersize*2+padding) * cols + padding local height = (iconsize + bordersize*2+padding) * rows + padding @@ -1295,9 +1310,9 @@ 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) + local cols, rows, mode, orientation = ResolveBarLayout(barsize, formfactor, uneven, fillmode) if not cols or not rows then cols, rows, mode, orientation = unpack(pfGridmath[barsize][1]), "rows", "DOWN" end @@ -1312,12 +1327,14 @@ function pfUI.api.BarButtonAnchor(button,basename,buttonindex,barsize,formfactor col = buttonindex - ((row-1) * cols) end if mode == "cols" and orientation == "LEFT" then + -- letzte Spalte nach links: col-Index verschieben local final_col = math.ceil(barsize / rows) local count = barsize - (final_col - 1) * rows if count > 0 and count < rows then if col == final_col then col = 1 else col = col + 1 end end elseif mode == "rows" and orientation == "UP" then + -- letzte Reihe nach oben: row-Index verschieben local final_row = math.ceil(barsize / cols) local count = barsize - (final_row - 1) * cols if count > 0 and count < cols then @@ -1331,6 +1348,7 @@ function pfUI.api.BarButtonAnchor(button,basename,buttonindex,barsize,formfactor else button._anchor = {"TOPLEFT", parent, "TOPLEFT", x, y} if mode == "cols" then + -- centering: letzte unvollstaendige Spalte links oder rechts ausrichten local final_col = math.ceil(barsize / rows) local count = barsize - (final_col - 1) * rows local target_col = (orientation == "LEFT") and 1 or cols @@ -1338,11 +1356,20 @@ function pfUI.api.BarButtonAnchor(button,basename,buttonindex,barsize,formfactor button._anchor[5] = button._anchor[5] - (rows - count) * step / 2 end else + -- row-mode: letzte unvollstaendige Reihe vertikal mittig positionieren (wie col-mode horizontal) + -- orientation bestimmt x-Position (LEFT/RIGHT) oder ob oben/unten (UP/DOWN) local final_row = math.ceil(barsize / cols) local count = barsize - (final_row - 1) * cols - local target_row = (orientation == "UP") and 1 or rows - if count > 0 and count < cols and row == target_row and col == 1 then - button._anchor[4] = button._anchor[4] + (cols - count) * step / 2 + if count > 0 and count < cols then + local target_row = (orientation == "UP") and 1 or final_row + if row == target_row then + -- vertikal mittig: y-Offset um halben step nach oben + button._anchor[5] = button._anchor[5] - (rows - (final_row - 1)) * step / 2 + step / 2 + -- x-Position: LEFT = linksbündig (kein Offset), RIGHT = rechtsbündig + if orientation == "RIGHT" then + button._anchor[4] = button._anchor[4] + (cols - count) * step + end + end end end end 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")