Skip to content

Commit a83f88e

Browse files
committed
show the number of available updates in the footer (fixes processing#3518)
1 parent 5fa9e4a commit a83f88e

5 files changed

Lines changed: 51 additions & 51 deletions

File tree

‎app/src/processing/app/ui/Editor.java‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
7474
protected Mode mode;
7575

7676
static public final int LEFT_GUTTER = 44;
77-
static public final int RIGHT_GUTTER = 20;
77+
static public final int RIGHT_GUTTER = 12;
7878
static public final int GUTTER_MARGIN = 3;
7979

8080

@@ -1094,11 +1094,10 @@ public void clearToolMenu() {
10941094

10951095
/**
10961096
* Updates update count in the UI. Called on EDT.
1097-
* @param n number of available updates
1097+
* @param count number of available updates
10981098
*/
1099-
public void setUpdatesAvailable(int n) {
1100-
// TODO: refresh UI and remove the debug message
1101-
PApplet.println("setting update count to", n);
1099+
public void setUpdatesAvailable(int count) {
1100+
footer.setUpdateCount(count);
11021101
}
11031102

11041103

‎app/src/processing/app/ui/EditorFooter.java‎

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import java.awt.Image;
3333
import java.awt.event.MouseAdapter;
3434
import java.awt.event.MouseEvent;
35+
import java.awt.font.FontRenderContext;
36+
import java.awt.geom.Ellipse2D;
3537
import java.util.ArrayList;
3638
import java.util.List;
3739

@@ -68,6 +70,7 @@ public class EditorFooter extends Box {
6870

6971
Color[] textColor = new Color[2];
7072
Color[] tabColor = new Color[2];
73+
Color updateColor;
7174

7275
Editor editor;
7376

@@ -86,6 +89,8 @@ public class EditorFooter extends Box {
8689
CardLayout cardLayout;
8790
Controller controller;
8891

92+
int updateCount;
93+
8994

9095
public EditorFooter(Editor eddie) {
9196
super(BoxLayout.Y_AXIS);
@@ -145,6 +150,12 @@ public void setNotification(Component comp, boolean note) {
145150
}
146151

147152

153+
public void setUpdateCount(int count) {
154+
this.updateCount = count;
155+
repaint();
156+
}
157+
158+
148159
public void updateMode() {
149160
Mode mode = editor.getMode();
150161

@@ -155,7 +166,7 @@ public void updateMode() {
155166
tabColor[SELECTED] = mode.getColor("footer.tab.selected.color");
156167
tabColor[UNSELECTED] = mode.getColor("footer.tab.unselected.color");
157168

158-
// errorColor = mode.getColor("status.error.bgcolor");
169+
updateColor = mode.getColor("footer.updates.color");
159170

160171
gradient = mode.makeGradient("footer", 400, HIGH);
161172
}
@@ -233,7 +244,9 @@ public void paintComponent(Graphics screen) {
233244
}
234245

235246
// now actually draw the tabs
236-
placeTabs(Editor.LEFT_GUTTER, g2);
247+
drawTabs(Editor.LEFT_GUTTER, g2);
248+
249+
drawUpdates(g2);
237250

238251
// // draw the two pixel line that extends left/right below the tabs
239252
// g.setColor(tabColor[SELECTED]);
@@ -249,7 +262,7 @@ public void paintComponent(Graphics screen) {
249262
* @param left starting position from the left
250263
* @param g graphics context, or null if we're not drawing
251264
*/
252-
private void placeTabs(int left, Graphics2D g) {
265+
private void drawTabs(int left, Graphics2D g) {
253266
int x = left;
254267

255268
for (Tab tab : tabs) {
@@ -261,43 +274,30 @@ private void placeTabs(int left, Graphics2D g) {
261274
x += tab.textWidth + MARGIN;
262275
tab.right = x;
263276

264-
// if drawing and not just placing
265-
if (g != null) {
266-
tab.draw(g);
267-
/*
268-
int state = tab.isCurrent() ? SELECTED : UNSELECTED;
269-
g.setColor(tabColor[state]);
270-
if (tab.notification) {
271-
g.setColor(errorColor);
272-
}
273-
//drawTab(g, tab.left, tab.right, tab.isFirst(), tab.isLast());
274-
tab.draw(g);
275-
276-
int textLeft = tab.getTextLeft();
277-
if (tab.notification && state == UNSELECTED) {
278-
g.setColor(Color.LIGHT_GRAY);
279-
} else {
280-
g.setColor(textColor[state]);
281-
}
282-
int tabHeight = TAB_BOTTOM - TAB_TOP;
283-
int baseline = TAB_TOP + (tabHeight + fontAscent) / 2;
284-
g.drawString(tab.name, textLeft, baseline);
285-
*/
286-
}
277+
tab.draw(g);
287278
x += TAB_BETWEEN;
288279
}
289280
}
290281

291282

292-
/*
293-
private void drawTab(Graphics g, int left, int right,
294-
boolean leftNotch, boolean rightNotch) {
295-
Graphics2D g2 = (Graphics2D) g;
296-
g2.fill(Toolkit.createRoundRect(left, TAB_TOP, right, TAB_BOTTOM, 0, 0,
297-
rightNotch ? CURVE_RADIUS : 0,
298-
leftNotch ? CURVE_RADIUS : 0));
283+
private void drawUpdates(Graphics2D g2) {
284+
FontRenderContext frc = g2.getFontRenderContext();
285+
final int GAP = 5;
286+
final String updateLabel = "Updates";
287+
String updatesStr = "" + updateCount;
288+
double countWidth = font.getStringBounds(updatesStr, frc).getWidth();
289+
float diameter = (float) (countWidth * 1.65f);
290+
float ex = getWidth() - Editor.RIGHT_GUTTER - diameter;
291+
float ey = (getHeight() - diameter) / 2;
292+
g2.setColor(updateColor);
293+
g2.fill(new Ellipse2D.Float(ex, ey, diameter, diameter));
294+
g2.setColor(textColor[SELECTED]);
295+
int baseline = (getHeight() + fontAscent) / 2;
296+
g2.drawString(updatesStr, (int) (ex + (diameter - countWidth)/2), baseline);
297+
double updatesWidth = font.getStringBounds(updateLabel, frc).getWidth();
298+
g2.setColor(textColor[UNSELECTED]);
299+
g2.drawString(updateLabel, (int) (ex - updatesWidth - GAP), baseline);
299300
}
300-
*/
301301

302302

303303
public Dimension getPreferredSize() {

‎build/shared/lib/theme.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ footer.gradient.bottom = #122535
3030
footer.tab.selected.color = #2d4251
3131
footer.tab.unselected.color = #1f3241
3232
# updates orange #eb7f15
33+
footer.updates.color = #ed7f15
3334

3435
# CONSOLE
3536
# The font is handled by preferences, so its size/etc are modifiable.

‎java/src/processing/mode/java/MarkerColumn.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import processing.app.Sketch;
4040
import processing.app.SketchCode;
4141
import processing.app.Util;
42+
import processing.app.ui.Editor;
4243
import processing.core.PApplet;
4344
import processing.mode.java.pdex.LineMarker;
4445
import processing.mode.java.pdex.Problem;
@@ -56,7 +57,7 @@
5657
public class MarkerColumn extends JPanel {
5758
protected JavaEditor editor;
5859

59-
static final int WIDE = 12;
60+
// static final int WIDE = 12;
6061

6162
private Color errorColor;
6263
private Color warningColor;
@@ -244,11 +245,11 @@ private LineMarker findClosestMarker(final int y) {
244245

245246

246247
public Dimension getPreferredSize() {
247-
return new Dimension(WIDE, super.getPreferredSize().height);
248+
return new Dimension(Editor.RIGHT_GUTTER, super.getPreferredSize().height);
248249
}
249250

250251

251252
public Dimension getMinimumSize() {
252-
return new Dimension(WIDE, super.getMinimumSize().height);
253+
return new Dimension(Editor.RIGHT_GUTTER, super.getMinimumSize().height);
253254
}
254255
}

‎todo.txt‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ X applies to both MarkerColumn and JavaTextAreaPainter
5353
X make gutter of console match error list
5454
X https://github.com/processing/processing/issues/3904
5555

56-
earlier
56+
earlier/cleaning
5757
X list with contrib types separated is really wonky
5858
o do we keep the list?
5959
o does it even work for different contrib types?
6060
X cleaned this up in the last release
6161
X remove the dated releases from download.processing.org
6262
X new Android release (EditorButton constructor changed)
63+
o JavaEditor has several null colors, remove color support
64+
o once the design is complete and we for sure do not need color
6365

6466

6567
known issues
@@ -74,15 +76,12 @@ _ mouse events (i.e. toggle breakpoint) seem to be firing twice
7476

7577
3.0 final
7678
_ https://github.com/processing/processing/milestones/3.0%20final
77-
_ JavaEditor has several null colors, remove color support
78-
_ once the design is complete and we for sure do not need color
79-
80-
gui / James
8179
_ fix the design of the completions window
82-
_ remove extra border around the outside
83-
_ change font
84-
_ change selection highlight color
85-
_ put some margin around it
80+
_ remove extra border around the outside
81+
_ change font
82+
_ change selection highlight color
83+
_ put some margin around it
84+
_ https://github.com/processing/processing/issues/3906
8685
_ import suggestions box needs design review
8786
_ https://github.com/processing/processing/issues/3407
8887
_ different design of squiggly line

0 commit comments

Comments
 (0)