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 | 100 +++++++++++++++++++++++++++++++++---------------- 1 files changed, 67 insertions(+), 33 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index ec26bdb..7a750fb 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -84,10 +84,10 @@ void CloneSelection(boolean supports) { - if (Globals.SAVEONMAKE) + if (Globals.REPLACEONMAKE) Save(); - boolean keep = Globals.SAVEONMAKE; - Globals.SAVEONMAKE = false; + 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();) @@ -98,7 +98,7 @@ makeSomething(clone, i==group.selection.size()-1); } - Globals.SAVEONMAKE = keep; + Globals.REPLACEONMAKE = keep; } void CloneClipboard(boolean supports) @@ -544,6 +544,7 @@ buildToolsMenu(menu); } + void SetupUI2(ObjEditor oe) { // June 2019 @@ -615,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); @@ -820,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); @@ -945,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) @@ -1024,7 +1041,7 @@ cCheckBox oeilCB; cCheckBox shadowCB; - cCheckBox autosaveCB; + cCheckBox autokeepCB; cCheckBox lookAtCB; // static int COLOR = 1; @@ -1136,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) { @@ -2225,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 @@ -3479,6 +3510,9 @@ } copy = group; + + SetUndoStates(); + //Globals.theRenderer.object = group; if(!useclient) { @@ -4942,10 +4976,10 @@ void paste(boolean expand) { - if (Globals.SAVEONMAKE) + if (Globals.REPLACEONMAKE) Save(); - boolean keep = Globals.SAVEONMAKE; - Globals.SAVEONMAKE = false; + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; // if (GrafreeD.clipboard == null) // return; boolean first = true; @@ -5005,7 +5039,7 @@ Grafreed.clipboard.get(0).parent = keepparent; } - Globals.SAVEONMAKE = keep; + Globals.REPLACEONMAKE = keep; ResetModel(); refreshContents(); } @@ -5141,10 +5175,10 @@ void group(Object3D csg, boolean grab) { - if (Globals.SAVEONMAKE) + if (Globals.REPLACEONMAKE) Save(); - boolean keep = Globals.SAVEONMAKE; - Globals.SAVEONMAKE = false; + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; if (//false) // why?? !group.selection.isEmpty()) { @@ -5258,15 +5292,15 @@ //node.add(csg); //makeSomething(node); makeSomething(csg); - Globals.SAVEONMAKE = keep; + Globals.REPLACEONMAKE = keep; } void Ungroup(Object3D g) { - if (Globals.SAVEONMAKE) + if (Globals.REPLACEONMAKE) Save(); - boolean keep = Globals.SAVEONMAKE; - Globals.SAVEONMAKE = false; + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; if (g instanceof HiddenObject) { HiddenObject h = (HiddenObject) g; @@ -5283,7 +5317,7 @@ objEditor.makeSomething(g.get(i), false); } } - Globals.SAVEONMAKE = keep; + Globals.REPLACEONMAKE = keep; } void ungroup() -- Gitblit v1.6.2