Skip to content

Commit 59ec660

Browse files
committed
Fixed minimum size for a bunch of GUI elements
1 parent f235774 commit 59ec660

File tree

6 files changed

+39
-38
lines changed

6 files changed

+39
-38
lines changed

app/src/processing/app/Editor.java

+3-14
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,9 @@ public void windowDeactivated(WindowEvent e) {
350350

351351

352352
// Set the minimum size for the editor window
353-
setMinimumSize(new Dimension(PreferencesData.getInteger("editor.window.width.min"),
354-
PreferencesData.getInteger("editor.window.height.min")));
353+
setMinimumSize(scale(new Dimension(
354+
PreferencesData.getInteger("editor.window.width.min"),
355+
PreferencesData.getInteger("editor.window.height.min"))));
355356
// System.out.println("t3");
356357

357358
// Bring back the general options for the editor
@@ -468,18 +469,6 @@ protected int[] getPlacement() {
468469
}
469470

470471

471-
/**
472-
* Hack for #@#)$(* Mac OS X 10.2.
473-
* <p/>
474-
* This appears to only be required on OS X 10.2, and is not
475-
* even being called on later versions of OS X or Windows.
476-
*/
477-
// public Dimension getMinimumSize() {
478-
// //System.out.println("getting minimum size");
479-
// return new Dimension(500, 550);
480-
// }
481-
482-
483472
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
484473

485474

app/src/processing/app/EditorHeader.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public class EditorHeader extends JComponent {
7575
static final int PIECE_HEIGHT = scale(33);
7676

7777
// value for the size bars, buttons, etc
78-
static final int GRID_SIZE = scale(33);
78+
// TODO: Should be a Theme value?
79+
static final int GRID_SIZE = 33;
7980

8081
static Image[][] pieces;
8182
static Image menuButtons[];
@@ -341,17 +342,17 @@ public Dimension getPreferredSize() {
341342

342343

343344
public Dimension getMinimumSize() {
344-
if (OSUtils.isMacOS()) {
345-
return new Dimension(300, GRID_SIZE);
346-
}
347-
return new Dimension(300, GRID_SIZE - 1);
345+
Dimension size = scale(new Dimension(300, GRID_SIZE));
346+
if (OSUtils.isMacOS())
347+
size.height--;
348+
return size;
348349
}
349350

350351

351352
public Dimension getMaximumSize() {
352-
if (OSUtils.isMacOS()) {
353-
return new Dimension(3000, GRID_SIZE);
354-
}
355-
return new Dimension(3000, GRID_SIZE - 1);
353+
Dimension size = scale(new Dimension(3000, GRID_SIZE));
354+
if (OSUtils.isMacOS())
355+
size.height--;
356+
return size;
356357
}
357358
}

app/src/processing/app/EditorLineStatus.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class EditorLineStatus extends JComponent {
4747
Color messageForeground;
4848

4949
Font font;
50-
int high;
50+
int height;
5151

5252
String text = "";
5353
String name = "";
@@ -57,7 +57,7 @@ public EditorLineStatus() {
5757
background = Theme.getColor("linestatus.bgcolor");
5858
font = Theme.getFont("linestatus.font");
5959
foreground = Theme.getColor("linestatus.color");
60-
high = scale(Theme.getInteger("linestatus.height"));
60+
height = Theme.getInteger("linestatus.height");
6161

6262
if (OSUtils.isMacOS()) {
6363
resize = Theme.getThemeImage("resize", this, RESIZE_IMAGE_SIZE, RESIZE_IMAGE_SIZE);
@@ -105,7 +105,7 @@ public void paintComponent(Graphics graphics) {
105105

106106
g.setFont(font);
107107
g.setColor(foreground);
108-
int baseline = (high + g.getFontMetrics().getAscent()) / 2;
108+
int baseline = (size.height + g.getFontMetrics().getAscent()) / 2;
109109
g.drawString(text, scale(6), baseline);
110110

111111
g.setColor(messageForeground);
@@ -130,14 +130,14 @@ public void setSerialPort(String serialport) {
130130
}
131131

132132
public Dimension getPreferredSize() {
133-
return new Dimension(300, high);
133+
return scale(new Dimension(300, height));
134134
}
135135

136136
public Dimension getMinimumSize() {
137137
return getPreferredSize();
138138
}
139139

140140
public Dimension getMaximumSize() {
141-
return new Dimension(3000, high);
141+
return scale(new Dimension(3000, height));
142142
}
143143
}

app/src/processing/app/EditorStatus.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import java.awt.event.KeyEvent;
3434

3535
import static processing.app.I18n.tr;
36-
36+
import static processing.app.Theme.scale;
3737

3838
/**
3939
* Panel just below the editing area that contains status messages.
@@ -68,7 +68,8 @@ public class EditorStatus extends JPanel {
6868
}
6969

7070
// value for the size bars, buttons, etc
71-
static final int GRID_SIZE = Theme.scale(33);
71+
// TODO: Should be a Theme value?
72+
static final int GRID_SIZE = 33;
7273

7374
private final Editor editor;
7475
private final Font font;
@@ -398,11 +399,11 @@ public Dimension getPreferredSize() {
398399
}
399400

400401
public Dimension getMinimumSize() {
401-
return new Dimension(300, GRID_SIZE);
402+
return scale(new Dimension(300, GRID_SIZE));
402403
}
403404

404405
public Dimension getMaximumSize() {
405-
return new Dimension(3000, GRID_SIZE);
406+
return scale(new Dimension(3000, GRID_SIZE));
406407
}
407408

408409
public boolean isErr() {

app/src/processing/app/EditorToolbar.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import java.awt.event.MouseEvent;
3232

3333
import static processing.app.I18n.tr;
34-
34+
import static processing.app.Theme.scale;
3535

3636
/**
3737
* run/stop/etc buttons for the ide
@@ -56,19 +56,19 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
5656
/**
5757
* Width of each toolbar button.
5858
*/
59-
private static final int BUTTON_WIDTH = Theme.scale(27);
59+
private static final int BUTTON_WIDTH = scale(27);
6060
/**
6161
* Height of each toolbar button.
6262
*/
63-
private static final int BUTTON_HEIGHT = Theme.scale(32);
63+
private static final int BUTTON_HEIGHT = scale(32);
6464
/**
6565
* The amount of space between groups of buttons on the toolbar.
6666
*/
67-
private static final int BUTTON_GAP = Theme.scale(5);
67+
private static final int BUTTON_GAP = scale(5);
6868
/**
6969
* Size of the button image being chopped up.
7070
*/
71-
private static final int BUTTON_IMAGE_SIZE = Theme.scale(33);
71+
private static final int BUTTON_IMAGE_SIZE = scale(33);
7272

7373

7474
private static final int RUN = 0;
@@ -441,7 +441,7 @@ public Dimension getMinimumSize() {
441441

442442

443443
public Dimension getMaximumSize() {
444-
return new Dimension(Theme.scale(3000), BUTTON_HEIGHT);
444+
return new Dimension(scale(3000), BUTTON_HEIGHT);
445445
}
446446

447447

app/src/processing/app/Theme.java

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.awt.Graphics2D;
3232
import java.awt.Image;
3333
import java.awt.MediaTracker;
34+
import java.awt.Rectangle;
3435
import java.awt.RenderingHints;
3536
import java.awt.SystemColor;
3637
import java.awt.Toolkit;
@@ -132,6 +133,15 @@ static public Dimension scale(Dimension dim) {
132133
return new Dimension(scale(dim.width), scale(dim.height));
133134
}
134135

136+
static public Rectangle scale(Rectangle rect) {
137+
Rectangle res = new Rectangle(rect);
138+
res.x = scale(res.x);
139+
res.y = scale(res.y);
140+
res.width = scale(res.width);
141+
res.height = scale(res.height);
142+
return res;
143+
}
144+
135145
static public Color getColorCycleColor(String name, int i) {
136146
int cycleSize = getInteger(name + ".size");
137147
name = String.format("%s.%02d", name, i % cycleSize);

0 commit comments

Comments
 (0)