Browse Source

Added an Inspector to the Gui Editor

Peter Robinson 2 years ago
parent
commit
c6690daceb

+ 56 - 5
editor/GuiEditor/GuiEditor.cs

@@ -23,8 +23,10 @@
 function GuiEditor::create( %this )
 {
 	exec("./scripts/GuiEditorBrain.cs");
-	exec("./scripts/GuiEditorControlList.cs");
+	exec("./scripts/GuiEditorControlListWindow.cs");
 	exec("./scripts/GuiEditorControlListBox.cs");
+	exec("./scripts/GuiEditorInspectorWindow.cs");
+	exec("./scripts/GuiEditorExplorerWindow.cs");
 
 	%this.guiPage = EditorCore.RegisterEditor("Gui Editor", %this);
 
@@ -46,10 +48,10 @@ function GuiEditor::create( %this )
     ThemeManager.setProfile(%this.content, "emptyProfile");
     %this.guiPage.add(%this.content);
 
-    %this.brain = new GuiEditCtrl(GuiEditorBrain)
+    %this.brain = new GuiEditCtrl()
     {
         Profile = "GuiTextEditProfile";
-        //Class = "GuiEditorBrain";
+        Class = "GuiEditorBrain";
 		HorizSizing = "width";
         VertSizing = "height";
         Position = "0 0";
@@ -59,10 +61,10 @@ function GuiEditor::create( %this )
 
     %this.ctrlListWindow = new GuiWindowCtrl()
     {
-        Class = "GuiEditorControlList";
+        Class = "GuiEditorControlListWindow";
         HorizSizing = "right";
         VertSizing = "bottom";
-        Position = "0 0";
+        Position = "360 0";
         Extent = "250 380";
         MinExtent = "100 100";
         text = "Control List";
@@ -80,6 +82,54 @@ function GuiEditor::create( %this )
     ThemeManager.setProfile(%this.ctrlListWindow, "windowButtonProfile", "MaxButtonProfile");
     %this.guiPage.add(%this.ctrlListWindow);
 
+    %this.inspectorWindow = new GuiWindowCtrl()
+    {
+        Class = "GuiEditorInspectorWindow";
+        HorizSizing = "right";
+        VertSizing = "bottom";
+        Position = "0 0";
+        Extent = "360 380";
+        MinExtent = "100 100";
+        text = "Gui Inspector";
+        canMove = true;
+        canClose = false;
+        canMinimize = true;
+        canMaximize = false;
+        resizeWidth = false;
+        resizeHeight = true;
+    };
+    ThemeManager.setProfile(%this.inspectorWindow, "windowProfile");
+    ThemeManager.setProfile(%this.inspectorWindow, "windowContentProfile", "ContentProfile");
+    ThemeManager.setProfile(%this.inspectorWindow, "windowButtonProfile", "CloseButtonProfile");
+    ThemeManager.setProfile(%this.inspectorWindow, "windowButtonProfile", "MinButtonProfile");
+    ThemeManager.setProfile(%this.inspectorWindow, "windowButtonProfile", "MaxButtonProfile");
+    %this.guiPage.add(%this.inspectorWindow);
+    %this.inspectorWindow.startListening(%this.brain);
+
+    %this.explorerWindow = new GuiWindowCtrl()
+    {
+        Class = "GuiEditorExplorerWindow";
+        HorizSizing = "right";
+        VertSizing = "bottom";
+        Position = "610 0";
+        Extent = "250  380";
+        MinExtent = "100 100";
+        text = "Explorer";
+        canMove = true;
+        canClose = false;
+        canMinimize = true;
+        canMaximize = false;
+        resizeWidth = false;
+        resizeHeight = true;
+    };
+    ThemeManager.setProfile(%this.explorerWindow, "windowProfile");
+    ThemeManager.setProfile(%this.explorerWindow, "windowContentProfile", "ContentProfile");
+    ThemeManager.setProfile(%this.explorerWindow, "windowButtonProfile", "CloseButtonProfile");
+    ThemeManager.setProfile(%this.explorerWindow, "windowButtonProfile", "MinButtonProfile");
+    ThemeManager.setProfile(%this.explorerWindow, "windowButtonProfile", "MaxButtonProfile");
+    %this.guiPage.add(%this.explorerWindow);
+    %this.explorerWindow.startListening(%this.brain);
+
     %this.onNewGui();
 
     EditorCore.FinishRegistration(%this.guiPage);
@@ -112,4 +162,5 @@ function GuiEditor::onNewGui(%this)
     %this.content.add(%this.blankGui);
     %this.brain.setRoot(%this.blankGui);
     %this.brain.root = %this.blankGui;
+    %this.explorerWindow.open(%this.blankGui);
 }

+ 32 - 5
editor/GuiEditor/scripts/GuiEditorBrain.cs

@@ -7,7 +7,6 @@ function GuiEditorBrain::onAdd(%this)
 
 function GuiEditorBrain::onControlDragged(%this, %payload, %position)
 {
-    echo("GuiEditorBrain::onControlDragged - Enter");
 	%pos = VectorSub(%position, %this.getGlobalPosition());
 	%x = getWord(%pos, 0);
 	%y = getWord(%pos, 1);
@@ -22,13 +21,10 @@ function GuiEditorBrain::onControlDragged(%this, %payload, %position)
 	{
 		%this.setCurrentAddSet(%target);
 	}
-	//GuiEditorCtrlProperties.update(%ctrl);
-    echo("GuiEditorBrain::onControlDragged - Leave");
 }
 
 function GuiEditorBrain::onControlDropped(%this, %payload, %position)
 {
-    echo("GuiEditorBrain::onControlDropped - Enter");
    %pos = %payload.getGlobalPosition();
    %x = getWord(%pos, 0);
    %y = getWord(%pos, 1);
@@ -43,5 +39,36 @@ function GuiEditorBrain::onControlDropped(%this, %payload, %position)
 
    %payload.setPositionGlobal(%x, %y);
    %this.setFirstResponder();
-    echo("GuiEditorBrain::onControlDropped - Leave");
+    %this.postEvent("Inspect", %payload);
+}
+
+function GuiEditorBrain::onSelect(%this, %ctrl)
+{
+	GuiEditorBrain.clearSelection();
+	GuiEditorBrain.select(%ctrl);
+    %this.postEvent("Inspect", %ctrl);
+}
+
+function GuiEditorBrain::onClearSelected(%this)
+{
+    %this.postEvent("ClearInspect");
+}
+
+function GuiEditorBrain::onSelectionParentChange(%this)
+{
+}
+
+function GuiEditorBrain::onDelete(%this)
+{
+	%this.postEvent("ClearInspect", %ctrl);
+}
+
+function GuiEditorBrain::onAddSelected(%this,%ctrl)
+{
+    %this.postEvent("AlsoInspect", %ctrl);
+}
+
+function GuiEditorBrain::onRemoveSelected(%this,%ctrl)
+{
+    %this.postEvent("ClearInspect", %ctrl);
 }

+ 3 - 10
editor/GuiEditor/scripts/GuiEditorControlListBox.cs

@@ -1,26 +1,20 @@
 
 function GuiEditorControlListBox::onTouchDragged(%this, %index, %text)
 {
-	echo("test start");
-	%position = %this.getGlobalPosition();
-	echo(%position);
+	%position = GuiEditor.guiPage.getGlobalPosition();
 	%cursorpos = Canvas.getCursorPos();
-	echo(%cursorpos);
 
 	%class = %this.getItemText(%this.getSelectedItem());
 	%payload = eval("return new " @ %class @ "();");
-	echo("payload is " @ %payload.getId());
 	if(!isObject(%payload))
 		return;
 
-	%xOffset = getWord(%payload.extent, 0) / 2;
-	%yOffset = getWord(%payload.extent, 1) / 2;
-	echo(%xOffset SPC %yOffset);
+	%xOffset = (getWord(%payload.extent, 0) / 2) + getWord(%position, 0);
+	%yOffset = (getWord(%payload.extent, 1) / 2) + getWord(%position, 1);
 
 	// position where the drag will start, to prevent visible jumping.
 	%xPos = getWord(%cursorpos, 0) - %xOffset;
 	%yPos = getWord(%cursorpos, 1) - %yOffset;
-	echo(%xPos SPC %yPos);
 
 	%dragCtrl = new GuiDragAndDropCtrl() {
 		canSaveDynamicFields = "0";
@@ -41,5 +35,4 @@ function GuiEditorControlListBox::onTouchDragged(%this, %index, %text)
 	GuiEditor.guiPage.add(%dragCtrl);
 
 	%dragCtrl.startDragging(%xOffset, %yOffset);
-	echo("test end");
 }

+ 5 - 4
editor/GuiEditor/scripts/GuiEditorControlList.cs → editor/GuiEditor/scripts/GuiEditorControlListWindow.cs

@@ -1,6 +1,6 @@
-//GuiEditorControlList.cs
+//GuiEditorControlListWindow.cs
 
-function GuiEditorControlList::onAdd(%this)
+function GuiEditorControlListWindow::onAdd(%this)
 {
     %this.scroller = new GuiScrollCtrl()
 	{
@@ -35,7 +35,7 @@ function GuiEditorControlList::onAdd(%this)
     %this.populate();
 }
 
-function GuiEditorControlList::onRemove(%this)
+function GuiEditorControlListWindow::onRemove(%this)
 {
     if(isObject(%this.scroller))
     {
@@ -43,7 +43,7 @@ function GuiEditorControlList::onRemove(%this)
     }
 }
 
-function GuiEditorControlList::populate(%this)
+function GuiEditorControlListWindow::populate(%this)
 {
     %controls = enumerateConsoleClasses("GuiControl");
 	%this.listBox.clearItems();
@@ -56,6 +56,7 @@ function GuiEditorControlList::populate(%this)
             getSubStr(%field, 0, 12) !$= "GuiInspector" && %field !$= "GuiMessageVectorCtrl" &&
             %field !$= "GuiParticleGraphInspector" && %field !$= "GuiGraphCtrl" && %field !$= "GuiSceneObjectCtrl")
         {
+			echo("adding item "@ %field);
 		    %this.listBox.addItem(%field);
         }
 	}

+ 36 - 0
editor/GuiEditor/scripts/GuiEditorExplorerWindow.cs

@@ -0,0 +1,36 @@
+
+function GuiEditorExplorerWindow::onAdd(%this)
+{
+    %this.scroller = new GuiScrollCtrl()
+	{
+		HorizSizing="width";
+		VertSizing="height";
+		Position="0 0";
+		Extent="242 355";
+		hScrollBar="alwaysOff";
+		vScrollBar="alwaysOn";
+		constantThumbHeight="0";
+		showArrowButtons="1";
+		scrollBarThickness="14";
+	};
+	ThemeManager.setProfile(%this.scroller, "emptyProfile");
+	ThemeManager.setProfile(%this.scroller, "thumbProfile", "ThumbProfile");
+	ThemeManager.setProfile(%this.scroller, "trackProfile", "TrackProfile");
+	ThemeManager.setProfile(%this.scroller, "scrollArrowProfile", "ArrowProfile");
+	%this.add(%this.scroller);
+
+    %this.tree = new GuiTreeViewCtrl()
+	{
+		HorizSizing="width";
+		VertSizing="height";
+		Position="0 0";
+		Extent="228 355";
+	};
+	ThemeManager.setProfile(%this.tree, "panelProfile");
+	%this.scroller.add(%this.tree);
+}
+
+function GuiEditorExplorerWindow::open(%this, %object)
+{
+    %this.tree.open(%object);
+}

+ 93 - 0
editor/GuiEditor/scripts/GuiEditorInspectorWindow.cs

@@ -0,0 +1,93 @@
+
+
+function GuiEditorInspectorWindow::onAdd(%this)
+{
+    %this.scroller = new GuiScrollCtrl()
+	{
+		HorizSizing="width";
+		VertSizing="height";
+		Position="0 0";
+		Extent="352 355";
+		hScrollBar="alwaysOff";
+		vScrollBar="alwaysOn";
+		constantThumbHeight="0";
+		showArrowButtons="1";
+		scrollBarThickness="14";
+	};
+	ThemeManager.setProfile(%this.scroller, "emptyProfile");
+	ThemeManager.setProfile(%this.scroller, "thumbProfile", "ThumbProfile");
+	ThemeManager.setProfile(%this.scroller, "trackProfile", "TrackProfile");
+	ThemeManager.setProfile(%this.scroller, "scrollArrowProfile", "ArrowProfile");
+	%this.add(%this.scroller);
+
+    %this.inspector = new GuiInspector()
+	{
+		HorizSizing="width";
+		VertSizing="height";
+		Position="0 0";
+		Extent="338 355";
+		FieldCellSize="288 40";
+		ControlOffset="10 18";
+		ConstantThumbHeight=false;
+		ScrollBarThickness=12;
+		ShowArrowButtons=true;
+	};
+	ThemeManager.setProfile(%this.inspector, "emptyProfile");
+	ThemeManager.setProfile(%this.inspector, "panelProfile", "GroupPanelProfile");
+	ThemeManager.setProfile(%this.inspector, "emptyProfile", "GroupGridProfile");
+	ThemeManager.setProfile(%this.inspector, "labelProfile", "LabelProfile");
+	ThemeManager.setProfile(%this.inspector, "textEditProfile", "textEditProfile");
+	ThemeManager.setProfile(%this.inspector, "dropDownProfile", "dropDownProfile");
+	ThemeManager.setProfile(%this.inspector, "dropDownItemProfile", "dropDownItemProfile");
+	ThemeManager.setProfile(%this.inspector, "emptyProfile", "backgroundProfile");
+	ThemeManager.setProfile(%this.inspector, "scrollingPanelProfile", "ScrollProfile");
+	ThemeManager.setProfile(%this.inspector, "scrollingPanelThumbProfile", "ThumbProfile");
+	ThemeManager.setProfile(%this.inspector, "scrollingPanelTrackProfile", "TrackProfile");
+	ThemeManager.setProfile(%this.inspector, "scrollingPanelArrowProfile", "ArrowProfile");
+	ThemeManager.setProfile(%this.inspector, "checkboxProfile", "checkboxProfile");
+	ThemeManager.setProfile(%this.inspector, "buttonProfile", "buttonProfile");
+	ThemeManager.setProfile(%this.inspector, "tipProfile", "tooltipProfile");
+	%this.scroller.add(%this.inspector);
+
+    %this.inspectList = new SimSet();
+}
+
+function GuiEditorInspectorWindow::onRemove(%this)
+{
+    if(isObject(%this.inspectList))
+    {
+        %this.inspectList.deleteObjects();
+        %this.inspectList.delete();
+    }
+}
+
+function GuiEditorInspectorWindow::onInspect(%this, %object)
+{
+    %this.inspectList.clear();
+    %this.inspectList.add(%object);
+    %this.inspector.inspect(%object);
+}
+
+function GuiEditorInspectorWindow::onClearInspect(%this, %object)
+{
+    if(isObject(%object))
+    {
+        %this.inspectList.removeIfMember(%object);
+        %count = %this.inspectList.getCount();
+        if(%count > 0)
+        {
+            %this.inspector.inspect(%this.inspectList.getObject(%count - 1));
+        }
+    }
+    else 
+    {
+        %this.inspectList.clear();
+        %this.inspector.clear();
+    }
+}
+
+function GuiEditorInspectorWindow::onAlsoInspect(%this, %object)
+{
+    %this.inspectList.add(%object);
+    %this.inspector.inspect(%object);
+}

+ 2 - 0
engine/source/gui/buttons/guiButtonCtrl.cc

@@ -56,10 +56,12 @@ void GuiButtonCtrl::initPersistFields()
 {
 	Parent::initPersistFields();
 
+	addGroup("Gui Button Easing");
 	addField("easeFillColorHL", TypeEnum, Offset(mEaseFillColorHL, GuiButtonCtrl), 1, &gEasingTable);
 	addField("easeFillColorSL", TypeEnum, Offset(mEaseFillColorSL, GuiButtonCtrl), 1, &gEasingTable);
 	addField("easeTimeFillColorHL", TypeS32, Offset(mEaseTimeFillColorHL, GuiButtonCtrl));
 	addField("easeTimeFillColorSL", TypeS32, Offset(mEaseTimeFillColorSL, GuiButtonCtrl));
+	endGroup("Gui Button Easing");
 }
 
 void GuiButtonCtrl::setActive(bool value)

+ 2 - 0
engine/source/gui/containers/guiChainCtrl.cc

@@ -43,8 +43,10 @@ void GuiChainCtrl::initPersistFields()
 {
 	Parent::initPersistFields();
 
+	addGroup("Gui Chain Settings");
 	addField("ChildSpacing", TypeS32, Offset(mChildSpacing, GuiChainCtrl));
 	addField("IsVertical", TypeBool, Offset(mIsVertical, GuiChainCtrl));
+	endGroup("Gui Chain Settings");
 }
 
 //------------------------------------------------------------------------------

+ 3 - 1
engine/source/gui/editor/guiEditCtrl.cc

@@ -497,7 +497,9 @@ void GuiEditCtrl::onRender(Point2I offset, const RectI &updateRect)
             box.inset(1,1);
          dglDrawRect(box, ColorI(0, 101, 0,190));
             box.inset(1,1);
-            dglDrawRect(box, ColorI(0, 101, 0,200));
+         dglDrawRect(box, ColorI(0, 101, 0,200));
+			box.inset(1, 1);
+		 dglDrawRect(box, ColorI(0, 101, 0, 220));
       }
       Vector<GuiControl *>::iterator i;
       bool multisel = mSelectedControls.size() > 1;

+ 9 - 0
engine/source/gui/editor/guiInspector.cc

@@ -379,6 +379,15 @@ ConsoleMethod( GuiInspector, getInspectObject, const char*, 2, 2, "() - Returns
    return "";
 }
 
+
+ConsoleMethod(GuiInspector, clear, const char*, 2, 2, "() - Uninspects\n"
+	"@return Not used.")
+{
+	object->clearGroups();
+
+	return "";
+}
+
 void GuiInspector::setName( const char* newName )
 {
    if( mTarget == NULL )

+ 1 - 1
engine/source/gui/guiTreeViewCtrl.cc

@@ -1087,7 +1087,7 @@ void GuiTreeViewCtrl::moveItemDown( S32 itemId )
 
 bool GuiTreeViewCtrl::onWake()
 {
-   if(!Parent::onWake() || !mProfile->constructBitmapArray())
+   if(!Parent::onWake())
       return false;
 
    // If destroy on sleep, then we have to give things a chance to rebuild.