Browse Source

Squashed commit of the following:

commit 53b7204fded9ce69fa69e96b0531a12161c1036d
Author: Liichi <[email protected]>
Date:   Tue Feb 7 13:52:27 2017 -0300

    Restore windows positions when viewportmode switch

    Now the hierarchy and inspector windows will be restored to original state if you switch between viewport_compact and others.

commit 8a15c06ea468fd42268fa3d937433ff624b03a42
Author: Liichi <[email protected]>
Date:   Mon Feb 6 15:04:43 2017 -0300

    Replaced tabs by spaces.

commit 9663fef07f5dcebc3a78d2e82c875736cb6d1a70
Author: Liichi <[email protected]>
Date:   Mon Feb 6 14:56:06 2017 -0300

    Replaced tabs by spaces.

commit 6fbea29b26491675d9783769cc9f01e8f925dabe
Author: Liichi <[email protected]>
Date:   Mon Feb 6 14:49:15 2017 -0300

    Replaced tabs by spaces.

commit 6dbe8b451e444391f82c642374f1bcba506035ce
Author: Liichi <[email protected]>
Date:   Mon Feb 6 14:48:30 2017 -0300

    Replaced tabs by spaces.

commit 1d3c98689183abcc99271a65fe9ec3d9be5b6ca0
Author: Liichi <[email protected]>
Date:   Mon Feb 6 14:19:00 2017 -0300

    Fixed stats text position.

commit 9632876aee4470d722872223f62a072cef1e8137
Author: Liichi <[email protected]>
Date:   Mon Feb 6 13:54:20 2017 -0300

    Prevent inspector hide if viewport_compact

commit 46775b205bb340dddcb2f1950d9c1912845d36aa
Author: Liichi <[email protected]>
Date:   Mon Feb 6 13:52:25 2017 -0300

    Prevent hierarchy hide if viewport_compact

commit b301b244a47c4f374ca7b97f6c06029f95531c5e
Author: Liichi <[email protected]>
Date:   Mon Feb 6 13:47:10 2017 -0300

    Replaced .visible by functions.

commit a30879d68d2145c6521a9ed9f7d282e9f63b4404
Author: Liichi <[email protected]>
Date:   Mon Feb 6 13:42:51 2017 -0300

    Enable hierarchy/inspector on compact viewport mode.

commit d6f9d2748e96d8f7b76ea875e5079385f4d9af60
Author: Liichi <[email protected]>
Date:   Mon Feb 6 13:30:18 2017 -0300

    Clean version of code

    Now the content of SetCompactMode is inside of SetViewportMode.
    Code commented.
    Now the code match the engine code convention.

commit 9777750d41f6f45701438b65fae20ea008db3f71
Author: Liichi <[email protected]>
Date:   Sat Feb 4 17:21:57 2017 -0300

    Update EditorView.as

commit e00dbbac2a528a535dab2e1bbc24fe91933caf3b
Author: Liichi <[email protected]>
Date:   Sat Feb 4 17:18:11 2017 -0300

    Added compact option to viewport mode list.
Lasse Öörni 8 years ago
parent
commit
337056b657

+ 2 - 0
bin/Data/Scripts/Editor/EditorHierarchyWindow.as

@@ -109,6 +109,8 @@ void ShowHierarchyWindow()
 
 void HideHierarchyWindow()
 {
+    if(viewportMode == VIEWPORT_COMPACT)
+        return;
     hierarchyWindow.visible = false;
 }
 

+ 2 - 0
bin/Data/Scripts/Editor/EditorInspectorWindow.as

@@ -189,6 +189,8 @@ void ShowAttributeInspectorWindow()
 
 void HideAttributeInspectorWindow()
 {
+    if(viewportMode == VIEWPORT_COMPACT)
+        return;
     attributeInspectorWindow.visible = false;
 }
 

+ 1 - 0
bin/Data/Scripts/Editor/EditorToolBar.as

@@ -81,6 +81,7 @@ void CreateToolBar()
     viewportModeList.SetAlignment(HA_LEFT, VA_CENTER);
     toolBar.AddChild(viewportModeList);
     viewportModeList.AddItem(CreateViewPortModeText("Single", VIEWPORT_SINGLE));
