Skip to content

Commit 3030ca5

Browse files
committed
GuiInspector Persistent Open Panels
The GuiInspector now keeps track of which panels are open (based on name) and maintains that open list between inspecting objects. This is a great time saver when swapping back and forth between objects.
1 parent d3b96b9 commit 3030ca5

File tree

6 files changed

+51
-12
lines changed

6 files changed

+51
-12
lines changed

editor/AssetAdmin/AssetInspector.cs

-6
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@
234234
%this.inspector.addHiddenField("AssetPrivate");
235235
%this.inspector.addHiddenField("ExplicitMode");
236236
%this.inspector.inspect(%imageAsset);
237-
%this.inspector.openGroupByIndex(0);
238237

239238
%this.imageFrameEditPage.inspect(%imageAsset);
240239
%this.imageLayersEditPage.inspect(%imageAsset);
@@ -251,7 +250,6 @@
251250
%this.inspector.addHiddenField("AssetInternal");
252251
%this.inspector.addHiddenField("AssetPrivate");
253252
%this.inspector.inspect(%animationAsset);
254-
%this.inspector.openGroupByIndex(0);
255253
}
256254

257255
function AssetInspector::loadParticleAsset(%this, %particleAsset, %assetID)
@@ -306,7 +304,6 @@
306304
%this.emitterGraphPage.inspect(%particleAsset, %index - 1);
307305
}
308306
%this.tabBook.selectPage(%curSel);
309-
%this.inspector.openGroupByIndex(0);
310307

311308
%this.emitterButtonBar.visible = true;
312309
%this.emitterButtonBar.refreshEnabled();
@@ -323,7 +320,6 @@
323320
%this.inspector.addHiddenField("AssetInternal");
324321
%this.inspector.addHiddenField("AssetPrivate");
325322
%this.inspector.inspect(%fontAsset);
326-
%this.inspector.openGroupByIndex(0);
327323
}
328324

329325
function AssetInspector::loadAudioAsset(%this, %audioAsset, %assetID)
@@ -337,7 +333,6 @@
337333
%this.inspector.addHiddenField("AssetInternal");
338334
%this.inspector.addHiddenField("AssetPrivate");
339335
%this.inspector.inspect(%audioAsset);
340-
%this.inspector.openGroupByIndex(0);
341336
}
342337

343338
function AssetInspector::loadSpineAsset(%this, %spineAsset, %assetID)
@@ -351,7 +346,6 @@
351346
%this.inspector.addHiddenField("AssetInternal");
352347
%this.inspector.addHiddenField("AssetPrivate");
353348
%this.inspector.inspect(%spineAsset);
354-
%this.inspector.openGroupByIndex(0);
355349
}
356350

357351
function AssetInspector::deleteAsset(%this)

editor/GuiEditor/scripts/GuiEditorExplorerTree.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
{
2020
if(%this.getSelCount() == 1)
2121
{
22-
%this.postEvent("Inspect", %item);
22+
%this.postEvent("ClearInspectAll");
23+
%this.postEvent("AlsoInspect", %item);
2324
}
2425
else
2526
{

engine/source/gui/containers/guiExpandCtrl.cc

+15
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,21 @@ void GuiExpandCtrl::setExpanded(bool isExpanded)
183183
}
184184
}
185185

