From 914255f70cf047897212839cbf3a6722703f4457 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 24 Jun 2019 13:19:16 -0400
Subject: [PATCH] Fix manip window + new icons.

---
 GroupEditor.java |  231 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 166 insertions(+), 65 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index bae9769..cce9b1b 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -176,7 +176,6 @@
 		copyItem.addActionListener(this);
 		pasteItem = menu.add(new MenuItem("Paste"));
 		pasteItem.addActionListener(this);
-		menu.add("-");
                 
 		menu.add("-");
 		pasteIntoItem = menu.add(new MenuItem("Paste into"));
@@ -246,7 +245,7 @@
 
                 cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
                 toggleDebugItem.addItemListener(this);
-                toggleDebugItem.setState(CameraPane.DEBUG);
+                toggleDebugItem.setState(Globals.DEBUG);
 
                 cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
                 toggleFrustumItem.addItemListener(this);
@@ -369,11 +368,11 @@
 		billboardItem.addActionListener(this);
 		csgItem = menu.add(new MenuItem("CSG"));
 		csgItem.addActionListener(this);
-                shadowXItem = menu.add(new MenuItem("Shadow X"));
+                shadowXItem = menu.add(new MenuItem("Shadow Red"));
 		shadowXItem.addActionListener(this);
-                shadowYItem = menu.add(new MenuItem("Shadow Y"));
+                shadowYItem = menu.add(new MenuItem("Shadow Green"));
 		shadowYItem.addActionListener(this);
