1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-20 14:54:31 +01:00

Added some missing Theme.scale(..)

Now toolbar and header are correctly rendered
This commit is contained in:
Cristian Maglie 2016-01-02 20:17:45 +01:00
parent 967153fe87
commit e2fec88f5f
3 changed files with 18 additions and 11 deletions

View File

@ -35,6 +35,7 @@ import java.io.IOException;
import javax.swing.*;
import static processing.app.Theme.scale;
/**
* Sketch tabs at the top of the editor window.
@ -71,10 +72,10 @@ 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_WIDTH = scale(4);
// value for the size bars, buttons, etc
static final int GRID_SIZE = Theme.scale(33);
static final int GRID_SIZE = scale(33);
static Image[][] pieces;
@ -238,7 +239,7 @@ public class EditorHeader extends JComponent {
tabRight = new int[codeCount];
}
int x = 6; // offset from left edge of the component
int x = scale(6); // offset from left edge of the component
for (int i = 0; i < sketch.getCodeCount(); i++) {
SketchCode code = sketch.getCode(i);
@ -249,6 +250,7 @@ public class EditorHeader extends JComponent {
String text = " " + codeName + (code.isModified() ? " \u00A7" : " ");
Graphics2D g2 = (Graphics2D) g;
int textWidth = (int)
font.getStringBounds(text, g2.getFontRenderContext()).getWidth();

View File

@ -30,14 +30,17 @@ import processing.app.helpers.OSUtils;
import processing.app.helpers.PreferencesMap;
import static processing.app.I18n.tr;
import static processing.app.Theme.scale;
/**
* Li'l status bar fella that shows the line number.
*/
public class EditorLineStatus extends JComponent {
int start = -1, stop;
Image resize;
private static final int RESIZE_IMAGE_SIZE = scale(20);
Color foreground;
Color background;
@ -50,12 +53,11 @@ public class EditorLineStatus extends JComponent {
String name = "";
String serialport = "";
public EditorLineStatus() {
background = Theme.getColor("linestatus.bgcolor");
font = Theme.getFont("linestatus.font");
foreground = Theme.getColor("linestatus.color");
high = Theme.scale(Theme.getInteger("linestatus.height"));
high = scale(Theme.getInteger("linestatus.height"));
if (OSUtils.isMacOS()) {
resize = Theme.getThemeImage("resize.png", this);
@ -103,17 +105,18 @@ public class EditorLineStatus extends JComponent {
g.setFont(font);
g.setColor(foreground);
int baseline = (high + g.getFontMetrics().getAscent()) / 2;
g.drawString(text, 6, baseline);
g.drawString(text, scale(6), baseline);
g.setColor(messageForeground);
String tmp = I18n.format(tr("{0} on {1}"), name, serialport);
Rectangle2D bounds = g.getFontMetrics().getStringBounds(tmp, null);
g.drawString(tmp, size.width - (int) bounds.getWidth() -20 , baseline);
g.drawString(tmp, size.width - (int) bounds.getWidth() - RESIZE_IMAGE_SIZE,
baseline);
if (OSUtils.isMacOS()) {
g.drawImage(resize, size.width - 20, 0, this);
g.drawImage(resize, size.width - RESIZE_IMAGE_SIZE, 0, this);
}
}

View File

@ -146,9 +146,11 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
for (int state = 0; state < 3; state++) {
Image image = createImage(BUTTON_WIDTH, BUTTON_HEIGHT);
Graphics g = image.getGraphics();
g.drawImage(allButtons,
-(i * BUTTON_IMAGE_SIZE) - 3,
(-2 + state) * BUTTON_IMAGE_SIZE, null);
g.setColor(bgcolor);
g.fillRect(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
int offset = (BUTTON_IMAGE_SIZE - BUTTON_WIDTH) / 2;
g.drawImage(allButtons, -(i * BUTTON_IMAGE_SIZE) - offset,
(-2 + state) * BUTTON_IMAGE_SIZE, null);
buttonImages[i][state] = image;
}
}