Browse Source

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.
Peter Robinson 2 years ago
parent
commit
3030ca5fc9

+ 0 - 6
editor/AssetAdmin/AssetInspector.cs

@@ -234,7 +234,6 @@ function AssetInspector::loadImageAsset(%this, %imageAsset, %assetID)
 	%this.inspector.addHiddenField("AssetPrivate");
 	%this.inspector.addHiddenField("AssetPrivate");
 	%this.inspector.addHiddenField("ExplicitMode");
 	%this.inspector.addHiddenField("ExplicitMode");
 	%this.inspector.inspect(%imageAsset);
 	%this.inspector.inspect(%imageAsset);
-	%this.inspector.openGroupByIndex(0);
 
 
 	%this.imageFrameEditPage.inspect(%imageAsset);
 	%this.imageFrameEditPage.inspect(%imageAsset);
 	%this.imageLayersEditPage.inspect(%imageAsset);
 	%this.imageLayersEditPage.inspect(%imageAsset);
@@ -251,7 +250,6 @@ function AssetInspector::loadAnimationAsset(%this, %animationAsset, %assetID)
 	%this.inspector.addHiddenField("AssetInternal");
 	%this.inspector.addHiddenField("AssetInternal");
 	%this.inspector.addHiddenField("AssetPrivate");
 	%this.inspector.addHiddenField("AssetPrivate");
 	%this.inspector.inspect(%animationAsset);
 	%this.inspector.inspect(%animationAsset);
-	%this.inspector.openGroupByIndex(0);
 }
 }
 
 
 function AssetInspector::loadParticleAsset(%this, %particleAsset, %assetID)
 function AssetInspector::loadParticleAsset(%this, %particleAsset, %assetID)
@@ -306,7 +304,6 @@ function AssetInspector::onChooseParticleAsset(%this, %particleAsset)
 		%this.emitterGraphPage.inspect(%particleAsset, %index - 1);
 		%this.emitterGraphPage.inspect(%particleAsset, %index - 1);
 	}
 	}
 	%this.tabBook.selectPage(%curSel);
 	%this.tabBook.selectPage(%curSel);
-	%this.inspector.openGroupByIndex(0);
 
 
 	%this.emitterButtonBar.visible = true;
 	%this.emitterButtonBar.visible = true;
 	%this.emitterButtonBar.refreshEnabled();
 	%this.emitterButtonBar.refreshEnabled();
@@ -323,7 +320,6 @@ function AssetInspector::loadFontAsset(%this, %fontAsset, %assetID)
 	%this.inspector.addHiddenField("AssetInternal");
 	%this.inspector.addHiddenField("AssetInternal");
 	%this.inspector.addHiddenField("AssetPrivate");
 	%this.inspector.addHiddenField("AssetPrivate");
 	%this.inspector.inspect(%fontAsset);
 	%this.inspector.inspect(%fontAsset);
-	%this.inspector.openGroupByIndex(0);
 }
 }
 
 
 function AssetInspector::loadAudioAsset(%this, %audioAsset, %assetID)
 function AssetInspector::loadAudioAsset(%this, %audioAsset, %assetID)
@@ -337,7 +333,6 @@ function AssetInspector::loadAudioAsset(%this, %audioAsset, %assetID)
 	%this.inspector.addHiddenField("AssetInternal");
 	%this.inspector.addHiddenField("AssetInternal");
 	%this.inspector.addHiddenField("AssetPrivate");
 	%this.inspector.addHiddenField("AssetPrivate");
 	%this.inspector.inspect(%audioAsset);
 	%this.inspector.inspect(%audioAsset);
-	%this.inspector.openGroupByIndex(0);
 }
 }
 
 
 function AssetInspector::loadSpineAsset(%this, %spineAsset, %assetID)
 function AssetInspector::loadSpineAsset(%this, %spineAsset, %assetID)
@@ -351,7 +346,6 @@ function AssetInspector::loadSpineAsset(%this, %spineAsset, %assetID)
 	%this.inspector.addHiddenField("AssetInternal");
 	%this.inspector.addHiddenField("AssetInternal");
 	%this.inspector.addHiddenField("AssetPrivate");
 	%this.inspector.addHiddenField("AssetPrivate");
 	%this.inspector.inspect(%spineAsset);
 	%this.inspector.inspect(%spineAsset);
-	%this.inspector.openGroupByIndex(0);
 }
 }
 
 
 function AssetInspector::deleteAsset(%this)
 function AssetInspector::deleteAsset(%this)

+ 2 - 1
editor/GuiEditor/scripts/GuiEditorExplorerTree.cs

@@ -19,7 +19,8 @@ function GuiEditorExplorerTree::onSelect(%this, %index, %text, %item)
 {
 {
     if(%this.getSelCount() == 1)
     if(%this.getSelCount() == 1)
     {
     {
-        %this.postEvent("Inspect", %item);
+        %this.postEvent("ClearInspectAll");
+        %this.postEvent("AlsoInspect", %item);
     }
     }
     else 
     else 
     {
     {

+ 15 - 0
engine/source/gui/containers/guiExpandCtrl.cc

@@ -183,6 +183,21 @@ void GuiExpandCtrl::setExpanded(bool isExpanded)
 	}
 	}
 }
 }
 
 
