Drawing actions fix.

Frame index fix.
This commit is contained in:
Jindra Petřík
2024-10-05 17:40:44 +02:00
parent 7b2268adf3
commit 3daf2d4169
4 changed files with 20 additions and 9 deletions

View File

@@ -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);

View File

@@ -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);
}
});
}

View File

@@ -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

View File

@@ -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) {