diff --git a/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java b/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java index 33db2c7d1..6e560ef05 100644 --- a/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/EasySwfPanel.java @@ -129,12 +129,6 @@ public class EasySwfPanel extends JPanel { final List 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 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 swfTags; - private final int fframe = stagePanel.getFrame(); - private final List 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 depths) { + timelinePanel.setFrame(frame, depths); + } } diff --git a/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java b/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java index 5d320a7c4..68f429340 100644 --- a/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java @@ -110,6 +110,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe private final List changeListeners = new ArrayList<>(); public Set 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 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 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 orderedCursor = getBackOrderedCursor(); - undoManager.doOperation(new TimelinedTagListDoableOperation(timeline.timelined) { + undoManager.doOperation(new TimelinedTagListDoableOperation(swfPanel, timeline.timelined) { @Override public void doOperation() { super.doOperation(); diff --git a/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java b/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java index f7f8e2424..3988619ec 100644 --- a/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java @@ -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); diff --git a/src/com/jpexs/decompiler/flash/easygui/TimelinedTagListDoableOperation.java b/src/com/jpexs/decompiler/flash/easygui/TimelinedTagListDoableOperation.java index af21403c5..531b55ccb 100644 --- a/src/com/jpexs/decompiler/flash/easygui/TimelinedTagListDoableOperation.java +++ b/src/com/jpexs/decompiler/flash/easygui/TimelinedTagListDoableOperation.java @@ -27,16 +27,26 @@ import java.util.List; */ public abstract class TimelinedTagListDoableOperation implements DoableOperation { + private final EasySwfPanel swfPanel; + private final Timelined timelined; protected List tags; protected boolean wasModified = false; + protected int fframe; + protected List 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);