Native look&feel, fixed bug when closing views, other cosmetic changes

This commit is contained in:
Iván Delgado 2021-02-03 00:33:56 +01:00
parent c8752a6389
commit ae94b52a00
7 changed files with 59 additions and 33 deletions

Binary file not shown.

8
resources/TM200.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE tmres SYSTEM "tmres.dtd">
<tmres>
<bookmarks>
</bookmarks>
<palettes>
</palettes>
</tmres>

View file

@ -5,6 +5,7 @@
<property key="viewStatusBar" value="true"/> <property key="viewStatusBar" value="true"/>
<property key="viewToolBar" value="true"/> <property key="viewToolBar" value="true"/>
<property key="maxRecentFiles" value="10"/> <property key="maxRecentFiles" value="10"/>
<property key="recentFile" value="/home/ivan/Escritorio/Otros/Apps/TM200"/>
<property key="lastPath" value=""/> <property key="lastPath" value=""/>
<property key="MenuBG" value="#151b1c"/> <property key="MenuBG" value="#151b1c"/>
<property key="WindowBG" value="#222b2e"/> <property key="WindowBG" value="#222b2e"/>

View file

@ -16,8 +16,12 @@
* *
*/ */
import javax.swing.UIManager;
import tm.ui.TMUI; import tm.ui.TMUI;
/** /**
* *
* Tile Molester main class. * Tile Molester main class.
@ -35,8 +39,18 @@ public class TileMolester {
* *
**/ **/
private static String OS = System.getProperty("os.name").toLowerCase();
public static Boolean isLinux = OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0;
public static Boolean isWindows = OS.indexOf("win") >= 0;
public TileMolester() { public TileMolester() {
new TMUI(); try {
if(isLinux) UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
if(isWindows) UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
new TMUI();
} }
/** /**

View file

@ -72,12 +72,12 @@ public class TMStatusBar extends JPanel {
add(p3); add(p3);
// pane.add(new JLabel(" ")); // just some whitespace // pane.add(new JLabel(" ")); // just some whitespace
offsetLabel.setBorder(new BevelBorder(BevelBorder.LOWERED)); //offsetLabel.setBorder(new BevelBorder(BevelBorder.LOWERED));
coordsLabel.setBorder(new BevelBorder(BevelBorder.LOWERED)); //coordsLabel.setBorder(new BevelBorder(BevelBorder.LOWERED));
palOffsetLabel.setBorder(new BevelBorder(BevelBorder.LOWERED)); //palOffsetLabel.setBorder(new BevelBorder(BevelBorder.LOWERED));
codecLabel.setBorder(new BevelBorder(BevelBorder.LOWERED)); //codecLabel.setBorder(new BevelBorder(BevelBorder.LOWERED));
modeLabel.setBorder(new BevelBorder(BevelBorder.LOWERED)); //modeLabel.setBorder(new BevelBorder(BevelBorder.LOWERED));
tilesLabel.setBorder(new BevelBorder(BevelBorder.LOWERED)); //tilesLabel.setBorder(new BevelBorder(BevelBorder.LOWERED));
} }
/** /**

View file

@ -258,7 +258,7 @@ public class TMUI extends JFrame {
// Help menu // Help menu
private JMenu helpMenu = new JMenu("Help"); private JMenu helpMenu = new JMenu("Help");
private JMenuItem helpTopicsMenuItem = new JMenuItem("Help Topics"); private JMenuItem helpTopicsMenuItem = new JMenuItem("Help Topics");
private JMenuItem tipMenuItem = new JMenuItem("Tip of the Millennium..."); //private JMenuItem tipMenuItem = new JMenuItem("Tip of the Millennium..."); // Still say no to drugs, okay?
private JMenuItem aboutMenuItem = new JMenuItem("About Tile Molester..."); private JMenuItem aboutMenuItem = new JMenuItem("About Tile Molester...");
// button groups // button groups
@ -370,7 +370,7 @@ public class TMUI extends JFrame {
JComponent.setDefaultLocale(this.locale); JComponent.setDefaultLocale(this.locale);
// show splash screen // show splash screen
new TMSplashScreen(this); //new TMSplashScreen(this); // No need for a splash screen, it runs immediately on modern systems
// create a translator // create a translator
try { try {
@ -474,7 +474,6 @@ public class TMUI extends JFrame {
// Help menu // Help menu
helpMenu.setText(xlate("Help")); helpMenu.setText(xlate("Help"));
helpTopicsMenuItem.setText(xlate("Help_Topics")); helpTopicsMenuItem.setText(xlate("Help_Topics"));
tipMenuItem.setText(xlate("Tip_of_the_Millennium"));
aboutMenuItem.setText(xlate("About_Tile_Molester")); aboutMenuItem.setText(xlate("About_Tile_Molester"));
UIManager.put("OptionPane.yesButtonText", xlate("Yes")); UIManager.put("OptionPane.yesButtonText", xlate("Yes"));
@ -561,7 +560,8 @@ public class TMUI extends JFrame {
// main toolbar // main toolbar
initToolBar(); initToolBar();
initNavBar(); initNavBar();
toolBarPane.setLayout(new FlowLayout(FlowLayout.LEFT)); toolBarPane.setLayout(new FlowLayout(FlowLayout.LEFT));
toolBarPane.setBackground(MenuBG);
toolBarPane.add(toolBar); toolBarPane.add(toolBar);
toolBarPane.add(navBar); toolBarPane.add(navBar);
pane.add(toolBarPane, BorderLayout.NORTH); pane.add(toolBarPane, BorderLayout.NORTH);
@ -571,7 +571,7 @@ public class TMUI extends JFrame {
// palette pane & statusbar // palette pane & statusbar
palettePane = new TMPalettePane(this); palettePane = new TMPalettePane(this);
statusBar.setBorder(new BevelBorder(BevelBorder.LOWERED)); //statusBar.setBorder(new BevelBorder(BevelBorder.LOWERED));
bottomPane.setLayout(new BorderLayout()); bottomPane.setLayout(new BorderLayout());
bottomPane.add(palettePane, BorderLayout.CENTER); bottomPane.add(palettePane, BorderLayout.CENTER);
bottomPane.add(statusBar, BorderLayout.SOUTH); bottomPane.add(statusBar, BorderLayout.SOUTH);
@ -583,7 +583,8 @@ public class TMUI extends JFrame {
JPanel barPane = new JPanel(); JPanel barPane = new JPanel();
barPane.setLayout(new GridLayout(1, 2)); barPane.setLayout(new GridLayout(1, 2));
barPane.add(selectionToolBar); barPane.add(selectionToolBar);
barPane.add(toolPalette); barPane.add(toolPalette);
toolPane.setBackground(AsideBG);
toolPane.setLayout(new BorderLayout()); toolPane.setLayout(new BorderLayout());
toolPane.add(barPane, BorderLayout.NORTH); toolPane.add(barPane, BorderLayout.NORTH);
pane.add(toolPane, BorderLayout.WEST); pane.add(toolPane, BorderLayout.WEST);
@ -628,6 +629,7 @@ public class TMUI extends JFrame {
doExitCommand(); doExitCommand();
} }
public void windowActivated(WindowEvent e) { public void windowActivated(WindowEvent e) {
setExtendedState(JFrame.NORMAL); // Hacky way to make it not run in full screen by default
// HACK to fix the GUI after running FCEU in fullscreen mode // HACK to fix the GUI after running FCEU in fullscreen mode
// int state = getExtendedState(); // int state = getExtendedState();
// setExtendedState(JFrame.ICONIFIED); // setExtendedState(JFrame.ICONIFIED);
@ -1159,7 +1161,7 @@ public class TMUI extends JFrame {
toolButtonGroup.add(replaceButton); toolButtonGroup.add(replaceButton);
toolButtonGroup.add(moveButton); toolButtonGroup.add(moveButton);
selectButton.setSelected(true); // starting tool selectButton.setSelected(true); // starting tool
toolPalette.setBorder(new BevelBorder(BevelBorder.LOWERED)); //toolPalette.setBorder(new BevelBorder(BevelBorder.LOWERED));
} }
/** /**
@ -1318,7 +1320,7 @@ public class TMUI extends JFrame {
); );
fileMenu.add(closeAllMenuItem); fileMenu.add(closeAllMenuItem);
// //
fileMenu.addSeparator(); //fileMenu.addSeparator();
// Save // Save
saveMenuItem.setMnemonic(KeyEvent.VK_S); saveMenuItem.setMnemonic(KeyEvent.VK_S);
saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)); saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));
@ -2009,16 +2011,7 @@ public class TMUI extends JFrame {
} }
); );
helpMenu.add(helpTopicsMenuItem); helpMenu.add(helpTopicsMenuItem);
// Tip of the Millennium
tipMenuItem.setMnemonic(KeyEvent.VK_M);
tipMenuItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
doTipCommand();
}
}
);
helpMenu.add(tipMenuItem);
// About // About
aboutMenuItem.setMnemonic(KeyEvent.VK_A); aboutMenuItem.setMnemonic(KeyEvent.VK_A);
aboutMenuItem.addActionListener( aboutMenuItem.addActionListener(
@ -2130,8 +2123,8 @@ public class TMUI extends JFrame {
// remove view from the FileImage and desktop // remove view from the FileImage and desktop
img.removeView(view); img.removeView(view);
view.dispose();
desktop.remove(view); desktop.remove(view);
view.dispose();
desktop.revalidate(); desktop.revalidate();
desktop.repaint(); desktop.repaint();
@ -2239,8 +2232,8 @@ public class TMUI extends JFrame {
// remove the view // remove the view
img.removeView(view); img.removeView(view);
view.dispose();
desktop.remove(view); desktop.remove(view);
view.dispose();
} }
buildReopenMenu(); buildReopenMenu();
@ -2719,7 +2712,7 @@ public class TMUI extends JFrame {
public void doAboutCommand() public void doAboutCommand()
{ {
JOptionPane.showMessageDialog(this, JOptionPane.showMessageDialog(this,
"Tile Molester v0.19\nby SnowBro 2003-2005 (v0.16)\nby Dr. MefistO 2013 (v0.17.2)\nby Mewster 2014-2015 (v0.19)", "Tile Molester", "Tile Molester v0.20\nby SnowBro 2003-2005 (v0.16)\nby Dr. MefistO 2013 (v0.17.2)\nby Mewster 2014-2015 (v0.19)\nby toruzz 2020 (v0.20)", "Tile Molester",
1); 1);
} }

View file

@ -43,6 +43,9 @@ import java.util.Vector;
**/ **/
public class TMView extends JInternalFrame implements ChangeListener { public class TMView extends JInternalFrame implements ChangeListener {
Color MenuBG = TMUI.MenuBG;
Color WindowBG = TMUI.WindowBG;
Color AsideBG = TMUI.AsideBG;
private static int frameCount = 0; private static int frameCount = 0;
private JPanel contentPane = new JPanel(); private JPanel contentPane = new JPanel();
@ -77,7 +80,10 @@ public class TMView extends JInternalFrame implements ChangeListener {
this.fileImage = fileImage; this.fileImage = fileImage;
fileImage.addView(this); fileImage.addView(this);
setDoubleBuffered(true); setDoubleBuffered(true);
setBackground(Color.gray); //setBackground(Color.gray);
setFrameIcon(null);
setBackground(MenuBG);
setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
addInternalFrameListener(new InternalFrameAdapter() { addInternalFrameListener(new InternalFrameAdapter() {
@ -99,7 +105,8 @@ public class TMView extends JInternalFrame implements ChangeListener {
// init UI components // init UI components
// the panel containing the slider and editor canvas // the panel containing the slider and editor canvas
contentPane.setBackground(Color.gray); //contentPane.setBackground(Color.gray);
contentPane.setBackground(AsideBG);
contentPane.setLayout(null); contentPane.setLayout(null);
contentPane.setFocusable(true); contentPane.setFocusable(true);
contentPane.addKeyListener(new ViewKeyListener(this)); contentPane.addKeyListener(new ViewKeyListener(this));
@ -120,9 +127,12 @@ public class TMView extends JInternalFrame implements ChangeListener {
// the slider // the slider
slider.setFocusable(false); slider.setFocusable(false);
slider.setInverted(true); slider.setInverted(true);
contentPane.add(slider); contentPane.add(slider);
slider.setLocation(0, 0); slider.setForeground(AsideBG);
slider.setSize(24, 384); //slider.setLocation(0, 0);
//slider.setSize(24, 384);
slider.setLocation(4, -14);
slider.setSize(32, 424);
slider.addChangeListener(this); slider.addChangeListener(this);
// the scrollpane // the scrollpane