New UI layout, ROM loading, Font selection

- The UI layout has changed, and will likely change again in the future.

- Symon can now re-load ROM images from the File menu, under "Load ROM..."

- Font size can be changed under the "View" menu
This commit is contained in:
Seth Morabito committed 2012-12-05 23:19:34 -08:00
1 parent a7d9239ef1
commit 38a4458aff
14 files changed
+449 -310

No files matched your search

@@ -1,5 +1,6 @@
package com.loomcom.symon.ui;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
@@ -36,12 +37,8 @@ public class Console extends JTerminal implements KeyListener, MouseListener {
private FifoRingBuffer<Character> typeAheadBuffer;
public Console() {
this(DEFAULT_COLUMNS, DEFAULT_ROWS);
}
public Console(int columns, int rows) {
super(new Vt100TerminalModel(columns, rows));
public Console(int columns, int rows, Font font) {
super(new Vt100TerminalModel(columns, rows), font);
// A small type-ahead buffer, as might be found in any real
// VT100-style serial terminal.
this.typeAheadBuffer = new FifoRingBuffer<Character>(128);
@@ -12,13 +12,13 @@ public class PreferencesDialog extends Observable implements Preferences {
private final JDialog dialog;
private JTextField aciaAddressField;
private JCheckBox haltOnBreakCheckBox;
private JTextField programLoadAddressField;
private JTextField borderWidthField;
private int programLoadAddress = DEFAULT_PROGRAM_LOAD_ADDRESS;
private int aciaAddress = DEFAULT_ACIA_ADDRESS;
private int borderWidth = DEFAULT_BORDER_WIDTH;
private boolean haltOnBreak = DEFAULT_HALT_ON_BREAK;
public PreferencesDialog(Frame parent, boolean modal) {
this.dialog = new JDialog(parent, modal);
@@ -43,15 +43,14 @@ public class PreferencesDialog extends Observable implements Preferences {
GridBagLayout layout = new GridBagLayout();
settingsContainer.setLayout(layout);
final JLabel aciaAddressLabel = new JLabel("ACIA Address");
final JLabel haltOnBreakLabel = new JLabel("Halt on BRK");
final JLabel programLoadAddressLabel = new JLabel("Program Load Address");
final JLabel borderWidthLabel = new JLabel("Console Border Width");
aciaAddressField = new JTextField(8);
haltOnBreakCheckBox = new JCheckBox();
programLoadAddressField = new JTextField(8);
borderWidthField = new JTextField(8);
aciaAddressLabel.setLabelFor(aciaAddressField);
programLoadAddressLabel.setLabelFor(programLoadAddressField);
borderWidthLabel.setLabelFor(borderWidthField);
@@ -61,11 +60,10 @@ public class PreferencesDialog extends Observable implements Preferences {
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridx = 0;
constraints.gridy = 0;
settingsContainer.add(aciaAddressLabel, constraints);
settingsContainer.add(haltOnBreakLabel, constraints);
constraints.gridx = 1;
settingsContainer.add(aciaAddressField, constraints);
settingsContainer.add(haltOnBreakCheckBox, constraints);
constraints.gridy = 1;
constraints.gridx = 0;
@@ -94,8 +92,8 @@ public class PreferencesDialog extends Observable implements Preferences {
applyButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
haltOnBreak = haltOnBreakCheckBox.isSelected();
programLoadAddress = hexToInt(programLoadAddressField.getText());
aciaAddress = hexToInt(aciaAddressField.getText());
borderWidth = Integer.parseInt(borderWidthField.getText());
updateUi();
// TODO: Actually check to see if values have changed, don't assume.
@@ -118,10 +116,6 @@ public class PreferencesDialog extends Observable implements Preferences {
return programLoadAddress;
}
public int getAciaAddress() {
return aciaAddress;
}
/**
* @return The width of the console border, in pixels.
*/
@@ -129,8 +123,15 @@ public class PreferencesDialog extends Observable implements Preferences {
return borderWidth;
}
/**
* @return True if 'halt on break' is desired, false otherwise.
*/
public boolean getHaltOnBreak() {
return haltOnBreak;
}
public void updateUi() {
aciaAddressField.setText(intToHex(aciaAddress));
haltOnBreakCheckBox.setSelected(haltOnBreak);
programLoadAddressField.setText(intToHex(programLoadAddress));
borderWidthField.setText(Integer.toString(borderWidth));
}
@@ -26,6 +26,7 @@ public class StatusPanel extends JPanel {
private final ImageIcon negativeOn;
private final ImageIcon negativeOff;
private final JLabel statusFlagsLabel;
private final JLabel carryFlagLabel;
private final JLabel zeroFlagLabel;
private final JLabel irqDisableFlagLabel;
@@ -40,7 +41,6 @@ public class StatusPanel extends JPanel {
private JTextField aField;
private JTextField xField;
private JTextField yField;
// private JTextField stepCountField;
private final JLabel opcodeLabel;
private final JLabel pcLabel;
@@ -48,11 +48,10 @@ public class StatusPanel extends JPanel {
private final JLabel aLabel;
private final JLabel xLabel;
private final JLabel yLabel;
// private final JLabel stepCountLabel;
private static final int EMPTY_BORDER = 5;
private static final Border LABEL_BORDER = BorderFactory.createEmptyBorder(0, 4, 0, 0);
private static final Font LABEL_FONT = new Font("sansserif", Font.PLAIN, 11);
private static final int EMPTY_BORDER = 10;
private static final Border LABEL_BORDER = BorderFactory.createEmptyBorder(0, 5, 0, 0);
private static final Font LABEL_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 12);
public StatusPanel() {
super();
@@ -63,7 +62,10 @@ public class StatusPanel extends JPanel {
setBorder(BorderFactory.createCompoundBorder(emptyBorder, etchedBorder));
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
GridBagLayout layout = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
setLayout(layout);
JPanel statusFlagsPanel = new JPanel();
statusFlagsPanel.setAlignmentX(LEFT_ALIGNMENT);
@@ -101,37 +103,72 @@ public class StatusPanel extends JPanel {
statusFlagsPanel.add(carryFlagLabel);
// Create and add register and address labels
opcodeLabel = makeLabel("Instruction");
pcLabel = makeLabel("Program Counter");
spLabel = makeLabel("Stack Pointer");
aLabel = makeLabel("Accumulator");
xLabel = makeLabel("X Register");
yLabel = makeLabel("Y Register");
// stepCountLabel = new JLabel("Steps");
statusFlagsLabel = makeLabel("Flags");
opcodeLabel = makeLabel("IR");
pcLabel = makeLabel("PC");
spLabel = makeLabel("SP");
aLabel = makeLabel("A");
xLabel = makeLabel("X");
yLabel = makeLabel("Y");
opcodeField = makeTextField();
pcField = makeTextField();
spField = makeTextField();
aField = makeTextField();
xField = makeTextField();
yField = makeTextField();
// stepCountField = new JTextField("");
opcodeField = makeTextField(LARGE_TEXT_FIELD_SIZE);
pcField = makeTextField(LARGE_TEXT_FIELD_SIZE);
spField = makeTextField(SMALL_TEXT_FIELD_SIZE);
aField = makeTextField(SMALL_TEXT_FIELD_SIZE);
xField = makeTextField(SMALL_TEXT_FIELD_SIZE);
yField = makeTextField(SMALL_TEXT_FIELD_SIZE);
add(statusFlagsPanel);
add(opcodeLabel);
add(opcodeField);
add(pcLabel);
add(pcField);
add(spLabel);
add(spField);
add(aLabel);
add(aField);
add(xLabel);
add(xField);
add(yLabel);
add(yField);
// add(stepCountLabel);
// add(stepCountField);
constraints.anchor = GridBagConstraints.LINE_START;
constraints.gridwidth = 2;
constraints.gridx = 0;
constraints.gridy = 0;
add(statusFlagsLabel, constraints);
constraints.gridy = 1;
add(statusFlagsPanel, constraints);
constraints.insets = new Insets(5, 0, 0, 0);
constraints.gridy = 2;
add(opcodeLabel, constraints);
constraints.insets = new Insets(0, 0, 0, 0);
constraints.gridy = 3;
add(opcodeField, constraints);
constraints.insets = new Insets(5, 0, 0, 0);
constraints.gridy = 4;
add(pcLabel, constraints);
constraints.insets = new Insets(0, 0, 0, 0);
constraints.gridy = 5;
add(pcField, constraints);
constraints.insets = new Insets(5, 0, 0, 0);
constraints.gridwidth = 1;
constraints.gridy = 6;
add(spLabel, constraints);
constraints.gridx = 1;
add(aLabel, constraints);
constraints.insets = new Insets(0, 0, 0, 0);
constraints.gridx = 0;
constraints.gridy = 7;
add(spField, constraints);
constraints.gridx = 1;
add(aField, constraints);
constraints.insets = new Insets(5, 0, 0, 0);
constraints.gridx = 0;
constraints.gridy = 8;
add(yLabel, constraints);
constraints.gridx = 1;
add(xLabel, constraints);
constraints.insets = new Insets(0, 0, 5, 0);
constraints.gridx = 0;
constraints.gridy = 9;
add(xField, constraints);
constraints.gridx = 1;
add(yField, constraints);
}
/**
@@ -158,7 +195,6 @@ public class StatusPanel extends JPanel {
aField.setText(cpu.getAccumulatorStatus());
xField.setText(cpu.getXRegisterStatus());
yField.setText(cpu.getYRegisterStatus());
// stepCountField.setText(Long.toString(cpu.getStepCounter()));
repaint();
}
@@ -228,10 +264,16 @@ public class StatusPanel extends JPanel {
return label;
}
private JTextField makeTextField() {
private static final Dimension LARGE_TEXT_FIELD_SIZE = new Dimension(134, 22);
private static final Dimension SMALL_TEXT_FIELD_SIZE = new Dimension(65, 22);
private JTextField makeTextField(Dimension size) {
JTextField textField = new JTextField("");
textField.setAlignmentX(LEFT_ALIGNMENT);
textField.setEditable(false);
textField.setMinimumSize(size);
textField.setMaximumSize(size);
textField.setPreferredSize(size);
return textField;
}