+    viewportModeList.AddItem(CreateViewPortModeText("Compact", VIEWPORT_COMPACT));
     viewportModeList.AddItem(CreateViewPortModeText("Vertical Split", VIEWPORT_LEFT|VIEWPORT_RIGHT));
     viewportModeList.AddItem(CreateViewPortModeText("Horizontal Split", VIEWPORT_TOP|VIEWPORT_BOTTOM));
     viewportModeList.AddItem(CreateViewPortModeText("Quad", VIEWPORT_TOP_LEFT|VIEWPORT_TOP_RIGHT|VIEWPORT_BOTTOM_LEFT|VIEWPORT_BOTTOM_RIGHT));

+ 167 - 71
bin/Data/Scripts/Editor/EditorView.as

@@ -34,6 +34,11 @@ String coloringPropertyName;
 Color coloringOldColor;
 float coloringOldScalar;
 bool debugRenderDisabled = false;
+bool restoreViewport = false;
+IntVector2 oldHierarchyWindowPosition; // used for restore hierarchy position when switch between viewport modes
+int oldHierarchyWindowHeight;
+IntVector2 oldInspectorWindowPosition; // used for restore inspector position when switch between viewport modes
+int oldInspectorWindowHeight;
 
 const uint VIEWPORT_BORDER_H     = 0x00000001;
 const uint VIEWPORT_BORDER_H1    = 0x00000002;
@@ -43,6 +48,7 @@ const uint VIEWPORT_BORDER_V1    = 0x00000020;
 const uint VIEWPORT_BORDER_V2    = 0x00000040;
 
 const uint VIEWPORT_SINGLE       = 0x00000000;
+const uint VIEWPORT_COMPACT 	 = 0x00009000;
 const uint VIEWPORT_TOP          = 0x00000100;
 const uint VIEWPORT_BOTTOM       = 0x00000200;
 const uint VIEWPORT_LEFT         = 0x00000400;
@@ -499,7 +505,17 @@ void CreateCamera()
     // Set the initial viewport rect
     viewportArea = IntRect(0, 0, graphics.width, graphics.height);
 
-    SetViewportMode(viewportMode);
+    // Set viewport single to store default hierarchy/inspector height/positions
+    if(viewportMode == VIEWPORT_COMPACT)
+    {
+        SetViewportMode(VIEWPORT_SINGLE);
+        SetViewportMode(VIEWPORT_COMPACT);
+    }
+    else
+    {
+        SetViewportMode(viewportMode);
+    }
+    
     SetActiveViewport(viewports[0]);
 
     // Note: the camera is not inside the scene, so that it is not listed, and does not get deleted
@@ -624,7 +640,6 @@ void SetFillMode(FillMode fillMode_)
         viewports[i].camera.fillMode = fillMode_;
 }
 
-
 // Sets the viewport mode
 void SetViewportMode(uint mode = VIEWPORT_SINGLE)
 {
@@ -638,66 +653,137 @@ void SetViewportMode(uint mode = VIEWPORT_SINGLE)
     }
 
     viewports.Clear();
