mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Merge pull request #8808 from furo321/collapse-all-button-editor
Add button to collapse/expand all groups in editor
This commit is contained in:
commit
2fc3f81725
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue