diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index addba79df..7b64fa060 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -665,6 +665,11 @@ public class DefineEditTextTag extends TextTag { return true; } + @Override + public boolean translateText(int diff) { + return true; + } + @Override public RECT getRect(Set added) { return bounds; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index 5e0b57ea6..f1942ff91 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -447,6 +447,13 @@ public class DefineText2Tag extends TextTag { return true; } + @Override + public boolean translateText(int diff) { + textMatrix.translateX += diff; + setModified(true); + return true; + } + @Override public RECT getRect(Set added) { return textBounds; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 3f58ecd38..0b0da95f8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -455,6 +455,13 @@ public class DefineTextTag extends TextTag { return true; } + @Override + public boolean translateText(int diff) { + textMatrix.translateX += diff; + setModified(true); + return true; + } + @Override public int getCharacterId() { return characterID; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index 60e5e9993..57449092b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -87,6 +87,8 @@ public abstract class TextTag extends CharacterTag implements DrawableTag { public abstract boolean alignText(TextAlign textAlign); + public abstract boolean translateText(int diff); + @Override public abstract int getCharacterId(); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 91395b52a..82cf6b069 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2007,6 +2007,14 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec return false; } + public boolean translateText(TextTag textTag, int diff) { + if (textTag.translateText(diff)) { + return true; + } + + return false; + } + @Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { diff --git a/src/com/jpexs/decompiler/flash/gui/TextPanel.java b/src/com/jpexs/decompiler/flash/gui/TextPanel.java index afa02c5b7..935e4a145 100644 --- a/src/com/jpexs/decompiler/flash/gui/TextPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TextPanel.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.gui; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; import com.jpexs.decompiler.flash.tags.DefineEditTextTag; @@ -30,7 +31,6 @@ import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.Font; import java.awt.Insets; -import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.util.logging.Level; @@ -48,23 +48,7 @@ import jsyntaxpane.DefaultSyntaxKit; * * @author JPEXS */ -public class TextPanel extends JPanel implements ActionListener { - - private static final String ACTION_EDIT_TEXT = "EDITTEXT"; - - private static final String ACTION_CANCEL_TEXT = "CANCELTEXT"; - - private static final String ACTION_SAVE_TEXT = "SAVETEXT"; - - private static final String ACTION_TEXT_ALIGN_LEFT = "TEXTALIGNLEFT"; - - private static final String ACTION_TEXT_ALIGN_CENTER = "TEXTALIGNCENTER"; - - private static final String ACTION_TEXT_ALIGN_RIGHT = "TEXTALIGNRIGHT"; - - private static final String ACTION_TEXT_ALIGN_JUSTIFY = "TEXTALIGNJUSTIFY"; - - private static final String ACTION_UNDO_CHANGES = "UNDOCHANGES"; +public class TextPanel extends JPanel { private final MainPanel mainPanel; @@ -86,6 +70,10 @@ public class TextPanel extends JPanel implements ActionListener { private final JButton textAlignJustifyButton; + private final JButton decreaseTranslateXButton; + + private final JButton increaseTranslateXButton; + private final JButton undoChangesButton; public TextPanel(final MainPanel mainPanel) { @@ -124,16 +112,20 @@ public class TextPanel extends JPanel implements ActionListener { JPanel textButtonsPanel = new JPanel(); textButtonsPanel.setLayout(new FlowLayout(SwingConstants.WEST)); - textAlignLeftButton = createButton(null, "textalignleft16", ACTION_TEXT_ALIGN_LEFT, "text.align.left"); - textAlignCenterButton = createButton(null, "textaligncenter16", ACTION_TEXT_ALIGN_CENTER, "text.align.center"); - textAlignRightButton = createButton(null, "textalignright16", ACTION_TEXT_ALIGN_RIGHT, "text.align.right"); - textAlignJustifyButton = createButton(null, "textalignjustify16", ACTION_TEXT_ALIGN_JUSTIFY, "text.align.justify"); - undoChangesButton = createButton(null, "reload16", ACTION_UNDO_CHANGES, "text.undo"); + textAlignLeftButton = createButton(null, "textalignleft16", "text.align.left", e -> textAlign(TextAlign.LEFT)); + textAlignCenterButton = createButton(null, "textaligncenter16", "text.align.center", e -> textAlign(TextAlign.CENTER)); + textAlignRightButton = createButton(null, "textalignright16", "text.align.right", e -> textAlign(TextAlign.RIGHT)); + textAlignJustifyButton = createButton(null, "textalignjustify16", "text.align.justify", e -> textAlign(TextAlign.JUSTIFY)); + decreaseTranslateXButton = createButton(null, "textoutdent16", "text.align.translatex.decrease", e -> translateX(-(int) SWF.unitDivisor)); + increaseTranslateXButton = createButton(null, "textindent16", "text.align.translatex.increase", e -> translateX((int) SWF.unitDivisor)); + undoChangesButton = createButton(null, "reload16", "text.undo", e -> undoChanges()); textButtonsPanel.add(textAlignLeftButton); textButtonsPanel.add(textAlignCenterButton); textButtonsPanel.add(textAlignRightButton); textButtonsPanel.add(textAlignJustifyButton); + textButtonsPanel.add(decreaseTranslateXButton); + textButtonsPanel.add(increaseTranslateXButton); textButtonsPanel.add(undoChangesButton); textButtonsPanel.setAlignmentX(0); @@ -141,9 +133,9 @@ public class TextPanel extends JPanel implements ActionListener { add(topPanel, BorderLayout.NORTH); JPanel buttonsPanel = new JPanel(new FlowLayout()); - textSaveButton = createButton("button.save", "save16", ACTION_SAVE_TEXT, null); - textEditButton = createButton("button.edit", "edit16", ACTION_EDIT_TEXT, null); - textCancelButton = createButton("button.cancel", "cancel16", ACTION_CANCEL_TEXT, null); + textSaveButton = createButton("button.save", "save16", null, e -> saveText()); + textEditButton = createButton("button.edit", "edit16", null, e -> editText()); + textCancelButton = createButton("button.cancel", "cancel16", null, e -> cancelText()); textSaveButton.setVisible(false); textCancelButton.setVisible(false); @@ -154,12 +146,11 @@ public class TextPanel extends JPanel implements ActionListener { add(buttonsPanel, BorderLayout.SOUTH); } - private JButton createButton(String textResource, String iconName, String command, String toolTipResource) { + private JButton createButton(String textResource, String iconName, String toolTipResource, ActionListener actionListener) { String text = textResource == null ? "" : mainPanel.translate(textResource); JButton button = new JButton(text, View.getIcon(iconName)); button.setMargin(new Insets(3, 3, 3, 10)); - button.setActionCommand(command); - button.addActionListener(this); + button.addActionListener(actionListener); if (toolTipResource != null) { button.setToolTipText(mainPanel.translate(toolTipResource)); } @@ -192,6 +183,8 @@ public class TextPanel extends JPanel implements ActionListener { textAlignCenterButton.setVisible(alignable); textAlignRightButton.setVisible(alignable); textAlignJustifyButton.setVisible(alignable); + increaseTranslateXButton.setVisible(alignable); + decreaseTranslateXButton.setVisible(alignable); undoChangesButton.setVisible(item != null && item instanceof TextTag && ((Tag) item).isModified()); } @@ -207,78 +200,66 @@ public class TextPanel extends JPanel implements ActionListener { }); } - @Override - public void actionPerformed(ActionEvent e) { - switch (e.getActionCommand()) { - case ACTION_EDIT_TEXT: - setEditText(true); - textChanged(); - break; - case ACTION_CANCEL_TEXT: + private void editText() { + setEditText(true); + textChanged(); + } + + private void cancelText() { + setEditText(false); + mainPanel.reload(true); + } + + private void saveText() { + TreeItem item = mainPanel.tagTree.getCurrentTreeItem(); + if (item instanceof TextTag) { + TextTag textTag = (TextTag) item; + if (mainPanel.saveText(textTag, textValue.getText(), null)) { setEditText(false); - mainPanel.reload(true); - break; - case ACTION_SAVE_TEXT: { - TreeItem item = mainPanel.tagTree.getCurrentTreeItem(); - if (item instanceof TextTag) { - TextTag textTag = (TextTag) item; - if (mainPanel.saveText(textTag, textValue.getText(), null)) { - setEditText(false); - item.getSwf().clearImageCache(); - mainPanel.refreshTree(); - } - } - break; + item.getSwf().clearImageCache(); + mainPanel.refreshTree(); } - case ACTION_TEXT_ALIGN_LEFT: - case ACTION_TEXT_ALIGN_CENTER: - case ACTION_TEXT_ALIGN_RIGHT: - case ACTION_TEXT_ALIGN_JUSTIFY: { - TreeItem item = mainPanel.tagTree.getCurrentTreeItem(); - if (item instanceof TextTag) { - TextTag textTag = (TextTag) item; - TextAlign ta = null; - switch (e.getActionCommand()) { - case ACTION_TEXT_ALIGN_LEFT: - ta = TextAlign.LEFT; - break; - case ACTION_TEXT_ALIGN_CENTER: - ta = TextAlign.CENTER; - break; - case ACTION_TEXT_ALIGN_RIGHT: - ta = TextAlign.RIGHT; - break; - case ACTION_TEXT_ALIGN_JUSTIFY: - ta = TextAlign.JUSTIFY; - break; - } + } + } - if (mainPanel.alignText(textTag, ta)) { - setEditText(false); - item.getSwf().clearImageCache(); - mainPanel.refreshTree(); - } - } - undoChangesButton.setVisible(item != null && item instanceof TextTag && ((Tag) item).isModified()); - break; + private void textAlign(TextAlign textAlign) { + TreeItem item = mainPanel.tagTree.getCurrentTreeItem(); + if (item instanceof TextTag) { + TextTag textTag = (TextTag) item; + if (mainPanel.alignText(textTag, textAlign)) { + setEditText(false); + item.getSwf().clearImageCache(); + mainPanel.refreshTree(); } - case ACTION_UNDO_CHANGES: { - TreeItem item = mainPanel.tagTree.getCurrentTreeItem(); - if (item instanceof TextTag) { - try { - ((Tag) item).undo(); - } catch (InterruptedException | IOException ex) { - Logger.getLogger(TextPanel.class.getName()).log(Level.SEVERE, null, ex); - } + } + } - item.getSwf().clearImageCache(); - mainPanel.refreshTree(); - } - break; + private void translateX(int delta) { + TreeItem item = mainPanel.tagTree.getCurrentTreeItem(); + if (item instanceof TextTag) { + TextTag textTag = (TextTag) item; + if (mainPanel.translateText(textTag, delta)) { + setEditText(false); + item.getSwf().clearImageCache(); + mainPanel.refreshTree(); } } } + private void undoChanges() { + TreeItem item = mainPanel.tagTree.getCurrentTreeItem(); + if (item instanceof TextTag) { + try { + ((Tag) item).undo(); + } catch (InterruptedException | IOException ex) { + Logger.getLogger(TextPanel.class.getName()).log(Level.SEVERE, null, ex); + } + + item.getSwf().clearImageCache(); + mainPanel.refreshTree(); + } + } + private void textChanged() { if (!Configuration.showOldTextDuringTextEditing.get()) { return; diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/textindent16.png b/src/com/jpexs/decompiler/flash/gui/graphics/textindent16.png new file mode 100644 index 000000000..ecd8e3fab Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/textindent16.png differ diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/textoutdent16.png b/src/com/jpexs/decompiler/flash/gui/graphics/textoutdent16.png new file mode 100644 index 000000000..e308dfabf Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/textoutdent16.png differ diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 801703526..70a439a50 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -568,3 +568,7 @@ text.undo = Undo changes menu.file.import.xml = Import SWF XML menu.file.export.xml = Export SWF XML + +#after version 4.1.1 +text.align.translatex.decrease = Decrease TranslateX +text.align.translatex.increase = Increase TranslateX diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties index 76f820274..026287175 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties @@ -567,3 +567,7 @@ text.undo = M\u00f3dos\u00edt\u00e1sok visszavon\u00e1sa menu.file.import.xml = SWF XML import\u00e1l\u00e1s menu.file.export.xml = SWF XML export\u00e1l\u00e1s + +#after version 4.1.1 +text.align.translatex.decrease = TranslateX cs\u00f6kkent\u00e9se +text.align.translatex.increase = TranslateX n\u00f6vel\u00e9se