Skip to content

Commit a23dce7

Browse files
committed
Sync active CollectionBox list selection with selected CollectionBox in workspace
1 parent 21ff04e commit a23dce7

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

Editor/GUIEditorApp.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,24 @@ namespace RTEGUI {
214214
m_EditorBase->SetFocus();
215215
}
216216

217+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
218+
219+
void GUIEditorApp::SelectActiveControlInList() const {
220+
if (m_SelectionInfo.Control == nullptr) {
221+
m_CollectionBoxList->SetSelectedIndex(-1);
222+
return;
223+
}
224+
// Check if this is selected in the editor, and if so, select it in the list too
225+
if (m_SelectionInfo.Control->GetID() == "COLLECTIONBOX") {
226+
for (const GUIListBox::Item *listEntry : *m_CollectionBoxList->GetItemList()) {
227+
if (listEntry->m_Name == m_SelectionInfo.Control->GetName()) {
228+
m_CollectionBoxList->SetSelectedIndex(listEntry->m_ID);
229+
}
230+
}
231+
if (!m_SelectionInfo.Control->GetChildren()->empty()) { PopulateCollectionBoxChildrenList(dynamic_cast<GUICollectionBox *>(m_SelectionInfo.Control)); }
232+
}
233+
}
234+
217235
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
218236

219237
void GUIEditorApp::AddItemToCollectionBoxList(GUIControl *control, const std::string &indent) const {
@@ -242,11 +260,6 @@ namespace RTEGUI {
242260
AddItemToCollectionBoxList(collectionBox, "\t");
243261
}
244262
}
245-
// Check if this is selected in the editor, and if so, select it in the list too
246-
if (m_SelectionInfo.Control == collectionBox) {
247-
m_CollectionBoxList->SetSelectedIndex(m_CollectionBoxList->GetItemList()->size() - 1);
248-
PopulateCollectionBoxChildrenList(collectionBox);
249-
}
250263
}
251264
}
252265
}
@@ -593,13 +606,16 @@ namespace RTEGUI {
593606
m_SelectionInfo.ClickY = mousePosY;
594607

595608
UpdateControlProperties(m_SelectionInfo.Control, false);
609+
610+
SelectActiveControlInList();
596611
} else if (control == m_RootControl) {
597612
// Unselect control
598613
m_SelectionInfo.GrabbedControl = false;
599614
m_SelectionInfo.GrabbedHandle = false;
600615
m_SelectionInfo.Control = nullptr;
601616

602617
m_PropertyPage->ClearValues();
618+
SelectActiveControlInList();
603619
}
604620
}
605621
}

Editor/GUIEditorApp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ namespace RTEGUI {
168168
/// </summary>
169169
void PopulateCollectionBoxChildrenList(GUICollectionBox *collectionBox) const;
170170

171+
/// <summary>
172+
///
173+
/// </summary>
174+
void SelectActiveControlInList() const;
175+
171176
/// <summary>
172177
/// Checks if a control is under the mouse point.
173178
/// </summary>

0 commit comments

Comments
 (0)