mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-25 21:40:49 +00:00
Merge pull request #147 from me0wg4ming/revert-131-master
Revert "Fix for bar layout+alternatives+uneven orientation"
This commit is contained in:
+12
-132
@@ -1197,45 +1197,10 @@ end
|
|||||||
-- returns: array of options as strings for pfUI.gui.bar
|
-- returns: array of options as strings for pfUI.gui.bar
|
||||||
function pfUI.api.BarLayoutOptions(barsize)
|
function pfUI.api.BarLayoutOptions(barsize)
|
||||||
assert(barsize > 0 and barsize <= NUM_ACTIONBAR_BUTTONS,"BarLayoutOptions: barsize "..tostring(barsize).." is invalid")
|
assert(barsize > 0 and barsize <= NUM_ACTIONBAR_BUTTONS,"BarLayoutOptions: barsize "..tostring(barsize).." is invalid")
|
||||||
local options, seen = {}, {}
|
local options = {}
|
||||||
|
|
||||||
local function add(option)
|
|
||||||
if not seen[option] then
|
|
||||||
table.insert(options, option)
|
|
||||||
seen[option] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for i,layout in ipairs(pfGridmath[barsize]) do
|
for i,layout in ipairs(pfGridmath[barsize]) do
|
||||||
add(string.format("%d x %d",layout[1],layout[2]))
|
options[i] = string.format("%d x %d",layout[1],layout[2])
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, option in ipairs({
|
|
||||||
"1 x 12", "1 x 10", "2 x 10", "2 x 5", "3 x 10", "3 x 5", "3 x 3",
|
|
||||||
"5 x 3", "10 x 3", "5 x 2", "10 x 2", "10 x 1", "12 x 1"
|
|
||||||
}) do
|
|
||||||
add(option)
|
|
||||||
end
|
|
||||||
|
|
||||||
table.sort(options, function(a, b)
|
|
||||||
local _, _, ac, ar = string.find(a, "(%d+)%s*x%s*(%d+)")
|
|
||||||
local _, _, bc, br = string.find(b, "(%d+)%s*x%s*(%d+)")
|
|
||||||
ac, ar = tonumber(ac) or 1, tonumber(ar) or 1
|
|
||||||
bc, br = tonumber(bc) or 1, tonumber(br) or 1
|
|
||||||
|
|
||||||
local ah = ac >= ar and 0 or 1
|
|
||||||
local bh = bc >= br and 0 or 1
|
|
||||||
|
|
||||||
if ah ~= bh then return ah < bh end
|
|
||||||
if ah == 0 then -- horizontal first: wider to narrower
|
|
||||||
if ac ~= bc then return ac > bc end
|
|
||||||
return ar < br
|
|
||||||
else -- vertical: taller to shorter
|
|
||||||
if ar ~= br then return ar > br end
|
|
||||||
return ac < bc
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1260,45 +1225,15 @@ function pfUI.api.BarLayoutFormfactor(option)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ResolveBarLayout(barsize, formfactor, uneven)
|
|
||||||
local layout = tostring(formfactor or "")
|
|
||||||
local _, _, a, b = string.find(layout, "(%d+)%s*x%s*(%d+)")
|
|
||||||
|
|
||||||
if a and b then
|
|
||||||
local cols, rows = tonumber(a), tonumber(b)
|
|
||||||
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
|
|
||||||
rows = math.max(1, math.min(rows, barsize))
|
|
||||||
cols = math.max(1, math.ceil(barsize / rows))
|
|
||||||
end
|
|
||||||
|
|
||||||
return cols, rows, mode, orientation
|
|
||||||
end
|
|
||||||
|
|
||||||
local index = pfUI.api.BarLayoutFormfactor(layout)
|
|
||||||
if not index then return nil end
|
|
||||||
local cols, rows = unpack(pfGridmath[barsize][index])
|
|
||||||
return cols, rows, "rows", "DOWN"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- [ Bar Layout Size ] --
|
-- [ Bar Layout Size ] --
|
||||||
-- 'bar' frame reference,
|
-- 'bar' frame reference,
|
||||||
-- 'barsize' integer number of buttons,
|
-- 'barsize' integer number of buttons,
|
||||||
-- 'formfactor' string formfactor in cols x rows,
|
-- 'formfactor' string formfactor in cols x rows,
|
||||||
-- 'padding' the spacing between buttons
|
-- '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)
|
||||||
assert(barsize > 0 and barsize <= NUM_ACTIONBAR_BUTTONS,"BarLayoutSize: barsize "..tostring(barsize).." is invalid")
|
assert(barsize > 0 and barsize <= NUM_ACTIONBAR_BUTTONS,"BarLayoutSize: barsize "..tostring(barsize).." is invalid")
|
||||||
local cols, rows = ResolveBarLayout(barsize, formfactor, uneven)
|
local formfactor = pfUI.api.BarLayoutFormfactor(formfactor)
|
||||||
if not cols or not rows then
|
local cols, rows = unpack(pfGridmath[barsize][formfactor])
|
||||||
cols, rows = unpack(pfGridmath[barsize][1])
|
|
||||||
end
|
|
||||||
local width = (iconsize + bordersize*2+padding) * cols + padding
|
local width = (iconsize + bordersize*2+padding) * cols + padding
|
||||||
local height = (iconsize + bordersize*2+padding) * rows + padding
|
local height = (iconsize + bordersize*2+padding) * rows + padding
|
||||||
bar._size = {width,height}
|
bar._size = {width,height}
|
||||||
@@ -1313,71 +1248,16 @@ end
|
|||||||
-- 'iconsize' size of the button
|
-- 'iconsize' size of the button
|
||||||
-- 'bordersize' default bordersize
|
-- 'bordersize' default bordersize
|
||||||
-- 'padding' the spacing between buttons
|
-- '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)
|
||||||
assert(barsize > 0 and barsize <= NUM_ACTIONBAR_BUTTONS,"BarButtonAnchor: barsize "..tostring(barsize).." is invalid")
|
assert(barsize > 0 and barsize <= NUM_ACTIONBAR_BUTTONS,"BarButtonAnchor: barsize "..tostring(barsize).." is invalid")
|
||||||
local cols, rows, mode, orientation = ResolveBarLayout(barsize, formfactor, uneven)
|
local formfactor = pfUI.api.BarLayoutFormfactor(formfactor)
|
||||||
if not cols or not rows then
|
|
||||||
cols, rows, mode, orientation = unpack(pfGridmath[barsize][1]), "rows", "DOWN"
|
|
||||||
end
|
|
||||||
local parent = button:GetParent()
|
local parent = button:GetParent()
|
||||||
local step = iconsize + bordersize*2 + padding
|
local cols, rows = unpack(pfGridmath[barsize][formfactor])
|
||||||
|
|
||||||
local row, col
|
|
||||||
if mode == "cols" then
|
|
||||||
col = math.ceil(buttonindex / rows)
|
|
||||||
row = buttonindex - ((col-1) * rows)
|
|
||||||
else
|
|
||||||
row = math.ceil(buttonindex / cols)
|
|
||||||
col = buttonindex - ((row-1) * cols)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- move only the uneven remainder to the selected edge without reversing full order
|
|
||||||
if mode == "cols" and orientation == "LEFT" then
|
|
||||||
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
|
|
||||||
local final_row = math.ceil(barsize / cols)
|
|
||||||
local count = barsize - (final_row - 1) * cols
|
|
||||||
if count > 0 and count < cols then
|
|
||||||
if row == final_row then
|
|
||||||
row = 1
|
|
||||||
else
|
|
||||||
row = row + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local x = bordersize + padding + (col - 1) * step
|
|
||||||
local y = -bordersize - padding - (row - 1) * step
|
|
||||||
|
|
||||||
if buttonindex == 1 then
|
if buttonindex == 1 then
|
||||||
button._anchor = {"TOPLEFT", parent, "TOPLEFT", x, y}
|
button._anchor = {"TOPLEFT", parent, "TOPLEFT", bordersize+padding, -bordersize-padding}
|
||||||
else
|
else
|
||||||
button._anchor = {"TOPLEFT", parent, "TOPLEFT", x, y}
|
local col = buttonindex-((math.ceil(buttonindex/cols)-1)*cols)
|
||||||
|
button._anchor = col==1 and {"TOP",_G[basename..(buttonindex-cols)],"BOTTOM",0,-(bordersize*2+padding)} or {"LEFT",_G[basename..(buttonindex-1)],"RIGHT",(bordersize*2+padding),0}
|
||||||
-- center partially filled final row/column
|
|
||||||
if mode == "cols" then
|
|
||||||
local final_col = math.ceil(barsize / rows)
|
|
||||||
local count = barsize - (final_col - 1) * rows
|
|
||||||
local target_col = (orientation == "LEFT") and 1 or cols
|
|
||||||
if count > 0 and count < rows and col == target_col and row == 1 then
|
|
||||||
button._anchor[5] = button._anchor[5] - (rows - count) * step / 2
|
|
||||||
end
|
|
||||||
else
|
|
||||||
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
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return button._anchor
|
return button._anchor
|
||||||
end
|
end
|
||||||
@@ -1630,4 +1510,4 @@ function pfUI.api.TryMemoizedFuncLoadstringForSpellCasts(funcOrStr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
+1
-2
@@ -8,8 +8,7 @@ do -- statusbars
|
|||||||
|
|
||||||
local animate = CreateFrame("Frame", "pfStatusBarAnimation", UIParent)
|
local animate = CreateFrame("Frame", "pfStatusBarAnimation", UIParent)
|
||||||
animate:SetScript("OnUpdate", function()
|
animate:SetScript("OnUpdate", function()
|
||||||
local unitframes = pfUI_config and pfUI_config.unitframes
|
stepsize = tonumber(pfUI_config.unitframes.animation_speed)
|
||||||
stepsize = tonumber(unitframes and unitframes.animation_speed) or 20
|
|
||||||
|
|
||||||
for bar in pairs(animations) do
|
for bar in pairs(animations) do
|
||||||
if not bar.val_ or abs(bar.val_ - bar.val) < stepsize or bar.instant then
|
if not bar.val_ or abs(bar.val_ - bar.val) < stepsize or bar.instant then
|
||||||
|
|||||||
Vendored
+7
-7
@@ -33,15 +33,15 @@ CLASS_ICON_TCOORDS = CLASS_ICON_TCOORDS or {
|
|||||||
pfGridmath = {
|
pfGridmath = {
|
||||||
[1] = {{1,1}},
|
[1] = {{1,1}},
|
||||||
[2] = {{2,1},{1,2}},
|
[2] = {{2,1},{1,2}},
|
||||||
[3] = {{3,1},{2,2},{1,3}},
|
[3] = {{3,1},{1,3}},
|
||||||
[4] = {{4,1},{2,2},{1,4}},
|
[4] = {{4,1},{2,2},{1,4}},
|
||||||
[5] = {{5,1},{3,2},{2,3},{1,5}},
|
[5] = {{5,1},{1,5}},
|
||||||
[6] = {{6,1},{3,2},{2,3},{1,6}},
|
[6] = {{6,1},{3,2},{2,3},{1,6}},
|
||||||
[7] = {{7,1},{4,2},{3,3},{2,4},{1,7}},
|
[7] = {{7,1},{1,7}},
|
||||||
[8] = {{8,1},{4,2},{3,3},{2,4},{1,8}},
|
[8] = {{8,1},{4,2},{2,4},{1,8}},
|
||||||
[9] = {{9,1},{5,2},{3,3},{2,5},{1,9}},
|
[9] = {{9,1},{3,3},{1,9}},
|
||||||
[10] = {{10,1},{5,2},{4,3},{3,4},{2,5},{1,10}},
|
[10] = {{10,1},{5,2},{2,5},{1,10}},
|
||||||
[11] = {{11,1},{6,2},{4,3},{3,4},{2,6},{1,11}},
|
[11] = {{11,1},{1,11}},
|
||||||
[12] = {{12,1},{6,2},{4,3},{3,4},{2,6},{1,12}}
|
[12] = {{12,1},{6,2},{4,3},{3,4},{2,6},{1,12}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-25
@@ -1276,26 +1276,6 @@ pfUI:RegisterModule("actionbar", "vanilla", function ()
|
|||||||
local spacing = C.bars["bar"..i].spacing
|
local spacing = C.bars["bar"..i].spacing
|
||||||
local background = C.bars["bar"..i].background
|
local background = C.bars["bar"..i].background
|
||||||
local formfactor = C.bars["bar"..i].formfactor
|
local formfactor = C.bars["bar"..i].formfactor
|
||||||
local uneven = C.bars["bar"..i].uneven
|
|
||||||
local _, _, cols, rows = string.find(tostring(formfactor or ""), "(%d+)%s*x%s*(%d+)")
|
|
||||||
cols, rows = tonumber(cols), tonumber(rows)
|
|
||||||
local is_square = cols == 3 and rows == 3
|
|
||||||
local is_vertical = cols and cols <= 3 and not is_square
|
|
||||||
local is_horizontal = rows and rows <= 3 and not is_square
|
|
||||||
|
|
||||||
if is_vertical then
|
|
||||||
if uneven ~= "Up" and uneven ~= "Down" then
|
|
||||||
uneven = "Up"
|
|
||||||
end
|
|
||||||
elseif is_horizontal then
|
|
||||||
if uneven ~= "Left" and uneven ~= "Right" then
|
|
||||||
uneven = "Left"
|
|
||||||
end
|
|
||||||
elseif not uneven then
|
|
||||||
uneven = "Up"
|
|
||||||
end
|
|
||||||
|
|
||||||
C.bars["bar"..i].uneven = uneven
|
|
||||||
local autohide = C.bars["bar"..i].autohide
|
local autohide = C.bars["bar"..i].autohide
|
||||||
local hide_time = C.bars["bar"..i].hide_time
|
local hide_time = C.bars["bar"..i].hide_time
|
||||||
local hide_combat = C.bars["bar"..i].hide_combat == "1" and true or nil
|
local hide_combat = C.bars["bar"..i].hide_combat == "1" and true or nil
|
||||||
@@ -1318,8 +1298,7 @@ pfUI:RegisterModule("actionbar", "vanilla", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- the stored layout is invalid, temporary fallback
|
-- the stored layout is invalid, temporary fallback
|
||||||
local _, _, fcols, frows = string.find(tostring(formfactor or ""), "(%d+)%s*x%s*(%d+)")
|
if not pfGridmath[buttons][BarLayoutFormfactor(formfactor)] then
|
||||||
if not ((fcols and frows) or pfGridmath[buttons][BarLayoutFormfactor(formfactor)]) then
|
|
||||||
formfactor = BarLayoutOptions(buttons)[1]
|
formfactor = BarLayoutOptions(buttons)[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1428,7 +1407,7 @@ pfUI:RegisterModule("actionbar", "vanilla", function ()
|
|||||||
bars[i][j] = CreateActionButton(bars[i], i, j)
|
bars[i][j] = CreateActionButton(bars[i], i, j)
|
||||||
bars[i][j].bar = i
|
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)
|
||||||
bars[i][j]:ClearAllPoints()
|
bars[i][j]:ClearAllPoints()
|
||||||
bars[i][j]:SetPoint(unpack(bars[i][j]._anchor))
|
bars[i][j]:SetPoint(unpack(bars[i][j]._anchor))
|
||||||
bars[i][j]:Show()
|
bars[i][j]:Show()
|
||||||
@@ -1459,7 +1438,7 @@ pfUI:RegisterModule("actionbar", "vanilla", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- adjust actionbar size
|
-- adjust actionbar size
|
||||||
BarLayoutSize(bars[i], buttons, formfactor, size, border, spacing, uneven)
|
BarLayoutSize(bars[i], buttons, formfactor, size, border, spacing)
|
||||||
bars[i]:SetWidth(bars[i]._size[1])
|
bars[i]:SetWidth(bars[i]._size[1])
|
||||||
bars[i]:SetHeight(bars[i]._size[2])
|
bars[i]:SetHeight(bars[i]._size[2])
|
||||||
bars[i]:ClearAllPoints()
|
bars[i]:ClearAllPoints()
|
||||||
@@ -1773,4 +1752,4 @@ pfUI:RegisterModule("actionbar", "vanilla", function ()
|
|||||||
return reagent_counts[reagent_slots[slot]]
|
return reagent_counts[reagent_slots[slot]]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
+1
-17
@@ -2609,21 +2609,6 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
|
|||||||
local formfactors = function()
|
local formfactors = function()
|
||||||
return BarLayoutOptions(tonumber(C.bars["bar"..id].buttons) or id < 11 and NUM_ACTIONBAR_BUTTONS or id > 11 and NUM_SHAPESHIFT_SLOTS or NUM_PET_ACTION_SLOTS)
|
return BarLayoutOptions(tonumber(C.bars["bar"..id].buttons) or id < 11 and NUM_ACTIONBAR_BUTTONS or id > 11 and NUM_SHAPESHIFT_SLOTS or NUM_PET_ACTION_SLOTS)
|
||||||
end
|
end
|
||||||
local uneven_options = function()
|
|
||||||
local formfactor = tostring(C.bars["bar"..id].formfactor or "")
|
|
||||||
local _, _, cols, rows = string.find(formfactor, "(%d+)%s*x%s*(%d+)")
|
|
||||||
cols, rows = tonumber(cols), tonumber(rows)
|
|
||||||
|
|
||||||
if cols == 3 and rows == 3 then
|
|
||||||
return { "Up", "Down", "Left", "Right" }
|
|
||||||
elseif cols and cols <= 3 then
|
|
||||||
return { "Up", "Down" }
|
|
||||||
elseif rows and rows <= 3 then
|
|
||||||
return { "Left", "Right" }
|
|
||||||
end
|
|
||||||
|
|
||||||
return { "Up", "Down", "Left", "Right" }
|
|
||||||
end
|
|
||||||
|
|
||||||
CreateGUIEntry(T["Actionbar"], caption, function()
|
CreateGUIEntry(T["Actionbar"], caption, function()
|
||||||
CreateConfig(U["bars"], T["Enable"], C.bars["bar"..id], "enable", "checkbox")
|
CreateConfig(U["bars"], T["Enable"], C.bars["bar"..id], "enable", "checkbox")
|
||||||
@@ -2642,7 +2627,6 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
|
|||||||
CreateConfig(U["bars"], T["Icon Size"], C.bars["bar"..id], "icon_size")
|
CreateConfig(U["bars"], T["Icon Size"], C.bars["bar"..id], "icon_size")
|
||||||
CreateConfig(U["bars"], T["Spacing"], C.bars["bar"..id], "spacing", "dropdown", pfUI.gui.dropdowns.actionbarbuttons)
|
CreateConfig(U["bars"], T["Spacing"], C.bars["bar"..id], "spacing", "dropdown", pfUI.gui.dropdowns.actionbarbuttons)
|
||||||
CreateConfig(U["bars"], T["Layout"], C.bars["bar"..id], "formfactor", "dropdown", formfactors)
|
CreateConfig(U["bars"], T["Layout"], C.bars["bar"..id], "formfactor", "dropdown", formfactors)
|
||||||
CreateConfig(U["bars"], T["Layout Uneven Orientation"], C.bars["bar"..id], "uneven", "dropdown", uneven_options)
|
|
||||||
CreateConfig(U["bars"], T["Bar Background"], C.bars["bar"..id], "background", "checkbox")
|
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")
|
CreateConfig(U["bars"], T["Show Hotkey Text"], C.bars["bar"..id], "showkeybind", "checkbox")
|
||||||
|
|
||||||
@@ -2994,4 +2978,4 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
Reference in New Issue
Block a user