mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-08 11:58:15 +00:00
Added: Simple editor - change background color
This commit is contained in:
@@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.
|
||||
- [#2453] SVG export/import - use image-rendering attribute for image smoothing
|
||||
- Option to enter custom zoom level by clicking on zoom percentage label
|
||||
- Show in Simple editor context menu item for timelined items (sprites, buttons, swfs)
|
||||
- Simple editor - change background color
|
||||
|
||||
### Fixed
|
||||
- [#2424] DefineEditText handling of letterSpacing, font size on incorrect values
|
||||
|
||||
@@ -23,9 +23,13 @@ import com.jpexs.decompiler.flash.easygui.EasyStrings;
|
||||
import com.jpexs.decompiler.flash.easygui.UndoManager;
|
||||
import com.jpexs.decompiler.flash.easygui.properties.FloatPropertyField;
|
||||
import com.jpexs.decompiler.flash.easygui.properties.IntegerPropertyField;
|
||||
import com.jpexs.decompiler.flash.easygui.properties.PropertyChangeDoableOperation;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.gui.ColorSelectionButton;
|
||||
import com.jpexs.decompiler.flash.gui.ComboBoxItem;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag;
|
||||
import com.jpexs.decompiler.flash.types.RGB;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
@@ -50,8 +54,6 @@ import javax.swing.event.ChangeEvent;
|
||||
*/
|
||||
public class DocumentPropertiesPanel extends AbstractPropertiesPanel {
|
||||
|
||||
private final JLabel displayRectPixelsLabel = new JLabel();
|
||||
|
||||
private final JPanel compressionEditorPanel = new JPanel();
|
||||
|
||||
private final JComboBox<ComboBoxItem<SWFCompression>> compressionComboBox = new JComboBox<>();
|
||||
@@ -76,6 +78,8 @@ public class DocumentPropertiesPanel extends AbstractPropertiesPanel {
|
||||
|
||||
private final IntegerPropertyField heightEditor = new IntegerPropertyField(400, 1, 8192);
|
||||
|
||||
private final ColorSelectionButton colorSelectionButton;
|
||||
|
||||
private final JPanel warningPanel = new JPanel();
|
||||
|
||||
private final JLabel warningLabel = new JLabel();
|
||||
@@ -132,6 +136,8 @@ public class DocumentPropertiesPanel extends AbstractPropertiesPanel {
|
||||
displayRectEditorPanel.add(new JLabel("\u00D7 "));
|
||||
displayRectEditorPanel.add(heightEditor);
|
||||
displayRectEditorPanel.add(new JLabel(" px"));
|
||||
|
||||
colorSelectionButton = new ColorSelectionButton(Color.white, null);
|
||||
|
||||
warningLabel.setIcon(View.getIcon("warning16"));
|
||||
warningPanel.setLayout(layout);
|
||||
@@ -141,25 +147,35 @@ public class DocumentPropertiesPanel extends AbstractPropertiesPanel {
|
||||
GridBagLayout gridBag = new GridBagLayout();
|
||||
propertiesPanel.setLayout(gridBag);
|
||||
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.compression")), 0, 1);
|
||||
addToGrid(gridBag, propertiesPanel, compressionEditorPanel, 1, 1);
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.version")), 0, 2);
|
||||
addToGrid(gridBag, propertiesPanel, versionEditorPanel, 1, 2);
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.encrypted")), 0, 3);
|
||||
addToGrid(gridBag, propertiesPanel, encryptedCheckBox, 1, 3);
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.gfx")), 0, 4);
|
||||
addToGrid(gridBag, propertiesPanel, gfxCheckBox, 1, 4);
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.framerate")), 0, 6);
|
||||
addToGrid(gridBag, propertiesPanel, frameRateEditorPanel, 1, 6);
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.displayrect")), 0, 7);
|
||||
addToGrid(gridBag, propertiesPanel, displayRectEditorPanel, 1, 7);
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(""), 0, 8);
|
||||
addToGrid(gridBag, propertiesPanel, displayRectPixelsLabel, 1, 8);
|
||||
addToGrid(gridBag, propertiesPanel, warningPanel, 0, 9, 2, 1);
|
||||
int y = 0;
|
||||
y++;
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.compression")), 0, y);
|
||||
addToGrid(gridBag, propertiesPanel, compressionEditorPanel, 1, y);
|
||||
y++;
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.version")), 0, y);
|
||||
addToGrid(gridBag, propertiesPanel, versionEditorPanel, 1, y);
|
||||
y++;
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.encrypted")), 0, y);
|
||||
addToGrid(gridBag, propertiesPanel, encryptedCheckBox, 1, y);
|
||||
y++;
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.gfx")), 0, y);
|
||||
addToGrid(gridBag, propertiesPanel, gfxCheckBox, 1, y);
|
||||
y++;
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.framerate")), 0, y);
|
||||
addToGrid(gridBag, propertiesPanel, frameRateEditorPanel, 1, y);
|
||||
y++;
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(AppStrings.translate("header.displayrect")), 0, y);
|
||||
addToGrid(gridBag, propertiesPanel, displayRectEditorPanel, 1, y);
|
||||
y++;
|
||||
addToGrid(gridBag, propertiesPanel, new JLabel(EasyStrings.translate("property.label").replace("%item%", EasyStrings.translate("property.document.backgroundColor"))), 0, y);
|
||||
addToGrid(gridBag, propertiesPanel, colorSelectionButton, 1, y);
|
||||
y++;
|
||||
addToGrid(gridBag, propertiesPanel, warningPanel, 0, y, 2, 1);
|
||||
|
||||
y++;
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 10;
|
||||
gbc.gridy = y;
|
||||
gbc.gridwidth = 3;
|
||||
gbc.weighty = 1;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
@@ -168,7 +184,7 @@ public class DocumentPropertiesPanel extends AbstractPropertiesPanel {
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 2;
|
||||
gbc.gridy = 0;
|
||||
gbc.gridheight = 10;
|
||||
gbc.gridheight = y;
|
||||
gbc.weightx = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
propertiesPanel.add(new JPanel(), gbc);
|
||||
@@ -327,6 +343,48 @@ public class DocumentPropertiesPanel extends AbstractPropertiesPanel {
|
||||
}
|
||||
}, swf);
|
||||
});
|
||||
|
||||
colorSelectionButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
SetBackgroundColorTag backgroundColorTag = swf.getBackgroundColor();
|
||||
if (backgroundColorTag == null) {
|
||||
return; //???
|
||||
}
|
||||
|
||||
undoManager.doOperation(new PropertyChangeDoableOperation("document.backgroundColor") {
|
||||
final RGB prevColor = backgroundColorTag.backgroundColor;
|
||||
final RGB newColor = new RGB(colorSelectionButton.getValue());
|
||||
final boolean prevModified = backgroundColorTag.isModified();
|
||||
|
||||
@Override
|
||||
public void doOperation() {
|
||||
modifying = true;
|
||||
SetBackgroundColorTag backgroundColorTag = swf.getBackgroundColor();
|
||||
if (backgroundColorTag == null) {
|
||||
return;
|
||||
}
|
||||
backgroundColorTag.backgroundColor = newColor;
|
||||
backgroundColorTag.setModified(true);
|
||||
swf.resetTimeline();
|
||||
refresh();
|
||||
modifying = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undoOperation() {
|
||||
SetBackgroundColorTag backgroundColorTag = swf.getBackgroundColor();
|
||||
if (backgroundColorTag == null) {
|
||||
return;
|
||||
}
|
||||
backgroundColorTag.backgroundColor = prevColor;
|
||||
backgroundColorTag.setModified(prevModified);
|
||||
swf.resetTimeline();
|
||||
refresh();
|
||||
}
|
||||
}, swf);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -401,6 +459,12 @@ public class DocumentPropertiesPanel extends AbstractPropertiesPanel {
|
||||
widthEditor.setValue(swf.displayRect.getWidth() / 20);
|
||||
heightEditor.setValue(swf.displayRect.getHeight() / 20);
|
||||
|
||||
SetBackgroundColorTag backgroundColorTag = swf.getBackgroundColor();
|
||||
|
||||
if (backgroundColorTag != null) {
|
||||
colorSelectionButton.setValue(backgroundColorTag.backgroundColor.toColor());
|
||||
}
|
||||
|
||||
modifying = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -415,7 +415,7 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
}
|
||||
}
|
||||
if (itemType == Color.class) {
|
||||
defaultValue = ConfigurationColorSelection.colorToHex((Color) defaultValue);
|
||||
defaultValue = ColorSelectionButton.colorToHex((Color) defaultValue);
|
||||
}
|
||||
String locNameHtml = locName;
|
||||
if (!filter.trim().equals("")) {
|
||||
@@ -492,7 +492,7 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
cb.setToolTipText(description);
|
||||
c = cb;
|
||||
} else if (itemType == Color.class) {
|
||||
ConfigurationColorSelection cb = new ConfigurationColorSelection(item, (Color) item.get(), description);
|
||||
ColorSelectionButton cb = new ColorSelectionButton((Color) item.get(), description);
|
||||
|
||||
cb.setMaximumSize(new Dimension(Integer.MAX_VALUE, cb.getPreferredSize().height));
|
||||
c = cb;
|
||||
@@ -618,7 +618,7 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
value = ((JCheckBox) c).isSelected();
|
||||
}
|
||||
if (itemType == Color.class) {
|
||||
value = ((ConfigurationColorSelection) c).getValue();
|
||||
value = ((ColorSelectionButton) c).getValue();
|
||||
}
|
||||
|
||||
if (itemType == Calendar.class) {
|
||||
|
||||
@@ -32,16 +32,17 @@ import javax.swing.border.BevelBorder;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ConfigurationColorSelection extends FocusablePanel {
|
||||
public class ColorSelectionButton extends FocusablePanel {
|
||||
private JPanel colorPanel;
|
||||
private JLabel colorLabel;
|
||||
|
||||
public ConfigurationColorSelection(ConfigurationItem item, Color value, String description) {
|
||||
public ColorSelectionButton(Color value, String description) {
|
||||
setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
colorPanel = new JPanel();
|
||||
setToolTipText(description);
|
||||
colorPanel.setSize(16, 16);
|
||||
colorPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
|
||||
JLabel colorLabel = new JLabel();
|
||||
colorLabel = new JLabel();
|
||||
colorPanel.setBackground(value);
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@@ -75,24 +76,17 @@ public class ConfigurationColorSelection extends FocusablePanel {
|
||||
add(colorLabel);
|
||||
}
|
||||
|
||||
public static String colorToHex(Color value) {
|
||||
String rh = Integer.toHexString(value.getRed());
|
||||
if (rh.length() < 2) {
|
||||
rh = "0" + rh;
|
||||
}
|
||||
String gh = Integer.toHexString(value.getGreen());
|
||||
if (gh.length() < 2) {
|
||||
gh = "0" + gh;
|
||||
}
|
||||
String bh = Integer.toHexString(value.getBlue());
|
||||
if (bh.length() < 2) {
|
||||
bh = "0" + bh;
|
||||
}
|
||||
return "#" + rh + gh + bh;
|
||||
public static String colorToHex(Color color) {
|
||||
return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
|
||||
}
|
||||
|
||||
public Color getValue() {
|
||||
return colorPanel.getBackground();
|
||||
}
|
||||
|
||||
public void setValue(Color color) {
|
||||
colorLabel.setText(colorToHex(color));
|
||||
colorPanel.setBackground(color);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,7 +42,7 @@ import javax.swing.JTextField;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class GridDialog extends AppDialog {
|
||||
private final ConfigurationColorSelection colorSelection;
|
||||
private final ColorSelectionButton colorSelection;
|
||||
private final JCheckBox showGridCheckBox;
|
||||
private final JCheckBox snapToGridCheckBox;
|
||||
private final JCheckBox showOverObjectsCheckBox;
|
||||
@@ -68,7 +68,7 @@ public class GridDialog extends AppDialog {
|
||||
|
||||
centralPanel.add(colorLabel, c);
|
||||
|
||||
colorSelection = new ConfigurationColorSelection(Configuration.gridColor, Configuration.gridColor.get(), null);
|
||||
colorSelection = new ColorSelectionButton(Configuration.gridColor.get(), null);
|
||||
colorLabel.setLabelFor(colorSelection);
|
||||
c.gridx = 1;
|
||||
c.anchor = GridBagConstraints.LINE_START;
|
||||
|
||||
@@ -42,7 +42,7 @@ import javax.swing.JPanel;
|
||||
*/
|
||||
public class GuidesDialog extends AppDialog {
|
||||
|
||||
private final ConfigurationColorSelection colorSelection;
|
||||
private final ColorSelectionButton colorSelection;
|
||||
private final JCheckBox showGuidesCheckBox;
|
||||
private final JCheckBox snapToGuidesCheckBox;
|
||||
private final JCheckBox lockGuidesCheckBox;
|
||||
@@ -68,7 +68,7 @@ public class GuidesDialog extends AppDialog {
|
||||
|
||||
centralPanel.add(colorLabel, c);
|
||||
|
||||
colorSelection = new ConfigurationColorSelection(Configuration.guidesColor, Configuration.guidesColor.get(), null);
|
||||
colorSelection = new ColorSelectionButton(Configuration.guidesColor.get(), null);
|
||||
colorLabel.setLabelFor(colorSelection);
|
||||
c.gridx = 1;
|
||||
c.anchor = GridBagConstraints.LINE_START;
|
||||
|
||||
@@ -115,3 +115,6 @@ property.instance.display.blending.hardlight = Hardlight
|
||||
property.instance.display.cacheAsBitmap = Cache as bitmap
|
||||
property.instance.display.cacheAsBitmap.transparent = Transparent
|
||||
property.instance.display.cacheAsBitmap.opaque = Opaque
|
||||
|
||||
#after 22.0.2
|
||||
property.document.backgroundColor = Background color
|
||||
@@ -115,3 +115,6 @@ property.instance.display.blending.hardlight = Hardlight
|
||||
property.instance.display.cacheAsBitmap = Ke\u0161ovat jako bitmapu
|
||||
property.instance.display.cacheAsBitmap.transparent = Pr\u016fhledn\u00e1
|
||||
property.instance.display.cacheAsBitmap.opaque = S barvou
|
||||
|
||||
#after 22.0.2
|
||||
property.document.backgroundColor = Barva pozad\u00ed
|
||||
Reference in New Issue
Block a user