add retina version of search icon and supporting methods

This commit is contained in:
Ben Fry
2015-09-19 13:23:54 -04:00
parent 5e1e4f65c5
commit e2f9062457
4 changed files with 63 additions and 12 deletions
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2013 The Processing Foundation
Copyright (c) 2012-15 The Processing Foundation
Copyright (c) 2011-12 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify
@@ -43,6 +43,7 @@ public class ContributionTab {
ContributionType contributionType;
ContributionManagerDialog contributionManagerDialog;
JPanel panel;
String title;
ContributionFilter filter;
@@ -68,7 +69,10 @@ public class ContributionTab {
JProgressBar progressBar;
public ContributionTab(ContributionType type,ContributionManagerDialog contributionManagerDialog) {
public ContributionTab(ContributionType type, ContributionManagerDialog contributionManagerDialog) {
this.contributionType = type;
this.contributionManagerDialog = contributionManagerDialog;
if (type == ContributionType.MODE) {
title = Language.text("contrib.manager_title.mode");
} else if (type == ContributionType.TOOL) {
@@ -80,8 +84,6 @@ public class ContributionTab {
}
filter = type.createFilter();
this.contributionType = type;
this.contributionManagerDialog = contributionManagerDialog;
contribListing = ContributionListing.getInstance();
statusPanel = new StatusPanel(650,this);
contributionListPanel = new ContributionListPanel(this, filter);
@@ -207,7 +209,7 @@ public class ContributionTab {
}
void buildErrorPanel(){
void buildErrorPanel() {
errorPanel = new JPanel();
GroupLayout layout = new GroupLayout(errorPanel);
layout.setAutoCreateGaps(true);
@@ -342,6 +344,7 @@ public class ContributionTab {
}
}
protected void setFilterText(String filter) {
if (filter == null || filter.isEmpty()) {
filterField.setText("");
@@ -359,7 +362,6 @@ public class ContributionTab {
JLabel filterLabel;
public FilterField () {
super("");
filterLabel = new JLabel("Filter");
@@ -367,9 +369,12 @@ public class ContributionTab {
filterLabel.setOpaque(false);
setFont(Toolkit.getSansFont(14, Font.PLAIN));
searchIcon = Toolkit.getLibIcon("manager/search.png");
//searchIcon = Toolkit.getLibIcon("manager/search.png");
searchIcon = Toolkit.getLibIconX("manager/search");
filterLabel.setIcon(searchIcon);
//searchIcon = new ImageIcon(java.awt.Toolkit.getDefaultToolkit().getImage("NSImage://NSComputerTemplate"));
setOpaque(false);
setBorder(BorderFactory.createMatteBorder(0, 33, 0, 0, searchIcon));
//setBorder(BorderFactory.createMatteBorder(0, 33, 0, 0, searchIcon));
GroupLayout fl = new GroupLayout(this);
setLayout(fl);
@@ -386,13 +391,13 @@ public class ContributionTab {
addFocusListener(new FocusListener() {
public void focusLost(FocusEvent focusEvent) {
if (getText().isEmpty()) {
setBorder(BorderFactory.createMatteBorder(0, 33, 0, 0, searchIcon));
// setBorder(BorderFactory.createMatteBorder(0, 33, 0, 0, searchIcon));
filterLabel.setVisible(true);
}
}
public void focusGained(FocusEvent focusEvent) {
setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
// setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
filterLabel.setVisible(false);
}
});
+35
View File
@@ -43,6 +43,7 @@ import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.image.ImageObserver;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -482,6 +483,40 @@ public class Toolkit {
}
static public ImageIcon getLibIconX(String base) {
final int scale = Toolkit.highResDisplay() ? 2 : 1;
String filename = base + "-" + scale + "x.png";
File file = Platform.getContentFile("lib/" + filename);
if (!file.exists()) {
// System.err.println("does not exist: " + file);
return null;
}
// ImageIcon icon = new ImageIcon(file.getAbsolutePath());
// ImageIcon outgoing = new ImageIcon(icon.getImage()) {
ImageIcon outgoing = new ImageIcon(file.getAbsolutePath()) {
@Override
public int getIconWidth() {
return super.getIconWidth() / scale;
}
@Override
public int getIconHeight() {
return super.getIconHeight() / scale;
}
@Override
public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
ImageObserver imageObserver = getImageObserver();
if (imageObserver == null) {
imageObserver = c;
}
g.drawImage(getImage(), x, y, getIconWidth(), getIconHeight(), imageObserver);
}
};
return outgoing;
}
static List<Image> iconImages;
+9 -2
View File
@@ -9,9 +9,18 @@ X Make the PApplet regex cache LRU
X https://github.com/processing/processing/pull/3815
andres
X Cannot re-enable stroke or fill of a PShape with P2D
X https://github.com/processing/processing/issues/3808
X setResizable broke with oscilating behavior in 3.0b6
X https://github.com/processing/processing/issues/3825
X https://github.com/processing/processing/commit/42c0150da0f400637de916db1f94a687a7bc4288
X surface.setLocation() causing a freeze on Windows
X https://github.com/processing/processing/commit/4c0f9234c0a48f62363233cafc9c9951ee351d3e
_ selectInput/Output() is behind the drawing window (Windows)
_ https://github.com/processing/processing/issues/3775
_ fixed has been added, test on Windows
3.0 final
_ P2D and P3D windows behave strangely when larger than the screen size
@@ -36,8 +45,6 @@ _ update wiki/docs to say "don't override sketchXxxx() methods"
_ SVG only exports last frame
_ possibly because Java2D is disposing the Graphics2D in between?
_ https://github.com/processing/processing/issues/3753
_ selectInput/Output() is behind the drawing window (Windows)
_ https://github.com/processing/processing/issues/3775
javafx
_ do we really need setTextFont/Size when we already have Impl?
+4
View File
@@ -36,6 +36,8 @@ X https://github.com/processing/processing/issues/3806
X https://github.com/processing/processing/pull/3817
X CM list should be sortable by status and author name
X https://github.com/processing/processing/issues/3608
_ All contributions listed after install button is clicked
_ https://github.com/processing/processing/issues/3826
jakub
X Make preprocessor scope-aware
@@ -150,6 +152,8 @@ _ https://github.com/processing/processing/issues/136
manager
_ ArrayIndexOutOfBoundsException freak out when clicking the header line
_ think this was on name, with libraries, but not sure
_ needs a frame title
_ CM selected tabs are too tall
_ https://github.com/processing/processing/issues/3598