-    viewportMode = mode;
-
-    // Always have quad a
-    {
-        uint viewport = 0;
-        ViewportContext@ vc = ViewportContext(
-            IntRect(
-                0,
-                0,
-                mode & (VIEWPORT_LEFT|VIEWPORT_TOP_LEFT) > 0 ? viewportArea.width / 2 : viewportArea.width,
-                mode & (VIEWPORT_TOP|VIEWPORT_TOP_LEFT) > 0 ? viewportArea.height / 2 : viewportArea.height),
-            viewports.length + 1,
-            viewportMode & (VIEWPORT_TOP|VIEWPORT_LEFT|VIEWPORT_TOP_LEFT)
-        );
-        viewports.Push(vc);
-    }
-
-    uint topRight = viewportMode & (VIEWPORT_RIGHT|VIEWPORT_TOP_RIGHT);
-    if (topRight > 0)
-    {
-        ViewportContext@ vc = ViewportContext(
-            IntRect(
-                viewportArea.width/2,
-                0,
-                viewportArea.width,
-                mode & VIEWPORT_TOP_RIGHT > 0 ? viewportArea.height / 2 : viewportArea.height),
-            viewports.length + 1,
-            topRight
-        );
-        viewports.Push(vc);
-    }
-
-    uint bottomLeft = viewportMode & (VIEWPORT_BOTTOM|VIEWPORT_BOTTOM_LEFT);
-    if (bottomLeft > 0)
-    {
-        ViewportContext@ vc = ViewportContext(
-            IntRect(
-                0,
-                viewportArea.height / 2,
-                mode & (VIEWPORT_BOTTOM_LEFT) > 0 ? viewportArea.width / 2 : viewportArea.width,
-                viewportArea.height),
-            viewports.length + 1,
-            bottomLeft
-        );
-        viewports.Push(vc);
-    }
-
-    uint bottomRight = viewportMode & (VIEWPORT_BOTTOM_RIGHT);
-    if (bottomRight > 0)
-    {
-        ViewportContext@ vc = ViewportContext(
-            IntRect(
-                viewportArea.width / 2,
-                viewportArea.height / 2,
-                viewportArea.width,
-                viewportArea.height),
-            viewports.length + 1,
-            bottomRight
-        );
-        viewports.Push(vc);
+
+    if(mode == VIEWPORT_COMPACT)
+    {
+        // Remember old hierarchy/inspector height/positions
+        if(viewportMode != VIEWPORT_COMPACT){
+            restoreViewport = true;
+            oldHierarchyWindowPosition = hierarchyWindow.position;
+            oldHierarchyWindowHeight = hierarchyWindow.height;
+            oldInspectorWindowPosition = attributeInspectorWindow.position;
+            oldInspectorWindowHeight = attributeInspectorWindow.height;
+        }    
+    
+        // Move and scale hierarchy window to left of screen
+        ShowHierarchyWindow();
+        hierarchyWindow.position = IntVector2(secondaryToolBar.width,toolBar.height + uiMenuBar.height);
+        hierarchyWindow.height = viewportArea.height-(toolBar.height + uiMenuBar.height);
+        
+        // Move and scale inspector window to left of screen
+        ShowAttributeInspectorWindow();
+        attributeInspectorWindow.position = IntVector2(viewportArea.width-attributeInspectorWindow.width,toolBar.height + uiMenuBar.height);
+        attributeInspectorWindow.height = viewportArea.height-(toolBar.height + uiMenuBar.height);
+
+        // Hide close button and disable resize/movement inspector/hierarchy of windows
+        attributeInspectorWindow.GetChild("CloseButton",true).visible = false;
+        attributeInspectorWindow.resizable = false;
+        attributeInspectorWindow.movable = false;
+        hierarchyWindow.GetChild("CloseButton",true).visible = false;
+        hierarchyWindow.resizable = false;
+        hierarchyWindow.movable = false;
+
+        // Create viewport on center of window
+        {
+            uint viewport = 0;
+            ViewportContext@ vc = ViewportContext(
+                IntRect(
+                    secondaryToolBar.width + hierarchyWindow.width,
+                    toolBar.height + uiMenuBar.height,
+                    viewportArea.width-attributeInspectorWindow.width,
+                    viewportArea.height),
+                viewports.length + 1,
+                viewportMode & (VIEWPORT_TOP|VIEWPORT_LEFT|VIEWPORT_TOP_LEFT)
+            );
+            viewports.Push(vc);
+        }
+        viewportMode = mode;
+
+    }
+    else
+    {
+        if(viewportMode == VIEWPORT_COMPACT)
+        {
+            // Restore hierarchy/inspector windows height/positions
+            if(restoreViewport)
+            {
+                hierarchyWindow.position = oldHierarchyWindowPosition;
+                hierarchyWindow.height = oldHierarchyWindowHeight;
+                attributeInspectorWindow.position = oldInspectorWindowPosition;
+                attributeInspectorWindow.height = oldInspectorWindowHeight;
+            }
+	    
+            // Show close button and enable resize/movement of inspector/hierarchy windows
+            attributeInspectorWindow.GetChild("CloseButton",true).visible = true;
+            attributeInspectorWindow.resizable = true;
+            attributeInspectorWindow.movable = true;
+            hierarchyWindow.GetChild("CloseButton",true).visible = true;
+            hierarchyWindow.resizable = true;
+            hierarchyWindow.movable = true;
+        }
+
+        viewportMode = mode;
+        
+        // Always have quad a
+        {
+            uint viewport = 0;
+            ViewportContext@ vc = ViewportContext(
+                IntRect(
+                    0,
+                    0,
+                    mode & (VIEWPORT_LEFT|VIEWPORT_TOP_LEFT) > 0 ? viewportArea.width / 2 : viewportArea.width,
+                    mode & (VIEWPORT_TOP|VIEWPORT_TOP_LEFT) > 0 ? viewportArea.height / 2 : viewportArea.height),
+                viewports.length + 1,
+                viewportMode & (VIEWPORT_TOP|VIEWPORT_LEFT|VIEWPORT_TOP_LEFT)
+            );
+            viewports.Push(vc);
+        }
+
+        uint topRight = viewportMode & (VIEWPORT_RIGHT|VIEWPORT_TOP_RIGHT);
+        if (topRight > 0)
+        {
+            ViewportContext@ vc = ViewportContext(
+                IntRect(
+                    viewportArea.width/2,
+                    0,
+                    viewportArea.width,
+                    mode & VIEWPORT_TOP_RIGHT > 0 ? viewportArea.height / 2 : viewportArea.height),
+                viewports.length + 1,
+                topRight
+            );
+            viewports.Push(vc);
+        }
+
+        uint bottomLeft = viewportMode & (VIEWPORT_BOTTOM|VIEWPORT_BOTTOM_LEFT);
+        if (bottomLeft > 0)
+        {
+            ViewportContext@ vc = ViewportContext(
+                IntRect(
+                    0,
+                    viewportArea.height / 2,
+                    mode & (VIEWPORT_BOTTOM_LEFT) > 0 ? viewportArea.width / 2 : viewportArea.width,
+                    viewportArea.height),
+                viewports.length + 1,
+                bottomLeft
+            );
+            viewports.Push(vc);
+        }
+
+        uint bottomRight = viewportMode & (VIEWPORT_BOTTOM_RIGHT);
+        if (bottomRight > 0)
+        {
+            ViewportContext@ vc = ViewportContext(
+                IntRect(
+                    viewportArea.width / 2,
+                    viewportArea.height / 2,
+                    viewportArea.width,
+                    viewportArea.height),
+                viewports.length + 1,
+                bottomRight
+            );
+            viewports.Push(vc);
+        }
+
     }
 
     renderer.numViewports = viewports.length;
@@ -1177,17 +1263,27 @@ void UpdateStats(float timeStep)
 
     // Relayout stats bar
     Font@ font = cache.GetResource("Font", "Fonts/Anonymous Pro.ttf");
-    if (graphics.width >= editorModeText.size.x + renderStatsText.size.x + 45)
-    {
-        SetupStatsBarText(editorModeText, font, 35, 64, HA_LEFT, VA_TOP);
-        SetupStatsBarText(renderStatsText, font, -4, 64, HA_RIGHT, VA_TOP);
-        SetupStatsBarText(modelInfoText, font, 35, 88, HA_LEFT, VA_TOP);
+    
+    if(viewportMode != VIEWPORT_COMPACT)
+    {
+	if (graphics.width >= editorModeText.size.x + renderStatsText.size.x + 45)
+	{
+            SetupStatsBarText(editorModeText, font, 35, 64, HA_LEFT, VA_TOP);
+            SetupStatsBarText(renderStatsText, font, -4, 64, HA_RIGHT, VA_TOP);
+            SetupStatsBarText(modelInfoText, font, 35, 88, HA_LEFT, VA_TOP);
+	}
+	else
+	{
+            SetupStatsBarText(editorModeText, font, 35, 64, HA_LEFT, VA_TOP);
+            SetupStatsBarText(renderStatsText, font, 35, 78, HA_LEFT, VA_TOP);
+            SetupStatsBarText(modelInfoText, font, 35, 102, HA_LEFT, VA_TOP);
+	}
     }
     else
     {
-        SetupStatsBarText(editorModeText, font, 35, 64, HA_LEFT, VA_TOP);
-        SetupStatsBarText(renderStatsText, font, 35, 78, HA_LEFT, VA_TOP);
-        SetupStatsBarText(modelInfoText, font, 35, 102, HA_LEFT, VA_TOP);
+        SetupStatsBarText(editorModeText, font, secondaryToolBar.width + hierarchyWindow.width + 10 , 64, HA_LEFT, VA_TOP);
+        SetupStatsBarText(renderStatsText, font, secondaryToolBar.width + hierarchyWindow.width + 10 , 84, HA_LEFT, VA_TOP);
+        SetupStatsBarText(modelInfoText, font, secondaryToolBar.width + hierarchyWindow.width + 10, 104, HA_LEFT, VA_TOP);	
     }
 }
 
@@ -2127,4 +2223,4 @@ void HandleEndViewRender(StringHash eventType, VariantMap& eventData)
             suppressSceneChanges = false;
         }
     }
-}
+}