diff --git a/lang/ca.txt b/lang/ca.txt index fb026b7e01e4b0a84c7e7e54d0459b01d56d8fb6..f2589789e8997849079964b99a32c3b17cded450 100644 --- a/lang/ca.txt +++ b/lang/ca.txt @@ -115,6 +115,7 @@ WIN_PREFS_TITLE|Preferències WIN_PREFS_UPDATE_L|Habilita l'actualització automàtica WIN_PREFS_LANG_L|Llengua: WIN_PREFS_LAF_L|Programa d'aspecte i comportament: +WIN_PREFS_TBAR_L|Show toolbar: WIN_PREFS_RESTART_L|Alguns paràmetres només tenen efecte quan el programa es reinicia. #SubBitmap Edit and Skin Preview window diff --git a/lang/de.txt b/lang/de.txt index 262053f1770c09c1eff73171c535f0bc95e46020..62aec38909916bac7e96c3f992aafad7d6a13084 100644 --- a/lang/de.txt +++ b/lang/de.txt @@ -115,6 +115,7 @@ WIN_PREFS_TITLE|Einstellungen WIN_PREFS_UPDATE_L|Automatisches Update aktivieren: WIN_PREFS_LANG_L|Sprache: WIN_PREFS_LAF_L|Programm-Aussehen: +WIN_PREFS_TBAR_L|Toolbar anzeigen: WIN_PREFS_RESTART_L|Einige Einstellungen werden erst nach Programmneustart aktiv. #SubBitmap Edit and Skin Preview window diff --git a/lang/en.txt b/lang/en.txt index ef7bdc3ea0a42cd88c2c929473219fffb7bff654..44a279785447f5768f5460120552594d5adbc7ec 100644 --- a/lang/en.txt +++ b/lang/en.txt @@ -115,6 +115,7 @@ WIN_PREFS_TITLE|Preferences WIN_PREFS_UPDATE_L|Enable auto-update: WIN_PREFS_LANG_L|Language: WIN_PREFS_LAF_L|Program look-and-feel: +WIN_PREFS_TBAR_L|Show toolbar: WIN_PREFS_RESTART_L|Some settings only take effect when the program is restarted. #SubBitmap Edit and Skin Preview window diff --git a/lang/fr.txt b/lang/fr.txt index 47912fae15e48e27c17ef563f2466ac398862919..ec0c5fc04e02274fe1276f4143cf44c3f3b5743a 100644 --- a/lang/fr.txt +++ b/lang/fr.txt @@ -115,6 +115,7 @@ WIN_PREFS_TITLE|Préférences WIN_PREFS_UPDATE_L|Activer l'auto-update : WIN_PREFS_LANG_L|Langage: WIN_PREFS_LAF_L|Apparence du program : +WIN_PREFS_TBAR_L|Afficher la barre d'outils : WIN_PREFS_RESTART_L|Certaines options ne prennent effet qu'après redémarrage du programme. #SubBitmap Edit and Skin Preview window diff --git a/lang/nl.txt b/lang/nl.txt index e5f2e8910b9a16bf544d6d6d72b8c4325dd410e7..ca0544af79e3aae070f9c547a4ed76dd7b1145bc 100644 --- a/lang/nl.txt +++ b/lang/nl.txt @@ -116,6 +116,7 @@ WIN_PREFS_TITLE|Voorkeuren WIN_PREFS_UPDATE_L|Auto-update activeren: WIN_PREFS_LANG_L|Taal: WIN_PREFS_LAF_L|Programma-uiterlijk: +WIN_PREFS_TBAR_L|Toolbar activeren: WIN_PREFS_RESTART_L|Enkele instellingen worden pas van kracht na een herstart van het programma. #SubBitmap Edit and Skin Preview window diff --git a/lang/ru.txt b/lang/ru.txt index 4559fc71d4772787c13a7d52eb5c144a1827608a..e52b8f39c7c252ad1f974d8c98611a5c52cdcb9a 100644 --- a/lang/ru.txt +++ b/lang/ru.txt @@ -115,6 +115,7 @@ WIN_PREFS_TITLE|Preferences WIN_PREFS_UPDATE_L|Enable auto-update: WIN_PREFS_LANG_L|Language: WIN_PREFS_LAF_L|Program look-and-feel: +WIN_PREFS_TBAR_L|Show toolbar: WIN_PREFS_RESTART_L|Some settings only take effect when the program is restarted. #SubBitmap Edit and Skin Preview window diff --git a/lang/sk.txt b/lang/sk.txt index d481a7d87a4e9cd626e987c291688a6fc75a9d7a..71e915201419125cd6ab2c5364b0e8afde7fbe07 100644 --- a/lang/sk.txt +++ b/lang/sk.txt @@ -115,6 +115,7 @@ WIN_PREFS_TITLE|Nastavenia WIN_PREFS_UPDATE_L|Aktivovať automatické aktualizácie: WIN_PREFS_LANG_L|Jazyk: WIN_PREFS_LAF_L|Vzhľad programu: +WIN_PREFS_TBAR_L|Show toolbar: WIN_PREFS_RESTART_L|Niektoré nastavenia sa aktivujú až po reštartovaní programu. #SubBitmap Edit and Skin Preview window diff --git a/lang/sv.txt b/lang/sv.txt index d6c385a58bf2b378e8fe9abfc1f94469dde5f8e0..ac1b41e3ebf2980bc9b0d5fdb84c5fb7a900ef0c 100644 --- a/lang/sv.txt +++ b/lang/sv.txt @@ -115,6 +115,7 @@ WIN_PREFS_TITLE|Inställningar WIN_PREFS_UPDATE_L|Enable auto-update: WIN_PREFS_LANG_L|Språk: WIN_PREFS_LAF_L|Program look-and-feel: +WIN_PREFS_TBAR_L|Show toolbar: WIN_PREFS_RESTART_L|Some settings only take effect when the program is restarted. #SubBitmap Edit and Skin Preview window diff --git a/src/vlcskineditor/Config.java b/src/vlcskineditor/Config.java index 55e085ea3255deb8f08fa69383139c27d82dc6a3..1fae6383261b14e43e48badd41dffbd00b8bbec7 100644 --- a/src/vlcskineditor/Config.java +++ b/src/vlcskineditor/Config.java @@ -61,6 +61,7 @@ public class Config { strings.put("win.items.width","190"); strings.put("win.items.height","200"); strings.put("swing.laf","System"); + strings.put("toolbar","true"); //Locate the config file if(System.getProperty("os.name").indexOf("Windows")!=-1) { @@ -179,8 +180,12 @@ public class Config { JLabel laf_l = new JLabel(Language.get("WIN_PREFS_LAF_L")); String[] lafs = { "System" , "Metal: Steel", "Metal: Ocean" }; final JComboBox laf_cb = new JComboBox(lafs); - laf_cb.setSelectedItem(Config.get("swing.laf")); - + laf_cb.setSelectedItem(Config.get("swing.laf")); + + JLabel tbar_l = new JLabel(Language.get("WIN_PREFS_TBAR_L")); + final JCheckBox tbar_cb = new JCheckBox(); + tbar_cb.setSelected(Boolean.parseBoolean(Config.get("toolbar"))); + JLabel restart_l = new JLabel(Language.get("WIN_PREFS_RESTART_L")); JButton ok_btn = new JButton(Language.get("BUTTON_OK")); @@ -189,7 +194,10 @@ public class Config { public void actionPerformed(ActionEvent e) { strings.put("autoupdate", String.valueOf(update_cb.isSelected())); strings.put("language", ((Language)lang_cb.getSelectedItem()).getCode()); - strings.put("swing.laf", (String)laf_cb.getSelectedItem()); + strings.put("swing.laf", (String)laf_cb.getSelectedItem()); + strings.put("toolbar", String.valueOf(update_cb.isSelected())); + + frame.setVisible(false); frame.dispose(); } @@ -210,6 +218,8 @@ public class Config { frame.add(update_cb); frame.add(laf_l); frame.add(laf_cb); + frame.add(tbar_l); + frame.add(tbar_cb); frame.add(restart_l); frame.add(ok_btn); frame.add(cancel_btn); @@ -241,7 +251,13 @@ public class Config { layout.putConstraint(SpringLayout.WEST, laf_cb, tf_dx, SpringLayout.WEST, frame.getContentPane()); layout.putConstraint(SpringLayout.EAST, laf_cb, 0, SpringLayout.EAST, lang_cb); - layout.putConstraint(SpringLayout.NORTH, restart_l, 10, SpringLayout.SOUTH, laf_l); + layout.putConstraint(SpringLayout.NORTH, tbar_l, 10, SpringLayout.SOUTH, laf_l); + layout.putConstraint(SpringLayout.WEST, tbar_l, 5, SpringLayout.WEST, frame.getContentPane()); + layout.putConstraint(SpringLayout.VERTICAL_CENTER, tbar_cb, 0, SpringLayout.VERTICAL_CENTER, tbar_l); + layout.putConstraint(SpringLayout.WEST, tbar_cb, tf_dx, SpringLayout.WEST, frame.getContentPane()); + layout.putConstraint(SpringLayout.EAST, tbar_cb, 0, SpringLayout.EAST, lang_cb); + + layout.putConstraint(SpringLayout.NORTH, restart_l, 10, SpringLayout.SOUTH, tbar_l); layout.putConstraint(SpringLayout.WEST, restart_l, 5, SpringLayout.WEST, frame.getContentPane()); layout.putConstraint(SpringLayout.NORTH, ok_btn, 10, SpringLayout.SOUTH, restart_l); diff --git a/src/vlcskineditor/Main.java b/src/vlcskineditor/Main.java index 9ce5247ee866b2c3340111d6aa5298ae1c1d88a4..e27a307192f163a568cf82d464a6a0286913178d 100644 --- a/src/vlcskineditor/Main.java +++ b/src/vlcskineditor/Main.java @@ -64,6 +64,9 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele private JMenuItem m_edit_undo, m_edit_redo, m_edit_theme, m_edit_vars, m_edit_prefs, m_edit_up, m_edit_down, m_edit_right, m_edit_left; private JMenuItem m_help_doc, m_help_about; + private JPanel tbar; + private JButton tbar_open_btn, tbar_save_btn, tbar_undo_btn, tbar_redo_btn; + private JDesktopPane jdesk; private JInternalFrame resources,windows,items; protected JTree res_tree,win_tree,items_tree; @@ -266,6 +269,49 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele mbar.add(m_help); setJMenuBar(mbar); + + //Toolbar + + if(Boolean.parseBoolean(Config.get("toolbar"))) { + tbar = new JPanel(); + //tbar.setLayout(new BoxLayout(tbar, BoxLayout.LINE_AXIS)); + tbar_open_btn = new ToolbarButton(Toolkit.getDefaultToolkit().createImage(Main.class.getResource("icons/tbar_open.png"))); + tbar_open_btn.setToolTipText(Language.get("TOOLBAR_OPEN")); + tbar_open_btn.addActionListener(this); + tbar.add(tbar_open_btn); + tbar_save_btn = new ToolbarButton(Toolkit.getDefaultToolkit().createImage(Main.class.getResource("icons/tbar_save.png"))); + tbar_save_btn.setToolTipText(Language.get("TOOLBAR_SAVE")); + tbar_save_btn.addActionListener(this); + tbar.add(tbar_save_btn); + JToolBar.Separator tbar_sep_1 = new JToolBar.Separator(new Dimension(10,22)); + tbar_sep_1.setOrientation(JSeparator.VERTICAL); + tbar.add(tbar_sep_1); + tbar_undo_btn = new ToolbarButton(Toolkit.getDefaultToolkit().createImage(Main.class.getResource("icons/tbar_undo.png"))); + tbar_undo_btn.setToolTipText(Language.get("TOOLBAR_UNDO")); + tbar_undo_btn.addActionListener(this); + tbar.add(tbar_undo_btn); + tbar_redo_btn = new ToolbarButton(Toolkit.getDefaultToolkit().createImage(Main.class.getResource("icons/tbar_redo.png"))); + tbar_redo_btn.setToolTipText(Language.get("TOOLBAR_REDO")); + tbar_redo_btn.addActionListener(this); + tbar.add(tbar_redo_btn); + SpringLayout tbar_layout = new SpringLayout(); + tbar_layout.putConstraint(SpringLayout.VERTICAL_CENTER, tbar_open_btn, 0, SpringLayout.VERTICAL_CENTER, tbar); + tbar_layout.putConstraint(SpringLayout.WEST, tbar_open_btn, 2, SpringLayout.WEST, tbar); + tbar_layout.putConstraint(SpringLayout.VERTICAL_CENTER, tbar_save_btn, 0, SpringLayout.VERTICAL_CENTER, tbar); + tbar_layout.putConstraint(SpringLayout.WEST, tbar_save_btn, 2, SpringLayout.EAST, tbar_open_btn); + tbar_layout.putConstraint(SpringLayout.VERTICAL_CENTER, tbar_sep_1, 0, SpringLayout.VERTICAL_CENTER, tbar); + tbar_layout.putConstraint(SpringLayout.WEST, tbar_sep_1, 2, SpringLayout.EAST, tbar_save_btn); + tbar_layout.putConstraint(SpringLayout.VERTICAL_CENTER, tbar_undo_btn, 0, SpringLayout.VERTICAL_CENTER, tbar); + tbar_layout.putConstraint(SpringLayout.WEST, tbar_undo_btn, 2, SpringLayout.EAST, tbar_sep_1); + tbar_layout.putConstraint(SpringLayout.VERTICAL_CENTER, tbar_redo_btn, 0, SpringLayout.VERTICAL_CENTER, tbar); + tbar_layout.putConstraint(SpringLayout.WEST, tbar_redo_btn, 2, SpringLayout.EAST, tbar_undo_btn); + tbar.setLayout(tbar_layout); + tbar.setPreferredSize(new Dimension(tbar.getPreferredSize().width,26)); + tbar.setMaximumSize(new Dimension(tbar.getMaximumSize().width,26)); + add(tbar); + } + + //Resources, window and item windows jdesk = new JDesktopPane(); @@ -588,8 +634,22 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele items_add_pu.add(items_add_pu_video); jdesk.add(items_add_pu); - jdesk.setMinimumSize(new Dimension(800,600)); - add(jdesk); + add(jdesk); + + //Main window layout + if(Boolean.parseBoolean(Config.get("toolbar"))) { + SpringLayout layout = new SpringLayout(); + layout.putConstraint(SpringLayout.NORTH, tbar, 0, SpringLayout.NORTH, getContentPane()); + layout.putConstraint(SpringLayout.WEST, tbar, 0, SpringLayout.WEST, getContentPane()); + layout.putConstraint(SpringLayout.EAST, tbar, 0, SpringLayout.EAST, getContentPane()); + layout.putConstraint(SpringLayout.NORTH, jdesk, 0, SpringLayout.SOUTH, tbar); + layout.putConstraint(SpringLayout.WEST, jdesk, 0, SpringLayout.WEST, getContentPane()); + layout.putConstraint(SpringLayout.EAST, getContentPane(), 0, SpringLayout.EAST, jdesk); + layout.putConstraint(SpringLayout.SOUTH, getContentPane(), 0, SpringLayout.SOUTH, jdesk); + setLayout(layout); + } + + setMinimumSize(new Dimension(800,600)); setSize(Config.getInt("win.main.width"),Config.getInt("win.main.height")); if(Config.get("win.main.x")==null) setLocationRelativeTo(null); @@ -600,7 +660,7 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele setExtendedState(JFrame.MAXIMIZED_BOTH); } - setVisible(true); + setVisible(true); update(); diff --git a/src/vlcskineditor/ToolbarButton.java b/src/vlcskineditor/ToolbarButton.java new file mode 100644 index 0000000000000000000000000000000000000000..6c12f96032ab85882c2b3919e2b75c411be7f66b --- /dev/null +++ b/src/vlcskineditor/ToolbarButton.java @@ -0,0 +1,162 @@ +/***************************************************************************** + * ToolbarButton.java + ***************************************************************************** + * Copyright (C) 2009 Daniel Dreibrodt + * + * This file is part of VLC Skin Editor + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + + +package vlcskineditor; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import javax.swing.ImageIcon; +import javax.swing.JButton; + +/** + * A toolbar image button, with hover effects + * @author Daniel Dreibrodt + */ +public class ToolbarButton extends JButton implements MouseListener { + + ImageIcon normal, over, down; + + boolean hover = false; + + boolean mac = System.getProperty("os.name").indexOf("Mac")!=-1; + + public ToolbarButton(Image img) { + try { + + normal = new ImageIcon(img); + + BufferedImage icon = new BufferedImage(normal.getIconWidth(), normal.getIconHeight(), BufferedImage.TYPE_INT_ARGB); + icon.getGraphics().drawImage(normal.getImage(), 0, 0, this); + + if(!mac) { + BufferedImage ovbi = new BufferedImage(icon.getWidth(this),icon.getHeight(this),BufferedImage.TYPE_INT_ARGB); + for(int x=0;x> 16) & 0xff; + int green = (argb >> 8) & 0xff; + int blue = argb & 0xff; + int alpha = (argb >> 24) & 0xff; + g.setColor(brighter(new Color(red,green,blue,alpha),0.92)); + g.fillRect(x, y, 1, 1); + } + } + over = new ImageIcon(ovbi); + + BufferedImage dobi = new BufferedImage(icon.getWidth(this),icon.getHeight(this),BufferedImage.TYPE_INT_ARGB); + for(int x=0;x> 16) & 0xff; + int green = (argb >> 8) & 0xff; + int blue = argb & 0xff; + int alpha = (argb >> 24) & 0xff; + g.setColor(darker(new Color(red,green,blue,alpha),0.92)); + g.fillRect(x, y, 1, 1); + } + } + down = new ImageIcon(dobi); + } + + setIcon(normal); + setBorderPainted(false); + setContentAreaFilled(false); + setFocusPainted(false); + addMouseListener(this); + setPreferredSize(new Dimension(normal.getIconWidth()+8,normal.getIconHeight()+8)); + } catch(Exception ex) { + ex.printStackTrace(); + setText(" "); + } + } + public void mouseClicked(MouseEvent e) { + + } + public void mousePressed(MouseEvent e) { + if(mac) return; + + setIcon(down); + repaint(); + } + public void mouseReleased(MouseEvent e) { + if(mac) return; + + if(hover) setIcon(over); + else setIcon(normal); + repaint(); + } + public void mouseEntered(MouseEvent e) { + if(mac) return; + + hover = true; + setIcon(over); + repaint(); + } + public void mouseExited(MouseEvent e) { + if(mac) return; + + hover = false; + setIcon(normal); + repaint(); + } + + public Color brighter(Color c, double factor) { + int r = c.getRed(); + int g = c.getGreen(); + int b = c.getBlue(); + int a = c.getAlpha(); + + /* From 2D group: + * 1. black.brighter() should return grey + * 2. applying brighter to blue will always return blue, brighter + * 3. non pure color (non zero rgb) will eventually return white + */ + int i = (int)(1.0/(1.0-factor)); + if ( r == 0 && g == 0 && b == 0) { + return new Color(i, i, i, a); + } + if ( r > 0 && r < i ) r = i; + if ( g > 0 && g < i ) g = i; + if ( b > 0 && b < i ) b = i; + + return new Color(Math.min((int)(r/factor), 255), + Math.min((int)(g/factor), 255), + Math.min((int)(b/factor), 255), + a); + } + + public Color darker(Color c, double factor) { + return new Color(Math.max((int)(c.getRed() *factor), 0), + Math.max((int)(c.getGreen()*factor), 0), + Math.max((int)(c.getBlue() *factor), 0), + c.getAlpha()); + } + +} diff --git a/src/vlcskineditor/icons/tbar_open.png b/src/vlcskineditor/icons/tbar_open.png new file mode 100644 index 0000000000000000000000000000000000000000..7c4ee7923234f46445b31d621fa802ac43c0e45c Binary files /dev/null and b/src/vlcskineditor/icons/tbar_open.png differ diff --git a/src/vlcskineditor/icons/tbar_redo.png b/src/vlcskineditor/icons/tbar_redo.png new file mode 100644 index 0000000000000000000000000000000000000000..576cfc76c6b8868e648ad44ad39afc63b8bf8e81 Binary files /dev/null and b/src/vlcskineditor/icons/tbar_redo.png differ diff --git a/src/vlcskineditor/icons/tbar_save.png b/src/vlcskineditor/icons/tbar_save.png new file mode 100644 index 0000000000000000000000000000000000000000..a94e0eab97def13486256451f08973e0b68f9ad8 Binary files /dev/null and b/src/vlcskineditor/icons/tbar_save.png differ diff --git a/src/vlcskineditor/icons/tbar_undo.png b/src/vlcskineditor/icons/tbar_undo.png new file mode 100644 index 0000000000000000000000000000000000000000..f37c6963d5a09fca4392a9c624171b6ebd8ed75f Binary files /dev/null and b/src/vlcskineditor/icons/tbar_undo.png differ