Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/src/processing/app/ColorChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,23 @@ public void paintComponent(Graphics g) {
row.add(Box.createHorizontalGlue());
box.add(row);

row = Box.createHorizontalBox();
if (Base.isMacOS()) {
row.add(Box.createHorizontalStrut(11));
} else {
row.add(createFixedLabel(""));
}
button = new JButton("Cancel");
button.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
ColorChooser.this.hide();
}
});
row.add(button);
row.add(Box.createHorizontalGlue());
box.add(row);
//

box.add(Box.createVerticalGlue());
Expand Down
136 changes: 136 additions & 0 deletions app/src/processing/app/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.*;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;

import processing.core.*;

Expand Down Expand Up @@ -107,6 +109,8 @@ public class Preferences {
int wide, high;

JTextField sketchbookLocationField;
JTextField presentColor;
JTextField presentColorHex;
JCheckBox editorAntialiasBox;
JCheckBox deletePreviousBox;
JCheckBox whinyBox;
Expand All @@ -118,6 +122,8 @@ public class Preferences {
JComboBox consoleSizeField;
JCheckBox inputMethodBox;
JCheckBox autoAssociateBox;

ColorChooser selector;

//JRadioButton bitsThirtyTwoButton;
//JRadioButton bitsSixtyFourButton;
Expand Down Expand Up @@ -369,6 +375,131 @@ public void actionPerformed(ActionEvent e) {
top += d.height + GUI_BETWEEN;


Container colorBox = Box.createHorizontalBox();

label = new JLabel("Background color when Presenting: ");
colorBox.add(label);

final String colorTip = "<html>"
+ "Select the background color used when using Present.<br/>"
+ "Present is used to present a sketch in full-screen, <br/>"
+ "accessible from the Sketch menu.";
label.setToolTipText(colorTip);

presentColor = new JTextField(" ");
presentColor.setOpaque(true);
presentColor.setEnabled(false);
presentColor.setBorder(new CompoundBorder(BorderFactory.createMatteBorder(
1, 1, 0, 0, new Color(195, 195, 195)), BorderFactory.createMatteBorder(
0, 0, 1, 1, new Color(54, 54, 54))));
presentColor.setBackground(Preferences.getColor("run.present.bgcolor"));

presentColorHex = new JTextField(6);
presentColorHex
.setText(Preferences.get("run.present.bgcolor").substring(1));
presentColorHex.getDocument().addDocumentListener(new DocumentListener() {

@Override
public void removeUpdate(DocumentEvent e) {
final String colorValue = presentColorHex.getText().toUpperCase();
if (colorValue.length() == 7 && (colorValue.startsWith("#")))
EventQueue.invokeLater(new Runnable() {
public void run() {
presentColorHex.setText(colorValue.substring(1));
}
});
if (colorValue.length() == 6
&& colorValue.matches("[0123456789ABCDEF]*")) {
presentColor.setBackground(new Color(Integer.parseInt(
colorValue.substring(0, 2), 16), Integer.parseInt(
colorValue.substring(2, 4), 16), Integer.parseInt(
colorValue.substring(4, 6), 16)));
if (!colorValue.equals(presentColorHex.getText()))
EventQueue.invokeLater(new Runnable() {
public void run() {
presentColorHex.setText(colorValue);
}
});
}
}

@Override
public void insertUpdate(DocumentEvent e) {
final String colorValue = presentColorHex.getText().toUpperCase();
if (colorValue.length() == 7 && (colorValue.startsWith("#")))
EventQueue.invokeLater(new Runnable() {
public void run() {
presentColorHex.setText(colorValue.substring(1));
}
});
if (colorValue.length() == 6
&& colorValue.matches("[0123456789ABCDEF]*")) {
presentColor.setBackground(new Color(Integer.parseInt(
colorValue.substring(0, 2), 16), Integer.parseInt(
colorValue.substring(2, 4), 16), Integer.parseInt(
colorValue.substring(4, 6), 16)));
if (!colorValue.equals(presentColorHex.getText()))
EventQueue.invokeLater(new Runnable() {
public void run() {
presentColorHex.setText(colorValue);
}
});
}
}

@Override public void changedUpdate(DocumentEvent e) {}
});

selector = new ColorChooser(dialog, false,
Preferences.getColor("run.present.bgcolor"), "OK",
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String colorValue = selector.getHexColor();
presentColorHex.setText(colorValue.substring(1));
presentColor.setBackground(new Color(Integer.parseInt(
colorValue.substring(1, 3), 16), Integer.parseInt(
colorValue.substring(3, 5), 16), Integer.parseInt(
colorValue.substring(5, 7), 16)));
selector.hide();
}
});

presentColor.addMouseListener(new MouseListener() {
@Override public void mouseReleased(MouseEvent e) {}
@Override public void mousePressed(MouseEvent e) {}

@Override
public void mouseExited(MouseEvent e) {
dialog.setCursor(Cursor.DEFAULT_CURSOR);
}

@Override
public void mouseEntered(MouseEvent e) {
dialog.setCursor(Cursor.HAND_CURSOR);
}

@Override
public void mouseClicked(MouseEvent e) {
selector.show();
}
});

label = new JLabel("#");
colorBox.add(label);

colorBox.add(presentColorHex);

colorBox.add(Box.createHorizontalStrut(GUI_SMALL + 2 / 3 * GUI_SMALL));

colorBox.add(presentColor);

pain.add(colorBox);
d = colorBox.getPreferredSize();
colorBox.setBounds(left, top, d.width, d.height);

top += d.height + GUI_BETWEEN;

// [ ] Use smooth text in editor window

editorAntialiasBox = new JCheckBox("Use smooth text in editor window");
Expand Down Expand Up @@ -784,6 +915,8 @@ protected void applyFrame() {
consoleSizeField.setSelectedItem(getInteger("console.font.size"));
}

setColor("run.present.bgcolor", presentColor.getBackground());

setBoolean("editor.input_method_support", inputMethodBox.isSelected()); //$NON-NLS-1$

if (autoAssociateBox != null) {
Expand Down Expand Up @@ -842,6 +975,9 @@ public void run() {
fontSizeField.setSelectedItem(getInteger("editor.font.size"));
consoleSizeField.setSelectedItem(getInteger("console.font.size"));

presentColor.setBackground(Preferences.getColor("run.present.bgcolor"));
presentColorHex.setText(Preferences.get("run.present.bgcolor").substring(1));

memoryOverrideBox.
setSelected(getBoolean("run.options.memory")); //$NON-NLS-1$
memoryField.
Expand Down