Commit 5be7b0dd authored by Darth Predator's avatar Darth Predator

Fix custom tab width for scroll frame, apparently shit breaks a lot with default size calculations

parent 74ec364d
......@@ -10,7 +10,6 @@ local FCFDock_GetSelectedWindow = FCFDock_GetSelectedWindow
local FCFTab_UpdateAlpha = FCFTab_UpdateAlpha
local FCFTab_UpdateColors = FCFTab_UpdateColors
local FCFDock_ScrollToSelectedTab = FCFDock_ScrollToSelectedTab
local FCFDock_CalculateTabSize = FCFDock_CalculateTabSize
local PanelTemplates_TabResize = PanelTemplates_TabResize
--This variable is used to see if overflow button should be shown when using non-blizz width
......@@ -38,6 +37,37 @@ function C:ApplySelectedTabIndicator(tab, title)
end
end
--Analog for blizz dynamic chat framers calculation, used only here. Based on original blizz function with altered numbers and shit
local function SLE_FCFDock_CalculateTabSize(dock, numDynFrames, sleWidth)
local MIN_SIZE, MAX_SIZE = 60, 100;
local scrollSize = dock.scrollFrame:GetWidth() + (dock.overflowButton:IsShown() and dock.overflowButton.width or 0); --We want the total width assuming no overflow button.
--First, see if we can fit all the tabs at the maximum size
if ( numDynFrames * MAX_SIZE < scrollSize ) then
return MAX_SIZE, false;
end
if (C.TotalTabsWidth > scrollSize) or ( scrollSize / MIN_SIZE < numDynFrames ) then
--Not everything fits, so we'll need room for the overflow button.
scrollSize = scrollSize - dock.overflowButton.width;
end
--Figure out how many tabs we're going to be able to fit at the minimum size
local numWholeTabs = min(floor(scrollSize / sleWidth), numDynFrames)
if ( scrollSize == 0 ) then
return 1, (numDynFrames > 0);
end
if ( numWholeTabs == 0 ) then
return scrollSize, true;
end
--How big each tab should be.
local tabSize = E.db.sle.chat.tab.resize ~= "Blizzard" and sleWidth or (scrollSize / numWholeTabs);
return tabSize, (numDynFrames > numWholeTabs);
end
--Full update tabs function. Hooking to it allows to set size and selection at the same time.
--Most of the content is default blizz function with sligh modifications
function C:FCFDock_UpdateTabs(dock, forceUpdate)
......@@ -53,6 +83,8 @@ function C:FCFDock_UpdateTabs(dock, forceUpdate)
local selectedDynIndex = nil;
C.TotalTabsWidth = 0 --Reseting saved combined width
--Determain width for non blizzard resize. Needed cause I fucked up in the past allowing it for non-scroll tabs only
local sleWidth
for index, chatFrame in T.ipairs(dock.DOCKED_CHAT_FRAMES) do
local chatTab = _G[chatFrame:GetName().."Tab"];
......@@ -63,11 +95,13 @@ function C:FCFDock_UpdateTabs(dock, forceUpdate)
--Resizing tabs, don't need to do that if blizz sizing is selected
if E.db.sle.chat.tab.resize ~= "Blizzard" then
local width = (E.db.sle.chat.tab.resize == "None" and chatTab.origWidth) or (E.db.sle.chat.tab.resize == "Title" and chatTab.textWidth) or (E.db.sle.chat.tab.resize == "Custom" and E.db.sle.chat.tab.customWidth)
C.TotalTabsWidth = C.TotalTabsWidth + width
--Setting the width now
sleWidth = (E.db.sle.chat.tab.resize == "None" and chatTab.origWidth) or (E.db.sle.chat.tab.resize == "Title" and (chatTab.textWidth)) or (E.db.sle.chat.tab.resize == "Custom" and E.db.sle.chat.tab.customWidth)
if sleWidth < 45 then sleWidth = 45 end --We have a min of 45. If somehow this happens to be lower., stuff looks ugly.
if ( chatFrame.isStaticDocked ) then
chatTab:SetParent(dock);
PanelTemplates_TabResize(chatTab, chatTab.isTemporary and 20 or 10, nil, nil, nil, width);
PanelTemplates_TabResize(chatTab, chatTab.isTemporary and 20 or 10, nil, nil, nil, sleWidth);
if ( lastDockedStaticTab ) then
chatTab:SetPoint("LEFT", lastDockedStaticTab, "RIGHT", 0, 0);
else
......@@ -88,14 +122,14 @@ function C:FCFDock_UpdateTabs(dock, forceUpdate)
chatTab:SetPoint("LEFT", scrollChild, "LEFT", 0, 0);
end
lastDockedDynamicTab = chatTab;
C.TotalTabsWidth = C.TotalTabsWidth + sleWidth
end
end
end
--If blizz sizing is selected then messing around with scroll frame is unnessesary
if E.db.sle.chat.tab.resize == "Blizzard" then return end
local dynTabSize, origOverflow = FCFDock_CalculateTabSize(dock, numDynFrames); --Usually this returns "hasOverflow" as well, but I use my own variable for that
local hasOverflow = C.TotalTabsWidth > E.db.chat.panelWidth
local dynTabSize, hasOverflow = SLE_FCFDock_CalculateTabSize(dock, numDynFrames, sleWidth) --Call for own dynamic size calc, cause blizz one fuck up custom sized due to not even knowing we do custom shit
--Dynamically resize tabs
for index, chatFrame in T.ipairs(dock.DOCKED_CHAT_FRAMES) do
......
......@@ -29,7 +29,7 @@ local function configTable()
type = "range",
name = L["Width"],
disabled = function() return E.db.sle.chat.tab.resize ~= "Custom" end,
min = 10, max = 100, step = 1,
min = 45, max = 100, step = 1,
},
spacer = {
order = 3,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment