@@ -25,7 +25,7 @@ namespace RTEGUI {
25
25
m_EditorBase->SetDrawColor (makecol (32 , 32 , 32 ));
26
26
m_EditorBase->SetDrawType (GUICollectionBox::Color);
27
27
28
- GUILabel *frameTimeLabel = dynamic_cast <GUILabel *>(m_EditorControlManager->AddControl (" FrameTimer" , " LABEL" , m_EditorBase.get (), 300 , 10 , 0 , 20 ));
28
+ GUILabel *frameTimeLabel = dynamic_cast <GUILabel *>(m_EditorControlManager->AddControl (" FrameTimer" , " LABEL" , m_EditorBase.get (), 300 , 10 , 100 , 20 ));
29
29
frameTimeLabel->SetText (" Frame Time: 0" );
30
30
31
31
m_LeftColumn.reset (dynamic_cast <GUICollectionBox *>(m_EditorControlManager->AddControl (" LeftColumn" , " COLLECTIONBOX" , nullptr , 0 , 0 , 290 , screen->GetBitmap ()->GetHeight ())));
@@ -126,66 +126,17 @@ namespace RTEGUI {
126
126
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
127
127
128
128
void EditorManager::SetFrameTimeLabelText (int64_t frameTime) const {
129
- dynamic_cast <GUILabel *>(m_EditorControlManager->GetControl (" FrameTimer" ))->SetText (" Frame Time: " + std::to_string (frameTime));
129
+ dynamic_cast <GUILabel *>(m_EditorControlManager->GetControl (" FrameTimer" ))->SetText (" Frame Time: " + std::to_string (frameTime) + " ms " );
130
130
}
131
131
132
132
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
133
133
134
- void EditorManager::PopulateCollectionBoxList () const {
135
- m_CollectionBoxList->ClearList ();
136
- m_CollectionBoxList->AddItem (m_RootControl->GetName ());
137
-
138
- // Lambda expression to recursively add lower-level CollectionBoxes belonging to the higher-level CollectionBoxes
139
- std::function<void (GUICollectionBox *, const std::string &)> recursiveAddItem = [&recursiveAddItem, this ](GUICollectionBox *control, const std::string &indent) {
140
- m_CollectionBoxList->AddItem (indent + control->GetName ());
141
- for (GUIControl *childControl : *control->GetChildren ()) {
142
- if ((control = dynamic_cast <GUICollectionBox *>(childControl))) { recursiveAddItem (control, indent + " \t " ); }
143
- }
144
- };
145
-
146
- GUICollectionBox *collectionBox = nullptr ;
147
- for (GUIControl *control : *m_WorkspaceManager->GetControlList ()) {
148
- if ((collectionBox = dynamic_cast <GUICollectionBox *>(control)) && collectionBox->GetParent () == m_RootControl) { recursiveAddItem (collectionBox, " \t " ); }
149
- }
150
- }
151
-
152
- // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
153
-
154
- void EditorManager::PopulateCollectionBoxChildrenList (GUICollectionBox *collectionBox) const {
155
- m_ControlsInCollectionBoxList->ClearList ();
156
-
157
- // Go through all the top-level (directly under root) controls and add only the CollectionBoxes to the list here
158
- for (GUIControl *control : *collectionBox->GetChildren ()) {
159
- if (control->GetID () != " COLLECTIONBOX" ) { m_ControlsInCollectionBoxList->AddItem (control->GetName ()); }
160
- // Check if this is selected in the editor, and if so, select it in the list too
161
- if (collectionBox == s_SelectionInfo.GetControl ()) { m_ControlsInCollectionBoxList->SetSelectedIndex (m_CollectionBoxList->GetItemList ()->size () - 1 ); }
162
- }
163
- }
164
-
165
- // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
166
-
167
- void EditorManager::SelectActiveControlInList (GUIControl *control) const {
168
- // Check if this is selected in the editor, and if so, select it in the list too
169
- if (control->GetID () == " COLLECTIONBOX" ) {
170
- for (const GUIListBox::Item *listEntry : *m_CollectionBoxList->GetItemList ()) {
171
- if (listEntry->m_Name == control->GetName ()) { m_CollectionBoxList->SetSelectedIndex (listEntry->m_ID ); }
172
- }
173
- if (!control->GetChildren ()->empty ()) { PopulateCollectionBoxChildrenList (dynamic_cast <GUICollectionBox *>(control)); }
174
- } else {
175
- for (const GUIListBox::Item *listEntry : *m_ControlsInCollectionBoxList->GetItemList ()) {
176
- if (listEntry->m_Name == control->GetName ()) {
177
- for (const GUIListBox::Item *parentListEntry : *m_CollectionBoxList->GetItemList ()) {
178
- if (parentListEntry->m_Name == listEntry->m_Name ) { m_CollectionBoxList->SetSelectedIndex (parentListEntry->m_ID ); }
179
- }
180
- m_ControlsInCollectionBoxList->SetSelectedIndex (listEntry->m_ID );
181
- }
182
- }
134
+ bool EditorManager::AddNewControl (GUIEvent &editorEvent) {
135
+ if (s_SelectionInfo.GetControl () && s_SelectionInfo.GetControl ()->GetID () != " COLLECTIONBOX" ) {
136
+ s_SelectionInfo.ClearSelection ();
137
+ m_PropertyPage->ClearValues ();
183
138
}
184
- }
185
139
186
- // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
187
-
188
- bool EditorManager::AddNewControl (GUIEvent &editorEvent) {
189
140
std::string controlClass = editorEvent.GetControl ()->GetName ().substr (2 , std::string::npos);
190
141
GUIControl *parent = m_RootControl;
191
142
@@ -199,18 +150,24 @@ namespace RTEGUI {
199
150
m_WorkspaceManager->GetControl (name)->SetEnabled (false );
200
151
}
201
152
202
- PopulateCollectionBoxList ();
203
- PopulateCollectionBoxChildrenList (dynamic_cast <GUICollectionBox *>(parent));
153
+ UpdateCollectionBoxList ();
154
+ UpdateCollectionBoxChildrenList (dynamic_cast <GUICollectionBox *>(parent));
204
155
205
156
return true ;
206
157
}
207
158
208
159
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
209
160
210
- void EditorManager::RemoveControl (const std::string &controlToRemove) const {
211
- m_WorkspaceManager->RemoveControl (controlToRemove, true );
212
- ClearCurrentSelection ();
213
- PopulateCollectionBoxList ();
161
+ void EditorManager::RemoveControl (GUIControl *controlToRemove) const {
162
+ m_WorkspaceManager->RemoveControl (controlToRemove->GetName (), true );
163
+ if (controlToRemove->GetID () == " COLLECTIONBOX" ) {
164
+ ClearCurrentSelection ();
165
+ UpdateCollectionBoxList ();
166
+ } else {
167
+ s_SelectionInfo.ClearSelection ();
168
+ m_PropertyPage->ClearValues ();
169
+ UpdateCollectionBoxChildrenList (dynamic_cast <GUICollectionBox *>(controlToRemove->GetParent ()));
170
+ }
214
171
}
215
172
216
173
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -236,6 +193,119 @@ namespace RTEGUI {
236
193
return controlType;
237
194
}
238
195
196
+ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
197
+
198
+ void EditorManager::SelectActiveControlFromParentList () const {
199
+ const GUIListPanel::Item *selectedItem = m_CollectionBoxList->GetSelected ();
200
+
201
+ if (selectedItem) {
202
+ // Try to find the box of that name, and select it
203
+ GUIControl *control = m_WorkspaceManager->GetControl (selectedItem->m_Name .substr (selectedItem->m_Name .find_first_not_of (' \t ' ), std::string::npos));
204
+ if (control) {
205
+ // If the selected item is the root control don't grab it but proceed to populate the children list from it
206
+ if (selectedItem->m_Name == m_RootControl->GetName ()) {
207
+ s_SelectionInfo.ClearSelection ();
208
+ m_PropertyPage->ClearValues ();
209
+ } else {
210
+ s_SelectionInfo.ReleaseAnyGrabs ();
211
+ s_SelectionInfo.SetControl (control);
212
+ }
213
+ UpdateCollectionBoxChildrenList (dynamic_cast <GUICollectionBox *>(control));
214
+ m_ControlsInCollectionBoxList->SetSelectedIndex (-1 );
215
+ }
216
+ } else {
217
+ // Deselection if clicked on no list item
218
+ ClearCurrentSelection ();
219
+ // When nothing is selected populate the children list with the root control's children to show any "loose" controls
220
+ UpdateCollectionBoxChildrenList (dynamic_cast <GUICollectionBox *>(m_RootControl));
221
+ m_ControlsInCollectionBoxList->SetSelectedIndex (-1 );
222
+ }
223
+ RemoveFocus ();
224
+ }
225
+
226
+ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
227
+
228
+ void EditorManager::SelectActiveControlFromChildrenList () const {
229
+ const GUIListPanel::Item *selectedItem = m_ControlsInCollectionBoxList->GetSelected ();
230
+ if (selectedItem) {
231
+ // Try to find the control of that name, and select it
232
+ GUIControl *control = m_WorkspaceManager->GetControl (selectedItem->m_Name );
233
+ if (control) {
234
+ s_SelectionInfo.ReleaseAnyGrabs ();
235
+ s_SelectionInfo.SetControl (control);
236
+ }
237
+ } else {
238
+ // Deselection if clicked on no list item
239
+ s_SelectionInfo.ClearSelection ();
240
+ m_PropertyPage->ClearValues ();
241
+ }
242
+ RemoveFocus ();
243
+ }
244
+
245
+ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
246
+
247
+ void EditorManager::SelectActiveControlInParentList (GUIControl *control) const {
248
+ // Check if this is selected in the editor and select it in the list too
249
+ for (const GUIListBox::Item *listEntry : *m_CollectionBoxList->GetItemList ()) {
250
+ if (listEntry->m_Name .substr (listEntry->m_Name .find_first_not_of (' \t ' ), std::string::npos) == control->GetName ()) {
251
+ m_CollectionBoxList->SetSelectedIndex (listEntry->m_ID );
252
+ break ;
253
+ }
254
+ }
255
+ UpdateCollectionBoxChildrenList (dynamic_cast <GUICollectionBox *>(control));
256
+ m_ControlsInCollectionBoxList->SetSelectedIndex (-1 );
257
+ }
258
+
259
+ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
260
+
261
+ void EditorManager::SelectActiveControlInChildrenList (GUIControl *control) const {
262
+ // Check if this is selected in the editor and select it's parent in the parent list and then select it in the children list
263
+ SelectActiveControlInParentList (control->GetParent ());
264
+ for (const GUIListBox::Item *listEntry : *m_ControlsInCollectionBoxList->GetItemList ()) {
265
+ if (listEntry->m_Name == control->GetName ()) {
266
+ m_ControlsInCollectionBoxList->SetSelectedIndex (listEntry->m_ID );
267
+ break ;
268
+ }
269
+ }
270
+ }
271
+
272
+ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
273
+
274
+ void EditorManager::UpdateCollectionBoxList () const {
275
+ m_CollectionBoxList->ClearList ();
276
+ m_CollectionBoxList->AddItem (m_RootControl->GetName ());
277
+
278
+ // Lambda expression to recursively add lower-level CollectionBoxes belonging to the higher-level CollectionBoxes
279
+ std::function<void (GUICollectionBox *, const std::string &)> recursiveAddItem = [&recursiveAddItem, this ](GUICollectionBox *control, const std::string &indent) {
280
+ m_CollectionBoxList->AddItem (indent + control->GetName ());
281
+ for (GUIControl *childControl : *control->GetChildren ()) {
282
+ if ((control = dynamic_cast <GUICollectionBox *>(childControl))) { recursiveAddItem (control, indent + " \t " ); }
283
+ }
284
+ };
285
+
286
+ GUICollectionBox *collectionBox = nullptr ;
287
+ for (GUIControl *control : *m_WorkspaceManager->GetControlList ()) {
288
+ if ((collectionBox = dynamic_cast <GUICollectionBox *>(control)) && collectionBox->GetParent () == m_RootControl) { recursiveAddItem (collectionBox, " \t " ); }
289
+ }
290
+ }
291
+
292
+ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
293
+
294
+ void EditorManager::UpdateCollectionBoxChildrenList (GUICollectionBox *collectionBox) const {
295
+ m_ControlsInCollectionBoxList->ClearList ();
296
+
297
+ // Go through all the top-level (directly under root) controls and add only the CollectionBoxes to the list here
298
+ for (GUIControl *control : *collectionBox->GetChildren ()) {
299
+ if (control->GetID () != " COLLECTIONBOX" ) { m_ControlsInCollectionBoxList->AddItem (control->GetName ()); }
300
+ // Check if this is selected in the editor, and if so, select it in the list too
301
+ // if (collectionBox == s_SelectionInfo.GetControl()) { m_ControlsInCollectionBoxList->SetSelectedIndex(m_CollectionBoxList->GetItemList()->size() - 1); }
302
+ if (collectionBox == s_SelectionInfo.GetControl ()) {
303
+ m_ControlsInCollectionBoxList->SetSelectedIndex (-1 );
304
+ break ;
305
+ }
306
+ }
307
+ }
308
+
239
309
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
240
310
241
311
bool EditorManager::MouseInsideBox (int mousePosX, int mousePosY, int boxPosX, int boxPosY, int boxWidth, int boxHeight) const {
@@ -303,34 +373,11 @@ namespace RTEGUI {
303
373
m_PropertyPage->ClearValues ();
304
374
m_CollectionBoxList->SetSelectedIndex (-1 );
305
375
m_ControlsInCollectionBoxList->ClearList ();
306
- // PopulateCollectionBoxChildrenList(dynamic_cast<GUICollectionBox *>(m_RootControl));
307
376
308
377
// Clear focused control of the manager itself so it doesn't persist between selection changes (e.g property page line remains selected after clearing or changing selection)
309
378
RemoveFocus ();
310
379
}
311
380
312
- // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
313
-
314
- void EditorManager::UpdateCollectionBoxList () const {
315
- const GUIListPanel::Item *selectedItem = m_CollectionBoxList->GetSelected ();
316
-
317
- // If the selected item is the root control treat it as if no item was selected
318
- if (selectedItem && selectedItem->m_Name != m_RootControl->GetName ()) {
319
- // Try to find the box of that name, and select it
320
- GUIControl *control = m_WorkspaceManager->GetControl (selectedItem->m_Name .substr (selectedItem->m_Name .find_first_not_of (' \t ' ), std::string::npos));
321
- if (control) {
322
- s_SelectionInfo.ReleaseAnyGrabs ();
323
- s_SelectionInfo.SetControl (control);
324
-
325
- PopulateCollectionBoxChildrenList (dynamic_cast <GUICollectionBox *>(control));
326
- }
327
- } else {
328
- // Deselection if clicked on no list item
329
- ClearCurrentSelection ();
330
- }
331
- RemoveFocus ();
332
- }
333
-
334
381
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
335
382
336
383
void EditorManager::UpdateSnapGridSize (GUIEvent &editorEvent) const {
0 commit comments