From 27b786d2889a79bf5352661338621240399bc224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Wed, 14 May 2025 23:19:20 +0200 Subject: [PATCH] Added: Enable/disable filters --- .../decompiler/flash/timeline/Timeline.java | 9 +++++ .../flash/types/filters/FILTER.java | 7 ++++ .../flash/easygui/FiltersTreeTable.java | 9 +++++ .../panels/InstancePropertiesPanel.java | 33 ++++++++++++------ .../decompiler/flash/gui/graphics/cross16.png | Bin 0 -> 473 bytes .../flash/gui/locales/EasyPanel.properties | 2 ++ 6 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/cross16.png diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index 1a9808108..3ed364823 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -1084,6 +1084,9 @@ public class Timeline { if (filters != null && filters.size() > 0) { // calculate size after applying the filters for (FILTER filter : filters) { + if (!filter.enabled) { + continue; + } double x = filter.getDeltaX(); double y = filter.getDeltaY(); deltaXMax += x; @@ -1204,6 +1207,9 @@ public class Timeline { if (filters != null) { for (FILTER filter : filters) { + if (!filter.enabled) { + continue; + } img = filter.apply(img, unzoom, 0, 0, newWidth, newHeight); } } @@ -1703,6 +1709,9 @@ public class Timeline { */ public void getSounds(int frame, int time, ButtonTag mouseOverButton, int mouseButton, List sounds, List soundClasses, List soundInfos) { Frame fr = getFrame(frame); + if (fr == null) { + return; + } if (time == 0) { sounds.addAll(fr.sounds); soundClasses.addAll(fr.soundClasses); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/FILTER.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/FILTER.java index 76d62fb92..348592be5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/FILTER.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/FILTER.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.types.filters; import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.RGBA; +import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.helpers.ConcreteClasses; import com.jpexs.helpers.SerializableImage; @@ -42,6 +43,12 @@ public abstract class FILTER implements Serializable { @SWFType(BasicType.UI8) public int id; + /** + * FILTER is enabled. Used internally by Simple editor GUI. Not a real SWF field. + */ + @Internal + public boolean enabled = true; + /** * Constructor * diff --git a/src/com/jpexs/decompiler/flash/easygui/FiltersTreeTable.java b/src/com/jpexs/decompiler/flash/easygui/FiltersTreeTable.java index 8da1f7e16..0d889aa28 100644 --- a/src/com/jpexs/decompiler/flash/easygui/FiltersTreeTable.java +++ b/src/com/jpexs/decompiler/flash/easygui/FiltersTreeTable.java @@ -804,6 +804,12 @@ public class FiltersTreeTable extends JTreeTable { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; Object object = node.getUserObject(); label.setText(object.toString()); + if (object instanceof FilterName) { + FilterName filterName = (FilterName) object; + if (!filterName.filter.enabled) { + label.setIcon(View.getIcon("cross16")); + } + } } if (View.isOceanic()) { if (selected) { @@ -1003,6 +1009,9 @@ public class FiltersTreeTable extends JTreeTable { if ("id".equals(field.getName())) { continue; } + if ("enabled".equals(field.getName())) { + continue; + } if ("gradientRatio".equals(field.getName())) { continue; } diff --git a/src/com/jpexs/decompiler/flash/easygui/properties/panels/InstancePropertiesPanel.java b/src/com/jpexs/decompiler/flash/easygui/properties/panels/InstancePropertiesPanel.java index 3e3bb9e70..9faef5ad0 100644 --- a/src/com/jpexs/decompiler/flash/easygui/properties/panels/InstancePropertiesPanel.java +++ b/src/com/jpexs/decompiler/flash/easygui/properties/panels/InstancePropertiesPanel.java @@ -433,16 +433,7 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { filtersTable.removeSelectedFilter(); } }); - removeFilterButton.setToolTipText(EasyStrings.translate("property.instance.filters.menu.remove")); - - - filtersTable.getTree().addTreeSelectionListener(new TreeSelectionListener() { - @Override - public void valueChanged(TreeSelectionEvent e) { - removeFilterButton.setEnabled(filtersTable.isFilterSelected()); - } - }); - + removeFilterButton.setToolTipText(EasyStrings.translate("property.instance.filters.menu.remove")); PopupButton clipboardFilterButton = new PopupButton(View.getIcon("clipboard16")) { @Override protected JPopupMenu getPopupMenu() { @@ -491,10 +482,32 @@ public class InstancePropertiesPanel extends AbstractPropertiesPanel { } }; + JButton enableFilterButton = new JButton(View.getIcon("show16")); + enableFilterButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FILTER filter = filtersTable.getSelectedFilter(); + filter.enabled = !filter.enabled; + filtersTable.fireFilterChanged(); + filtersTable.repaint(); + } + }); + enableFilterButton.setToolTipText(EasyStrings.translate("property.instance.filters.menu.enable")); + + filtersTable.getTree().addTreeSelectionListener(new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent e) { + boolean filterSelected = filtersTable.isFilterSelected(); + removeFilterButton.setEnabled(filterSelected); + enableFilterButton.setEnabled(filterSelected); + } + }); + filtersToolbar.add(addFilterButton); filtersToolbar.add(removeFilterButton); filtersToolbar.add(clipboardFilterButton); + filtersToolbar.add(enableFilterButton); JScrollPane sp = new JScrollPane(filtersTable); filtersPanel.add(sp, BorderLayout.CENTER); diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/cross16.png b/src/com/jpexs/decompiler/flash/gui/graphics/cross16.png new file mode 100644 index 0000000000000000000000000000000000000000..33a383748bca465d6d0e7be4fa2ce83c861e36ba GIT binary patch literal 473 zcmV;~0Ve*5P)1Bai@#8xK6ALSt`Ds!U zgJE$w!x4r~upuBeNDL+qQVRo&AX69_8I6G^o-xSIWB9ggCR~y$DjiIti(QyHiNWT; z1rwm&voHfda$rLYlhYZ#Z(52q5IOy#8P3n03Dykco(1bgG5}#nY&^ryJ)2N8v%B~) zoL{^Ut{E1HENGU1B^ZDHMEDoxSD+ZO8uT!Lhqh5*5X0XKC$V~g*}$CP-1>DOS1`g{ z05<@n+1SUM;or?Ga1BiAI$#=I?Ch4UU_;fHo8W8^o&;cN2@GxNd{hQ%GD^#sypjxcyz{1W3 zEO_G35tPt|#SXeWC><~$WhP^!%wmis3^C+UG80S@4$WBQ;juso00=MutP2U)_A3w6 P00000NkvXXu0mjf8D7L! literal 0 HcmV?d00001 diff --git a/src/com/jpexs/decompiler/flash/gui/locales/EasyPanel.properties b/src/com/jpexs/decompiler/flash/gui/locales/EasyPanel.properties index c1fdf2cac..718262e8a 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/EasyPanel.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/EasyPanel.properties @@ -189,3 +189,5 @@ property.instance.filters.preserveAlpha = preserve alpha property.instance.filters.matrix = matrix property.instance.filters.glowColor = glow color property.instance.filters.innerGlow = inner glow + +property.instance.filters.menu.enable = Enable or disable filter \ No newline at end of file