Skip to content

Commit 49393a2

Browse files
committed
remove unused icon code from ManagerTabs
1 parent beb6aeb commit 49393a2

File tree

2 files changed

+10
-77
lines changed

2 files changed

+10
-77
lines changed

app/src/processing/app/contrib/ManagerTabs.java

Lines changed: 8 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ public class ManagerTabs extends Box {
6363
// amount of margin on the left/right for the text on the tab
6464
static final int MARGIN = Toolkit.zoom(14);
6565

66-
static final int ICON_WIDTH = Toolkit.zoom(16);
67-
static final int ICON_HEIGHT = Toolkit.zoom(16);
68-
static final int ICON_TOP = Toolkit.zoom(7);
69-
static final int ICON_MARGIN = Toolkit.zoom(7);
70-
7166
static final int UNSELECTED = 0;
7267
static final int SELECTED = 1;
7368

@@ -81,8 +76,6 @@ public class ManagerTabs extends Box {
8176
Font font;
8277
int fontAscent;
8378

84-
Image gradient;
85-
8679
JPanel cardPanel;
8780
CardLayout cardLayout;
8881
Controller controller;
@@ -117,32 +110,20 @@ public ManagerTabs(Base base) {
117110
}
118111

119112

120-
/** Add a panel with no icon. */
121-
public void addPanel(Component comp, String name) {
122-
addPanel(comp, name, null);
123-
}
124-
125-
126113
/**
127-
* Add a panel with a name and icon.
114+
* Add a panel with a name.
128115
* @param comp Component that will be shown when this tab is selected
129116
* @param name Title to appear on the tab itself
130-
* @param icon Prefix of the file name for the icon
131117
*/
132-
public void addPanel(Component comp, String name, String icon) {
118+
public void addPanel(Component comp, String name) {
133119
if (tabList.isEmpty()) {
134120
currentPanel = comp;
135121
}
136-
tabList.add(new Tab(comp, name, icon));
122+
tabList.add(new Tab(comp, name));
137123
cardPanel.add(name, comp);
138124
}
139125

140126

141-
// public void setPanel(int index) {
142-
// cardLayout.show(cardPanel, tabs.get(index).name);
143-
// }
144-
145-
146127
public void setPanel(Component comp) {
147128
for (Tab tab : tabList) {
148129
if (tab.comp == comp) {
@@ -159,16 +140,6 @@ public Component getPanel() {
159140
}
160141

161142

162-
public void setNotification(Component comp, boolean note) {
163-
for (Tab tab : tabList) {
164-
if (tab.comp == comp) {
165-
tab.notification = note;
166-
repaint();
167-
}
168-
}
169-
}
170-
171-
172143
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
173144

174145

@@ -212,32 +183,19 @@ public void paintComponent(Graphics g) {
212183
tab.textWidth = (int)
213184
font.getStringBounds(tab.name, g2.getFontRenderContext()).getWidth();
214185
}
215-
216-
placeTabs(0);
186+
placeTabs();
217187
// now actually draw the tabs
218188
drawTabs(g2);
219189
}
220190

221191

222-
/**
223-
* @param left starting position from the left
224-
*/
225-
private void placeTabs(int left) { //, Graphics2D g) {
226-
int x = left;
227-
192+
private void placeTabs() {
193+
int x = 0;
228194
for (Tab tab : tabList) {
229195
tab.left = x;
230196
x += MARGIN;
231-
if (tab.hasIcon()) {
232-
x += ICON_WIDTH + MARGIN;
233-
}
234197
x += tab.textWidth + MARGIN;
235198
tab.right = x;
236-
237-
// // if drawing and not just placing
238-
// if (g != null) {
239-
// tab.draw(g);
240-
// }
241199
x += TAB_BETWEEN;
242200
}
243201
// Align the final tab (the "updates") to the right-hand side
@@ -279,24 +237,13 @@ class Tab {
279237
Component comp;
280238
boolean notification;
281239

282-
Image enabledIcon;
283-
Image selectedIcon;
284-
285240
int left;
286241
int right;
287242
int textWidth;
288243

289-
Tab(Component comp, String name, String icon) {
244+
Tab(Component comp, String name) {
290245
this.comp = comp;
291246
this.name = name;
292-
293-
if (icon != null) {
294-
enabledIcon = mode.loadImageX(icon + "-enabled");
295-
selectedIcon = mode.loadImageX(icon + "-selected");
296-
if (selectedIcon == null) {
297-
selectedIcon = enabledIcon; // use this as the default
298-
}
299-
}
300247
}
301248

302249
boolean contains(int x) {
@@ -319,36 +266,20 @@ boolean hasRightNotch() {
319266
}
320267

321268
int getTextLeft() {
322-
int links = left;
323-
if (enabledIcon != null) {
324-
links += ICON_WIDTH + ICON_MARGIN;
325-
}
326-
return links + ((right - links) - textWidth) / 2;
327-
}
328-
329-
boolean hasIcon() {
330-
return enabledIcon != null;
269+
return left + ((right - left) - textWidth) / 2;
331270
}
332271

333272
void draw(Graphics g) {
334273
int state = isCurrent() ? SELECTED : UNSELECTED;
335274
g.setColor(tabColor[state]);
336275

337276
Graphics2D g2 = (Graphics2D) g;
338-
// g2.fill(Toolkit.createRoundRect(left, TAB_TOP, right, TAB_BOTTOM, 0, 0,
339-
// isLast() ? CURVE_RADIUS : 0,
340-
// hastLeftCurve() ? CURVE_RADIUS : 0));
341277
g2.fill(Toolkit.createRoundRect(left, TAB_TOP,
342278
right, TAB_BOTTOM,
343279
hasLeftNotch() ? CURVE_RADIUS : 0,
344280
hasRightNotch() ? CURVE_RADIUS : 0,
345281
0, 0));
346282

347-
if (hasIcon()) {
348-
Image icon = (isCurrent() || notification) ? selectedIcon : enabledIcon;
349-
g.drawImage(icon, left + MARGIN, ICON_TOP, ICON_WIDTH, ICON_HEIGHT, null);
350-
}
351-
352283
int textLeft = getTextLeft();
353284
if (notification && state == UNSELECTED) {
354285
g.setColor(textColor[SELECTED]);

todo.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ X https://github.com/processing/processing4/issues/445
1212
X Manager fails to complete install of PythonMode when no windows open
1313
X https://github.com/processing/processing/issues/5309
1414
X https://github.com/processing/processing4/issues/446
15+
X removed weird double call of installPreviouslyFailed()
16+
X remove unused icon code from ManagerTabs
1517
_ allow update of the current Mode
1618

1719
_ an incompatible Mode prevents the PDE from quitting after last window is closed

0 commit comments

Comments
 (0)