+void GuiExpandCtrl::setExpandedInstant(bool isExpanded)
+{
+	mExpanded = isExpanded;
+
+	if (mExpanded)
+	{
+		mBounds.extent.set(mExpandedExtent.x, mExpandedExtent.y);
+	}
+	else
+	{
+		mBounds.extent.set(mCollapsedExtent.x, mCollapsedExtent.y);
+	}
+	toggleHiddenChildren();
+}
+
 bool GuiExpandCtrl::processExpansion()
 bool GuiExpandCtrl::processExpansion()
 {
 {
 	F32 progress = getProgress(32.0f);
 	F32 progress = getProgress(32.0f);

+ 1 - 0
engine/source/gui/containers/guiExpandCtrl.h

@@ -66,6 +66,7 @@ public:
 
 
 	inline bool getExpanded() { return mExpanded; };
 	inline bool getExpanded() { return mExpanded; };
 	void setExpanded(bool isExpanded);
 	void setExpanded(bool isExpanded);
+	void setExpandedInstant(bool isExpanded);
 	void startExpand();
 	void startExpand();
 	void startCollapse();
 	void startCollapse();
 	void expandComplete();
 	void expandComplete();

+ 31 - 5
engine/source/gui/editor/guiInspector.cc

@@ -33,6 +33,7 @@ GuiInspector::GuiInspector()
 {
 {
    mGroups.clear();
    mGroups.clear();
    mTarget = NULL;
    mTarget = NULL;
+   mOpenGroupList.clear();
 
 
    mGroupPanelProfile = NULL;
    mGroupPanelProfile = NULL;
    setField("GroupPanelProfile", "GuiPanelProfile");
    setField("GroupPanelProfile", "GuiPanelProfile");
@@ -278,12 +279,23 @@ void GuiInspector::clearGroups()
    if( mGroups.empty() )
    if( mGroups.empty() )
       return;
       return;
 
 
-   // Attempt to find it in the group list
-   Vector<GuiInspectorGroup*>::iterator i = mGroups.begin();
+	mOpenGroupList.clear();
 
 
-   for( ; i != mGroups.end(); i++ )
-      if( (*i)->isProperlyAdded() )
-         (*i)->deleteObject();
+	for(Vector<GuiInspectorGroup*>::iterator i = mGroups.begin(); i != mGroups.end(); i++ )
+	{
+		if ((*i)->isProperlyAdded())
+		{
+			GuiInspectorGroup* group = static_cast<GuiInspectorGroup*>(*i);
+
+			//First, save which groups are open by name
+			if (group->getExpanded())
+			{
+				mOpenGroupList.push_back(group->getGroupName());
+			}
+
+			group->deleteObject();
+		}
+	}
 
 
    mGroups.clear();
    mGroups.clear();
 
 
@@ -326,6 +338,7 @@ void GuiInspector::inspectObject( SimObject *object )
       general->registerObject();
       general->registerObject();
       mGroups.push_back( general );
       mGroups.push_back( general );
       addObject( general );
       addObject( general );
+	  checkOpenGroupList(general);
    }
    }
 
 
    // Grab this objects field list
    // Grab this objects field list
@@ -343,6 +356,7 @@ void GuiInspector::inspectObject( SimObject *object )
             group->registerObject();
             group->registerObject();
             mGroups.push_back( group );
             mGroups.push_back( group );
             addObject( group );
             addObject( group );
+			checkOpenGroupList(group);
          }            
          }            
       }
       }
    }
    }
@@ -373,6 +387,18 @@ void GuiInspector::inspectObject( SimObject *object )
       guiCanvas->setFirstResponder( currResponder );
       guiCanvas->setFirstResponder( currResponder );
 }
 }
 
 
+void GuiInspector::checkOpenGroupList(GuiInspectorGroup* group)
+{
+	for (Vector<StringTableEntry>::iterator i = mOpenGroupList.begin(); i != mOpenGroupList.end(); i++)
+	{
+		StringTableEntry text = static_cast<StringTableEntry>(*i);
+		if (dStrcmp(text, group->getGroupName()) == 0)
+		{
+			group->setExpandedInstant(true);
+		}
+	}
+}
+
 ConsoleMethod( GuiInspector, inspect, void, 3, 3, "(obj) Goes through the object's fields and autogenerates editor boxes\n"
 ConsoleMethod( GuiInspector, inspect, void, 3, 3, "(obj) Goes through the object's fields and autogenerates editor boxes\n"
               "@return No return value.")
               "@return No return value.")
 {
 {

+ 2 - 0
engine/source/gui/editor/guiInspector.h

@@ -86,6 +86,7 @@ private:
 public:
 public:
    // Members
    // Members
    Vector<GuiInspectorGroup*>    mGroups;
    Vector<GuiInspectorGroup*>    mGroups;
+   Vector<StringTableEntry>      mOpenGroupList;
    SimObjectPtr<SimObject>       mTarget;
    SimObjectPtr<SimObject>       mTarget;
 
 
    GuiInspector();
    GuiInspector();
@@ -104,6 +105,7 @@ public:
    inline bool hideField(const char* fieldName) { return std::find(mHiddenFieldList.begin(), mHiddenFieldList.end(), fieldName) != mHiddenFieldList.end(); };
    inline bool hideField(const char* fieldName) { return std::find(mHiddenFieldList.begin(), mHiddenFieldList.end(), fieldName) != mHiddenFieldList.end(); };
    inline void clearHiddenField() { mHiddenFieldList.clear(); };
    inline void clearHiddenField() { mHiddenFieldList.clear(); };
    inline void addHiddenField(const char* fieldName) { mHiddenFieldList.push_back(fieldName); };
    inline void addHiddenField(const char* fieldName) { mHiddenFieldList.push_back(fieldName); };
+   void checkOpenGroupList(GuiInspectorGroup* group);
 
 
    GuiControlProfile* mGroupPanelProfile;
    GuiControlProfile* mGroupPanelProfile;
    GuiControlProfile* mGroupGridProfile;
    GuiControlProfile* mGroupGridProfile;