From 2b0bd289504dbd02a1d07043f200faf2fd562bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 6 Oct 2024 16:31:17 +0200 Subject: [PATCH] Clicking outside deselects object. Timeline time offset fix. --- .../flash/easygui/TimelinePanel.java | 2 ++ .../flash/easygui/TimelineTimePanel.java | 19 ++++++++++++++++--- .../decompiler/flash/gui/ImagePanel.java | 12 +++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java b/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java index 14745ab2a..e97c39962 100644 --- a/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/TimelinePanel.java @@ -63,6 +63,7 @@ public class TimelinePanel extends JPanel { public void run() { timeline = timelined.getTimeline(); depthPanel.setTimeline(timeline); + timePanel.setTimeline(timeline); } }); @@ -159,5 +160,6 @@ public class TimelinePanel extends JPanel { this.timelined = timelined; timelineBodyPanel.setTimeline(timelined.getTimeline()); depthPanel.setTimeline(timelined.getTimeline()); + timePanel.setTimeline(timelined.getTimeline()); } } diff --git a/src/com/jpexs/decompiler/flash/easygui/TimelineTimePanel.java b/src/com/jpexs/decompiler/flash/easygui/TimelineTimePanel.java index 12c0d18f4..302e48c03 100644 --- a/src/com/jpexs/decompiler/flash/easygui/TimelineTimePanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/TimelineTimePanel.java @@ -16,6 +16,9 @@ */ package com.jpexs.decompiler.flash.easygui; +import static com.jpexs.decompiler.flash.easygui.TimelineDepthPanel.FONT_SIZE; +import static com.jpexs.decompiler.flash.easygui.TimelineDepthPanel.PADDING; +import com.jpexs.decompiler.flash.timeline.Timeline; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; @@ -44,8 +47,9 @@ public class TimelineTimePanel extends JPanel implements MouseListener { private int scrollOffset = 0; private int selectedFrame = -1; + private int leftPos = 0; - private final List listeners = new ArrayList<>(); + private final List listeners = new ArrayList<>(); public TimelineTimePanel() { Dimension dim = new Dimension(Integer.MAX_VALUE, TimelineBodyPanel.FRAME_HEIGHT); @@ -54,6 +58,15 @@ public class TimelineTimePanel extends JPanel implements MouseListener { addMouseListener(this); } + public void setTimeline(Timeline timeline) { + int maxDepth = timeline == null ? 0 : timeline.getMaxDepth(); + String maxDepthStr = Integer.toString(maxDepth); + setFont(getFont().deriveFont(FONT_SIZE)); + int maxDepthW = getFontMetrics(getFont()).stringWidth(maxDepthStr); + leftPos = maxDepthW + 2 * PADDING; + } + + public void addFrameSelectionListener(FrameSelectionListener l) { listeners.add(l); } @@ -86,7 +99,7 @@ public class TimelineTimePanel extends JPanel implements MouseListener { g.setColor(TimelineBodyPanel.getBackgroundColor()); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(borderColor); - int xofs = TimelineBodyPanel.FRAME_WIDTH - scrollOffset % TimelineBodyPanel.FRAME_WIDTH - 1; + int xofs = leftPos - TimelineBodyPanel.FRAME_WIDTH - scrollOffset % TimelineBodyPanel.FRAME_WIDTH; for (int f = 0; f <= end_f; f++) { g.drawLine(xofs + f * TimelineBodyPanel.FRAME_WIDTH + 1, TimelineBodyPanel.FRAME_HEIGHT - 1, xofs + f * TimelineBodyPanel.FRAME_WIDTH + 1, TimelineBodyPanel.FRAME_HEIGHT - lineLength); } @@ -103,7 +116,7 @@ public class TimelineTimePanel extends JPanel implements MouseListener { if ((cur_f + 1) % 5 == 0 || cur_f == 0) { String timeStr = Integer.toString(cur_f + 1); int w = g.getFontMetrics().stringWidth(timeStr); - g.drawString(timeStr, xofs + (f - 1) * TimelineBodyPanel.FRAME_WIDTH + TimelineBodyPanel.FRAME_WIDTH / 2 - w / 2, TimelineBodyPanel.FRAME_HEIGHT - lineLength - lineTextSpace); + g.drawString(timeStr, xofs + (f - 1) * TimelineBodyPanel.FRAME_WIDTH + TimelineBodyPanel.FRAME_WIDTH / 2 - w / 2 + 1, TimelineBodyPanel.FRAME_HEIGHT - lineLength - lineTextSpace); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 368b84d04..f88473e87 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -1148,10 +1148,20 @@ public final class ImagePanel extends JPanel implements MediaDisplay { freeTransformDepth(depthStateUnderCursor.depth); firePlaceObjectSelected(); } - } else if (selectionMode) { + } else if ((altDown && !selectionMode) || selectionMode){ selectDepth(depthStateUnderCursor.depth); firePlaceObjectSelected(); } + } else { + if (transformSelectionMode) { + if (mode == Cursor.DEFAULT_CURSOR) { + freeTransformDepth(-1); + firePlaceObjectSelected(); + } + } else if ((altDown && !selectionMode) || selectionMode) { + selectDepth(-1); + firePlaceObjectSelected(); + } } if (!selectionMode) { return;