Permalink
Browse files

added possibility to collapse groups by double clicking them

  • Loading branch information...
1 parent ef881a5 commit f7a9e80163af47ef4ad1bc9df1cf635610ebe2eb SushiTee committed with oy Jul 12, 2011
Showing with 18 additions and 4 deletions.
  1. +15 −4 src/game/editor/editor.cpp
  2. +1 −0 src/game/editor/editor.h
  3. +2 −0 src/game/editor/popups.cpp
View
19 src/game/editor/editor.cpp
@@ -44,6 +44,7 @@ CLayerGroup::CLayerGroup()
m_aName[0] = 0;
m_Visible = true;
m_SaveToMap = true;
+ m_Collapse = false;
m_GameGroup = false;
m_OffsetX = 0;
m_OffsetY = 0;
@@ -1956,9 +1957,13 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
static float s_ScrollValue = 0;
for(int g = 0; g < m_Map.m_lGroups.size(); g++)
+ {
// Each group is 19.0f
// Each layer is 14.0f
- LayersHeight += 19.0f + m_Map.m_lGroups[g]->m_lLayers.size() * 14.0f;
+ LayersHeight += 19.0f;
+ if(!m_Map.m_lGroups[g]->m_Collapse)
+ LayersHeight += m_Map.m_lGroups[g]->m_lLayers.size() * 14.0f;
+ }
float ScrollDifference = LayersHeight - LayersBox.h;
@@ -2009,7 +2014,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
{
LayersBox.HSplitTop(12.0f, &Slot, &LayersBox);
Slot.VSplitLeft(12, &VisibleToggle, &Slot);
- if(DoButton_Ex(&m_Map.m_lGroups[g]->m_Visible, m_Map.m_lGroups[g]->m_Visible?"V":"H", 0, &VisibleToggle, 0, "Toggle group visibility", CUI::CORNER_L))
+ if(DoButton_Ex(&m_Map.m_lGroups[g]->m_Visible, m_Map.m_lGroups[g]->m_Visible?"V":"H", m_Map.m_lGroups[g]->m_Collapse ? 1 : 0, &VisibleToggle, 0, "Toggle group visibility", CUI::CORNER_L))
m_Map.m_lGroups[g]->m_Visible = !m_Map.m_lGroups[g]->m_Visible;
Slot.VSplitRight(12.0f, &Slot, &SaveCheck);
@@ -2022,14 +2027,17 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
while(TextRender()->TextWidth(0, FontSize, aBuf, -1) > Slot.w)
FontSize--;
if(int Result = DoButton_Ex(&m_Map.m_lGroups[g], aBuf, g==m_SelectedGroup, &Slot,
- BUTTON_CONTEXT, "Select group. Right click for properties.", 0, FontSize))
+ BUTTON_CONTEXT, m_Map.m_lGroups[g]->m_Collapse ? "Select group. Double click to expand." : "Select group. Double click to collapse.", 0, FontSize))
{
m_SelectedGroup = g;
m_SelectedLayer = 0;
static int s_GroupPopupId = 0;
if(Result == 2)
UiInvokePopupMenu(&s_GroupPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 220, PopupGroup);
+
+ if(m_Map.m_lGroups[g]->m_lLayers.size() && Input()->MouseDoubleClick())
+ m_Map.m_lGroups[g]->m_Collapse ^= 1;
}
LayersBox.HSplitTop(2.0f, &Slot, &LayersBox);
}
@@ -2045,6 +2053,9 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
continue;
}
+ if(m_Map.m_lGroups[g]->m_Collapse)
+ continue;
+
//visible
LayersBox.HSplitTop(12.0f, &Slot, &LayersBox);
Slot.VSplitLeft(12.0f, 0, &Button);
@@ -2069,7 +2080,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
while(TextRender()->TextWidth(0, FontSize, aBuf, -1) > Button.w)
FontSize--;
if(int Result = DoButton_Ex(m_Map.m_lGroups[g]->m_lLayers[i], aBuf, g==m_SelectedGroup&&i==m_SelectedLayer, &Button,
- BUTTON_CONTEXT, "Select layer. Right click for properties.", 0, FontSize))
+ BUTTON_CONTEXT, "Select layer.", 0, FontSize))
{
m_SelectedLayer = i;
m_SelectedGroup = g;
View
1 src/game/editor/editor.h
@@ -188,6 +188,7 @@ class CLayerGroup
bool m_GameGroup;
bool m_Visible;
bool m_SaveToMap;
+ bool m_Collapse;
CLayerGroup();
~CLayerGroup();
View
2 src/game/editor/popups.cpp
@@ -151,6 +151,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
l->m_pEditor = pEditor;
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l);
pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1;
+ pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false;
return 1;
}
@@ -164,6 +165,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
l->m_pEditor = pEditor;
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l);
pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1;
+ pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_Collapse = false;
return 1;
}

0 comments on commit f7a9e80

Please sign in to comment.