Skip to content

Commit 06666ed

Browse files
committed
more cleanup; use buttonSize constant instead of sizeH for clarity
1 parent adaf901 commit 06666ed

2 files changed

Lines changed: 44 additions & 44 deletions

File tree

app/src/processing/app/ui/EditorStatus.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,26 @@ public class EditorStatus extends BasicSplitPaneDivider {
6666
static public final int CURSOR_LINE_WARNING = 4;
6767
static public final int NOTICE = 0;
6868

69-
static final int YES = 1;
70-
static final int NO = 2;
69+
static final int YES = 1;
70+
static final int NO = 2;
7171
static final int CANCEL = 3;
72-
static final int OK = 4;
72+
static final int OK = 4;
7373

7474
Editor editor;
7575

7676
int mode;
7777
String message = "";
7878

7979
String url;
80+
8081
int rightEdge;
8182
int mouseX;
82-
int rolloverState;
83-
static final int ROLLOVER_NONE = 0;
84-
static final int ROLLOVER_URL = 1;
85-
static final int ROLLOVER_COLLAPSE = 2;
83+
84+
static final int ROLLOVER_NONE = 0;
85+
static final int ROLLOVER_URL = 1;
86+
static final int ROLLOVER_COLLAPSE = 2;
8687
static final int ROLLOVER_CLIPBOARD = 3;
88+
int rolloverState;
8789

8890
Font font;
8991
FontMetrics metrics;
@@ -94,6 +96,7 @@ public class EditorStatus extends BasicSplitPaneDivider {
9496
// other apps seem to use this one as a hack
9597
static final String CLIPBOARD_GLYPH = "\u2398";
9698

99+
// https://en.wikipedia.org/wiki/Geometric_Shapes
97100
// static final String COLLAPSE_GLYPH = "\u25B3"; // large up
98101
// static final String EXPAND_GLYPH = "\u25BD"; // large down
99102
// static final String COLLAPSE_GLYPH = "\u25B5"; // small up (unavailable)
@@ -108,6 +111,7 @@ public class EditorStatus extends BasicSplitPaneDivider {
108111

109112
Image offscreen;
110113
int sizeW, sizeH;
114+
// size of the glyph buttons (width and height are identical)
111115
int buttonSize;
112116
boolean collapsed = false;
113117

@@ -334,7 +338,7 @@ public void paint(Graphics screen) {
334338
if (offscreen == null) {
335339
sizeW = size.width;
336340
sizeH = size.height;
337-
// buttonSize = sizeH;
341+
buttonSize = sizeH;
338342
offscreen = Toolkit.offscreenGraphics(this, sizeW, sizeH);
339343
}
340344

@@ -349,27 +353,25 @@ public void paint(Graphics screen) {
349353

350354
g.drawImage(bgImage[mode], 0, 0, sizeW, sizeH, this);
351355

352-
// What's the mouse over?
353-
if (sizeW - sizeH < mouseX && mouseX < sizeW) {
356+
rolloverState = ROLLOVER_NONE;
357+
if (mouseX > sizeW - buttonSize && mouseX < sizeW) {
354358
rolloverState = ROLLOVER_COLLAPSE;
359+
355360
} else if (message != null && !message.isEmpty()) {
356-
if (sizeW - 2*sizeH < mouseX) {
361+
if (sizeW - 2*buttonSize < mouseX) {
357362
rolloverState = ROLLOVER_CLIPBOARD;
363+
358364
} else if (url != null && mouseX > LEFT_MARGIN &&
359365
// calculate right edge of the text for rollovers (otherwise the pane
360366
// cannot be resized up or down whenever a URL is being displayed)
361367
mouseX < (LEFT_MARGIN + g.getFontMetrics().stringWidth(message))) {
362368
rolloverState = ROLLOVER_URL;
363-
} else {
364-
rolloverState = ROLLOVER_NONE;
365369
}
366-
} else {
367-
rolloverState = ROLLOVER_NONE;
368370
}
369371

370372
// https://github.com/processing/processing/issues/3265
371373
if (message != null) {
372-
// needs to be set each time on osx
374+
// font needs to be set each time on osx
373375
g.setFont(font);
374376
// set the highlight color on rollover so that the user's not surprised
375377
// to see the web browser open when they click
@@ -381,7 +383,7 @@ public void paint(Graphics screen) {
381383
//int x = cancelButton.getX();
382384
//int w = cancelButton.getWidth();
383385
int w = Toolkit.getButtonWidth();
384-
int x = getWidth() - Math.max(RIGHT_MARGIN, (int)(sizeH*1.2)) - w;
386+
int x = getWidth() - Math.max(RIGHT_MARGIN, (int)(buttonSize*1.2)) - w;
385387
int y = sizeH / 3;
386388
int h = sizeH / 3;
387389
g.setColor(new Color(0x80000000, true));
@@ -405,25 +407,26 @@ public void paint(Graphics screen) {
405407
}
406408

407409

408-
private final Color whitishTint = new Color(0x20eeeeee, true);
410+
//private final Color whitishTint = new Color(0x20eeeeee, true);
409411

410412
/**
411-
* @param pos A zero-based index with 0 on the right.
413+
* @param pos A zero-based button index with 0 as the rightmost button
412414
*/
413415
private void drawButton(Graphics g, String symbol, int pos, boolean highlight) {
414-
int left = sizeW - (pos + 1) * sizeH;
416+
int left = sizeW - (pos + 1) * buttonSize;
415417
// Overlap very long errors
416-
g.drawImage(bgImage[mode], left, 0, sizeH, sizeH, this);
418+
g.drawImage(bgImage[mode], left, 0, buttonSize, sizeH, this);
417419

418420
if (highlight) {
419-
g.setColor(whitishTint);
420-
g.fillRect(left, 0, sizeH, sizeH);
421+
// disabling since this doesn't match any of our other UI
422+
// g.setColor(whitishTint);
423+
// g.fillRect(left, 0, sizeH, sizeH);
421424
g.setColor(urlColor);
422425
} else {
423426
g.setColor(fgColor[mode]);
424427
}
425428
g.drawString(symbol,
426-
left + (sizeH - g.getFontMetrics().stringWidth(symbol))/2,
429+
left + (buttonSize - g.getFontMetrics().stringWidth(symbol))/2,
427430
(sizeH + ascent) / 2);
428431
}
429432

todo.txt

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ X https://github.com/processing/processing/pull/5636
1414
X Examples dialog causes high CPU load
1515
X https://github.com/processing/processing/issues/5246
1616
X https://github.com/processing/processing/pull/5654
17+
X console hiding button
18+
X https://github.com/processing/processing/pull/5115
1719

1820
jakub
1921
X Fix sketch exception getting hidden by warning
@@ -29,6 +31,19 @@ _ Welcome screen doesn't size properly for HiDPI screens
2931
_ https://github.com/processing/processing/issues/4896
3032

3133

34+
nasty ones
35+
_ errors inside setup() aren't coming through at all?
36+
_ seen in Eclipse; have to turn on the debugger
37+
_ "Sketch disappeared" infinite pop up dialogs
38+
_ https://github.com/processing/processing/pull/4808
39+
_ https://github.com/processing/processing/issues/4805
40+
_ EventQueue problems with "could not find sketch size" message
41+
_ https://github.com/processing/processing/issues/4893
42+
_ https://github.com/processing/processing/issues/5030
43+
_ size(0, 0) just freezes instead of showing an error (as a result)
44+
_ https://github.com/processing/processing/issues/5233
45+
46+
3247
manager
3348
_ Manager fails to complete install of PythonMode when no windows open
3449
_ https://github.com/processing/processing/issues/5309
@@ -69,26 +84,6 @@ _ clean Windows temp folders
6984
_ https://github.com/processing/processing/issues/1896
7085

7186

72-
contrib
73-
_ console hiding button?
74-
_ https://github.com/processing/processing/pull/5115
75-
_ alternate handling of duplicate library conflicts
76-
_ https://github.com/processing/processing/pull/5126
77-
78-
79-
nasty ones
80-
_ errors inside setup() aren't coming through at all?
81-
_ seen in Eclipse; have to turn on the debugger
82-
_ "Sketch disappeared" infinite pop up dialogs
83-
_ https://github.com/processing/processing/pull/4808
84-
_ https://github.com/processing/processing/issues/4805
85-
_ EventQueue problems with "could not find sketch size" message
86-
_ https://github.com/processing/processing/issues/4893
87-
_ https://github.com/processing/processing/issues/5030
88-
_ size(0, 0) just freezes instead of showing an error (as a result)
89-
_ https://github.com/processing/processing/issues/5233
90-
91-
9287
_ sketch.properties not being written if initial mode is p5.js?
9388
_ when creating a sketch within non-Java mode, should write the settings file
9489
_ so that it re-loads in the proper environment
@@ -709,6 +704,8 @@ _ see how library installation goes, then possibly do same w/ examples
709704

710705
PDE / Libraries
711706

707+
_ alternate handling of duplicate library conflicts
708+
_ https://github.com/processing/processing/pull/5126
712709
_ Add a means to specify packages to import in library.properties
713710
_ https://github.com/processing/processing/issues/2134
714711
_ need to deal with classpath conflicts

0 commit comments

Comments
 (0)