From 480ad70047e54b2b92f974e6c2ac5a6c0bdc5a5c Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 18 Aug 2019 13:56:09 -0400
Subject: [PATCH] Fix new + checkbox

---
 GroupEditor.java |  140 ++++++++++++++++++++++++++--------------------
 1 files changed, 78 insertions(+), 62 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index cff60a6..c86dd4d 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -29,7 +29,7 @@
     {
         cButton skyboxButton;
         final String path = "cubemaps/" + f + "-skyboxes/" + s;
-        row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
+        row.add(skyboxButton = GetButton(path + "/preview.jpg", !Globals.NIMBUSLAF));
         //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF));
         skyboxButton.setToolTipText(s.equals("") ? "No background" : s);
         skyboxButton.addActionListener(new ActionListener()
@@ -46,7 +46,7 @@
     {
         cButton textureButton;
         final String path = "textures/" + f + "/" + c + "/"; // + t;
-        row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
+        row.add(textureButton = GetButton(path + "icons/" + t, !Globals.NIMBUSLAF));
         textureButton.setToolTipText(c + count);
         textureButton.addActionListener(new ActionListener()
         {
@@ -347,7 +347,7 @@
 
     public void CreateSkyboxPanel(cGridBag skyboxPanel)
     {
-        JTabbedPane skyboxpane = new JTabbedPane();
+        JTabbedPane skyboxpane = new JTabbedPane(JTabbedPane.LEFT);
         
         AddSkyboxTab0(skyboxpane);
         AddSkyboxTab1(skyboxpane);
@@ -415,12 +415,14 @@
 		this.copy = this.group = group;
 		//selectees = this.group.selectees;
 		
+                assert(false);
+                
         if (copy.versionlist == null)
         {
             copy.versionlist = new Object3D[100];
             copy.versionindex = -1;
             
-            Save(true);
+            //Save(true);
         }
         
 		if(ui)
@@ -449,7 +451,7 @@
             copy.versionlist = new Object3D[100];
             copy.versionindex = -1;
             
-            Save(true);
+            //Save(true);
         }
 	}
 
@@ -855,9 +857,9 @@
 		hideleavesItem.addActionListener(this);
 		showleavesItem = menu.add(new MenuItem("Show Leaves"));
 		showleavesItem.addActionListener(this);
-		markleavesItem = menu.add(new MenuItem("Mark Leaves"));
+		markleavesItem = menu.add(new MenuItem("Anim Leaves"));
 		markleavesItem.addActionListener(this);
-		unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves"));
+		unmarkleavesItem = menu.add(new MenuItem("Unanim Leaves"));
 		unmarkleavesItem.addActionListener(this);
 		rewindleavesItem = menu.add(new MenuItem("Rewind Leaves"));
 		rewindleavesItem.addActionListener(this);
@@ -1036,9 +1038,9 @@
         oe.radioPanel.add(dummyButton);
         oe.buttonGroup.add(dummyButton);
          */
-                cGridBag copyOptionsPanel = new cGridBag();
+                cGridBag versionManagerPanel = new cGridBag();
                                         
-                copyOptionsPanel.preferredHeight = 2;
+                versionManagerPanel.preferredHeight = 4;
                 
                 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
                 
@@ -1065,25 +1067,25 @@
 //                        }
 //                });
                 
-		oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 collapseButton.setToolTipText("Collapse toolbar");
 		collapseButton.addActionListener(this);
                 
-		oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(maximize3DButton = GetButton("icons/square.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 maximize3DButton.setToolTipText("Maximize 3D view");
 		maximize3DButton.addActionListener(this);
                 
-		oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 twoButton.setToolTipText("Show 3D view only");
 		twoButton.addActionListener(this);
                 this.fullscreenLayout = twoButton;
                 
-		oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 threeButton.setToolTipText("Show controls and 3D view");
 		threeButton.addActionListener(this);
                 if (Globals.ADVANCED)
                 {
-		oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 sixButton.setToolTipText("Show 3D view and controls");
 		sixButton.addActionListener(this);
                 }
@@ -1092,50 +1094,51 @@
 //		sevenButton.addActionListener(this);
                 //
                 
-		oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 fullButton.setToolTipText("Full-screen window");
 		fullButton.addActionListener(this);
                 
-		oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 screenfitButton.setToolTipText("Screen fit");
 		screenfitButton.addActionListener(this);
 
-		oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 restoreCameraButton.setToolTipText("Restore viewpoint");
 		restoreCameraButton.addActionListener(this);
                 
-		copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		versionManagerPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 saveVersionButton.setToolTipText("Duplicate current version");
 		saveVersionButton.addActionListener(this);
                                                 
-		copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		versionManagerPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 deleteVersionButton.setToolTipText("Delete current version");
 		deleteVersionButton.addActionListener(this);
+                deleteVersionButton.setEnabled(false);
                                                 
-		copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		versionManagerPanel.add(previousVersionButton = GetButton("icons/undo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 previousVersionButton.setToolTipText("Previous version");
 		previousVersionButton.addActionListener(this);
                 previousVersionButton.setEnabled(false);
                 
                 cGridBag updown = new cGridBag().setVertical(true);
-		updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		updown.add(restoreButton = GetButton("icons/restore.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 restoreButton.setToolTipText("Undo (restore current version)");
 		restoreButton.addActionListener(this);
-                //restoreButton.setEnabled(false);
+                restoreButton.setEnabled(false);
                 
-		updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		updown.add(replaceButton = GetButton("icons/replace.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 replaceButton.setToolTipText("Save (replace current version)");
 		replaceButton.addActionListener(this);
-                //replaceButton.setEnabled(false);
+                replaceButton.setEnabled(false);
                 
-                copyOptionsPanel.add(updown);
+                versionManagerPanel.add(updown);
                 
-		copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		versionManagerPanel.add(nextVersionButton = GetButton("icons/redo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 nextVersionButton.setToolTipText("Next version");
 		nextVersionButton.addActionListener(this);
                 nextVersionButton.setEnabled(false);
                 
-		oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 oneStepButton.setToolTipText("Animate one step forward");
 		oneStepButton.addActionListener(this);
                 
@@ -1158,11 +1161,11 @@
 
                 if (Globals.ADVANCED)
                 {
-                        oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                        oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                         snapobjectButton.addActionListener(this);
                         snapobjectButton.setToolTipText("Snap Object");
                         
-		oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
 		fourButton.addActionListener(this);
                 fourButton.setToolTipText("Show control panel only");
                 }
@@ -1170,11 +1173,11 @@
 		//oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
                 
 
-		oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 rootButton.setToolTipText("Open selection in new tab");
 		rootButton.addActionListener(this);
 
-                oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 closeButton.setToolTipText("Close tab");
 		closeButton.addActionListener(this);
 		//oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
@@ -1183,38 +1186,38 @@
                 cGridBag row1 = new cGridBag();
                 
                 // INSERT
-                row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row1.add(gridButton = GetButton("icons/grid.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 gridButton.setToolTipText("Create ground");
                                 gridButton.addActionListener(this);
 
-                row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row1.add(boxButton = GetButton("icons/box.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 boxButton.setToolTipText("Create box");
                                 boxButton.addActionListener(this);
 
-                row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row1.add(superButton = GetButton("icons/super.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 superButton.setToolTipText("Create superellipsoid");
                                 superButton.addActionListener(this);
 
-                row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row1.add(sphereButton = GetButton("icons/sphere.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 sphereButton.setToolTipText("Create sphere");
                                 sphereButton.addActionListener(this);
 
-                row1.add(coneButton = GetButton("icons/cone.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row1.add(coneButton = GetButton("icons/cone.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 coneButton.setToolTipText("Create cone");
                                 coneButton.addActionListener(this);
 
-                row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row1.add(torusButton = GetButton("icons/torus.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 torusButton.setToolTipText("Create torus");
                                 torusButton.addActionListener(this);
 
                 if (Globals.ADVANCED)
                 {
-                    oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                    oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                     kleinButton.setToolTipText("Create Klein bottle");
                                     kleinButton.addActionListener(this);
                 }
                 
-                row1.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row1.add(particlesButton = GetButton("icons/particles.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 particlesButton.setToolTipText("Create particle system");
                                particlesButton.addActionListener(this);
 
@@ -1222,31 +1225,31 @@
                 
                 cGridBag row2 = new cGridBag();
                 
-                row2.add(groupButton = GetButton("icons/group.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row2.add(groupButton = GetButton("icons/group.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 groupButton.setToolTipText("Create group");
                                groupButton.addActionListener(this);
 
-                row2.add(compositeButton = GetButton("icons/composite.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row2.add(compositeButton = GetButton("icons/composite.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 compositeButton.setToolTipText("Create composite");
                                compositeButton.addActionListener(this);
 
-                row2.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row2.add(switchButton = GetButton("icons/switch.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 switchButton.setToolTipText("Create item switcher");
                                switchButton.addActionListener(this);
 
-                row2.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row2.add(loopButton = GetButton("icons/loop.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 loopButton.setToolTipText("Create loop");
                                loopButton.addActionListener(this);
 
-                row2.add(textureButton = GetButton("icons/texture.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row2.add(textureButton = GetButton("icons/texture.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 textureButton.setToolTipText("Create texture");
                                textureButton.addActionListener(this);
 
-                row2.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row2.add(overlayButton = GetButton("icons/overlay.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 overlayButton.setToolTipText("Create overlay");
                                overlayButton.addActionListener(this);
 
-                row2.add(lightButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                row2.add(lightButton = GetButton("icons/light-bulb.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 lightButton.setToolTipText("Create light");
                                lightButton.addActionListener(this);
 
@@ -1256,6 +1259,8 @@
                 
                 CreateTexturePanel(textures);
                 
+                resourcecontainer.setSelectedIndex((int)(Math.random() * resourcecontainer.getTabCount()));
+                
                 oe.toolboxPanel.add(textures);
                 
                 textures.preferredHeight = 100;
@@ -1263,11 +1268,11 @@
                 CreateSkyboxPanel(oe.skyboxPanel);
                 
                 // EDIT panel
-		editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 editButton.setToolTipText("Pin selection controls");
 		editButton.addActionListener(this);
 
-		editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 uneditButton.setToolTipText("Unpin and remove selection controls");
 		uneditButton.addActionListener(this);
 
@@ -1275,7 +1280,7 @@
                 allParamsButton.setToolTipText("Show all controls");
 		allParamsButton.addActionListener(this);
 
-		editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 clearPanelButton.setToolTipText("Clear all controls");
 		clearPanelButton.addActionListener(this);
 
@@ -1283,7 +1288,7 @@
                 //unselectButton.setToolTipText("Unselect");
 		//unselectButton.addActionListener(this);
 
-		editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+		editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 flashSelectionButton.setToolTipText("Highlight selection");
 		flashSelectionButton.addActionListener(this);
                 
@@ -1306,6 +1311,8 @@
                 
                 cGridBag jSPPanel = new cGridBag();
 
+            jSPPanel.preferredHeight = 20;
+            
                 JScrollPane jSP;
 		//ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints);
 		jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints);
@@ -1314,11 +1321,11 @@
                 oe.treePanel.add(jSPPanel);
                 oe.treePanel.Return();
 
-                oe.treePanel.add(copyOptionsPanel);
+                oe.treePanel.add(versionManagerPanel);
                 oe.treePanel.Return();
-        cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
-            versionSlider = (cNumberSlider)sliderPane.getComponent(1);
-            sliderPane.preferredHeight = 1;
+        versionSliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
+            versionSlider = (cNumberSlider)versionSliderPane.getComponent(1);
+            versionSliderPane.preferredHeight = 3;
                 
 //        mainPanel.setDividerLocation(0.1); //1.0);
         mainPanel.setResizeWeight(0.4);
@@ -3963,6 +3970,8 @@
 		if (source == closeButton)
 		{
 //System.out.println("CLOSE: " + buttonGroup.getSelection());
+                    Replace();
+                    
                     cRadio ab;
                     for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
                     {
@@ -4061,6 +4070,8 @@
 		} else
                 if(source instanceof cRadio)
 		{
+                    Replace();
+                    
                     group.parent = keepparent;
                         group.attributes = 0;
                     //group.editWindow = null;
@@ -4116,13 +4127,21 @@
                     
         if (copy.versionlist == null)
         {
-            copy.versionlist = new Object3D[100];
             copy.versionindex = -1;
             
             // Cannot work with loops
-            // To fix this issue, first mark all nodes above the root,
+            // To fix this issue, we first mark all nodes above the root,
             // and check if any of these nodes are reachable below the root.
-            //Save(true);
+            Grafreed.grafreed.universe.TagObjects(copy, true);
+            
+            if (!copy.HasTags())
+            {
+                copy.versionlist = new Object3D[100];
+                
+                Save(true);
+            }
+            
+            Grafreed.grafreed.universe.TagObjects(copy, false);
         }
         
                     SetVersionStates();
@@ -4270,7 +4289,7 @@
                         TouchTransform(obj);
                         continue;
                     }
-                    if ((mask&2) != 0) // Scale
+                    if ((mask&2) != 0) // Scale/rotation
                     {
                         obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
                         obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
@@ -4278,10 +4297,6 @@
                         obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
                         obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
                         obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
-                    }
-                    if ((mask&4) != 0) // Rotation
-                    {
-                        // ?
                     }
                     if ((mask&1) != 0) // Translation
                     {
@@ -5380,6 +5395,7 @@
 
         void refreshContents(boolean cp)
         {
+            if (Globals.ADVANCED)
             //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
             if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
             {

--
Gitblit v1.6.2