From d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Wed, 17 Jul 2019 20:15:40 -0400 Subject: [PATCH] Version slider --- GroupEditor.java | 114 ++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 81 insertions(+), 33 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index ec26bdb..a08dc18 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -60,6 +60,12 @@ this.copy = this.group = group; //selectees = this.group.selectees; + if (copy.versions == null) + { + copy.versions = new byte[100][]; + copy.versionindex = -1; + } + if(ui) SetupUI(objEditor); } @@ -74,6 +80,12 @@ this.copy = this.group = copy; //selectees = this.group.selectees; + if (copy.versions == null) + { + copy.versions = new byte[100][]; + copy.versionindex = -1; + } + SetupMenu2(this); //objEditor); SetupUI2(objEditor); objEditor.SetupUI(true); @@ -84,10 +96,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 +110,7 @@ makeSomething(clone, i==group.selection.size()-1); } - Globals.SAVEONMAKE = keep; + Globals.REPLACEONMAKE = keep; } void CloneClipboard(boolean supports) @@ -544,6 +556,7 @@ buildToolsMenu(menu); } + void SetupUI2(ObjEditor oe) { // June 2019 @@ -615,29 +628,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 +846,9 @@ oe.treePanel.add(copyOptionsPanel); oe.treePanel.Return(); + cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0); + versionSlider = (cNumberSlider)sliderPane.getComponent(1); + sliderPane.preferredHeight = 1; // mainPanel.setDividerLocation(0.5); //1.0); // mainPanel.setResizeWeight(0.5); @@ -945,9 +974,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 +1053,7 @@ cCheckBox oeilCB; cCheckBox shadowCB; - cCheckBox autosaveCB; + cCheckBox autokeepCB; cCheckBox lookAtCB; // static int COLOR = 1; @@ -1136,9 +1165,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 +2254,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 +3522,9 @@ } copy = group; + + SetUndoStates(); + //Globals.theRenderer.object = group; if(!useclient) { @@ -3507,6 +3553,8 @@ radio.layout.doClick(); ClearUnpinned(); + Grafreed.Assert(group != null); + Grafreed.Assert(group.selection != null); SetPinStates(group.selection.size() > 0); if (group.selection.size() == 1) EditSelection(false); @@ -4942,10 +4990,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 +5053,7 @@ Grafreed.clipboard.get(0).parent = keepparent; } - Globals.SAVEONMAKE = keep; + Globals.REPLACEONMAKE = keep; ResetModel(); refreshContents(); } @@ -5141,10 +5189,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 +5306,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 +5331,7 @@ objEditor.makeSomething(g.get(i), false); } } - Globals.SAVEONMAKE = keep; + Globals.REPLACEONMAKE = keep; } void ungroup() -- Gitblit v1.6.2