Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Classes/ConfigTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
self.toggleConfigs = not self.toggleConfigs
end)

local function isCollapsed(section)
return self:IsSectionCollapsed(section)
end

local function searchMatch(varData)
local searchStr = self.controls.search.buf:lower():gsub("[%-%.%+%[%]%$%^%%%?%*]", "%%%0")
if searchStr and searchStr:match("%S") then
Expand Down Expand Up @@ -633,6 +637,15 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
end
end

local ownSection = lastSection
local eligibleShown = control.shown
control.shown = function()
if isCollapsed(ownSection) then
return false
end
return type(eligibleShown) == "boolean" and eligibleShown or eligibleShown()
end

t_insert(self.controls, control)
t_insert(lastSection.varControlList, control)
end
Expand Down Expand Up @@ -815,6 +828,10 @@ function ConfigTabClass:Draw(viewPort, inputEvents)
for _, section in ipairs(self.sectionList) do
local y = 14
section.shown = true
-- Probe with the section expanded, so a collapsed section that still has
-- eligible options keeps its (clickable) header on screen
local collapsed = section.collapsed
section.collapsed = false
local doShow = false
for _, varControl in pairs(section.varControlList) do
if varControl:IsShown() then
Expand All @@ -825,6 +842,7 @@ function ConfigTabClass:Draw(viewPort, inputEvents)
y = y + height + 4
end
end
section.collapsed = collapsed
section.shown = doShow
if doShow then
local width, height = section:GetSize()
Expand Down
17 changes: 17 additions & 0 deletions src/Classes/ConfigTab.lua.rej
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff a/src/Classes/ConfigTab.lua b/src/Classes/ConfigTab.lua (rejected hunks)
@@ -258,12 +258,12 @@ function ConfigTabClass:ConfigTab(build)
lastSection.varControlList = { }
lastSection.col = varData.col
lastSection.collapsed = false
- lastSection.height = function(self)
- if self.collapsed then
+ lastSection.height = function(section)
+ if isCollapsed(section) then
return 16
end
local height = 20
- for _, varControl in pairs(self.varControlList) do
+ for _, varControl in pairs(section.varControlList) do
if varControl:IsShown() then
local _, ctrlHeight = varControl:GetSize()
height = height + m_max(ctrlHeight or varControl.height, 16) + 4