Merge pull request #8808 from furo321/collapse-all-button-editor

Add button to collapse/expand all groups in editor
This commit is contained in:
Dennis Felsing 2024-08-25 21:13:27 +00:00 committed by GitHub
commit 2fc3f81725
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4297,7 +4297,7 @@ void CEditor::RenderLayers(CUIRect LayersBox)
s_ScrollToSelectionNext = true; s_ScrollToSelectionNext = true;
} }
CUIRect AddGroupButton; CUIRect AddGroupButton, CollapseAllButton;
LayersBox.HSplitTop(RowHeight + 1.0f, &AddGroupButton, &LayersBox); LayersBox.HSplitTop(RowHeight + 1.0f, &AddGroupButton, &LayersBox);
if(s_ScrollRegion.AddRect(AddGroupButton)) if(s_ScrollRegion.AddRect(AddGroupButton))
{ {
@ -4311,6 +4311,35 @@ void CEditor::RenderLayers(CUIRect LayersBox)
} }
} }
LayersBox.HSplitTop(5.0f, nullptr, &LayersBox);
LayersBox.HSplitTop(RowHeight + 1.0f, &CollapseAllButton, &LayersBox);
if(s_ScrollRegion.AddRect(CollapseAllButton))
{
unsigned long TotalCollapsed = 0;
for(const auto &pGroup : m_Map.m_vpGroups)
{
if(pGroup->m_Collapse)
{
TotalCollapsed++;
}
}
const char *pActionText = TotalCollapsed == m_Map.m_vpGroups.size() ? "Expand all" : "Collapse all";
CollapseAllButton.HSplitTop(RowHeight, &CollapseAllButton, 0);
static int s_CollapseAllButton = 0;
if(DoButton_Editor(&s_CollapseAllButton, pActionText, 0, &CollapseAllButton, IGraphics::CORNER_R, "Expand or collapse all groups"))
{
for(const auto &pGroup : m_Map.m_vpGroups)
{
if(TotalCollapsed == m_Map.m_vpGroups.size())
pGroup->m_Collapse = false;
else
pGroup->m_Collapse = true;
}
}
}
s_ScrollRegion.End(); s_ScrollRegion.End();
if(s_Operation == OP_NONE) if(s_Operation == OP_NONE)