Skip to content

Commit 4f6349f

Browse files
committed
Fix indentation atrocities (here as well)
1 parent 3d3f48f commit 4f6349f

1 file changed

Lines changed: 44 additions & 44 deletions

File tree

src/Classes/Tooltip.lua

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -319,41 +319,41 @@ function TooltipClass:CalculateColumns(ttY, ttX, ttH, ttW, viewPort)
319319
end
320320

321321
-- Resizing/Shrinking drawStack elements in extra columns
322-
-- NOTE: this logic depends on the current structure of `drawStack` --> needs adjustment if lengths or coordinates logic changes
323-
if columns > 1 and extraColumnWidth > 0 then
324-
for _, line in ipairs(drawStack) do
325-
local isText = #line >= 6 -- Text elements have 6 props, images/separators have 5
326-
local xIdx = isText and 1 or 2 -- `x` value at index 1 for text, 2 otherwise
327-
local origX = line[xIdx]
328-
329-
-- calculate column index (origX is at least x * original widths from start)
330-
local colIndex = m_floor((origX - ttX) / ttW) + 1
331-
332-
if colIndex > 1 then
333-
local oldBaseX = ttX + ttW * (colIndex - 1)
334-
local newBaseX = ttX + ttW + extraColumnWidth * (colIndex - 2) -- `- 2` because first column is unchanged
335-
336-
-- Update x coordinates
337-
if isText and line[3] == "CENTER_X" then
322+
-- NOTE: this logic depends on the current structure of `drawStack` --> needs adjustment if lengths or coordinates logic changes
323+
if columns > 1 and extraColumnWidth > 0 then
324+
for _, line in ipairs(drawStack) do
325+
local isText = #line >= 6 -- Text elements have 6 props, images/separators have 5
326+
local xIdx = isText and 1 or 2 -- `x` value at index 1 for text, 2 otherwise
327+
local origX = line[xIdx]
328+
329+
-- calculate column index (origX is at least x * original widths from start)
330+
local colIndex = m_floor((origX - ttX) / ttW) + 1
331+
332+
if colIndex > 1 then
333+
local oldBaseX = ttX + ttW * (colIndex - 1)
334+
local newBaseX = ttX + ttW + extraColumnWidth * (colIndex - 2) -- `- 2` because first column is unchanged
335+
336+
-- Update x coordinates
337+
if isText and line[3] == "CENTER_X" then
338338
-- centered texts
339-
line[xIdx] = newBaseX + extraColumnWidth / 2
340-
else
339+
line[xIdx] = newBaseX + extraColumnWidth / 2
340+
else
341341
-- "LEFT" aligned text and images (NOTE: "RIGHT" aligned does not seem to exist)
342-
line[xIdx] = origX - oldBaseX + newBaseX
343-
end
342+
line[xIdx] = origX - oldBaseX + newBaseX
343+
end
344344

345-
-- Resize separators/dividers (technically unlikely to appear in extra columns, but just in case)
346-
if not isText then
345+
-- Resize separators/dividers (technically unlikely to appear in extra columns, but just in case)
346+
if not isText then
347347
-- separator images have `width` value at index 4
348-
if line[1] and type(line[1]) == "table" and line[1].isSeparator then
349-
line[4] = extraColumnWidth - H_PAD -- "fancy" separators get extra padding
350-
else
351-
line[4] = extraColumnWidth - BORDER_WIDTH
352-
end
353-
end
354-
end
355-
end
356-
end
348+
if line[1] and type(line[1]) == "table" and line[1].isSeparator then
349+
line[4] = extraColumnWidth - H_PAD -- "fancy" separators get extra padding
350+
else
351+
line[4] = extraColumnWidth - BORDER_WIDTH
352+
end
353+
end
354+
end
355+
end
356+
end
357357

358358
return columns, maxColumnHeight, drawStack, extraColumnWidth
359359
end
@@ -435,24 +435,24 @@ function TooltipClass:Draw(x, y, w, h, viewPort)
435435

436436
-- ensure extraColumnWidth has sensible value and calculate new total width (original width + extraColumns)
437437
extraColumnWidth = (columns > 1 and extraColumnWidth > 0) and extraColumnWidth or ttW
438-
local totalDrawWidth = ttW + (m_max(columns - 1, 0) * extraColumnWidth)
438+
local totalDrawWidth = ttW + (m_max(columns - 1, 0) * extraColumnWidth)
439439

440440
-- If hover tooltip and extra columns don't fit, shift to left and adjust drawStack (because hover tooltips can't scroll)
441441
if columns > 1 and isHoverToolTip and totalDrawWidth + ttX >= viewPort.x + viewPort.width then
442-
local newX = m_max(viewPort.x, viewPort.x + viewPort.width - totalDrawWidth)
443-
local offsetX = newX - ttX
444-
ttX = newX
445-
446-
for _, line in ipairs(drawStack) do
447-
if #line < 6 then
442+
local newX = m_max(viewPort.x, viewPort.x + viewPort.width - totalDrawWidth)
443+
local offsetX = newX - ttX
444+
ttX = newX
445+
446+
for _, line in ipairs(drawStack) do
447+
if #line < 6 then
448448
-- Text element entries have 6 entries and `x` at `[2]`
449-
line[2] = line[2] + offsetX
450-
else
449+
line[2] = line[2] + offsetX
450+
else
451451
-- Image, Separators, etc. have 5 entries and `x` at `[1]`
452-
line[1] = line[1] + offsetX
453-
end
454-
end
455-
end
452+
line[1] = line[1] + offsetX
453+
end
454+
end
455+
end
456456

457457
-- background shading currently must be drawn before text lines. API change will allow something like the commented lines below
458458
SetDrawColor(0, 0, 0, .85)

0 commit comments

Comments
 (0)