From 47cd0f0a3870d843cb758535316060d30f15c811 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 24 Jun 2019 19:10:13 -0400 Subject: [PATCH] Toolbox + DnD --- GroupEditor.java | 179 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 135 insertions(+), 44 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index cce9b1b..9b1b9d3 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -150,6 +150,8 @@ void SetupMenu2(GroupEditor oe) { + oe.jTree = new cTree(); + Menu menu; oe.menuBar.add(menu = new Menu("Edit")); //editItem = menu.add(new MenuItem("Edit")); @@ -160,7 +162,7 @@ // redoItem = menu.add(new MenuItem("Redo")); // redoItem.addActionListener(this); // menu.add("-"); - duplicateItem = menu.add(new MenuItem("Duplicate")); + duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate")); duplicateItem.addActionListener(this); cloneItem = menu.add(new MenuItem("Clone")); cloneItem.addActionListener(this); @@ -334,13 +336,21 @@ frontItem.addActionListener(this); compositeItem = menu.add(new MenuItem("Composite")); compositeItem.addActionListener(this); + + if (Globals.ADVANCED) + { hideItem = menu.add(new MenuItem("Hidden Group")); hideItem.addActionListener(this); + } ungroupItem = menu.add(new MenuItem("Ungroup")); ungroupItem.addActionListener(this); + menu.add("-"); + randomItem = menu.add(new MenuItem("Switch node")); randomItem.addActionListener(this); + if (Globals.ADVANCED) + { switchGeoItem = menu.add(new MenuItem("Switch Geometry")); switchGeoItem.addActionListener(this); switchTransfoItem = menu.add(new MenuItem("Switch Transform")); @@ -348,8 +358,6 @@ morphItem = menu.add(new MenuItem("Morph Group")); morphItem.addActionListener(this); - if (Globals.ADVANCED) - { menu.add("-"); physicsItem = menu.add(new MenuItem("Physics")); physicsItem.addActionListener(this); @@ -588,35 +596,37 @@ fullButton.setToolTipText("Full-screen window"); fullButton.addActionListener(this); - oe.toolbarPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolboxPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); undoButton.setToolTipText("Undo changes"); undoButton.addActionListener(this); - oe.toolbarPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolboxPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); redoButton.setToolTipText("Redo changes"); redoButton.addActionListener(this); - oe.toolbarPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolboxPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); saveButton.setToolTipText("Save changes"); saveButton.addActionListener(this); - oe.toolbarPanel.add(liveCB = GetCheckBox("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); + oe.toolboxPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); liveCB.setToolTipText("Enable animation"); liveCB.addItemListener(this); - oe.toolbarPanel.add(fastCB = GetCheckBox("icons/runfast.png", CameraPane.FAST)); //, constraints); - fastCB.setToolTipText("Fast mode"); - fastCB.addItemListener(this); - - oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolboxPanel.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); + oe.toolboxPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints); + fastCB.setToolTipText("Fast mode"); + fastCB.addItemListener(this); + + oe.toolboxPanel.Return(); + + oe.toolboxPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints); trackCB.setToolTipText("Enable tracking"); trackCB.addItemListener(this); - oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolboxPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); screenfitButton.setToolTipText("Screen fit"); screenfitButton.addActionListener(this); @@ -630,15 +640,17 @@ snapobjectButton.setToolTipText("Snap Object"); } - oe.toolbarPanel.add(flashSelectionButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolboxPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); flashSelectionButton.setToolTipText("Highlight selection"); flashSelectionButton.addActionListener(this); - oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL)); + //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL)); oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); twoButton.setToolTipText("Show center view only"); twoButton.addActionListener(this); + this.fullscreenLayout = twoButton; + oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); fourButton.addActionListener(this); fourButton.setToolTipText("Show left panel only"); @@ -653,16 +665,63 @@ sevenButton.addActionListener(this); // - oe.toolbarPanel.add(rootButton = new cButton("o o o", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); rootButton.setToolTipText("Edit selection in new tab"); rootButton.addActionListener(this); - oe.toolbarPanel.add(closeButton = new cButton("X", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); closeButton.setToolTipText("Close tab"); closeButton.addActionListener(this); //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints); //clearButton.addActionListener(this); - + + // INSERT + oe.toolboxPanel.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + gridButton.setToolTipText("Create grid"); + gridButton.addActionListener(this); + + oe.toolboxPanel.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + boxButton.setToolTipText("Create box"); + boxButton.addActionListener(this); + + oe.toolboxPanel.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + sphereButton.setToolTipText("Create sphere"); + sphereButton.addActionListener(this); + + oe.toolboxPanel.Return(); + + oe.toolboxPanel.add(coneButton = GetButton("icons/cone.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + coneButton.setToolTipText("Create cone"); + coneButton.addActionListener(this); + + oe.toolboxPanel.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + torusButton.setToolTipText("Create torus"); + torusButton.addActionListener(this); + + oe.toolboxPanel.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + superButton.setToolTipText("Create superellipsoid"); + superButton.addActionListener(this); + + if (Globals.ADVANCED) + { + oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + kleinButton.setToolTipText("Create Klein bottle"); + kleinButton.addActionListener(this); + } + + oe.toolboxPanel.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + particlesButton.setToolTipText("Create particle system"); + particlesButton.addActionListener(this); + + oe.toolboxPanel.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + overlayButton.setToolTipText("Create overlay"); + overlayButton.addActionListener(this); + + oe.toolboxPanel.add(lightButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + lightButton.setToolTipText("Create light"); + lightButton.addActionListener(this); + + // EDIT panel editCommandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); editButton.setToolTipText("Edit selection"); editButton.addActionListener(this); @@ -703,7 +762,7 @@ JScrollPane jSP; //ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints); - jSPPanel.add(jSP = new JScrollPane(oe.jTree = new cTree(null))); //, oe.aConstraints); + jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints); ResetModel(); oe.treePanel.add(jSPPanel); @@ -868,16 +927,16 @@ /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this); } - cCheckBox liveCB; + cToggleButton liveCB; cCheckBox supportCB; cCheckBox localCB; cCheckBox crowdCB; cCheckBox smoothCB; - cCheckBox fastCB; + cToggleButton fastCB; cCheckBox slowCB; cCheckBox boxCB; cCheckBox zoomBoxCB; - cCheckBox trackCB; + cToggleButton trackCB; cCheckBox smoothfocusCB; // JCheckBox speakerMocapCB; cCheckBox speakerCameraCB; @@ -1014,7 +1073,8 @@ /**/ //DragSource.getDefaultDragSource().startDrag(dge, DragSource.DefaultMoveNoDrop, new StringSelection("Allo"), this); - TreePath path = new TreePath(objEditor.jTree.getSelectionPath().getLastPathComponent()); + //TreePath path = new TreePath(objEditor.jTree.getSelectionPath().getLastPathComponent()); + TreePath path = objEditor.jTree.getSelectionPath(); if ((path == null) || (path.getPathCount() <= 1)) { // We can't move the root node or an empty selection return; @@ -1138,16 +1198,16 @@ return; } - if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) // ?? LINK) - { +// june 2019 if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) // ?? LINK) +// { loadClipboard(true); objEditor.jTree.setSelectionPath(destinationPath); pasteInto(false, false); - } else { - loadClipboard(false); - objEditor.jTree.setSelectionPath(destinationPath); - pasteInto(false, false); // true); // ??? - } +// } else { +// loadClipboard(false); +// objEditor.jTree.setSelectionPath(destinationPath); +// pasteInto(false, false); // true); // ??? +// } } public void dropActionChanged(DropTargetDragEvent dtde) // Called if the user has modified the current drop gesture @@ -1739,11 +1799,11 @@ objEditor.cameraView.renderCamera.setAim(v2, v1); objEditor.cameraView.repaint(); } else - if (source == rectoidItem) + if (source == rectoidItem || source == boxButton) { makeSomething(new Box()); } else - if (source == particleItem) + if (source == particleItem || source == particlesButton) { ParticleNode particleGeom = new ParticleNode("Particles", 1000); //, particleType); ParticleController particleController = new ParticleController(particleGeom); @@ -1822,27 +1882,27 @@ makeSomething(obj); } else - if (source == gridItem) + if (source == gridItem || source == gridButton) { makeSomething(new Grid()); } else - if (source == ellipsoidItem) + if (source == ellipsoidItem || source == sphereButton) { makeSomething(new Sphere()); } else - if (source == coneItem) + if (source == coneItem || source == coneButton) { makeSomething(new Cone()); } else - if (source == torusItem) + if (source == torusItem || source == torusButton) { makeSomething(new Torus()); } else - if (source == superItem) + if (source == superItem || source == superButton) { makeSomething(new Superellipsoid()); } else - if (source == kleinItem) + if (source == kleinItem || source == kleinButton) { makeSomething(new Klein()); } else @@ -1862,7 +1922,7 @@ { makeSomething(new BezierSurface()); } else - if (source == overlayItem) + if (source == overlayItem || source == overlayButton) { /* Object3D obj = new BezierSurface(5,8); @@ -1910,7 +1970,7 @@ s.setup(); makeSomething(s); } else - if (source == lightItem) + if (source == lightItem || source == lightButton) { makeSomething(new Light()); } else @@ -2596,7 +2656,7 @@ { CastShadow(2); } else - if (source == ungroupItem) + if (source == ungroupItem || source == ungroupButton) { //ungroup(); for (int i=0; i<group.selection.size(); i++) @@ -2934,6 +2994,10 @@ if (source == twoButton) { radio.layout = twoButton; + + if (CameraPane.FULLSCREEN) + fullscreenLayout = radio.layout; + // bug //gridPanel.setDividerLocation(1.0); //bigPanel.setDividerLocation(0.0); @@ -2989,6 +3053,9 @@ { radio.layout = threeButton; + if (CameraPane.FULLSCREEN) + fullscreenLayout = radio.layout; + // bigThree.remove(scenePanel); // bigThree.remove(centralPanel); // bigThree.remove(XYZPanel); @@ -3027,6 +3094,9 @@ { radio.layout = fourButton; + if (CameraPane.FULLSCREEN) + fullscreenLayout = radio.layout; + // bigThree.remove(scenePanel); // bigThree.remove(centralPanel); // bigThree.remove(XYZPanel); @@ -3063,6 +3133,9 @@ if (source == sixButton) { radio.layout = sixButton; + + if (CameraPane.FULLSCREEN) + fullscreenLayout = radio.layout; // bigThree.remove(scenePanel); // bigThree.remove(centralPanel); @@ -3101,6 +3174,9 @@ if (source == sevenButton) { radio.layout = sevenButton; + + if (CameraPane.FULLSCREEN) + fullscreenLayout = radio.layout; // bigThree.remove(scenePanel); // bigThree.remove(centralPanel); @@ -4369,7 +4445,7 @@ { //System.out.println("edit : " + objectPanel.indexOfTab("Material")); //objectPanel.setEnabledAt(objectPanel.indexOfTab("Material"), false); - objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit")); + //objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit")); Object3D elem = (Object3D)group.selection.elementAt(i); if(elem != group || !newWindow) @@ -5333,6 +5409,21 @@ cButton saveButton; cButton oneStepButton; + cButton groupButton; + cButton ungroupButton; + cButton compositeButton; + + cButton gridButton; + cButton boxButton; + cButton sphereButton; + cButton coneButton; + cButton torusButton; + cButton superButton; + cButton kleinButton; + cButton particlesButton; + cButton overlayButton; + cButton lightButton; + cButton screenfitButton; cButton screenfitpointButton; cButton snapobjectButton; @@ -5357,7 +5448,7 @@ private MenuItem cutItem; private MenuItem undoItem; private MenuItem redoItem; - private MenuItem duplicateItem; + private JMenuItem duplicateItem; private MenuItem cloneItem; private MenuItem cloneSupportItem; private MenuItem overwriteGeoItem; -- Gitblit v1.6.2