diff --git a/app/src/processing/app/EditorHeader.java b/app/src/processing/app/EditorHeader.java index 0c86a07e8..31f65187c 100755 --- a/app/src/processing/app/EditorHeader.java +++ b/app/src/processing/app/EditorHeader.java @@ -42,11 +42,13 @@ 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 NOTCH = 4; + static final int NOTCH = 0; // how far to raise the tab from the bottom of this Component - static final int TAB_HEIGHT = 27; + static final int TAB_HEIGHT = 25; + // line that continues across all of the tabs for the current one + static final int TAB_STRETCH = 3; // amount of margin on the left/right for the text on the tab - static final int TEXT_MARGIN = 5; + static final int TEXT_MARGIN = 10; // 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; @@ -54,6 +56,7 @@ public class EditorHeader extends JComponent { Color backgroundColor; Color textColor[] = new Color[2]; Color tabColor[] = new Color[2]; + Color modifiedColor; Editor editor; @@ -196,6 +199,8 @@ public class EditorHeader extends JComponent { tabColor[SELECTED] = mode.getColor("header.tab.selected.color"); tabColor[UNSELECTED] = mode.getColor("header.tab.unselected.color"); + + modifiedColor = mode.getColor("editor.selection.color"); } @@ -262,7 +267,8 @@ public class EditorHeader extends JComponent { // EditorToolbar.BACKGROUND_WIDTH, // EditorToolbar.BACKGROUND_HEIGHT, null); // } - editor.getMode().drawBackground(g, EditorToolbar.BUTTON_HEIGHT); + //editor.getMode().drawBackground(g, EditorToolbar.BUTTON_HEIGHT); + editor.getMode().drawBackground(g, Preferences.GRID_SIZE); // int codeCount = sketch.getCodeCount(); // if ((tabLeft == null) || (tabLeft.length < codeCount)) { @@ -292,10 +298,12 @@ public class EditorHeader extends JComponent { // hide extensions for .pde files (or whatever else is the norm elsewhere boolean hide = editor.getMode().hideExtension(code.getExtension()); - String codeName = hide ? code.getPrettyName() : code.getFileName(); +// String codeName = hide ? code.getPrettyName() : code.getFileName(); // if modified, add the li'l glyph next to the name - tab.text = " " + codeName + (code.isModified() ? " \u00A7" : " "); - +// tab.text = " " + codeName + (code.isModified() ? " \u00A7" : " "); +// tab.text = " " + codeName + " "; + tab.text = hide ? code.getPrettyName() : code.getFileName(); + tab.textWidth = (int) font.getStringBounds(tab.text, g2.getFontRenderContext()).getWidth(); } @@ -345,9 +353,14 @@ public class EditorHeader extends JComponent { Sketch sketch = editor.getSketch(); int x = left; - final int bottom = getHeight(); + final int bottom = getHeight() - TAB_STRETCH; final int top = bottom - TAB_HEIGHT; GeneralPath path = null; + + if (g != null) { + g.setColor(tabColor[SELECTED]); + g.fillRect(0, bottom, getWidth(), TAB_STRETCH); + } for (int i = 0; i < sketch.getCodeCount(); i++) { SketchCode code = sketch.getCode(i); @@ -393,11 +406,8 @@ public class EditorHeader extends JComponent { g.setColor(tabColor[state]); g.fill(path); //g.drawImage(pieces[state][RIGHT], x, 0, PIECE_WIDTH, PIECE_HEIGHT, null); - } - if (tab.textVisible) { -// int textLeft = contentLeft + (pieceWidth - tab.textWidth) / 2; - if (g != null) { + if (tab.textVisible) { int textLeft = tab.left + ((tab.right - tab.left) - tab.textWidth) / 2; g.setColor(textColor[state]); // int baseline = (int) Math.ceil((sizeH + fontAscent) / 2.0); @@ -409,6 +419,11 @@ public class EditorHeader extends JComponent { // g.drawLine(tab.left, baseline-fontAscent, tab.right, baseline-fontAscent); // g.drawLine(tab.left, baseline, tab.right, baseline); } + + if (code.isModified()) { + g.setColor(modifiedColor); + g.drawLine(tab.left + NOTCH, top, tab.right - NOTCH, top); + } } // if (g != null) { @@ -416,6 +431,7 @@ public class EditorHeader extends JComponent { // } // x += PIECE_WIDTH - 1; // overlap by 1 pixel x += 1; + } return x <= right; } @@ -590,18 +606,18 @@ public class EditorHeader extends JComponent { public Dimension getMinimumSize() { - if (Base.isMacOS()) { - return new Dimension(300, Preferences.GRID_SIZE); - } - return new Dimension(300, Preferences.GRID_SIZE - 1); +// if (Base.isMacOS()) { + return new Dimension(300, Preferences.GRID_SIZE); +// } +// return new Dimension(300, Preferences.GRID_SIZE - 1); } public Dimension getMaximumSize() { - if (Base.isMacOS()) { - return new Dimension(3000, Preferences.GRID_SIZE); - } - return new Dimension(3000, Preferences.GRID_SIZE - 1); +// if (Base.isMacOS()) { + return new Dimension(3000, Preferences.GRID_SIZE); +// } +// return new Dimension(3000, Preferences.GRID_SIZE - 1); } diff --git a/app/src/processing/app/EditorToolbar.java b/app/src/processing/app/EditorToolbar.java index b0a4d2702..1e902a713 100644 --- a/app/src/processing/app/EditorToolbar.java +++ b/app/src/processing/app/EditorToolbar.java @@ -39,7 +39,7 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList /** Width of each toolbar button. */ static final int BUTTON_WIDTH = 27; /** Height of each toolbar button. */ - static final int BUTTON_HEIGHT = 32; +// static final int BUTTON_HEIGHT = 32; /** 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. */ @@ -149,7 +149,7 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList for (int i = 0; i < count; i++) { for (int state = 0; state < 3; state++) { - Image image = new BufferedImage(BUTTON_WIDTH*res, BUTTON_HEIGHT*res, BufferedImage.TYPE_INT_ARGB); + 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, @@ -223,7 +223,7 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList // g.drawImage(stateImage[i], x1[i], y1, null); // } for (Button b : buttons) { - g.drawImage(b.stateImage, b.left, 0, BUTTON_WIDTH, BUTTON_HEIGHT, null); + g.drawImage(b.stateImage, b.left, 0, BUTTON_WIDTH, Preferences.GRID_SIZE, null); } g.setColor(statusColor); @@ -242,7 +242,7 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList // if (currentRollover != -1) { if (rollover != null) { //int statusY = (BUTTON_HEIGHT + g.getFontMetrics().getAscent()) / 2; - int statusY = (BUTTON_HEIGHT + statusAscent) / 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); @@ -503,12 +503,12 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList public Dimension getMinimumSize() { - return new Dimension((buttons.size() + 1)*BUTTON_WIDTH, BUTTON_HEIGHT); + return new Dimension((buttons.size() + 1)*BUTTON_WIDTH, Preferences.GRID_SIZE); } public Dimension getMaximumSize() { - return new Dimension(3000, BUTTON_HEIGHT); + return new Dimension(3000, Preferences.GRID_SIZE); } diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 086c16c7a..404351074 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -89,11 +89,10 @@ public class Preferences { * inside a static block. */ static public int BUTTON_HEIGHT = 24; - - // value for the size bars, buttons, etc - - static final int GRID_SIZE = 33; - + + /** height of the EditorHeader, EditorToolbar, and EditorStatus */ + static final int GRID_SIZE = 32; + //static final int GRID_SIZE = 33; // indents and spacing standards. these probably need to be modified // per platform as well, since macosx is so huge, windows is smaller,