a little further along with the cleanups

This commit is contained in:
Ben Fry
2015-03-31 20:46:06 -04:00
parent 986d7615dd
commit 7aa709f366
5 changed files with 51 additions and 34 deletions
+1 -1
View File
@@ -2601,7 +2601,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
getRootPane().putClientProperty("Window.documentFile", null);
}
toolbar.setText(sketch.getName());
// toolbar.setText(sketch.getName());
}
+2 -2
View File
@@ -47,8 +47,8 @@ public class EditorHeader extends JComponent {
// distance from the righthand side of a tab to the drop-down arrow
// static final int ARROW_GAP_WIDTH = 8;
// indent x/y for notch on the tab
static final int ARROW_TOP = 14;
static final int ARROW_BOTTOM = 23;
static final int ARROW_TOP = 12;
static final int ARROW_BOTTOM = 20;
static final int ARROW_WIDTH = 9;
// static final int NOTCH = 0;
+39 -28
View File
@@ -50,7 +50,7 @@ abstract public class EditorToolbar extends JPanel {
protected EditorButton runButton;
protected EditorButton stopButton;
protected EditorButton currentButton;
// protected EditorButton currentButton;
protected Box box;
protected JLabel label;
@@ -96,14 +96,20 @@ abstract public class EditorToolbar extends JPanel {
box = Box.createHorizontalBox();
box.add(Box.createHorizontalStrut(Editor.LEFT_GUTTER));
box.add(runButton);
box.add(Box.createHorizontalStrut(GAP));
box.add(stopButton);
box.add(Box.createHorizontalStrut(LABEL_GAP));
label = new JLabel();
label.setFont(mode.getFont("toolbar.sketch.font"));
label.setForeground(mode.getColor("toolbar.sketch.color"));
label.setFont(mode.getFont("toolbar.rollover.font"));
label.setForeground(mode.getColor("toolbar.rollover.color"));
box.add(label);
currentButton = runButton;
// currentButton = runButton;
runButton.setRolloverLabel(label);
stopButton.setRolloverLabel(label);
box.add(Box.createHorizontalGlue());
addModeButtons(box);
@@ -125,9 +131,9 @@ abstract public class EditorToolbar extends JPanel {
// }
public void setText(String text) {
label.setText(text);
}
// public void setText(String text) {
// label.setText(text);
// }
public void paintComponent(Graphics g) {
@@ -152,22 +158,22 @@ abstract public class EditorToolbar extends JPanel {
// }
protected void swapButton(EditorButton replacement) {
if (currentButton != replacement) {
box.remove(currentButton);
box.add(replacement, 1); // has to go after the strut
box.revalidate();
box.repaint(); // may be needed
currentButton = replacement;
}
}
// protected void swapButton(EditorButton replacement) {
// if (currentButton != replacement) {
// box.remove(currentButton);
// box.add(replacement, 1); // has to go after the strut
// box.revalidate();
// box.repaint(); // may be needed
// currentButton = replacement;
// }
// }
public void activateRun() {
//runButton.setPressed(true);
// Rectangle bounds = runButton.getBounds();
// remove(runButton);
swapButton(stopButton);
// //runButton.setPressed(true);
//// Rectangle bounds = runButton.getBounds();
//// remove(runButton);
// swapButton(stopButton);
}
@@ -181,7 +187,7 @@ abstract public class EditorToolbar extends JPanel {
public void deactivateStop() {
swapButton(runButton);
// swapButton(runButton);
}
@@ -218,14 +224,16 @@ abstract public class EditorToolbar extends JPanel {
final int MODE_GAP_WIDTH = 13;
final int ARROW_GAP_WIDTH = 6;
final int ARROW_WIDTH = 8;
final int ARROW_TOP = 21;
final int ARROW_BOTTOM = 29;
final int ARROW_WIDTH = 6;
final int ARROW_TOP = 15;
final int ARROW_BOTTOM = 21;
int[] triangleX = new int[3];
int[] triangleY = new int[] { ARROW_TOP, ARROW_TOP, ARROW_BOTTOM };
Image background;
// Image background;
Color backgroundColor;
@SuppressWarnings("deprecation")
public ModeSelector() {
@@ -243,7 +251,8 @@ abstract public class EditorToolbar extends JPanel {
}
});
background = mode.getGradient("reversed", 100, EditorButton.DIM);
//background = mode.getGradient("reversed", 100, EditorButton.DIM);
backgroundColor = mode.getColor("mode.background.color");
}
@Override
@@ -276,10 +285,12 @@ abstract public class EditorToolbar extends JPanel {
FontMetrics metrics = g.getFontMetrics();
titleWidth = metrics.stringWidth(title);
g.drawImage(background, 0, 0, width, height, this);
//g.drawImage(background, 0, 0, width, height, this);
g.setColor(backgroundColor);
g.fillRect(0, 0, width, height);
g.setColor(titleColor);
g.drawString(title, MODE_GAP_WIDTH, (height + titleAscent) / 2);
g.drawString(title.toUpperCase(), MODE_GAP_WIDTH, (height + titleAscent) / 2);
int x = MODE_GAP_WIDTH + titleWidth + ARROW_GAP_WIDTH;
triangleX[0] = x;
+7 -3
View File
@@ -50,18 +50,22 @@ divider.dot.color = #505050
# TOOLBAR BUTTON TEXT
#buttons.status.font = processing.sans,bold,13
#buttons.status.color = #ffffff
toolbar.sketch.font = processing.sans,plain,24
toolbar.sketch.color = #ffffff
#toolbar.sketch.font = processing.sans,plain,24
#toolbar.sketch.color = #ffffff
toolbar.rollover.font = processing.sans,plain,12
toolbar.rollover.color = #ffffff
toolbar.gradient.top = #142c40
toolbar.gradient.bottom = #132638
# MODE SELECTOR
mode.title.font = processing.sans,bold,15
#mode.title.font = processing.sans,bold,15
mode.title.font = processing.sans,plain,12
mode.title.color = #ffffff
# outline color of the mode button
#mode.button.color = #ffffff
#mode.button.gap = 13
#mode.arrow.width
mode.background.color = #3D5362
# LINE STATUS
# The editor line number status bar at the bottom of the screen
@@ -41,6 +41,7 @@ public class JavaToolbar extends EditorToolbar {
}
/*
public void addModeButtons(Box box) {
EditorButton debugButton = new EditorButton(mode, "/lib/toolbar/debug",
Language.text("toolbar.debug")) {
@@ -54,6 +55,7 @@ public class JavaToolbar extends EditorToolbar {
box.add(debugButton);
addGap(box);
}
*/
@Override