tabs replaced with new design

This commit is contained in:
Ben Fry
2015-01-30 11:27:00 -05:00
parent 4dfd6e08df
commit ddd166ffba
8 changed files with 134 additions and 677 deletions

View File

@@ -3,6 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2013-15 The Processing Foundation
Copyright (c) 2004-13 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
@@ -35,25 +36,33 @@ import javax.swing.*;
* Sketch tabs at the top of the editor window.
*/
public class EditorHeader extends JComponent {
// height of this tab bar
static final int HIGH = 36;
// standard UI sizing (OS-specific, but generally consistent)
static final int SCROLLBAR_WIDTH = 16;
// static final int SCROLLBAR_WIDTH = 16;
// amount of space on the left edge before the tabs start
static final int MARGIN_WIDTH = 6;
static final int MARGIN_WIDTH = Editor.GUTTER;
static final int ARROW_TAB_WIDTH = 23;
// distance from the righthand side of a tab to the drop-down arrow
static final int ARROW_GAP_WIDTH = 8;
// static final int ARROW_GAP_WIDTH = 8;
// indent x/y for notch on the tab
static final int NOTCH = 0;
static final int ARROW_TOP = 14;
static final int ARROW_BOTTOM = 23;
static final int ARROW_WIDTH = 9;
// static final int NOTCH = 0;
// how far to raise the tab from the bottom of this Component
static final int TAB_HEIGHT = 25;
// line that continues across all of the tabs for the current one
static final int TAB_STRETCH = 3;
static final int TAB_HEIGHT = HIGH;
// // line that continues across all of the tabs for the current one
// static final int TAB_STRETCH = 3;
// amount of extra space between individual tabs
static final int TAB_BETWEEN = 2;
static final int TAB_BETWEEN = 4;
// amount of margin on the left/right for the text on the tab
static final int TEXT_MARGIN = 10;
static final int TEXT_MARGIN = 16;
// width of the tab when no text visible
// (total tab width will be this plus TEXT_MARGIN*2)
static final int NO_TEXT_WIDTH = 10;
static final int NO_TEXT_WIDTH = 16;
Color bgColor;
// boolean hiding;
@@ -62,6 +71,7 @@ public class EditorHeader extends JComponent {
Color textColor[] = new Color[2];
Color tabColor[] = new Color[2];
Color modifiedColor;
Color arrowColor;
Editor editor;
@@ -80,7 +90,7 @@ public class EditorHeader extends JComponent {
//
static final String STATUS[] = { "unsel", "sel" };
// static final String STATUS[] = { "unsel", "sel" };
static final int UNSELECTED = 0;
static final int SELECTED = 1;
@@ -90,13 +100,13 @@ public class EditorHeader extends JComponent {
// static final int RIGHT = 2;
// static final int MENU = 3;
static final int PIECE_WIDTH = 4;
static final int PIECE_HEIGHT = 33;
Image[][] pieces;
// static final int PIECE_WIDTH = 4;
// static final int PIECE_HEIGHT = 33;
// Image[][] pieces;
static final int ARROW_WIDTH = 14;
static final int ARROW_HEIGHT = 14;
static Image tabArrow;
// static final int ARROW_WIDTH = 14;
// static final int ARROW_HEIGHT = 14;
// static Image tabArrow;
//
@@ -105,11 +115,15 @@ public class EditorHeader extends JComponent {
int imageW, imageH;
String lastNoticeName;
Image gradient;
public EditorHeader(Editor eddie) {
this.editor = eddie;
gradient = editor.getMode().getGradient("header", 400, HIGH);
updateMode();
addMouseListener(new MouseAdapter() {
@@ -167,40 +181,13 @@ public class EditorHeader extends JComponent {
public void updateMode() {
Mode mode = editor.getMode();
// int res = Toolkit.isRetina() ? 2 : 1;
// String suffix = "-2x.png"; // wishful thinking
// // Some modes may not have a 2x version. If a mode doesn't have a 1x
// // version, this will cause an error... they should always have 1x.
// if (res == 2) {
// if (!mode.getContentFile(tabFile(0, 0) + suffix).exists()) {
// res = 1;
// }
// if (tabArrow == null) {
// String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png";
// tabArrow = Toolkit.getLibImage("tab-arrow" + suffix);
// }
// if (res == 1) {
// suffix = ".png";
// if (!mode.getContentFile(tabFile(0, 0) + suffix).exists()) {
// suffix = ".gif";
// }
// }
//
// pieces = new Image[STATUS.length][WHERE.length];
// for (int status = 0; status < STATUS.length; status++) {
// for (int where = 0; where < WHERE.length; where++) {
// //String filename = "theme/tab-" + STATUS[i] + "-" + WHERE[j] + ".gif";
// pieces[status][where] = mode.loadImage(tabFile(status, where) + suffix);
// }
// }
if (tabArrow == null) {
String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png";
tabArrow = Toolkit.getLibImage("tab-arrow" + suffix);
}
bgColor = mode.getColor("header.bgcolor");
// hiding = Preferences.getBoolean("buttons.hide.image");
// hideColor = mode.getColor("buttons.hide.color");
textColor[SELECTED] = mode.getColor("header.text.selected.color");
textColor[UNSELECTED] = mode.getColor("header.text.unselected.color");
font = mode.getFont("header.text.font");
@@ -208,6 +195,7 @@ public class EditorHeader extends JComponent {
tabColor[SELECTED] = mode.getColor("header.tab.selected.color");
tabColor[UNSELECTED] = mode.getColor("header.tab.unselected.color");
arrowColor = mode.getColor("header.tab.arrow.color");
modifiedColor = mode.getColor("editor.selection.color");
}
@@ -249,32 +237,13 @@ public class EditorHeader extends JComponent {
Graphics g = offscreen.getGraphics();
g.setFont(font); // need to set this each time through
// metrics = g.getFontMetrics();
// fontAscent = metrics.getAscent();
if (fontAscent == 0) {
fontAscent = (int) Toolkit.getAscent(g);
}
Graphics2D g2 = Toolkit.prepareGraphics(g);
/*
if (Toolkit.highResDisplay()) {
// scale everything 2x, will be scaled down when drawn to the screen
g2.scale(2, 2);
}
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
*/
// set the background for the offscreen
//g.setColor(hiding ? hideColor : bgColor);
g.setColor(new Color(0, 0, 0, 0));
g.fillRect(0, 0, imageW, imageH);
// if (!hiding) {
// editor.getMode().drawBackground(g, Preferences.GRID_SIZE);
// }
g.drawImage(gradient, 0, 0, imageW, imageH, this);
if (tabs.length != sketch.getCodeCount()) {
tabs = new Tab[sketch.getCodeCount()];
@@ -284,8 +253,7 @@ public class EditorHeader extends JComponent {
visitOrder = new Tab[sketch.getCodeCount() - 1];
}
int leftover =
ARROW_GAP_WIDTH + ARROW_WIDTH + MARGIN_WIDTH; // + SCROLLBAR_WIDTH;
int leftover = TAB_BETWEEN + ARROW_TAB_WIDTH; // + MARGIN_WIDTH; // + SCROLLBAR_WIDTH;
int tabMax = getWidth() - leftover;
// reset all tab positions
@@ -335,13 +303,24 @@ public class EditorHeader extends JComponent {
placeTabs(MARGIN_WIDTH, tabMax, g2);
// draw the dropdown menu target
menuLeft = tabs[tabs.length - 1].right + ARROW_GAP_WIDTH;
menuRight = menuLeft + ARROW_WIDTH;
int arrowY = (getHeight() - TAB_HEIGHT - TAB_STRETCH) + (TAB_HEIGHT - ARROW_HEIGHT)/2;
g.drawImage(tabArrow, menuLeft, arrowY,
ARROW_WIDTH, ARROW_HEIGHT, null);
// g.drawImage(pieces[popup.isVisible() ? SELECTED : UNSELECTED][MENU],
// menuLeft, 0, null);
menuLeft = tabs[tabs.length - 1].right + TAB_BETWEEN;
menuRight = menuLeft + ARROW_TAB_WIDTH;
g.setColor(tabColor[UNSELECTED]);
drawTab(g, menuLeft, menuRight);
// int arrowY = (getHeight() - TAB_HEIGHT - TAB_STRETCH) + (TAB_HEIGHT - ARROW_HEIGHT)/2;
// g.drawImage(tabArrow, menuLeft, arrowY,
// ARROW_WIDTH, ARROW_HEIGHT, null);
// TODO draw arrow here
g.setColor(arrowColor);
GeneralPath trianglePath = new GeneralPath();
float x1 = menuLeft + (ARROW_TAB_WIDTH - ARROW_WIDTH) / 2f;
float x2 = menuLeft + (ARROW_TAB_WIDTH + ARROW_WIDTH) / 2f;
trianglePath.moveTo(x1, ARROW_TOP);
trianglePath.lineTo(x2, ARROW_TOP);
trianglePath.lineTo((x1 + x2) / 2, ARROW_BOTTOM);
trianglePath.closePath();
g2.fill(trianglePath);
screen.drawImage(offscreen, 0, 0, imageW, imageH, null);
}
@@ -351,9 +330,9 @@ public class EditorHeader extends JComponent {
Sketch sketch = editor.getSketch();
int x = left;
final int bottom = getHeight() - TAB_STRETCH;
final int bottom = getHeight(); // - TAB_STRETCH;
final int top = bottom - TAB_HEIGHT;
GeneralPath path = null;
// GeneralPath path = null;
for (int i = 0; i < sketch.getCodeCount(); i++) {
SketchCode code = sketch.getCode(i);
@@ -366,13 +345,13 @@ public class EditorHeader extends JComponent {
// int pieceWidth = pieceCount * PIECE_WIDTH;
int state = (code == sketch.getCurrentCode()) ? SELECTED : UNSELECTED;
if (g != null) {
//g.drawImage(pieces[state][LEFT], x, 0, PIECE_WIDTH, PIECE_HEIGHT, null);
path = new GeneralPath();
path.moveTo(x, bottom);
path.lineTo(x, top + NOTCH);
path.lineTo(x + NOTCH, top);
}
// if (g != null) {
// //g.drawImage(pieces[state][LEFT], x, 0, PIECE_WIDTH, PIECE_HEIGHT, null);
// path = new GeneralPath();
// path.moveTo(x, bottom);
// path.lineTo(x, top + NOTCH);
// path.lineTo(x + NOTCH, top);
// }
tab.left = x;
x += TEXT_MARGIN;
// x += PIECE_WIDTH;
@@ -392,15 +371,17 @@ public class EditorHeader extends JComponent {
tab.right = x;
if (g != null) {
path.lineTo(x - NOTCH, top);
path.lineTo(x, top + NOTCH);
path.lineTo(x, bottom);
path.closePath();
g.setColor(tabColor[state]);
g.fill(path);
// have to draw an extra outline to make things line up on retina
g.draw(path);
//g.drawImage(pieces[state][RIGHT], x, 0, PIECE_WIDTH, PIECE_HEIGHT, null);
drawTab(g, tab.left, tab.right);
// path.lineTo(x - NOTCH, top);
// path.lineTo(x, top + NOTCH);
// path.lineTo(x, bottom);
// path.closePath();
// g.setColor(tabColor[state]);
// g.fill(path);
// // have to draw an extra outline to make things line up on retina
// g.draw(path);
// //g.drawImage(pieces[state][RIGHT], x, 0, PIECE_WIDTH, PIECE_HEIGHT, null);
if (tab.textVisible) {
int textLeft = tab.left + ((tab.right - tab.left) - tab.textWidth) / 2;
@@ -417,7 +398,8 @@ public class EditorHeader extends JComponent {
if (code.isModified()) {
g.setColor(modifiedColor);
g.drawLine(tab.left + NOTCH, top, tab.right - NOTCH, top);
//g.drawLine(tab.left + NOTCH, top, tab.right - NOTCH, top);
g.drawLine(tab.left, top, tab.right, top);
}
}
@@ -428,14 +410,22 @@ public class EditorHeader extends JComponent {
x += TAB_BETWEEN;
}
// Draw this last because of half-pixel overlaps on retina displays
if (g != null) {
g.setColor(tabColor[SELECTED]);
g.fillRect(0, bottom, getWidth(), TAB_STRETCH);
}
// removed 150130
// // Draw this last because of half-pixel overlaps on retina displays
// if (g != null) {
// g.setColor(tabColor[SELECTED]);
// g.fillRect(0, bottom, getWidth(), TAB_STRETCH);
// }
return x <= right;
}
private void drawTab(Graphics g, int left, int right) {
final int bottom = getHeight(); // - TAB_STRETCH;
final int top = bottom - TAB_HEIGHT;
g.fillRect(left, top, right - left, bottom - top);
}
/**
@@ -623,23 +613,17 @@ public class EditorHeader extends JComponent {
public Dimension getPreferredSize() {
return getMinimumSize();
return new Dimension(300, HIGH);
}
public Dimension getMinimumSize() {
// if (Base.isMacOS()) {
return new Dimension(300, Preferences.GRID_SIZE);
// }
// return new Dimension(300, Preferences.GRID_SIZE - 1);
return getPreferredSize();
}
public Dimension getMaximumSize() {
// if (Base.isMacOS()) {
return new Dimension(3000, Preferences.GRID_SIZE);
// }
// return new Dimension(3000, Preferences.GRID_SIZE - 1);
return new Dimension(super.getMaximumSize().width, HIGH);
}

View File

@@ -32,12 +32,11 @@ import javax.swing.*;
* Panel just below the editing area that contains status messages.
*/
public class EditorStatus extends JPanel {
static final int HIGH = 28;
Color[] bgcolor;
Color[] fgcolor;
@Deprecated
static final int BUTTON_HEIGHT = 24;
static public final int NOTICE = 0;
static public final int ERR = 1;
static public final int EDIT = 2;
@@ -392,12 +391,12 @@ public class EditorStatus extends JPanel {
public Dimension getMinimumSize() {
return new Dimension(300, Preferences.GRID_SIZE);
return new Dimension(300, HIGH);
}
public Dimension getMaximumSize() {
return new Dimension(3000, Preferences.GRID_SIZE);
return new Dimension(super.getMaximumSize().width, HIGH);
}

View File

@@ -36,7 +36,11 @@ import javax.swing.JPopupMenu;
* Run/Stop button plus Mode selection
*/
abstract public class EditorToolbar extends JPanel {
// haven't decided how to handle this/how to make public/consistency
// for components/does it live in theme.txt
static final int HIGH = 80;
// gap between buttons
static final int GAP = 8;
protected Editor editor;
protected Base base;
@@ -51,8 +55,8 @@ abstract public class EditorToolbar extends JPanel {
// int GRADIENT_TOP = 192;
// int GRADIENT_BOTTOM = 246;
protected Image backgroundGradient;
protected Image reverseGradient;
protected Image gradient;
// protected Image reverseGradient;
public EditorToolbar(Editor editor) {
@@ -64,8 +68,8 @@ abstract public class EditorToolbar extends JPanel {
//gradient = createGradient();
//System.out.println(gradient);
backgroundGradient = mode.getGradient("header", 400, HIGH);
reverseGradient = mode.getGradient("reversed", 100, EditorButton.DIM);
gradient = mode.getGradient("toolbar", 400, HIGH);
// reverseGradient = mode.getGradient("reversed", 100, EditorButton.DIM);
runButton = new EditorButton(mode,
"/lib/toolbar/run",
@@ -120,7 +124,7 @@ abstract public class EditorToolbar extends JPanel {
public void paintComponent(Graphics g) {
// super.paintComponent(g);
Dimension size = getSize();
g.drawImage(backgroundGradient, 0, 0, size.width, size.height, this);
g.drawImage(gradient, 0, 0, size.width, size.height, this);
}
@@ -128,6 +132,11 @@ abstract public class EditorToolbar extends JPanel {
}
public void addGap(Box box) {
box.add(Box.createHorizontalStrut(GAP));
}
// public Component createModeSelector() {
// return new ModeSelector();
// }
@@ -205,7 +214,8 @@ abstract public class EditorToolbar extends JPanel {
int[] triangleX = new int[3];
int[] triangleY = new int[] { ARROW_TOP, ARROW_TOP, ARROW_BOTTOM };
Image background;
@SuppressWarnings("deprecation")
public ModeSelector() {
@@ -222,6 +232,8 @@ abstract public class EditorToolbar extends JPanel {
popup.show(ModeSelector.this, event.getX(), event.getY());
}
});
background = mode.getGradient("reversed", 100, EditorButton.DIM);
}
@Override
@@ -254,7 +266,7 @@ abstract public class EditorToolbar extends JPanel {
FontMetrics metrics = g.getFontMetrics();
titleWidth = metrics.stringWidth(title);
g.drawImage(reverseGradient, 0, 0, width, height, this);
g.drawImage(background, 0, 0, width, height, this);
g.setColor(titleColor);
g.drawString(title, MODE_GAP_WIDTH, (height + titleAscent) / 2);
@@ -288,550 +300,4 @@ abstract public class EditorToolbar extends JPanel {
return getPreferredSize();
}
}
}
//public abstract class EditorToolbar extends JComponent implements MouseInputListener, KeyListener {
//
// /** Width of each toolbar button. */
// static final int BUTTON_WIDTH = 27;
// /** The amount of space between groups of buttons on the toolbar. */
// static final int BUTTON_GAP = 5;
// /** Size (both width and height) of the buttons in the source image. */
// static final int BUTTON_IMAGE_SIZE = 33;
//
// static final int INACTIVE = 0;
// static final int ROLLOVER = 1;
// static final int ACTIVE = 2;
//
//
// Image offscreen;
// int width, height;
//
// Color bgColor;
// boolean hiding;
// Color hideColor;
//
// protected Button rollover;
//
// Font statusFont;
// int statusAscent;
// Color statusColor;
//
// boolean shiftPressed;
//
// // what the mode indicator looks like
// Color modeButtonColor;
// Font modeTextFont;
// int modeTextAscent;
// Color modeTextColor;
// String modeTitle;
// int modeX1, modeY1;
// int modeX2, modeY2;
// JMenu modeMenu;
//
// protected ArrayList<Button> buttons;
//
// static final int ARROW_WIDTH = 7;
// static final int ARROW_HEIGHT = 6;
// static Image modeArrow;
//
//
// public EditorToolbar(Editor editor, Base base) { //, JMenu menu) {
// this.editor = editor;
// this.base = base;
//// this.menu = menu;
//
// buttons = new ArrayList<Button>();
// rollover = null;
//
// mode = editor.getMode();
// bgColor = mode.getColor("buttons.bgcolor");
// statusFont = mode.getFont("buttons.status.font");
// statusColor = mode.getColor("buttons.status.color");
//// modeTitle = mode.getTitle().toUpperCase();
// modeTitle = mode.getTitle();
// modeTextFont = mode.getFont("mode.button.font");
// modeButtonColor = mode.getColor("mode.button.color");
//
// hiding = Preferences.getBoolean("buttons.hide.image");
// hideColor = mode.getColor("buttons.hide.color");
//
// if (modeArrow == null) {
// String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png";
// modeArrow = Toolkit.getLibImage("mode-arrow" + suffix);
// }
//
// addMouseListener(this);
// addMouseMotionListener(this);
// }
//
//
// /** Load images and add toolbar buttons */
// abstract public void init();
//
//
// /**
// * Load button images and slice them up. Only call this from paintComponent,
// * or when the comp is displayable, otherwise createImage() might fail.
// * (Using BufferedImage instead of createImage() nowadays, so that may
// * no longer be relevant.)
// */
// public Image[][] loadImages() {
// int res = Toolkit.highResDisplay() ? 2 : 1;
//
// String suffix = null;
// Image allButtons = null;
// // Some modes may not have a 2x version. If a mode doesn't have a 1x
// // version, this will cause an error... they should always have 1x.
// if (res == 2) {
// suffix = "-2x.png";
// allButtons = mode.loadImage("theme/buttons" + suffix);
// if (allButtons == null) {
// res = 1; // take him down a notch
// }
// }
// if (res == 1) {
// suffix = ".png";
// allButtons = mode.loadImage("theme/buttons" + suffix);
// if (allButtons == null) {
// // use the old (pre-2.0b9) file name
// suffix = ".gif";
// allButtons = mode.loadImage("theme/buttons" + suffix);
// }
// }
//
// int count = allButtons.getWidth(this) / BUTTON_WIDTH*res;
// Image[][] buttonImages = new Image[count][3];
//
// for (int i = 0; i < count; i++) {
// for (int state = 0; state < 3; state++) {
// Image image = new BufferedImage(BUTTON_WIDTH*res, Preferences.GRID_SIZE*res, BufferedImage.TYPE_INT_ARGB);
// Graphics g = image.getGraphics();
// g.drawImage(allButtons,
// -(i*BUTTON_IMAGE_SIZE*res) - 3,
// (state-2)*BUTTON_IMAGE_SIZE*res, null);
// g.dispose();
// buttonImages[i][state] = image;
// }
// }
//
// return buttonImages;
// }
//
//
//// abstract static public String getTitle(int index, boolean shift);
//
//
// @Override
// public void paintComponent(Graphics screen) {
// if (buttons.size() == 0) {
// init();
// }
//
// Dimension size = getSize();
// if ((offscreen == null) ||
// (size.width != width) || (size.height != height)) {
// if (Toolkit.highResDisplay()) {
// offscreen = createImage(size.width*2, size.height*2);
// } else {
// offscreen = createImage(size.width, size.height);
// }
//
// width = size.width;
// height = size.height;
//
// int offsetX = 3;
// for (Button b : buttons) {
// b.left = offsetX;
// if (b.gap) {
// b.left += BUTTON_GAP;
// }
// b.right = b.left + BUTTON_WIDTH;
// offsetX = b.right;
// }
//// for (int i = 0; i < buttons.size(); i++) {
//// x1[i] = offsetX;
//// if (i == 2) x1[i] += BUTTON_GAP;
//// x2[i] = x1[i] + BUTTON_WIDTH;
//// offsetX = x2[i];
//// }
// }
// Graphics g = offscreen.getGraphics();
// /*Graphics2D g2 =*/ Toolkit.prepareGraphics(g);
//
// g.setColor(hiding ? hideColor : bgColor);
// g.fillRect(0, 0, width, height);
//// if (backgroundImage != null) {
//// g.drawImage(backgroundImage, 0, 0, BACKGROUND_WIDTH, BACKGROUND_HEIGHT, null);
//// }
//// if (!hiding) {
//// mode.drawBackground(g, 0);
//// }
//
//// for (int i = 0; i < buttonCount; i++) {
//// g.drawImage(stateImage[i], x1[i], y1, null);
//// }
// for (Button b : buttons) {
// g.drawImage(b.stateImage, b.left, 0, BUTTON_WIDTH, Preferences.GRID_SIZE, null);
// }
//
// g.setColor(statusColor);
// g.setFont(statusFont);
// if (statusAscent == 0) {
// statusAscent = (int) Toolkit.getAscent(g);
// }
//
// // If I ever find the guy who wrote the Java2D API, I will hurt him.
//// Graphics2D g2 = (Graphics2D) g;
//// FontRenderContext frc = g2.getFontRenderContext();
//// float statusW = (float) statusFont.getStringBounds(status, frc).getWidth();
//// float statusX = (getSize().width - statusW) / 2;
//// g2.drawString(status, statusX, statusY);
//
//// if (currentRollover != -1) {
// if (rollover != null) {
// //int statusY = (BUTTON_HEIGHT + g.getFontMetrics().getAscent()) / 2;
// int statusY = (Preferences.GRID_SIZE + statusAscent) / 2;
// //String status = shiftPressed ? titleShift[currentRollover] : title[currentRollover];
// String status = shiftPressed ? rollover.titleShift : rollover.title;
// g.drawString(status, buttons.size() * BUTTON_WIDTH + 3 * BUTTON_GAP, statusY);
// }
//
// g.setFont(modeTextFont);
// FontMetrics metrics = g.getFontMetrics();
// if (modeTextAscent == 0) {
// modeTextAscent = (int) Toolkit.getAscent(g); //metrics.getAscent();
// }
// int modeTextWidth = metrics.stringWidth(modeTitle);
// final int modeGapWidth = 8;
// final int modeBoxHeight = 20;
// modeX2 = getWidth() - 16;
// modeX1 = modeX2 - (modeGapWidth + modeTextWidth + modeGapWidth + ARROW_WIDTH + modeGapWidth);
//// modeY1 = 8; //(getHeight() - modeBoxHeight) / 2;
// modeY1 = (getHeight() - modeBoxHeight) / 2;
// modeY2 = modeY1 + modeBoxHeight; //modeY1 + modeH + modeGapV*2;
// g.setColor(modeButtonColor);
// g.drawRect(modeX1, modeY1, modeX2 - modeX1, modeY2 - modeY1 - 1);
//
// g.drawString(modeTitle,
// modeX1 + modeGapWidth,
// modeY1 + (modeBoxHeight + modeTextAscent) / 2);
// //modeY1 + modeTextAscent + (modeBoxHeight - modeTextAscent) / 2);
// g.drawImage(modeArrow,
// modeX2 - ARROW_WIDTH - modeGapWidth,
// modeY1 + (modeBoxHeight - ARROW_HEIGHT) / 2,
// ARROW_WIDTH, ARROW_HEIGHT, null);
//
//// g.drawLine(modeX1, modeY2, modeX2, modeY2);
//// g.drawLine(0, size.height, size.width, size.height);
//// g.fillRect(modeX1 - modeGapWidth*2, modeY1, modeGapWidth, modeBoxHeight);
//
// screen.drawImage(offscreen, 0, 0, size.width, size.height, null);
//
// // dim things out when not enabled (not currently in use)
//// if (!isEnabled()) {
//// screen.setColor(new Color(0, 0, 0, 100));
//// screen.fillRect(0, 0, getWidth(), getHeight());
//// }
// }
//
//
// protected void checkRollover(int x, int y) {
// Button over = findSelection(x, y);
// if (over != null) {
// // if (state[sel] != ACTIVE) {
// if (over.state != ACTIVE) {
// // setState(sel, ROLLOVER, true);
// over.setState(ROLLOVER, true);
// // currentRollover = sel;
// rollover = over;
// }
// }
// }
//
//
// public void mouseMoved(MouseEvent e) {
// if (!isEnabled()) return;
//
// // ignore mouse events before the first paintComponent() call
// if (offscreen == null) return;
//
// // TODO this isn't quite right, since it's gonna kill rollovers too
//// if (state[OPEN] != INACTIVE) {
//// // avoid flicker, since there should be another update event soon
//// setState(OPEN, INACTIVE, false);
//// }
//
// int x = e.getX();
// int y = e.getY();
//
// if (rollover != null) {
// //if (y > TOP && y < BOTTOM && x > rollover.left && x < rollover.right) {
// if (y > 0 && y < getHeight() && x > rollover.left && x < rollover.right) {
// // nothing has changed
// return;
//
// } else {
// if (rollover.state == ROLLOVER) {
// rollover.setState(INACTIVE, true);
// }
// rollover = null;
// }
// }
// checkRollover(x, y);
// }
//
//
// public void mouseDragged(MouseEvent e) { }
//
//
//// public void handleMouse(MouseEvent e) {
//// int x = e.getX();
//// int y = e.getY();
////
////// if (currentRollover != -1) {
//// if (rollover != null) {
////// if ((x > x1[currentRollover]) && (y > y1) &&
////// (x < x2[currentRollover]) && (y < y2)) {
//// if (y > y1 && y < y2 && x > rollover.left && x < rollover.right) {
//// // nothing has changed
//// return;
////
//// } else {
////// setState(currentRollover, INACTIVE, true);
//// rollover.setState(INACTIVE, true);
////// currentRollover = -1;
//// rollover = null;
//// }
//// }
////// int sel = findSelection(x, y);
//// Button over = findSelection(x, y);
//// if (over != null) {
////// if (state[sel] != ACTIVE) {
//// if (over.state != ACTIVE) {
////// setState(sel, ROLLOVER, true);
//// over.setState(ROLLOVER, true);
////// currentRollover = sel;
//// rollover = over;
//// }
//// }
//// }
//
//
//// private int findSelection(int x, int y) {
//// // if app loads slowly and cursor is near the buttons
//// // when it comes up, the app may not have time to load
//// if ((x1 == null) || (x2 == null)) return -1;
////
//// for (int i = 0; i < buttonCount; i++) {
//// if ((y > y1) && (x > x1[i]) &&
//// (y < y2) && (x < x2[i])) {
//// //System.out.println("sel is " + i);
//// return i;
//// }
//// }
//// return -1;
//// }
//
//
// private Button findSelection(int x, int y) {
// // if app loads slowly and cursor is near the buttons
// // when it comes up, the app may not have time to load
// if (offscreen != null && y > 0 && y < getHeight()) {
// for (Button b : buttons) {
// if (x > b.left && x < b.right) {
// return b;
// }
// }
// }
// return null;
// }
//
//
//// private void setState(int slot, int newState, boolean updateAfter) {
//// if (buttonImages != null) {
//// state[slot] = newState;
//// stateImage[slot] = buttonImages[which[slot]][newState];
//// if (updateAfter) {
//// repaint();
//// }
//// }
//// }
//
//
// public void mouseEntered(MouseEvent e) {
//// handleMouse(e);
// }
//
//
// public void mouseExited(MouseEvent e) {
//// // if the 'open' popup menu is visible, don't register this,
//// // because the popup being set visible will fire a mouseExited() event
//// if ((popup != null) && popup.isVisible()) return;
// // this might be better
// if (e.getComponent() != this) {
// return;
// }
//
// // TODO another weird one.. come back to this
//// if (state[OPEN] != INACTIVE) {
//// setState(OPEN, INACTIVE, true);
//// }
//// handleMouse(e);
//
// // there is no more rollover, make sure that the rollover text goes away
//// currentRollover = -1;
// if (rollover != null) {
// if (rollover.state == ROLLOVER) {
// rollover.setState(INACTIVE, true);
// }
// rollover = null;
// }
// }
//
//// int wasDown = -1;
//
//
// public void mousePressed(MouseEvent e) {
// // ignore mouse presses so hitting 'run' twice doesn't cause problems
// if (isEnabled()) {
// int x = e.getX();
// int y = e.getY();
// if (x > modeX1 && x < modeX2 && y > modeY1 && y < modeY2) {
// JPopupMenu popup = editor.getModeMenu().getPopupMenu();
// popup.show(this, x, y);
// }
//
// // Need to reset the rollover here. If the window isn't active,
// // the rollover wouldn't have been updated.
// // http://code.google.com/p/processing/issues/detail?id=561
// checkRollover(x, y);
// if (rollover != null) {
// //handlePressed(rollover);
// handlePressed(e, buttons.indexOf(rollover));
// }
// }
// }
//
//
// public void mouseClicked(MouseEvent e) { }
//
//
// public void mouseReleased(MouseEvent e) { }
//
//
//// public void handlePressed(Button b) {
//// handlePressed(buttons.indexOf(b));
//// }
//
//
// abstract public void handlePressed(MouseEvent e, int index);
//
//
// /**
// * Set a particular button to be active.
// */
// public void activate(int what) {
//// setState(what, ACTIVE, true);
// buttons.get(what).setState(ACTIVE, true);
// }
//
//
// /**
// * Set a particular button to be active.
// */
// public void deactivate(int what) {
//// setState(what, INACTIVE, true);
// buttons.get(what).setState(INACTIVE, true);
// }
//
//
// public Dimension getPreferredSize() {
// return getMinimumSize();
// }
//
//
// public Dimension getMinimumSize() {
// return new Dimension((buttons.size() + 1)*BUTTON_WIDTH, Preferences.GRID_SIZE);
// }
//
//
// public Dimension getMaximumSize() {
// return new Dimension(3000, Preferences.GRID_SIZE);
// }
//
//
// public void keyPressed(KeyEvent e) {
// if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
// shiftPressed = true;
// repaint();
// }
// }
//
//
// public void keyReleased(KeyEvent e) {
// if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
// shiftPressed = false;
// repaint();
// }
// }
//
//
// public void keyTyped(KeyEvent e) { }
//
//
// // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
//
//
// public void addButton(String title, String shiftTitle, Image[] images, boolean gap) {
// Button b = new Button(title, shiftTitle, images, gap);
// buttons.add(b);
// }
//
//
// public class Button {
// /** Button's description. */
// String title;
// /** Description of alternate behavior when shift is down. */
// String titleShift;
// /** Three state images. */
// Image[] images;
// /** Current state value, one of ACTIVE, INACTIVE, ROLLOVER. */
// int state;
// /** Current state image. */
// Image stateImage;
// /** Left and right coordinates. */
// int left, right;
// /** Whether there's a gap before this button. */
// boolean gap;
//
//// JPopupMenu popup;
//// JMenu menu;
//
//
// public Button(String title, String titleShift, Image[] images, boolean gap) {
// this.title = title;
// this.titleShift = titleShift;
// this.images = images;
// this.gap = gap;
//
// state = INACTIVE;
// stateImage = images[INACTIVE];
// }
//
//
//// public void setMenu(JMenu menu) {
//// this.menu = menu;
//// }
//
//
// public void setState(int newState, boolean updateAfter) {
// state = newState;
// stateImage = images[newState];
// if (updateAfter) {
// repaint();
// }
// }
// }
//}
}

View File

@@ -66,8 +66,8 @@ public class Preferences {
static public int BUTTON_WIDTH =
Integer.parseInt(Language.text("preferences.button.width"));
/** height of the EditorHeader, EditorToolbar, and EditorStatus */
static final int GRID_SIZE = 32;
// /** height of the EditorHeader, EditorToolbar, and EditorStatus */
// static final int GRID_SIZE = 32;
// Indents and spacing standards. These probably need to be modified
// per platform as well, because Mac OS X is so huge, Windows is smaller,

View File

@@ -552,14 +552,14 @@ public class Toolkit {
// }
static final Color CLEAR_COLOR = new Color(0, true);
// static final Color CLEAR_COLOR = new Color(0, true);
//
// static public void clearGraphics(Graphics g, int width, int height) {
// g.setColor(CLEAR_COLOR);
// g.fillRect(0, 0, width, height);
// }
static public void clearGraphics(Graphics g, int width, int height) {
g.setColor(CLEAR_COLOR);
g.fillRect(0, 0, width, height);
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

View File

@@ -10,11 +10,12 @@ status.font = processing.sans,plain,14
# TABS
# Settings for the tab area at the top.
header.text.font = processing.sans,plain,15
header.text.font = processing.sans,bold,15
header.text.selected.color = #000000
header.text.unselected.color = #ffffff
header.tab.selected.color = #ffffff
header.tab.unselected.color = #657d87
header.tab.arrow.color = #000000
header.gradient.top = #132638
header.gradient.bottom = #122535

View File

@@ -52,6 +52,7 @@ public class JavaToolbar extends EditorToolbar {
};
debugButton.setReverse();
box.add(debugButton);
addGap(box);
}

View File

@@ -132,6 +132,10 @@ _ or hide the tray when not debugging? Debug just a menu checkbox?
_ using svg images for res-indep icons/gui
_ http://stackoverflow.com/questions/2495501/swing-batik-create-an-imageicon-from-an-svg-file
what do these do, and are we doing it already?
System.setProperty("awt.useSystemAAFontSettings","on");
System.setProperty("swing.aatext", "true");
jre download/install
_ update build scripts for Windows and Linux to use JRE downloader Ant Task
_ https://github.com/processing/processing/issues/3059
@@ -142,6 +146,8 @@ _ https://github.com/processing/processing/issues/2960
_ fix file change detection on OS X
_ https://github.com/processing/processing/issues/2852
_ make the tabs have a default minimum size
_ multiple sizes as they get smaller (web browser style)
_ make examples pull/build automatic during dist
_ merge experimental into the main Java mode
_ thereby removing Java 2.0 mode from the next release