Skip to content

Commit 916c3bf

Browse files
committed
implement custom tooltip for error/warning hover
1 parent 7b56136 commit 916c3bf

File tree

5 files changed

+70
-18
lines changed

5 files changed

+70
-18
lines changed

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
import processing.core.*;
4141

4242
import java.awt.BorderLayout;
43+
import java.awt.Color;
4344
import java.awt.Component;
4445
import java.awt.Dimension;
4546
import java.awt.EventQueue;
47+
import java.awt.Font;
4648
import java.awt.Frame;
4749
import java.awt.Image;
4850
import java.awt.Point;
@@ -2836,6 +2838,47 @@ public boolean isHalted() {
28362838
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28372839

28382840

2841+
static Font font;
2842+
static Color textColor;
2843+
static Color bgColorWarning;
2844+
static Color bgColorError;
2845+
2846+
2847+
/*
2848+
public void toolTipError(JComponent comp, String message) {
2849+
setToolTip(comp, message, true);
2850+
}
2851+
2852+
2853+
public void toolTipWarning(JComponent comp, String message) {
2854+
setToolTip(comp, message, false);
2855+
}
2856+
*/
2857+
2858+
2859+
public void statusToolTip(JComponent comp, String message, boolean error) {
2860+
if (font == null) {
2861+
font = Toolkit.getSansFont(9, Font.PLAIN);
2862+
textColor = mode.getColor("errors.selection.fgcolor");
2863+
bgColorWarning = mode.getColor("errors.selection.warning.bgcolor");
2864+
bgColorError = mode.getColor("errors.selection.error.bgcolor");
2865+
}
2866+
2867+
Color bgColor = error ? //text.startsWith(Language.text("editor.status.error")) ?
2868+
bgColorError : bgColorWarning;
2869+
String content = "<html>" +
2870+
"<div style='margin: -3 -3 -3 -3; padding: 3 3 3 3; " +
2871+
"background: #" + PApplet.hex(bgColor.getRGB(), 8).substring(2) + ";" +
2872+
"font-family: " + font.getFontName() + ", sans-serif;" +
2873+
"font-size: " + font.getSize() + "px;'>" + message + "</div></html>";
2874+
//System.out.println(content);
2875+
comp.setToolTipText(content);
2876+
}
2877+
2878+
2879+
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2880+
2881+
28392882
/**
28402883
* Returns the edit popup menu.
28412884
*/

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@
2424

2525
package processing.app.ui;
2626

27-
import java.awt.*;
27+
import java.awt.Color;
28+
import java.awt.Cursor;
29+
import java.awt.Dimension;
30+
import java.awt.Font;
31+
import java.awt.FontMetrics;
32+
import java.awt.Graphics;
33+
import java.awt.Image;
2834
import java.awt.event.MouseAdapter;
2935
import java.awt.event.MouseEvent;
3036

3137
import javax.swing.plaf.basic.BasicSplitPaneDivider;
3238
import javax.swing.plaf.basic.BasicSplitPaneUI;
3339

34-
import processing.app.Language;
3540
import processing.app.Mode;
3641
import processing.app.Platform;
3742
import processing.core.PApplet;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import processing.core.PApplet;
4343
import processing.mode.java.pdex.LineMarker;
4444
import processing.mode.java.pdex.Problem;
45-
import processing.app.Language;
4645

4746

4847
/**
@@ -186,10 +185,11 @@ protected Object doInBackground() throws Exception {
186185
LineMarker m = findClosestMarker(y);
187186
if (m != null) {
188187
Problem p = m.getProblem();
189-
String kind = p.isError() ?
190-
Language.text("editor.status.error") :
191-
Language.text("editor.status.warning");
192-
setToolTipText(kind + ": " + p.getMessage());
188+
// String kind = p.isError() ?
189+
// Language.text("editor.status.error") :
190+
// Language.text("editor.status.warning");
191+
// setToolTipText(kind + ": " + p.getMessage());
192+
editor.statusToolTip(MarkerColumn.this, p.getMessage(), p.isError());
193193
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
194194
}
195195
return null;

java/src/processing/mode/java/pdex/JavaTextAreaPainter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ public void mouseMoved(final MouseEvent evt) {
137137

138138
if (x >= getJavaTextArea().offsetToX(line, startOffset) &&
139139
x <= getJavaTextArea().offsetToX(line, stopOffset)) {
140-
setToolTipText(problem.getMessage());
140+
//setToolTipText(problem.getMessage());
141+
getJavaEditor().statusToolTip(JavaTextAreaPainter.this,
142+
problem.getMessage(),
143+
problem.isError());
141144
evt.consume();
142145
}
143146
}

todo.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ X https://github.com/processing/processing/issues/3882
1313
X https://github.com/processing/processing/pull/3884
1414
X Hide useless error in error checker
1515
X https://github.com/processing/processing/pull/3887
16+
X grab bag of CM work from Jakub
17+
X https://github.com/processing/processing/issues/3895
18+
X https://github.com/processing/processing/pull/3897
1619

1720
gui
1821
X distinguish errors and warnings
@@ -36,7 +39,14 @@ X selecting a warning should also show the warning in the status area
3639
X https://github.com/processing/processing/pull/3907
3740
X clicking an error or warning should give the focus back to the editor
3841
X https://github.com/processing/processing/pull/3905
39-
42+
X replace startup/about screen (1x and 2x versions)
43+
X change 'alpha' to correct name
44+
X also change the revision in the "about processing" dialog
45+
X https://github.com/processing/processing/issues/3665
46+
X implement splash screen on OS X
47+
X also implement special retina version
48+
X implement custom tooltip for error/warning hover
49+
X applies to both MarkerColumn and JavaTextAreaPainter
4050

4151
earlier
4252
X list with contrib types separated is really wonky
@@ -61,9 +71,6 @@ _ mouse events (i.e. toggle breakpoint) seem to be firing twice
6171
_ https://github.com/processing/processing/milestones/3.0%20final
6272
_ JavaEditor has several null colors, remove color support
6373
_ once the design is complete and we for sure do not need color
64-
_ grab bag of CM work from Jakub
65-
_ https://github.com/processing/processing/issues/3895
66-
X https://github.com/processing/processing/pull/3897
6774

6875
gui / James
6976
_ make gutter of console match error list
@@ -73,16 +80,10 @@ _ remove extra border around the outside
7380
_ change font
7481
_ change selection highlight color
7582
_ put some margin around it
76-
_ implement custom tooltip for error/warning hover
77-
_ applies to both MarkerColumn and
7883
_ Fix placement and visual design when showing error on hover
7984
_ https://github.com/processing/processing/issues/3173
8085
_ import suggestions box needs design review
8186
_ https://github.com/processing/processing/issues/3407
82-
_ replace startup/about screen (1x and 2x versions)
83-
_ change 'alpha' to correct name
84-
_ also change the revision in the "about processing" dialog
85-
_ https://github.com/processing/processing/issues/3665
8687
_ different design of squiggly line
8788
_ easy to do inside JavaTextAreaPainter.paintSquiggle()
8889

0 commit comments

Comments
 (0)