186+
void GuiExpandCtrl::setExpandedInstant(bool isExpanded)
187+
{
188+
mExpanded = isExpanded;
189+
190+
if (mExpanded)
191+
{
192+
mBounds.extent.set(mExpandedExtent.x, mExpandedExtent.y);
193+
}
194+
else
195+
{
196+
mBounds.extent.set(mCollapsedExtent.x, mCollapsedExtent.y);
197+
}
198+
toggleHiddenChildren();
199+
}
200+
186201
bool GuiExpandCtrl::processExpansion()
187202
{
188203
F32 progress = getProgress(32.0f);

engine/source/gui/containers/guiExpandCtrl.h

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class GuiExpandCtrl : public GuiControl, public Fluid
6666

6767
inline bool getExpanded() { return mExpanded; };
6868
void setExpanded(bool isExpanded);
69+
void setExpandedInstant(bool isExpanded);
6970
void startExpand();
7071
void startCollapse();
7172
void expandComplete();

engine/source/gui/editor/guiInspector.cc

+31-5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ GuiInspector::GuiInspector()
3333
{
3434
mGroups.clear();
3535
mTarget = NULL;
36+
mOpenGroupList.clear();
3637

3738
mGroupPanelProfile = NULL;
3839
setField("GroupPanelProfile", "GuiPanelProfile");
@@ -278,12 +279,23 @@ void GuiInspector::clearGroups()
278279
if( mGroups.empty() )
279280
return;
280281

281-
// Attempt to find it in the group list
282-
Vector<GuiInspectorGroup*>::iterator i = mGroups.begin();
282+
mOpenGroupList.clear();
283283

284-
for( ; i != mGroups.end(); i++ )
285-
if( (*i)->isProperlyAdded() )
286-
(*i)->deleteObject();
284+
for(Vector<GuiInspectorGroup*>::iterator i = mGroups.begin(); i != mGroups.end(); i++ )
285+
{
286+
if ((*i)->isProperlyAdded())
287+
{
288+
GuiInspectorGroup* group = static_cast<GuiInspectorGroup*>(*i);
289+
290+
//First, save which groups are open by name
291+
if (group->getExpanded())
292+
{
293+
mOpenGroupList.push_back(group->getGroupName());
294+
}
295+
296+
group->deleteObject();
297+
}
298+
}
287299

288300
mGroups.clear();
289301

@@ -326,6 +338,7 @@ void GuiInspector::inspectObject( SimObject *object )
326338
general->registerObject();
327339
mGroups.push_back( general );
328340
addObject( general );
341+
checkOpenGroupList(general);
329342
}
330343

331344
// Grab this objects field list
@@ -343,6 +356,7 @@ void GuiInspector::inspectObject( SimObject *object )
343356
group->registerObject();
344357
mGroups.push_back( group );
345358
addObject( group );
359+
checkOpenGroupList(group);
346360
}
347361
}
348362
}
@@ -373,6 +387,18 @@ void GuiInspector::inspectObject( SimObject *object )
373387
guiCanvas->setFirstResponder( currResponder );
374388
}
375389

390+
void GuiInspector::checkOpenGroupList(GuiInspectorGroup* group)
391+
{
392+
for (Vector<StringTableEntry>::iterator i = mOpenGroupList.begin(); i != mOpenGroupList.end(); i++)
393+
{
394+
StringTableEntry text = static_cast<StringTableEntry>(*i);
395+
if (dStrcmp(text, group->getGroupName()) == 0)
396+
{
397+
group->setExpandedInstant(true);
398+
}
399+
}
400+
}
401+
376402
ConsoleMethod( GuiInspector, inspect, void, 3, 3, "(obj) Goes through the object's fields and autogenerates editor boxes\n"
377403
"@return No return value.")
378404
{

engine/source/gui/editor/guiInspector.h

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class GuiInspector : public GuiChainCtrl
8686
public:
8787
// Members
8888
Vector<GuiInspectorGroup*> mGroups;
89+
Vector<StringTableEntry> mOpenGroupList;
8990
SimObjectPtr<SimObject> mTarget;
9091

9192
GuiInspector();
@@ -104,6 +105,7 @@ class GuiInspector : public GuiChainCtrl
104105
inline bool hideField(const char* fieldName) { return std::find(mHiddenFieldList.begin(), mHiddenFieldList.end(), fieldName) != mHiddenFieldList.end(); };
105106
inline void clearHiddenField() { mHiddenFieldList.clear(); };
106107
inline void addHiddenField(const char* fieldName) { mHiddenFieldList.push_back(fieldName); };
108+
void checkOpenGroupList(GuiInspectorGroup* group);
107109

108110
GuiControlProfile* mGroupPanelProfile;
109111
GuiControlProfile* mGroupGridProfile;

0 commit comments

Comments
 (0)