From 89b25e7cc97f6fe221dfd41c4d463500f8a31bc1 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Tue, 25 Jun 2019 23:58:09 -0400
Subject: [PATCH] Edit panel pin state.

---
 GroupEditor.java |   56 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index d57f0f7..502ff05 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -605,10 +605,12 @@
 		copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 undoButton.setToolTipText("Undo changes");
 		undoButton.addActionListener(this);
+                undoButton.setEnabled(false);
                 
 		copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 redoButton.setToolTipText("Redo changes");
 		redoButton.addActionListener(this);
+                redoButton.setEnabled(false);
                 
 		copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 saveButton.setToolTipText("Save changes");
@@ -743,6 +745,18 @@
                 lightButton.setToolTipText("Create light");
                                lightButton.addActionListener(this);
 
+                for (int i=6; --i>=0;)
+                {
+                oe.toolboxPanel.Return();
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                oe.toolboxPanel.add(new cGridBag());
+                }
+                
                 // EDIT panel
 		editCommandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 editButton.setToolTipText("Edit selection");
@@ -3326,6 +3340,12 @@
 		} else
 		if (source == editItem || source == editButton)
 		{
+			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
+			{
+				Object3D child = (Object3D)e.nextElement();
+                                child.pinned = true;
+                        }
+                        
 			EditSelection(false);
 		} else
 		if (source == uneditButton)
@@ -3335,6 +3355,7 @@
 				Object3D child = (Object3D)e.nextElement();
                                 if(child.editWindow != null)
                                     objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
+                                child.pinned = false;
 				child.CloseUI();
                                 listUI.remove(child);
                                 
@@ -3351,6 +3372,7 @@
                     //copy.ClearUI();
                     for (Object3D obj : listUI)
                     {
+                        obj.pinned = true;
                         obj.CloseUI();
                     }
                     listUI.clear();
@@ -3360,7 +3382,7 @@
 		{
                     assert(copy == group);
                     
-                    objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
+                    //objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
                     
                     for (Object3D obj : listUI)
                     {
@@ -4502,10 +4524,6 @@
 //		}
 //	}
 	
-        static boolean allparams = true;
-        
-        static Vector<Object3D> listUI = new Vector<Object3D>();
-        
 	void EditSelection(boolean newWindow)
 	{
         //    aConstraints.gridy = 0;
@@ -4599,6 +4617,17 @@
 
 		freezemodel = true;
 		
+                //for (Object3D obj : listUI)
+                for (int i=listUI.size(); --i>=0;)
+                {
+                    Object3D obj = listUI.elementAt(i);
+                    if (!obj.pinned)
+                    {
+                        obj.CloseUI();
+                        listUI.remove(i);
+                    }
+                }
+                    
 		/**/
 		//switch (event.id)
 		{
@@ -4631,7 +4660,7 @@
 			if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera)
                             // a camera
                         {
-                            if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera())
+                            if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crash the camera because of invalid lightspace
                             {
                                 CameraPane.camerachangeframe = 0; // don't refuse it
                                 Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
@@ -4640,6 +4669,13 @@
                          //   Globals.theRenderer.eyeCamera = Globals.theRenderer.manipCamera;
                         }
                             
+                        if (tps != null && tps.length == 1)
+                        {
+                            EditSelection(false);
+                        }
+                        
+                        SetPinStates(tps != null && tps.length > 0);
+                        
 			refreshContents();
 			//return true;
 		}
@@ -4649,6 +4685,12 @@
 		freezemodel = false;
 	}
         
+        void SetPinStates(boolean enabled)
+        {
+            editButton.setEnabled(enabled);
+            uneditButton.setEnabled(enabled);
+        }
+
         void refreshContents(boolean cp)
         {
             if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
@@ -5475,8 +5517,6 @@
 	cButton minButton;
 	cButton maxButton;
 	cButton fullButton;
-	cButton undoButton;
-	cButton redoButton;
 	cButton saveButton;
 	cButton oneStepButton;
         

--
Gitblit v1.6.2