From 3daf2d4169ca4edc6662d2600c8f9110ee1cfb73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 5 Oct 2024 17:40:44 +0200 Subject: [PATCH] Drawing actions fix. Frame index fix. --- .../flash/easygui/LibraryTreeTable.java | 4 ++-- .../decompiler/flash/easygui/MainFrame.java | 2 +- .../flash/easygui/TimelineBodyPanel.java | 21 +++++++++++++++---- .../flash/easygui/TimelinePanel.java | 2 -- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java b/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java index 09e8d6dcd..dcf920080 100644 --- a/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java +++ b/src/com/jpexs/decompiler/flash/easygui/LibraryTreeTable.java @@ -56,7 +56,7 @@ public class LibraryTreeTable extends JTreeTable { getTree().setShowsRootHandles(true); addKeyListener(new KeyAdapter() { @Override - public void keyPressed(KeyEvent e) { + public void keyPressed(KeyEvent e) { int selectedRow = getSelectedRow(); JTree tree = getTree(); @@ -67,7 +67,7 @@ public class LibraryTreeTable extends JTreeTable { int parentRow = tree.getRowForPath(path); changeSelection(parentRow, 0, false, false); - } else { + } else if (path != null) { TreePath parentPath = path.getParentPath(); if (parentPath != null) { int parentRow = tree.getRowForPath(parentPath); diff --git a/src/com/jpexs/decompiler/flash/easygui/MainFrame.java b/src/com/jpexs/decompiler/flash/easygui/MainFrame.java index f0af7bcb1..a1d056367 100644 --- a/src/com/jpexs/decompiler/flash/easygui/MainFrame.java +++ b/src/com/jpexs/decompiler/flash/easygui/MainFrame.java @@ -136,7 +136,7 @@ public class MainFrame extends JFrame { public void frameSelected(int frame, int depth) { stagePanel.selectDepth(depth); stagePanel.pause(); - stagePanel.gotoFrame(frame); + stagePanel.gotoFrame(frame + 1); } }); } diff --git a/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java b/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java index e8ebf60d2..9c2501847 100644 --- a/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/TimelineBodyPanel.java @@ -179,12 +179,23 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe g.fillRect(cursor.x * frameWidth + 1, cursor.y * frameHeight + 1, frameWidth - 1, frameHeight - 1); } - g.setColor(A_COLOR); - g.setFont(getFont().deriveFont(FONT_SIZE)); int awidth = g.getFontMetrics().stringWidth("a"); - for (int f = start_f; f <= end_f; f++) { + boolean firstAction = true; + for (int f = start_f; f <= end_f || (firstAction && f <= max_f); f++) { if (!timeline.getFrame(f).actions.isEmpty()) { - g.drawString("a", f * frameWidth + frameWidth / 2 - awidth / 2, frameHeight / 2 + FONT_SIZE / 2); + if (firstAction) { + drawBlock(g, getEmptyFrameColor(), 0, 0, f, BlockType.EMPTY); + } + + int f2 = f + 1; + while(f2 <= max_f && timeline.getFrame(f2).actions.isEmpty()) { + f2++; + } + drawBlock(g, getEmptyFrameColor(), 0, f, f2 - f, BlockType.EMPTY); + g.setColor(A_COLOR); + g.setFont(getFont().deriveFont(FONT_SIZE)); + g.drawString("a", f * frameWidth + frameWidth / 2 - awidth / 2, frameHeight / 2); + firstAction = false; } } @@ -340,6 +351,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe } repaint(); this.frame = frame; + scrollRectToVisible(getFrameBounds(frame, depth)); } @Override @@ -355,6 +367,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe p.y = maxDepth; } frameSelect(p.x, p.y); + requestFocusInWindow(); } @Override diff --git a/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java b/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java index 7aff535a7..f300ab3d7 100644 --- a/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java @@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.timeline.Timelined; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; -import java.awt.Rectangle; import java.awt.SystemColor; import java.awt.event.AdjustmentEvent; import java.awt.event.AdjustmentListener; @@ -68,7 +67,6 @@ public class TimelinePanel extends JPanel { public void setDepth(int depth) { timelineBodyPanel.depthSelect(depth); - timelineBodyPanel.scrollRectToVisible(timelineBodyPanel.getDepthBounds(depth)); } public void setTimelined(Timelined timelined) {