diff --git a/src/com/jpexs/decompiler/flash/gui/ClipboardPanel.java b/src/com/jpexs/decompiler/flash/gui/ClipboardPanel.java new file mode 100644 index 000000000..e905fc54f --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/ClipboardPanel.java @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2022 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui; + +import com.jpexs.decompiler.flash.configuration.Configuration; +import java.awt.BasicStroke; +import java.awt.BorderLayout; +import java.awt.Cursor; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.SystemColor; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.geom.GeneralPath; +import java.util.EnumSet; +import java.util.Set; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import javax.swing.plaf.basic.BasicScrollPaneUI; +import org.pushingpixels.substance.api.ColorSchemeAssociationKind; +import org.pushingpixels.substance.api.ComponentState; +import org.pushingpixels.substance.api.DecorationAreaType; +import org.pushingpixels.substance.api.SubstanceColorScheme; +import org.pushingpixels.substance.api.SubstanceConstants; +import org.pushingpixels.substance.api.SubstanceLookAndFeel; +import org.pushingpixels.substance.api.SubstanceSkin; +import org.pushingpixels.substance.api.painter.border.StandardBorderPainter; +import org.pushingpixels.substance.internal.painter.SimplisticSoftBorderPainter; +import org.pushingpixels.substance.internal.utils.SubstanceColorSchemeUtilities; +import org.pushingpixels.substance.internal.utils.SubstanceOutlineUtilities; +import org.pushingpixels.substance.internal.utils.SubstanceSizeUtils; + +/** + * + * @author JPEXS + */ +public class ClipboardPanel extends JPanel { + + private JLabel label; + + private MainPanel mainPanel; + + public ClipboardPanel(MainPanel mainPanel) { + this.mainPanel = mainPanel; + label = new JLabel("", View.getIcon("clipboard16"), JLabel.CENTER); + label.setToolTipText(AppStrings.translate("clipboard.hint")); + label.setBorder(new EmptyBorder(0, 0, 0, 10)); + int scrollBarSize = ((Integer) UIManager.get("ScrollBar.width")).intValue(); + setBorder(new EmptyBorder(0, 0, 0, scrollBarSize)); + setLayout(new FlowLayout(FlowLayout.RIGHT)); + + JLabel clearButton = new JLabel(View.getIcon("cancel16")); + clearButton.setToolTipText(AppStrings.translate("clipboard.clear")); + clearButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + clearButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + mainPanel.emptyClipboard(); + } + }); + add(label); + add(clearButton); + setBackground(mainPanel.tagTree.getBackground()); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + + JComponent c = mainPanel.tagTreeScrollPanel; + + if (Configuration.useRibbonInterface.get()) { + StandardBorderPainter painter = new SimplisticSoftBorderPainter(); + + SubstanceColorScheme scheme = SubstanceColorSchemeUtilities + .getColorScheme(c, ColorSchemeAssociationKind.BORDER, c + .isEnabled() ? ComponentState.ENABLED + : ComponentState.DISABLED_UNSELECTED); + + float borderStrokeWidth = SubstanceSizeUtils + .getBorderStrokeWidth(SubstanceSizeUtils + .getComponentFontSize(c)); + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setStroke(new BasicStroke(borderStrokeWidth, + BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER)); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + int width = getWidth(); + int height = getHeight(); + + int x = 0; + int y = 0; + + //top + g2d.setColor(painter.getTopBorderColor(scheme)); + g2d.drawLine(x, y, x + width, y); + + // left portion + g2d.setColor(painter.getBottomBorderColor(scheme)); + g2d.drawLine(x, y, x, y + height - 1); + + // right portion + g2d.setColor(painter.getTopBorderColor(scheme)); + g2d.drawLine(x + width - 1, y, x + width - 1, y + height); + } + + } + + public void update() { + int clipboardSize = mainPanel.getClipboardSize(); + if (clipboardSize == 1) { + label.setText(AppStrings.translate("clipboard.item")); + } else { + label.setText(AppStrings.translate("clipboard.items").replace("%count%", "" + clipboardSize)); + } + setVisible(clipboardSize > 0); + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 9356b1ed1..6b443658a 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -188,10 +188,12 @@ import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; import java.awt.Container; +import java.awt.Cursor; import java.awt.Desktop; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; +import java.awt.Graphics; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; @@ -246,9 +248,12 @@ import javax.swing.Icon; import javax.swing.JColorChooser; import javax.swing.JFileChooser; import javax.swing.JLabel; +import javax.swing.JLayeredPane; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JProgressBar; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTabbedPane; import javax.swing.JTextField; @@ -260,6 +265,7 @@ import javax.swing.event.DocumentListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.filechooser.FileFilter; +import javax.swing.plaf.basic.BasicScrollPaneUI; import javax.swing.plaf.basic.BasicTreeUI; import javax.swing.tree.DefaultTreeSelectionModel; import javax.swing.tree.TreePath; @@ -289,10 +295,17 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se private final JProgressBar progressBar = new JProgressBar(0, 100); public TagTree tagTree; + + public FasterScrollPane tagTreeScrollPanel; - public DumpTree dumpTree; + public DumpTree dumpTree; public TagListTree tagListTree; + + private ClipboardPanel resourcesClipboardPanel; + private ClipboardPanel tagListClipboardPanel; + + private final FlashPlayerPanel flashPanel; @@ -398,6 +411,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } } } + resourcesClipboardPanel.update(); + tagListClipboardPanel.update(); } public void emptyClipboard() { @@ -412,6 +427,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se clipboard.put(item, true); } clipboardCut = false; + resourcesClipboardPanel.update(); + tagListClipboardPanel.update(); } public void cutToClipboard(Collection items) { @@ -426,7 +443,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public boolean clipboardEmpty() { return clipboard.isEmpty(); } - + + public int getClipboardSize() { + return clipboard.size(); + } + public Set getClipboardContents() { Set ret = new LinkedHashSet<>(); for (WeakReference ref : orderedClipboard) { @@ -812,6 +833,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se closeTagTreeSearch(); } }); + closeSearchButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); searchPanel.add(closeSearchButton, BorderLayout.EAST); searchPanel.setVisible(false); @@ -3875,14 +3897,19 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } private JPanel createTagListViewCard() { - JPanel r = new JPanel(new BorderLayout()); + tagListClipboardPanel = new ClipboardPanel(this); + + JPanel r = new JPanel(new BorderLayout()); + r.add(tagListClipboardPanel, BorderLayout.NORTH); r.add(new FasterScrollPane(tagListTree), BorderLayout.CENTER); return r; } private JPanel createResourcesViewCard() { - JPanel r = new JPanel(new BorderLayout()); - r.add(new FasterScrollPane(tagTree), BorderLayout.CENTER); + resourcesClipboardPanel = new ClipboardPanel(this); + JPanel r = new JPanel(new BorderLayout()); + r.add(resourcesClipboardPanel, BorderLayout.NORTH); + r.add(tagTreeScrollPanel = new FasterScrollPane(tagTree), BorderLayout.CENTER); r.add(searchPanel, BorderLayout.SOUTH); return r; } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 143b433b1..5d997e893 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -937,4 +937,9 @@ work.importing = Importing import.finishedin = Imported in %time% error.import = Error during import -import.image.result = %count% images imported. \ No newline at end of file +import.image.result = %count% images imported. + +clipboard.hint = Number of items in the tag clipboard +clipboard.item = 1 item +clipboard.items = %count% items +clipboard.clear = Clear the tag clipboard \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties index f8b5e078e..a74ee636e 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties @@ -909,4 +909,9 @@ work.importing = Importov\u00e1n\u00ed import.finishedin = Importov\u00e1no za %time% error.import = Chyba b\u011bhem importu -import.image.result = %count% obr\u00e1zk\u016f importov\u00e1no. \ No newline at end of file +import.image.result = %count% obr\u00e1zk\u016f importov\u00e1no. + +clipboard.hint = Po\u010det polo\u017eek v tagov\u00e9 schr\u00e1nce +clipboard.item = 1 polo\u017eka +clipboard.items = %count% polo\u017eek +clipboard.clear = Vy\u010distit tagovou schr\u00e1nku \ No newline at end of file