-                shadowZItem = menu.add(new MenuItem("Shadow Z"));
+                shadowZItem = menu.add(new MenuItem("Shadow Blue"));
 		shadowZItem.addActionListener(this);
         if (Globals.ADVANCED)
         {
@@ -535,6 +534,18 @@
 	
 	void SetupUI2(ObjEditor oe)
 	{
+            // June 2019
+            if (oe == null)
+            {
+                //super.SetupUI2(this);
+                //return;
+            }
+            
+            if (copy != group)
+            {
+                //super.SetupUI2(this);
+            }
+            
             //new Exception().printStackTrace();
                 
         oe.radioPanel = new JPanel(new GridBagLayout());
@@ -565,35 +576,47 @@
          */
                 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
                 
-		oe.toolbarPanel.add(undoButton = new cButton("Undo", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		//oe.toolbarPanel.add(minButton = new cButton("Min", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                //minButton.setToolTipText("Minimize window");
+		//minButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                maxButton.setToolTipText("Maximize window");
+		maxButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                fullButton.setToolTipText("Full-screen window");
+		fullButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 undoButton.setToolTipText("Undo changes");
 		undoButton.addActionListener(this);
                 
-		oe.toolbarPanel.add(redoButton = new cButton("Redo", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 redoButton.setToolTipText("Redo changes");
 		redoButton.addActionListener(this);
                 
-		oe.toolbarPanel.add(saveButton = new cButton("Save", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 saveButton.setToolTipText("Save changes");
 		saveButton.addActionListener(this);
                 
-                oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints);
+                oe.toolbarPanel.add(liveCB = GetCheckBox("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
                 liveCB.setToolTipText("Enable animation");
                                 liveCB.addItemListener(this);
 
-		oe.toolbarPanel.add(oneStepButton = new cButton("Step", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                oneStepButton.setToolTipText("Animate one step forward");
-		oneStepButton.addActionListener(this);
-                
-                oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST)); //, constraints);
+                oe.toolbarPanel.add(fastCB = GetCheckBox("icons/runfast.png", CameraPane.FAST)); //, constraints);
                 fastCB.setToolTipText("Fast mode");
                                 fastCB.addItemListener(this);
                                 
-                oe.toolbarPanel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints);
+		oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                oneStepButton.setToolTipText("Animate one step forward");
+		oneStepButton.addActionListener(this);
+                
+                oe.toolbarPanel.add(trackCB = GetCheckBox("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
                 trackCB.setToolTipText("Enable tracking");
                                 trackCB.addItemListener(this);
 
-		oe.toolbarPanel.add(screenfitButton = new cButton("@", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 screenfitButton.setToolTipText("Screen fit");
 		screenfitButton.addActionListener(this);
 
@@ -607,25 +630,25 @@
                         snapobjectButton.setToolTipText("Snap Object");
                 }
 
-		oe.toolbarPanel.add(flashSelectionButton = new cButton("?", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                flashSelectionButton.setToolTipText("Show selection");
+		oe.toolbarPanel.add(flashSelectionButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                flashSelectionButton.setToolTipText("Highlight selection");
 		flashSelectionButton.addActionListener(this);
                 
 		oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
                 
-		oe.toolbarPanel.add(twoButton = new cButton("|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 twoButton.setToolTipText("Show center view only");
 		twoButton.addActionListener(this);
-		oe.toolbarPanel.add(fourButton = new cButton("+||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
 		fourButton.addActionListener(this);
                 fourButton.setToolTipText("Show left panel only");
-		oe.toolbarPanel.add(sixButton = new cButton("+|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 sixButton.setToolTipText("2-column layout left");
 		sixButton.addActionListener(this);
-		oe.toolbarPanel.add(threeButton = new cButton("|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 threeButton.setToolTipText("2-column layout right");
 		threeButton.addActionListener(this);
-		oe.toolbarPanel.add(sevenButton = new cButton("+|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 sevenButton.setToolTipText("3-column layout");
 		sevenButton.addActionListener(this);
                 //
@@ -640,32 +663,30 @@
 		//oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
 		//clearButton.addActionListener(this);
                         
-                cGridBag commandsPanel = new cGridBag();
-                
-		commandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 editButton.setToolTipText("Edit selection");
 		editButton.addActionListener(this);
 
-		commandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 uneditButton.setToolTipText("Unedit selection");
 		uneditButton.addActionListener(this);
 
-		commandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
+		editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
                 allParamsButton.setToolTipText("Edit all params");
 		allParamsButton.addActionListener(this);
 
-		commandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 clearPanelButton.setToolTipText("Clear edit panel");
 		clearPanelButton.addActionListener(this);
 
-		commandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 unselectButton.setToolTipText("Unselect");
 		unselectButton.addActionListener(this);
 
-                commandsPanel.preferredHeight = 1;
+                editCommandsPanel.preferredHeight = 1;
                 
-                oe.treePanel.add(commandsPanel);
-                oe.treePanel.Return();
+//                oe.treePanel.add(commandsPanel);
+//                oe.treePanel.Return();
                 
 //		oe.aConstraints.gridx += 1;
 //		oe.aConstraints.weighty = 0;
@@ -787,11 +808,23 @@
 //                debugCB.addItemListener(this);
 
                 panel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL)); //, constraints);
+                oeilCB.setToolTipText("Move camera when tracking target");
                                 oeilCB.addItemListener(this);
 
+                panel.add(shadowCB = new cCheckBox("Shadow", Globals.COMPUTESHADOWWHENLIVE)); //, constraints);
+                shadowCB.setToolTipText("Compute shadows when live");
+                                shadowCB.addItemListener(this);
+
+                panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
+                autosaveCB.setToolTipText("Auto-save on structure change");
+                                autosaveCB.addItemListener(this);
+
+            if (Globals.ADVANCED)
+            {
                 panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints);
                 lookAtCB.setToolTipText("Look-at target");
                                 lookAtCB.addItemListener(this);
+            }
                 
         }
                                 
@@ -806,6 +839,14 @@
         void EditObject(Object3D obj)
         {
             cRadio radioButton = new cRadio(obj.name);
+            
+            // Patch to avoid bug with transparency.
+            radioButton.hadMaterial = obj.material != null;
+            if (!radioButton.hadMaterial)
+            {
+                obj.material = new cMaterial();
+            }
+            
             radioButton.SetObject(obj);
             radioButton.layout = sevenButton;
             radioButton.SetCamera(cameraView.renderCamera, false);
@@ -817,6 +858,8 @@
         
         void SetupViews(ObjEditor oe)
         {
+                    theFrame = this;
+                    
             oe.SetupViews();
             
 		System.out.println("SetupViews");
@@ -825,23 +868,26 @@
             /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this);
         }
 
-        JCheckBox liveCB;
-        JCheckBox supportCB;
-        JCheckBox localCB;
-        JCheckBox crowdCB;
-        JCheckBox smoothCB;
-        JCheckBox fastCB;
-        JCheckBox slowCB;
-        JCheckBox boxCB;
-        JCheckBox zoomBoxCB;
-        JCheckBox trackCB;
-        JCheckBox smoothfocusCB;
+        cCheckBox liveCB;
+        cCheckBox supportCB;
+        cCheckBox localCB;
+        cCheckBox crowdCB;
+        cCheckBox smoothCB;
+        cCheckBox fastCB;
+        cCheckBox slowCB;
+        cCheckBox boxCB;
+        cCheckBox zoomBoxCB;
+        cCheckBox trackCB;
+        cCheckBox smoothfocusCB;
 //        JCheckBox speakerMocapCB;
-        JCheckBox speakerCameraCB;
-        JCheckBox speakerFocusCB;
-        JCheckBox debugCB;
-        JCheckBox oeilCB;
-        JCheckBox lookAtCB;
+        cCheckBox speakerCameraCB;
+        cCheckBox speakerFocusCB;
+        cCheckBox debugCB;
+        
+        cCheckBox oeilCB;
+        cCheckBox shadowCB;
+        cCheckBox autosaveCB;
+        cCheckBox lookAtCB;
         
 //        static int COLOR = 1;
 //        static int MATERIAL = 2;
@@ -849,9 +895,9 @@
         
         int dropAttributes = Object3D.COLOR | Object3D.MATERIAL;
         
-        JCheckBox colorCB;
-        JCheckBox materialCB;
-        JCheckBox textureCB;
+        cCheckBox colorCB;
+        cCheckBox materialCB;
+        cCheckBox textureCB;
         
         public void itemStateChanged(ItemEvent e)
         {
@@ -943,6 +989,14 @@
             else if(e.getSource() == oeilCB)
             {
                 cameraView.ToggleOeil();
+            }
+            else if(e.getSource() == shadowCB)
+            {
+                Globals.COMPUTESHADOWWHENLIVE ^= true;
+            }
+            else if(e.getSource() == autosaveCB)
+            {
+                Globals.SAVEONMAKE ^= true;
             }
             else if(e.getSource() == lookAtCB)
             {
@@ -1428,6 +1482,7 @@
             shadow.material = new cMaterial(obj.material);
             shadow.material.diffuse = 0.0001f;
             shadow.material.specular = 0.0001f;
+            //shadow.projectedVertices[1].x = 300;
             
             makeSomething(shadow);
         }
@@ -1977,6 +2032,18 @@
 		if (source == dumpItem)
 		{
                     DumpObject();
+		} else
+		if (source == minButton)
+		{
+			Minimize();
+		} else
+		if (source == maxButton)
+		{
+			Maximize();
+		} else
+		if (source == fullButton)
+		{
+			ToggleFullScreen();
 		} else
 		if (source == undoButton)
 		{
@@ -2899,6 +2966,24 @@
                     bigThree.ClearUI();
                     bigThree.add(centralPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
+                    
+//                    refreshContents(true);
+//                    
+//                    try
+//                    {
+//                        java.awt.Robot bot = new java.awt.Robot();
+//                        int mask = InputEvent.BUTTON1_MASK;
+//                        bot.mouseMove(100, 100);           
+//                        bot.mousePress(mask);     
+//                        bot.mouseRelease(mask);                    
+//                    }
+//                    catch (Exception e)
+//                    {
+//                        
+//                    }
+                    
                 } else
 		if (source == threeButton)
 		{
@@ -2935,6 +3020,8 @@
                     bigThree.add(centralPanel);
                     bigThree.add(XYZPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == fourButton)
 		{
@@ -2970,6 +3057,8 @@
                     bigThree.ClearUI();
                     bigThree.add(scenePanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == sixButton)
 		{
@@ -3006,6 +3095,8 @@
                     bigThree.add(scenePanel);
                     bigThree.add(centralPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == sevenButton)
 		{
@@ -3043,6 +3134,8 @@
                     bigThree.add(centralPanel);
                     bigThree.add(XYZPanel);
                     bigThree.FlushUI();
+                    
+                    cameraView.requestFocusInWindow();
                 } else
 		if (source == rootButton)
 		{
@@ -3054,6 +3147,7 @@
                                 EditObject(obj);
                     }
 
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
 		} else
 		if (source == closeButton)
@@ -3063,18 +3157,27 @@
                     for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
                     {
                             ab = (cRadio)e.nextElement();
-                            if(ab.getModel().isSelected() && ab.GetObject() != client)
+                            if (ab.getModel().isSelected() && ab.GetObject() != client)
                             {
+                                // Patch to avoid bug with transparency.
+                                if (!ab.hadMaterial)
+                                {
+                                    ab.object.material = null;
+                                }
+                                
                                 buttonGroup.remove(ab);
                                 radioPanel.remove(ab);
                                 
-                                ab.GetObject().editWindow = null;
+                                //ab.GetObject().editWindow = null;
+                                ab.GetObject().manipWindow = null;
                             //    ab.GetObject().objectUI = null; // ?????????
                                 
                                 ((cRadio)radioPanel.getComponent(radioPanel.getComponentCount() - 1)).doClick();
                                 break;
                             }
                     }
+                    
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
 		} else
 		if (source == editItem || source == editButton)
@@ -3179,7 +3282,8 @@
                     }
                     
 // fix "+" issue
-                    group.editWindow = this;
+                    //group.editWindow = this;
+                    group.manipWindow = this;
                     
                     /*
                     currentLayout = radio.layout;
@@ -3192,6 +3296,8 @@
                     //group.parent = null; // ROOT
                     //group.attributes = -1;
                     ResetModel();
+                    
+                    cameraView.requestFocusInWindow();
                     refreshContents(true);
                 } else if (event.getSource() == editCameraItem)
                 {
@@ -3215,7 +3321,6 @@
 	}
         
         boolean useclient = false;
-        cRadio radio;
         
         void ToggleRoot()
         {
@@ -4501,6 +4606,7 @@
                 
 		if (cut)
 		{
+        if (Globals.SAVEONMAKE)
                     Save();
 			//int indices[] = jList.getSelectedIndices();
 			//for (int i = indices.length - 1; i >= 0; i--)
@@ -5219,9 +5325,12 @@
 	cButton clearpanelButton;
 	cButton unselectButton;
 	
-	cButton saveButton;
+	cButton minButton;
+	cButton maxButton;
+	cButton fullButton;
 	cButton undoButton;
 	cButton redoButton;
+	cButton saveButton;
 	cButton oneStepButton;
         
 	cButton screenfitButton;
@@ -5234,14 +5343,6 @@
 	cButton closeButton;
 
 	cButton setsupportButton;
-        
-	cButton twoButton;
-	cButton sixButton;
-	cButton threeButton;
-	cButton sevenButton;
-	cButton fourButton; // full panel
-	cButton oneButton; // full XYZ
-        //cButton currentLayout;
         
 	//
         //Composite

--
Gitblit v1.6.2