From 49393a221a5aa558d5d88e0df89b985d84446106 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 11 Mar 2022 19:38:24 -0500 Subject: [PATCH] remove unused icon code from ManagerTabs --- .../processing/app/contrib/ManagerTabs.java | 85 ++----------------- todo.txt | 2 + 2 files changed, 10 insertions(+), 77 deletions(-) diff --git a/app/src/processing/app/contrib/ManagerTabs.java b/app/src/processing/app/contrib/ManagerTabs.java index 5913f93c7e..eefe89029a 100644 --- a/app/src/processing/app/contrib/ManagerTabs.java +++ b/app/src/processing/app/contrib/ManagerTabs.java @@ -63,11 +63,6 @@ public class ManagerTabs extends Box { // amount of margin on the left/right for the text on the tab static final int MARGIN = Toolkit.zoom(14); - static final int ICON_WIDTH = Toolkit.zoom(16); - static final int ICON_HEIGHT = Toolkit.zoom(16); - static final int ICON_TOP = Toolkit.zoom(7); - static final int ICON_MARGIN = Toolkit.zoom(7); - static final int UNSELECTED = 0; static final int SELECTED = 1; @@ -81,8 +76,6 @@ public class ManagerTabs extends Box { Font font; int fontAscent; - Image gradient; - JPanel cardPanel; CardLayout cardLayout; Controller controller; @@ -117,32 +110,20 @@ public ManagerTabs(Base base) { } - /** Add a panel with no icon. */ - public void addPanel(Component comp, String name) { - addPanel(comp, name, null); - } - - /** - * Add a panel with a name and icon. + * Add a panel with a name. * @param comp Component that will be shown when this tab is selected * @param name Title to appear on the tab itself - * @param icon Prefix of the file name for the icon */ - public void addPanel(Component comp, String name, String icon) { + public void addPanel(Component comp, String name) { if (tabList.isEmpty()) { currentPanel = comp; } - tabList.add(new Tab(comp, name, icon)); + tabList.add(new Tab(comp, name)); cardPanel.add(name, comp); } -// public void setPanel(int index) { -// cardLayout.show(cardPanel, tabs.get(index).name); -// } - - public void setPanel(Component comp) { for (Tab tab : tabList) { if (tab.comp == comp) { @@ -159,16 +140,6 @@ public Component getPanel() { } - public void setNotification(Component comp, boolean note) { - for (Tab tab : tabList) { - if (tab.comp == comp) { - tab.notification = note; - repaint(); - } - } - } - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -212,32 +183,19 @@ public void paintComponent(Graphics g) { tab.textWidth = (int) font.getStringBounds(tab.name, g2.getFontRenderContext()).getWidth(); } - - placeTabs(0); + placeTabs(); // now actually draw the tabs drawTabs(g2); } - /** - * @param left starting position from the left - */ - private void placeTabs(int left) { //, Graphics2D g) { - int x = left; - + private void placeTabs() { + int x = 0; for (Tab tab : tabList) { tab.left = x; x += MARGIN; - if (tab.hasIcon()) { - x += ICON_WIDTH + MARGIN; - } x += tab.textWidth + MARGIN; tab.right = x; - -// // if drawing and not just placing -// if (g != null) { -// tab.draw(g); -// } x += TAB_BETWEEN; } // Align the final tab (the "updates") to the right-hand side @@ -279,24 +237,13 @@ class Tab { Component comp; boolean notification; - Image enabledIcon; - Image selectedIcon; - int left; int right; int textWidth; - Tab(Component comp, String name, String icon) { + Tab(Component comp, String name) { this.comp = comp; this.name = name; - - if (icon != null) { - enabledIcon = mode.loadImageX(icon + "-enabled"); - selectedIcon = mode.loadImageX(icon + "-selected"); - if (selectedIcon == null) { - selectedIcon = enabledIcon; // use this as the default - } - } } boolean contains(int x) { @@ -319,15 +266,7 @@ boolean hasRightNotch() { } int getTextLeft() { - int links = left; - if (enabledIcon != null) { - links += ICON_WIDTH + ICON_MARGIN; - } - return links + ((right - links) - textWidth) / 2; - } - - boolean hasIcon() { - return enabledIcon != null; + return left + ((right - left) - textWidth) / 2; } void draw(Graphics g) { @@ -335,20 +274,12 @@ void draw(Graphics g) { g.setColor(tabColor[state]); Graphics2D g2 = (Graphics2D) g; -// g2.fill(Toolkit.createRoundRect(left, TAB_TOP, right, TAB_BOTTOM, 0, 0, -// isLast() ? CURVE_RADIUS : 0, -// hastLeftCurve() ? CURVE_RADIUS : 0)); g2.fill(Toolkit.createRoundRect(left, TAB_TOP, right, TAB_BOTTOM, hasLeftNotch() ? CURVE_RADIUS : 0, hasRightNotch() ? CURVE_RADIUS : 0, 0, 0)); - if (hasIcon()) { - Image icon = (isCurrent() || notification) ? selectedIcon : enabledIcon; - g.drawImage(icon, left + MARGIN, ICON_TOP, ICON_WIDTH, ICON_HEIGHT, null); - } - int textLeft = getTextLeft(); if (notification && state == UNSELECTED) { g.setColor(textColor[SELECTED]); diff --git a/todo.txt b/todo.txt index 570f4cbe77..dd03ae6f1d 100755 --- a/todo.txt +++ b/todo.txt @@ -12,6 +12,8 @@ X https://github.com/processing/processing4/issues/445 X Manager fails to complete install of PythonMode when no windows open X https://github.com/processing/processing/issues/5309 X https://github.com/processing/processing4/issues/446 +X removed weird double call of installPreviouslyFailed() +X remove unused icon code from ManagerTabs _ allow update of the current Mode _ an incompatible Mode prevents the PDE from quitting after last window is closed