mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-21 15:54:39 +01:00
Factored out scaling formula into an helper method
Also use a default value of 100 in case "gui.scalePercent" is not set.
This commit is contained in:
parent
f239f5b5ab
commit
967153fe87
@ -1752,11 +1752,10 @@ public class Base {
|
|||||||
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||||
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
||||||
|
|
||||||
int scale = Theme.getInteger("gui.scalePercent");
|
Font f = new Font("SansSerif", Font.PLAIN, Theme.scale(11));
|
||||||
Font f = new Font("SansSerif", Font.PLAIN, 11 * scale / 100);
|
|
||||||
g.setFont(f);
|
g.setFont(f);
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
g.drawString(BaseNoGui.VERSION_NAME_LONG, 33 * scale / 100, 20 * scale / 100);
|
g.drawString(BaseNoGui.VERSION_NAME_LONG, Theme.scale(33), Theme.scale(20));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.addMouseListener(new MouseAdapter() {
|
window.addMouseListener(new MouseAdapter() {
|
||||||
|
@ -74,7 +74,7 @@ public class EditorHeader extends JComponent {
|
|||||||
static final int PIECE_WIDTH = 4;
|
static final int PIECE_WIDTH = 4;
|
||||||
|
|
||||||
// value for the size bars, buttons, etc
|
// value for the size bars, buttons, etc
|
||||||
static final int GRID_SIZE = 33 * Theme.getInteger("gui.scalePercent") / 100;
|
static final int GRID_SIZE = Theme.scale(33);
|
||||||
|
|
||||||
static Image[][] pieces;
|
static Image[][] pieces;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class EditorLineStatus extends JComponent {
|
|||||||
background = Theme.getColor("linestatus.bgcolor");
|
background = Theme.getColor("linestatus.bgcolor");
|
||||||
font = Theme.getFont("linestatus.font");
|
font = Theme.getFont("linestatus.font");
|
||||||
foreground = Theme.getColor("linestatus.color");
|
foreground = Theme.getColor("linestatus.color");
|
||||||
high = Theme.getInteger("linestatus.height") * Theme.getInteger("gui.scalePercent") / 100;
|
high = Theme.scale(Theme.getInteger("linestatus.height"));
|
||||||
|
|
||||||
if (OSUtils.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
resize = Theme.getThemeImage("resize.png", this);
|
resize = Theme.getThemeImage("resize.png", this);
|
||||||
|
@ -68,7 +68,7 @@ public class EditorStatus extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// value for the size bars, buttons, etc
|
// value for the size bars, buttons, etc
|
||||||
static final int GRID_SIZE = 33 * Theme.getInteger("gui.scalePercent") / 100;
|
static final int GRID_SIZE = Theme.scale(33);
|
||||||
|
|
||||||
private final Editor editor;
|
private final Editor editor;
|
||||||
private final Font font;
|
private final Font font;
|
||||||
|
@ -56,19 +56,19 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
|||||||
/**
|
/**
|
||||||
* Width of each toolbar button.
|
* Width of each toolbar button.
|
||||||
*/
|
*/
|
||||||
private static final int BUTTON_WIDTH = 27 * Theme.getInteger("gui.scalePercent") / 100;
|
private static final int BUTTON_WIDTH = Theme.scale(27);
|
||||||
/**
|
/**
|
||||||
* Height of each toolbar button.
|
* Height of each toolbar button.
|
||||||
*/
|
*/
|
||||||
private static final int BUTTON_HEIGHT = 32 * Theme.getInteger("gui.scalePercent") / 100;
|
private static final int BUTTON_HEIGHT = Theme.scale(32);
|
||||||
/**
|
/**
|
||||||
* The amount of space between groups of buttons on the toolbar.
|
* The amount of space between groups of buttons on the toolbar.
|
||||||
*/
|
*/
|
||||||
private static final int BUTTON_GAP = 5 * Theme.getInteger("gui.scalePercent") / 100;
|
private static final int BUTTON_GAP = Theme.scale(5);
|
||||||
/**
|
/**
|
||||||
* Size of the button image being chopped up.
|
* Size of the button image being chopped up.
|
||||||
*/
|
*/
|
||||||
private static final int BUTTON_IMAGE_SIZE = 33 * Theme.getInteger("gui.scalePercent") / 100;
|
private static final int BUTTON_IMAGE_SIZE = Theme.scale(33);
|
||||||
|
|
||||||
|
|
||||||
private static final int RUN = 0;
|
private static final int RUN = 0;
|
||||||
@ -437,7 +437,7 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
|||||||
|
|
||||||
|
|
||||||
public Dimension getMaximumSize() {
|
public Dimension getMaximumSize() {
|
||||||
return new Dimension(3000 * Theme.getInteger("gui.scalePercent") / 100, BUTTON_HEIGHT);
|
return new Dimension(Theme.scale(3000), BUTTON_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,6 +97,16 @@ public class Theme {
|
|||||||
set(key, String.valueOf(value));
|
set(key, String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public int getScale() {
|
||||||
|
if (get("gui.scalePercent") == null)
|
||||||
|
return 100;
|
||||||
|
return getInteger("gui.scalePercent");
|
||||||
|
}
|
||||||
|
|
||||||
|
static public int scale(int size) {
|
||||||
|
return size * getScale() / 100;
|
||||||
|
}
|
||||||
|
|
||||||
static public Color getColorCycleColor(String name, int i) {
|
static public Color getColorCycleColor(String name, int i) {
|
||||||
int cycleSize = getInteger(name + ".size");
|
int cycleSize = getInteger(name + ".size");
|
||||||
name = String.format("%s.%02d", name, i % cycleSize);
|
name = String.format("%s.%02d", name, i % cycleSize);
|
||||||
@ -125,12 +135,7 @@ public class Theme {
|
|||||||
set(attr, value);
|
set(attr, value);
|
||||||
font = PreferencesHelper.getFont(table, attr);
|
font = PreferencesHelper.getFont(table, attr);
|
||||||
}
|
}
|
||||||
int scale = getInteger("gui.scalePercent");
|
return font.deriveFont((float) scale(font.getSize()));
|
||||||
if (scale != 100) {
|
|
||||||
font = font
|
|
||||||
.deriveFont((float) (font.getSize()) * (float) scale / (float) 100.0);
|
|
||||||
}
|
|
||||||
return font;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,7 +204,7 @@ public class Theme {
|
|||||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||||
|
|
||||||
SplitFile name = FileUtils.splitFilename(filename);
|
SplitFile name = FileUtils.splitFilename(filename);
|
||||||
int scale = getInteger("gui.scalePercent");
|
int scale = getScale();
|
||||||
File libFolder = Base.getContentFile("lib");
|
File libFolder = Base.getContentFile("lib");
|
||||||
File imageFile1x = new File(libFolder, name.basename + "." + name.extension);
|
File imageFile1x = new File(libFolder, name.basename + "." + name.extension);
|
||||||
File imageFile2x = new File(libFolder, name.basename + "@2x." + name.extension);
|
File imageFile2x = new File(libFolder, name.basename + "@2x." + name.extension);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user