From a5580a47d246c1272b10adba68070f6e13da5e41 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Tue, 16 Jul 2019 21:08:38 -0400 Subject: [PATCH] Replace/restore buttons. --- GroupEditor.java | 104 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 79 insertions(+), 25 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index 84ed69e..7a750fb 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -84,6 +84,10 @@ void CloneSelection(boolean supports) { + if (Globals.REPLACEONMAKE) + Save(); + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; // Object3D keep = GrafreeD.clipboard; //Object3D obj; for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();) @@ -94,6 +98,7 @@ makeSomething(clone, i==group.selection.size()-1); } + Globals.REPLACEONMAKE = keep; } void CloneClipboard(boolean supports) @@ -380,14 +385,14 @@ shadowYItem.addActionListener(this); shadowZItem = menu.add(new MenuItem("Shadow Blue")); shadowZItem.addActionListener(this); + attributeItem = menu.add(new MenuItem("Attribute")); + attributeItem.addActionListener(this); if (Globals.ADVANCED) { menu.add("-"); linkerItem = menu.add(new MenuItem("Linker")); linkerItem.addActionListener(this); - attributeItem = menu.add(new MenuItem("Attribute")); - attributeItem.addActionListener(this); templateItem = menu.add(new MenuItem("Template")); templateItem.addActionListener(this); pointflowItem = menu.add(new MenuItem("Point Flow")); @@ -539,6 +544,7 @@ buildToolsMenu(menu); } + void SetupUI2(ObjEditor oe) { // June 2019 @@ -610,29 +616,42 @@ restoreCameraButton.setToolTipText("Restore viewpoint"); restoreCameraButton.addActionListener(this); + copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + saveButton.setToolTipText("New version"); + saveButton.addActionListener(this); + copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - undoButton.setToolTipText("Undo changes"); + undoButton.setToolTipText("Previous version"); undoButton.addActionListener(this); undoButton.setEnabled(false); + cGridBag updown = new cGridBag().setVertical(true); + updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + restoreButton.setToolTipText("Restore current"); + restoreButton.addActionListener(this); + restoreButton.setEnabled(false); + + updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + replaceButton.setToolTipText("Replace current"); + replaceButton.addActionListener(this); + replaceButton.setEnabled(false); + + copyOptionsPanel.add(updown); + copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - redoButton.setToolTipText("Redo changes"); + redoButton.setToolTipText("Next version"); redoButton.addActionListener(this); redoButton.setEnabled(false); - copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - saveButton.setToolTipText("Save changes"); - saveButton.addActionListener(this); - - copyOptionsPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); + oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); liveCB.setToolTipText("Enable animation"); liveCB.addItemListener(this); - copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); oneStepButton.setToolTipText("Animate one step forward"); oneStepButton.addActionListener(this); - copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints); + oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints); fastCB.setToolTipText("Fast mode"); fastCB.addItemListener(this); @@ -815,6 +834,9 @@ oe.treePanel.add(copyOptionsPanel); oe.treePanel.Return(); + cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 10, 0); + versionField = (cNumberSlider)sliderPane.getComponent(1); + sliderPane.preferredHeight = 1; // mainPanel.setDividerLocation(0.5); //1.0); // mainPanel.setResizeWeight(0.5); @@ -940,9 +962,9 @@ toggleSwitchCB.setToolTipText("Choose a single item"); toggleSwitchCB.addItemListener(this); - panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints); - autosaveCB.setToolTipText("On structure change"); - autosaveCB.addItemListener(this); + panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints); + autokeepCB.setToolTipText("On structure change"); + autokeepCB.addItemListener(this); panel.Return(); if (Globals.ADVANCED) @@ -971,7 +993,7 @@ { cRadio radioButton = new cRadio(obj.name); - // Patch to avoid bug with transparency. + // June 2019. Patch to avoid bug with transparency. radioButton.hadMaterial = obj.material != null; if (!radioButton.hadMaterial) { @@ -1019,7 +1041,7 @@ cCheckBox oeilCB; cCheckBox shadowCB; - cCheckBox autosaveCB; + cCheckBox autokeepCB; cCheckBox lookAtCB; // static int COLOR = 1; @@ -1131,9 +1153,9 @@ { Globals.FREEZEONMOVE ^= true; } - else if(e.getSource() == autosaveCB) + else if(e.getSource() == autokeepCB) { - Globals.SAVEONMAKE ^= true; + Globals.REPLACEONMAKE ^= true; } else if(e.getSource() == lookAtCB) { @@ -1223,7 +1245,7 @@ // return; // } - String string = (String) object; + String string = object.toString(); // File path for Mac and Windows if (string.charAt(0) == '/' || string.charAt(1) == ':') @@ -1488,6 +1510,8 @@ reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)")); reduce34MorphItem.addActionListener(this); menu.add("-"); + menu.add(memoryItem = new MenuItem("Memory Usage")); + memoryItem.addActionListener(this); menu.add(computeAOItem = new MenuItem("Compute AO")); computeAOItem.addActionListener(this); @@ -1496,8 +1520,6 @@ mirrorItem = menu.add(new MenuItem("Mirror Poses")); mirrorItem.addActionListener(this); menu.add("-"); - menu.add(memoryItem = new MenuItem("Memory Usage")); - memoryItem.addActionListener(this); menu.add(analyzeItem = new MenuItem("Analyze")); analyzeItem.addActionListener(this); menu.add(dumpItem = new MenuItem("Print")); @@ -2220,15 +2242,29 @@ } else if (source == undoButton) { - if (!Undo()) - java.awt.Toolkit.getDefaultToolkit().beep(); + // Go to previous version + //if (!Undo()) + //java.awt.Toolkit.getDefaultToolkit().beep(); + Undo(); + } else + if (source == restoreButton) + { + // Restore current version + Restore(); + } else + if (source == replaceButton) + { + // Overwrite current version + Replace(); } else if (source == redoButton) { + // Go to next version Redo(); } else if (source == saveButton) { + // Save a new version if (!Save(true)) java.awt.Toolkit.getDefaultToolkit().beep(); } else @@ -3474,6 +3510,9 @@ } copy = group; + + SetUndoStates(); + //Globals.theRenderer.object = group; if(!useclient) { @@ -4833,8 +4872,8 @@ if (cut) { - if (Globals.SAVEONMAKE) - Save(); +// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save. +// Save(); //int indices[] = jList.getSelectedIndices(); //for (int i = indices.length - 1; i >= 0; i--) //jList.remove(indices[i]); @@ -4937,6 +4976,10 @@ void paste(boolean expand) { + if (Globals.REPLACEONMAKE) + Save(); + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; // if (GrafreeD.clipboard == null) // return; boolean first = true; @@ -4996,6 +5039,7 @@ Grafreed.clipboard.get(0).parent = keepparent; } + Globals.REPLACEONMAKE = keep; ResetModel(); refreshContents(); } @@ -5131,6 +5175,10 @@ void group(Object3D csg, boolean grab) { + if (Globals.REPLACEONMAKE) + Save(); + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; if (//false) // why?? !group.selection.isEmpty()) { @@ -5244,10 +5292,15 @@ //node.add(csg); //makeSomething(node); makeSomething(csg); + Globals.REPLACEONMAKE = keep; } void Ungroup(Object3D g) { + if (Globals.REPLACEONMAKE) + Save(); + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; if (g instanceof HiddenObject) { HiddenObject h = (HiddenObject) g; @@ -5264,6 +5317,7 @@ objEditor.makeSomething(g.get(i), false); } } + Globals.REPLACEONMAKE = keep; } void ungroup() -- Gitblit v1.6.2