|
40 | 40 | import processing.app.Language; |
41 | 41 | import processing.app.Messages; |
42 | 42 | import processing.app.Mode; |
| 43 | +import processing.app.ui.Toolkit; |
43 | 44 | import processing.mode.java.JavaEditor; |
44 | 45 |
|
45 | 46 |
|
@@ -295,13 +296,45 @@ public String getColumnName(int i) { |
295 | 296 | * Handles icons, text color and tool tips. |
296 | 297 | */ |
297 | 298 | class OutlineRenderer implements RenderDataProvider { |
298 | | - Icon[][] icons; |
| 299 | + static final String ENABLED_COLOR = "#000000"; |
| 300 | + static final String DISABLED_COLOR = "#808080"; |
299 | 301 | static final int ICON_SIZE = 16; |
300 | 302 |
|
| 303 | + // Indices correspond to VariableNode.TYPE_OBJECT...TYPE_SHORT |
| 304 | + static final String[] TYPE_NAMES = { |
| 305 | + "object", "array", "integer", "float", "boolean", |
| 306 | + "char", "string", "long", "double", "byte", "short" |
| 307 | + }; |
| 308 | + |
| 309 | + Icon[][] icons; |
| 310 | + |
| 311 | + |
301 | 312 | OutlineRenderer() { |
302 | | - icons = loadIcons("theme/variables-1x.png"); |
| 313 | + icons = new Icon[][] { |
| 314 | + renderIcons("object"), |
| 315 | + renderIcons("array"), |
| 316 | + renderIcons("integer"), |
| 317 | + renderIcons("float"), |
| 318 | + renderIcons("boolean"), |
| 319 | + renderIcons("char"), |
| 320 | + renderIcons("string"), |
| 321 | + renderIcons("long"), |
| 322 | + renderIcons("double"), |
| 323 | + renderIcons("byte"), |
| 324 | + renderIcons("short") |
| 325 | + }; |
303 | 326 | } |
304 | 327 |
|
| 328 | + |
| 329 | + private ImageIcon[] renderIcons(String type) { |
| 330 | + File file = editor.getMode().getContentFile("theme/variables/" + type + ".svg"); |
| 331 | + return new ImageIcon[] { |
| 332 | + Toolkit.renderIcon(file, ENABLED_COLOR, ICON_SIZE), |
| 333 | + Toolkit.renderIcon(file, DISABLED_COLOR, ICON_SIZE) |
| 334 | + }; |
| 335 | + } |
| 336 | + |
| 337 | + |
305 | 338 | /** |
306 | 339 | * Load multiple icons (horizontal) with multiple states (vertical) from |
307 | 340 | * a single file. |
@@ -334,11 +367,11 @@ private ImageIcon[][] loadIcons(String fileName) { |
334 | 367 | } |
335 | 368 |
|
336 | 369 |
|
337 | | - protected Icon getIcon(int type, int state) { |
| 370 | + protected Icon getIcon(int type, boolean enabled) { |
338 | 371 | if (type < 0 || type > icons.length - 1) { |
339 | 372 | return null; |
340 | 373 | } |
341 | | - return icons[type][state]; |
| 374 | + return icons[type][enabled ? 0 : 1]; |
342 | 375 | } |
343 | 376 |
|
344 | 377 |
|
@@ -400,7 +433,7 @@ public String getTooltipText(Object o) { |
400 | 433 | public Icon getIcon(Object o) { |
401 | 434 | VariableNode var = toVariableNode(o); |
402 | 435 | if (var != null) { |
403 | | - return getIcon(var.getType(), tree.isEnabled() ? 0 : 1); |
| 436 | + return getIcon(var.getType(), tree.isEnabled()); |
404 | 437 | } |
405 | 438 | if (o instanceof TreeNode) { |
406 | 439 | UIDefaults defaults = UIManager.getDefaults(); |
|
0 commit comments