Skip to content

Commit 8dbdabd

Browse files
author
LocalIdentity
committed
Partial draw controls instead of completely omitting
Config options were not being drawn if the scroll bar cause them to be partially cut off
1 parent c6483fa commit 8dbdabd

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

src/Classes/CompareTab.lua

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,16 @@ function CompareTabClass:Draw(viewPort, inputEvents)
17981798
end
17991799

18001800
self:DrawControls(viewPort)
1801+
if self.compareViewMode == "CONFIG" and compareEntry then
1802+
self:DrawConfig(contentVP, compareEntry, true)
1803+
self:DrawControlList(viewPort, {
1804+
self.controls.copyConfigBtn,
1805+
self.controls.configToggleBtn,
1806+
self.controls.configSearchEdit,
1807+
self.controls.configPrimarySetLabel,
1808+
self.controls.configPrimarySetSelect,
1809+
})
1810+
end
18011811
if drawingTree then
18021812
SetDrawLayer(0)
18031813
end
@@ -1810,6 +1820,17 @@ end
18101820
-- DRAW HELPERS
18111821
-- ============================================================
18121822

1823+
function CompareTabClass:DrawControlList(viewPort, controls)
1824+
local noTooltip = function(control)
1825+
return self.selControl and self.selControl.hasFocus and self.selControl ~= control
1826+
end
1827+
for _, control in ipairs(controls) do
1828+
if control:IsShown() and control.Draw then
1829+
control:Draw(viewPort, noTooltip(control))
1830+
end
1831+
end
1832+
end
1833+
18131834
-- Pre-draw tree header/footer backgrounds and position tree controls.
18141835
-- Must run before ProcessControlsInput so controls render on top of backgrounds.
18151836
function CompareTabClass:LayoutTreeView(contentVP, compareEntry)
@@ -2123,6 +2144,7 @@ function CompareTabClass:LayoutConfigView(contentVP, compareEntry)
21232144
local scrollTopAbs = contentVP.y + fixedHeaderHeight
21242145
local scrollBottomAbs = contentVP.y + contentVP.height
21252146
local ctrlH = rowHeight
2147+
local mouseClipRect = { contentVP.x, scrollTopAbs, contentVP.width, scrollBottomAbs - scrollTopAbs }
21262148
for _, sec in ipairs(sectionLayout) do
21272149
local sectionAbsX = contentVP.x + sec.x
21282150
local rowY = sec.y + sectionInnerPad
@@ -2134,11 +2156,13 @@ function CompareTabClass:LayoutConfigView(contentVP, compareEntry)
21342156
ci.compareControl.y = contentVP.y + fixedHeaderHeight + rowY - self.scrollY
21352157
local shownFn = function()
21362158
local ay = ci.primaryControl.y
2137-
return ay >= scrollTopAbs and ay + ctrlH <= scrollBottomAbs
2159+
return ay + ctrlH > scrollTopAbs and ay < scrollBottomAbs
21382160
and self.compareViewMode == "CONFIG" and self:GetActiveCompare() ~= nil
21392161
end
21402162
ci.primaryControl.shown = shownFn
21412163
ci.compareControl.shown = shownFn
2164+
ci.primaryControl.mouseClipRect = mouseClipRect
2165+
ci.compareControl.mouseClipRect = mouseClipRect
21422166
rowY = rowY + rowHeight
21432167
end
21442168
end
@@ -4839,7 +4863,7 @@ end
48394863
-- ============================================================
48404864
-- CONFIG VIEW
48414865
-- ============================================================
4842-
function CompareTabClass:DrawConfig(vp, compareEntry)
4866+
function CompareTabClass:DrawConfig(vp, compareEntry, headerOnly)
48434867
local rowHeight = LAYOUT.configRowHeight
48444868
local columnHeaderHeight = LAYOUT.configColumnHeaderHeight
48454869
local fixedHeaderHeight = LAYOUT.configFixedHeaderHeight
@@ -4849,6 +4873,8 @@ function CompareTabClass:DrawConfig(vp, compareEntry)
48494873

48504874
-- Fixed header area: row 1 = buttons, row 2 = search/dropdowns, then column headers + separator
48514875
SetViewport(vp.x, vp.y, vp.width, fixedHeaderHeight)
4876+
SetDrawColor(0.05, 0.05, 0.05)
4877+
DrawImage(nil, 0, 0, vp.width, fixedHeaderHeight)
48524878
-- Controls are drawn by ControlHost (positioned in LayoutConfigView)
48534879
local colHeaderY = 54
48544880
SetDrawColor(1, 1, 1)
@@ -4860,6 +4886,10 @@ function CompareTabClass:DrawConfig(vp, compareEntry)
48604886
colorCodes.WARNING .. (compareEntry.label or "Compare Build"))
48614887
SetDrawColor(0.5, 0.5, 0.5)
48624888
DrawImage(nil, 4, colHeaderY + columnHeaderHeight + 4, vp.width - 8, 2)
4889+
if headerOnly then
4890+
SetViewport()
4891+
return
4892+
end
48634893

48644894
-- Scrollable content area (clipped below fixed header)
48654895
local scrollH = vp.height - fixedHeaderHeight

src/Classes/ControlHost.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@ end
2727
function ControlHostClass:GetMouseOverControl()
2828
for _, control in pairs(self.controls) do
2929
if control.IsMouseOver and control:IsMouseOver() then
30-
return control
30+
local clip = control.mouseClipRect
31+
if type(clip) == "function" then
32+
clip = clip(control)
33+
end
34+
if not clip then
35+
return control
36+
end
37+
local cursorX, cursorY = GetCursorPos()
38+
if cursorX >= clip[1] and cursorY >= clip[2] and cursorX < clip[1] + clip[3] and cursorY < clip[2] + clip[4] then
39+
return control
40+
end
3141
end
3242
end
3343
end

0 commit comments

Comments
 (0)