mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
Add scaling for themed fonts and graphics (hires displays) (Paul Stoffregen)
This commit is contained in:
parent
c3d2bbdb86
commit
08d35106c2
@ -157,8 +157,6 @@ public class Base {
|
||||
|
||||
BaseNoGui.initParameters(args);
|
||||
|
||||
System.setProperty("swing.aatext", PreferencesData.get("editor.antialias", "true"));
|
||||
|
||||
BaseNoGui.initVersion();
|
||||
|
||||
// if (System.getProperty("mrj.version") != null) {
|
||||
@ -207,6 +205,7 @@ public class Base {
|
||||
|
||||
// setup the theme coloring fun
|
||||
Theme.init();
|
||||
System.setProperty("swing.aatext", PreferencesData.get("editor.antialias", "true"));
|
||||
|
||||
// Set the look and feel before opening the window
|
||||
try {
|
||||
@ -1751,9 +1750,11 @@ public class Base {
|
||||
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
||||
|
||||
g.setFont(new Font("SansSerif", Font.PLAIN, 11));
|
||||
int scale = Theme.getInteger("gui.scalePercent");
|
||||
Font f = new Font("SansSerif", Font.PLAIN, 11 * scale / 100);
|
||||
g.setFont(f);
|
||||
g.setColor(Color.white);
|
||||
g.drawString(BaseNoGui.VERSION_NAME_LONG, 33, 20);
|
||||
g.drawString(BaseNoGui.VERSION_NAME_LONG, 33 * scale / 100, 20 * scale / 100);
|
||||
}
|
||||
};
|
||||
window.addMouseListener(new MouseAdapter() {
|
||||
@ -2049,6 +2050,9 @@ public class Base {
|
||||
static public Image getLibImage(String name, Component who) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
|
||||
int scale = Theme.getInteger("gui.scalePercent");
|
||||
// TODO: create high-res enlarged copies and load those if
|
||||
// the scale is more than 125%
|
||||
File imageLocation = new File(getContentFile("lib"), name);
|
||||
Image image = tk.getImage(imageLocation.getAbsolutePath());
|
||||
MediaTracker tracker = new MediaTracker(who);
|
||||
@ -2057,6 +2061,15 @@ public class Base {
|
||||
tracker.waitForAll();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
if (scale != 100) {
|
||||
int width = image.getWidth(null) * scale / 100;
|
||||
int height = image.getHeight(null) * scale / 100;
|
||||
image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||
tracker.addImage(image, 1);
|
||||
try {
|
||||
tracker.waitForAll();
|
||||
} catch (InterruptedException e) { }
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,9 @@ public class EditorHeader extends JComponent {
|
||||
|
||||
static final int PIECE_WIDTH = 4;
|
||||
|
||||
// value for the size bars, buttons, etc
|
||||
static final int GRID_SIZE = 33 * Theme.getInteger("gui.scalePercent") / 100;
|
||||
|
||||
static Image[][] pieces;
|
||||
|
||||
Image offscreen;
|
||||
@ -338,16 +341,16 @@ public class EditorHeader extends JComponent {
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
if (OSUtils.isMacOS()) {
|
||||
return new Dimension(300, Preferences.GRID_SIZE);
|
||||
return new Dimension(300, GRID_SIZE);
|
||||
}
|
||||
return new Dimension(300, Preferences.GRID_SIZE - 1);
|
||||
return new Dimension(300, GRID_SIZE - 1);
|
||||
}
|
||||
|
||||
|
||||
public Dimension getMaximumSize() {
|
||||
if (OSUtils.isMacOS()) {
|
||||
return new Dimension(3000, Preferences.GRID_SIZE);
|
||||
return new Dimension(3000, GRID_SIZE);
|
||||
}
|
||||
return new Dimension(3000, Preferences.GRID_SIZE - 1);
|
||||
return new Dimension(3000, GRID_SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class EditorLineStatus extends JComponent {
|
||||
background = Theme.getColor("linestatus.bgcolor");
|
||||
font = Theme.getFont("linestatus.font");
|
||||
foreground = Theme.getColor("linestatus.color");
|
||||
high = Theme.getInteger("linestatus.height");
|
||||
high = Theme.getInteger("linestatus.height") * Theme.getInteger("gui.scalePercent") / 100;
|
||||
|
||||
if (OSUtils.isMacOS()) {
|
||||
resize = Base.getThemeImage("resize.gif", this);
|
||||
|
@ -67,6 +67,9 @@ public class EditorStatus extends JPanel {
|
||||
FGCOLOR[5] = Theme.getColor("status.notice.fgcolor");
|
||||
}
|
||||
|
||||
// value for the size bars, buttons, etc
|
||||
static final int GRID_SIZE = 33 * Theme.getInteger("gui.scalePercent") / 100;
|
||||
|
||||
private final Editor editor;
|
||||
private final Font font;
|
||||
|
||||
@ -395,11 +398,11 @@ public class EditorStatus extends JPanel {
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
return new Dimension(300, Preferences.GRID_SIZE);
|
||||
return new Dimension(300, GRID_SIZE);
|
||||
}
|
||||
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(3000, Preferences.GRID_SIZE);
|
||||
return new Dimension(3000, GRID_SIZE);
|
||||
}
|
||||
|
||||
public boolean isErr() {
|
||||
|
@ -56,19 +56,19 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
/**
|
||||
* Width of each toolbar button.
|
||||
*/
|
||||
private static final int BUTTON_WIDTH = 27;
|
||||
private static final int BUTTON_WIDTH = 27 * Theme.getInteger("gui.scalePercent") / 100;
|
||||
/**
|
||||
* Height of each toolbar button.
|
||||
*/
|
||||
private static final int BUTTON_HEIGHT = 32;
|
||||
private static final int BUTTON_HEIGHT = 32 * Theme.getInteger("gui.scalePercent") / 100;
|
||||
/**
|
||||
* The amount of space between groups of buttons on the toolbar.
|
||||
*/
|
||||
private static final int BUTTON_GAP = 5;
|
||||
private static final int BUTTON_GAP = 5 * Theme.getInteger("gui.scalePercent") / 100;
|
||||
/**
|
||||
* Size of the button image being chopped up.
|
||||
*/
|
||||
private static final int BUTTON_IMAGE_SIZE = 33;
|
||||
private static final int BUTTON_IMAGE_SIZE = 33 * Theme.getInteger("gui.scalePercent") / 100;
|
||||
|
||||
|
||||
private static final int RUN = 0;
|
||||
@ -437,7 +437,7 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
|
||||
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(3000, BUTTON_HEIGHT);
|
||||
return new Dimension(3000 * Theme.getInteger("gui.scalePercent") / 100, BUTTON_HEIGHT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,11 +69,6 @@ public class Preferences {
|
||||
*/
|
||||
static public int BUTTON_HEIGHT = 24;
|
||||
|
||||
// value for the size bars, buttons, etc
|
||||
|
||||
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,
|
||||
// and linux is all over the map
|
||||
|
@ -122,6 +122,10 @@ public class Theme {
|
||||
set(attr, value);
|
||||
font = PreferencesHelper.getFont(table, attr);
|
||||
}
|
||||
int scale = getInteger("gui.scalePercent");
|
||||
if (scale != 100) {
|
||||
font = font.deriveFont((float)(font.getSize()) * (float)scale / (float)100.0);
|
||||
}
|
||||
return font;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#COMMENTS // COLOR #95A5A6 - LIGHT GREY
|
||||
#COMMENTS /**/ COLOR #434F54 - DARK GREY
|
||||
|
||||
# GUI - Scaling, edit this to scale to higher dots-per-inch displays
|
||||
gui.scalePercent = 100
|
||||
|
||||
# GUI - STATUS
|
||||
status.notice.fgcolor = #002325
|
||||
|
Loading…
x
Reference in New Issue
Block a user