mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-05 09:34:58 +00:00
Undos when switching timelined
This commit is contained in:
@@ -129,12 +129,6 @@ public class EasySwfPanel extends JPanel {
|
||||
final List<Integer> depths = stagePanel.getSelectedDepths();
|
||||
final int frame = stagePanel.getFrame();
|
||||
final Matrix newMatrix = stagePanel.getNewMatrix();
|
||||
MATRIX previousMatrix = new MATRIX();
|
||||
/*synchronized (stagePanel) {
|
||||
DepthState ds = stagePanel.getTimelined().getTimeline().getFrame(frame).layers.get(depths);
|
||||
previousMatrix = ds.placeObjectTag.getMatrix();
|
||||
}*/
|
||||
|
||||
final Point2D regPoint = stagePanel.getRegistrationPoint();
|
||||
final RegistrationPointPosition regPointPos = stagePanel.getRegistrationPointPosition();
|
||||
|
||||
@@ -155,9 +149,11 @@ public class EasySwfPanel extends JPanel {
|
||||
undoManager.doOperation(new DoableOperation() {
|
||||
|
||||
private final List<Boolean> wasModified = new ArrayList<>();
|
||||
Timelined timelined = stagePanel.getTimelined();
|
||||
|
||||
@Override
|
||||
public void doOperation() {
|
||||
setTimelined(timelined);
|
||||
timelinePanel.setFrame(frame, depths);
|
||||
for (int i = 0; i < depths.size(); i++) {
|
||||
int depth = depths.get(i);
|
||||
@@ -170,7 +166,7 @@ public class EasySwfPanel extends JPanel {
|
||||
ds.placeObjectTag.setPlaceFlagHasMatrix(newMatrix != null);
|
||||
ds.placeObjectTag.setModified(true);
|
||||
}
|
||||
stagePanel.getTimelined().resetTimeline();
|
||||
timelined.resetTimeline();
|
||||
stagePanel.repaint();
|
||||
if (transformEnabled()) {
|
||||
stagePanel.freeTransformDepths(depths);
|
||||
@@ -184,6 +180,7 @@ public class EasySwfPanel extends JPanel {
|
||||
|
||||
@Override
|
||||
public void undoOperation() {
|
||||
setTimelined(timelined);
|
||||
timelinePanel.setFrame(frame, depths);
|
||||
for (int i = 0; i < depths.size(); i++) {
|
||||
int depth = depths.get(i);
|
||||
@@ -233,20 +230,16 @@ public class EasySwfPanel extends JPanel {
|
||||
|| (tag instanceof ButtonTag)
|
||||
) {
|
||||
|
||||
undoManager.doOperation(new TimelinedTagListDoableOperation(stagePanel.getTimelined()) {
|
||||
undoManager.doOperation(new TimelinedTagListDoableOperation(EasySwfPanel.this, stagePanel.getTimelined()) {
|
||||
|
||||
private List<Tag> swfTags;
|
||||
private final int fframe = stagePanel.getFrame();
|
||||
private final List<Integer> fdepths = stagePanel.getSelectedDepths();
|
||||
|
||||
|
||||
@Override
|
||||
public void doOperation() {
|
||||
super.doOperation();
|
||||
timelinePanel.setFrame(fframe, fdepths);
|
||||
CharacterTag ch = (CharacterTag) tag;
|
||||
int maxDepth = stagePanel.getTimelined().getTimeline().getMaxDepth();
|
||||
int maxDepth = timelined.getTimeline().getMaxDepth();
|
||||
int newDepth = maxDepth + 1;
|
||||
Timelined timelined = stagePanel.getTimelined();
|
||||
|
||||
if (timelined.getSwf() != timelined) {
|
||||
swfTags = timelined.getSwf().getTags().toArrayList();
|
||||
@@ -392,7 +385,7 @@ public class EasySwfPanel extends JPanel {
|
||||
topPanel.add(toolbarPanel, BorderLayout.NORTH);
|
||||
topPanel.add(stagePanel, BorderLayout.CENTER);
|
||||
|
||||
timelinePanel = new TimelinePanel(undoManager);
|
||||
timelinePanel = new TimelinePanel(this, undoManager);
|
||||
|
||||
timelinePanel.addChangeListener(new Runnable() {
|
||||
@Override
|
||||
@@ -533,6 +526,9 @@ public class EasySwfPanel extends JPanel {
|
||||
}
|
||||
|
||||
public void setTimelined(Timelined timelined) {
|
||||
if (this.timelined == timelined) {
|
||||
return;
|
||||
}
|
||||
this.timelined = timelined;
|
||||
if (timelined == null) {
|
||||
stagePanel.clearAll();
|
||||
@@ -644,4 +640,8 @@ public class EasySwfPanel extends JPanel {
|
||||
public Timelined getTimelined() {
|
||||
return timelined;
|
||||
}
|
||||
|
||||
public void setFrame(int frame, List<Integer> depths) {
|
||||
timelinePanel.setFrame(frame, depths);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
|
||||
private final List<Runnable> changeListeners = new ArrayList<>();
|
||||
|
||||
public Set<Point> cursor = new LinkedHashSet<>();
|
||||
private final EasySwfPanel swfPanel;
|
||||
|
||||
/*private int frame = 0;
|
||||
|
||||
@@ -198,11 +199,12 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
|
||||
}
|
||||
}
|
||||
|
||||
public TimelineBodyPanel(UndoManager undoManager) {
|
||||
public TimelineBodyPanel(EasySwfPanel swfPanel, UndoManager undoManager) {
|
||||
refresh();
|
||||
addMouseListener(this);
|
||||
addKeyListener(this);
|
||||
setFocusable(true);
|
||||
this.swfPanel = swfPanel;
|
||||
this.undoManager = undoManager;
|
||||
|
||||
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
@@ -688,7 +690,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
|
||||
private void removeFrame(ActionEvent e) {
|
||||
|
||||
Set<Point> orderedCursor = getBackOrderedCursor();
|
||||
undoManager.doOperation(new TimelinedTagListDoableOperation(timeline.timelined) {
|
||||
undoManager.doOperation(new TimelinedTagListDoableOperation(swfPanel, timeline.timelined) {
|
||||
|
||||
@Override
|
||||
public void doOperation() {
|
||||
@@ -834,7 +836,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
|
||||
|
||||
Set<Point> orderedCursor = getBackOrderedCursor();
|
||||
|
||||
undoManager.doOperation(new TimelinedTagListDoableOperation(timeline.timelined) {
|
||||
undoManager.doOperation(new TimelinedTagListDoableOperation(swfPanel, timeline.timelined) {
|
||||
|
||||
@Override
|
||||
public void doOperation() {
|
||||
@@ -900,9 +902,8 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
|
||||
}
|
||||
|
||||
private void addKeyFrameEmptyBefore(ActionEvent e) {
|
||||
final int fframe = getFirstFrame();
|
||||
final int fdepth = getFirstDepth();
|
||||
undoManager.doOperation(new TimelinedTagListDoableOperation(timeline.timelined) {
|
||||
undoManager.doOperation(new TimelinedTagListDoableOperation(swfPanel, timeline.timelined) {
|
||||
|
||||
@Override
|
||||
public void doOperation() {
|
||||
@@ -986,7 +987,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
|
||||
private void addFrame(ActionEvent e) {
|
||||
Set<Point> orderedCursor = getBackOrderedCursor();
|
||||
|
||||
undoManager.doOperation(new TimelinedTagListDoableOperation(timeline.timelined) {
|
||||
undoManager.doOperation(new TimelinedTagListDoableOperation(swfPanel, timeline.timelined) {
|
||||
@Override
|
||||
public void doOperation() {
|
||||
super.doOperation();
|
||||
|
||||
@@ -51,8 +51,8 @@ public class TimelinePanel extends JPanel {
|
||||
|
||||
private JScrollPane timelineBodyScrollPane;
|
||||
|
||||
public TimelinePanel(UndoManager undoManager) {
|
||||
timelineBodyPanel = new TimelineBodyPanel(undoManager);
|
||||
public TimelinePanel(EasySwfPanel swfPanel, UndoManager undoManager) {
|
||||
timelineBodyPanel = new TimelineBodyPanel(swfPanel, undoManager);
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
timelineBodyScrollPane = new FasterScrollPane(timelineBodyPanel);
|
||||
|
||||
@@ -27,16 +27,26 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class TimelinedTagListDoableOperation implements DoableOperation {
|
||||
|
||||
private final EasySwfPanel swfPanel;
|
||||
|
||||
private final Timelined timelined;
|
||||
protected List<Tag> tags;
|
||||
protected boolean wasModified = false;
|
||||
protected int fframe;
|
||||
protected List<Integer> fdepths;
|
||||
|
||||
public TimelinedTagListDoableOperation(Timelined timelined) {
|
||||
public TimelinedTagListDoableOperation(EasySwfPanel swfPanel, Timelined timelined) {
|
||||
this.swfPanel = swfPanel;
|
||||
this.timelined = timelined;
|
||||
this.fframe = swfPanel.getFrame();
|
||||
this.fdepths = swfPanel.getDepths();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doOperation() {
|
||||
swfPanel.setTimelined(timelined);
|
||||
swfPanel.setFrame(fframe, fdepths);
|
||||
|
||||
saveTagList();
|
||||
wasModified = timelined.isModified();
|
||||
timelined.setModified(true);
|
||||
@@ -46,7 +56,7 @@ public abstract class TimelinedTagListDoableOperation implements DoableOperation
|
||||
tags = timelined.getTags().toArrayList();
|
||||
}
|
||||
|
||||
protected void restoreTagList() {
|
||||
protected void restoreTagList() {
|
||||
if (tags != null) {
|
||||
ReadOnlyTagList newTags = timelined.getTags();
|
||||
int size = newTags.size();
|
||||
@@ -63,6 +73,8 @@ public abstract class TimelinedTagListDoableOperation implements DoableOperation
|
||||
|
||||
@Override
|
||||
public void undoOperation() {
|
||||
swfPanel.setTimelined(timelined);
|
||||
swfPanel.setFrame(fframe, fdepths);
|
||||
restoreTagList();
|
||||
if (!wasModified) {
|
||||
timelined.setModified(false);
|
||||
|
||||
Reference in New Issue
Block a user