Skip to content

Commit 50c16ab

Browse files
committed
a bit of cleaning and implement updateTheme() in contrib manager
1 parent 49393a2 commit 50c16ab

File tree

5 files changed

+45
-51
lines changed

5 files changed

+45
-51
lines changed

app/src/processing/app/contrib/ContributionManager.java

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import java.net.*;
2828
import java.util.*;
2929

30-
import javax.swing.SwingWorker;
31-
3230
import processing.app.Base;
3331
import processing.app.Language;
3432
import processing.app.Messages;
@@ -676,79 +674,64 @@ static private void clearRestartFlags(File root) {
676674
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
677675

678676

679-
static ManagerFrame managerDialog;
677+
static ManagerFrame managerFrame;
680678

681679

682680
static public void init(Base base) throws Exception {
683681
// long t1 = System.currentTimeMillis();
684682
listing = ContributionListing.getInstance(); // Moved here to make sure it runs on EDT [jv 170121]
685683
// long t2 = System.currentTimeMillis();
686-
managerDialog = new ManagerFrame(base);
684+
managerFrame = new ManagerFrame(base);
687685
// long t3 = System.currentTimeMillis();
688686
cleanup(base);
689687
// long t4 = System.currentTimeMillis();
690688
// System.out.println("ContributionManager.init() " + (t2-t1) + " " + (t3-t2) + " " + (t4-t3));
691689
}
692690

693691

692+
static public void updateTheme() {
693+
if (managerFrame != null) {
694+
managerFrame.updateTheme();
695+
}
696+
}
697+
698+
694699
/**
695700
* Show the Library installer window.
696701
*/
697702
static public void openLibraries() {
698-
managerDialog.showFrame(ContributionType.LIBRARY);
703+
managerFrame.showFrame(ContributionType.LIBRARY);
699704
}
700705

701706

702707
/**
703708
* Show the Mode installer window.
704709
*/
705710
static public void openModes() {
706-
managerDialog.showFrame(ContributionType.MODE);
711+
managerFrame.showFrame(ContributionType.MODE);
707712
}
708713

709714

710715
/**
711716
* Show the Tool installer window.
712717
*/
713718
static public void openTools() {
714-
managerDialog.showFrame(ContributionType.TOOL);
719+
managerFrame.showFrame(ContributionType.TOOL);
715720
}
716721

717722

718723
/**
719724
* Show the Examples installer window.
720725
*/
721726
static public void openExamples() {
722-
managerDialog.showFrame(ContributionType.EXAMPLES);
727+
managerFrame.showFrame(ContributionType.EXAMPLES);
723728
}
724729

725730

726731
/**
727732
* Open the updates panel.
728733
*/
729734
static public void openUpdates() {
730-
managerDialog.showFrame(null);
735+
managerFrame.showFrame(null);
731736
}
732-
733-
734-
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
735-
736-
737-
/*
738-
static int getTypeIndex(ContributionType contributionType) {
739-
int index;
740-
if (contributionType == ContributionType.LIBRARY) {
741-
index = 0;
742-
} else if (contributionType == ContributionType.MODE) {
743-
index = 1;
744-
} else if (contributionType == ContributionType.TOOL) {
745-
index = 2;
746-
} else if (contributionType == ContributionType.EXAMPLES) {
747-
index = 3;
748-
} else {
749-
index = 4;
750-
}
751-
return index;
752-
}
753-
*/
754737
}

app/src/processing/app/contrib/ManagerFrame.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void showFrame(ContributionType contributionType) {
110110
private void makeFrame() {
111111
frame = new JFrame(title);
112112
frame.setMinimumSize(Toolkit.zoom(750, 500));
113-
tabs = new ManagerTabs(base);
113+
tabs = new ManagerTabs();
114114

115115
makeAndShowTab(false, true);
116116

@@ -137,7 +137,10 @@ private void makeFrame() {
137137

138138

139139
protected void updateTheme() {
140-
frame.getContentPane().setBackground(Theme.getColor("manager.tab.background"));
140+
Color bgColor = Theme.getColor("manager.tab.background");
141+
frame.getContentPane().setBackground(bgColor);
142+
143+
tabs.updateTheme();
141144
}
142145

143146

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

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@
3535
import java.util.ArrayList;
3636
import java.util.List;
3737

38-
import javax.swing.*;
38+
import javax.swing.Box;
39+
import javax.swing.BoxLayout;
40+
import javax.swing.JComponent;
41+
import javax.swing.JPanel;
3942
import javax.swing.border.EmptyBorder;
4043

41-
import processing.app.Base;
42-
import processing.app.Mode;
4344
import processing.app.ui.Theme;
4445
import processing.app.ui.Toolkit;
4546

@@ -71,25 +72,35 @@ public class ManagerTabs extends Box {
7172

7273
List<Tab> tabList = new ArrayList<>();
7374

74-
Mode mode;
75-
7675
Font font;
7776
int fontAscent;
7877

78+
Image gradient;
79+
7980
JPanel cardPanel;
8081
CardLayout cardLayout;
8182
Controller controller;
8283

8384
Component currentPanel;
8485

8586

86-
public ManagerTabs(Base base) {
87+
public ManagerTabs() {
8788
super(BoxLayout.Y_AXIS);
8889

89-
// A mode shouldn't actually override these, they're coming from theme.txt.
90-
// But use the default (Java) mode settings just in case.
91-
mode = base.getDefaultMode();
90+
updateTheme();
91+
92+
setBorder(new EmptyBorder(BORDER, BORDER, BORDER, BORDER));
9293

94+
controller = new Controller();
95+
add(controller);
96+
97+
cardLayout = new CardLayout();
98+
cardPanel = new JPanel(cardLayout);
99+
add(cardPanel);
100+
}
101+
102+
103+
protected void updateTheme() {
93104
textColor[SELECTED] = Theme.getColor("manager.tab.text.selected.color");
94105
textColor[UNSELECTED] = Theme.getColor("manager.tab.text.unselected.color");
95106
font = Theme.getFont("manager.tab.text.font");
@@ -99,14 +110,7 @@ public ManagerTabs(Base base) {
99110

100111
gradient = Theme.makeGradient("manager.tab", Toolkit.zoom(400), HIGH);
101112

102-
setBorder(new EmptyBorder(BORDER, BORDER, BORDER, BORDER));
103-
104-
controller = new Controller();
105-
add(controller);
106-
107-
cardLayout = new CardLayout();
108-
cardPanel = new JPanel(cardLayout);
109-
add(cardPanel);
113+
repaint();
110114
}
111115

112116

app/src/processing/app/tools/ThemeSelector.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
package processing.app.tools;
2525

2626
import processing.app.*;
27+
import processing.app.contrib.ContributionManager;
2728
import processing.app.ui.Editor;
2829
import processing.app.ui.Theme;
2930
import processing.app.ui.Toolkit;
@@ -126,6 +127,7 @@ private void setCurrentIndex(int index) {
126127
Util.saveFile(themeContents[index], sketchbookFile);
127128
Theme.load();
128129

130+
ContributionManager.updateTheme();
129131
for (Editor editor : base.getEditors()) {
130132
editor.updateTheme();
131133
//editor.repaint();

todo.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ X https://github.com/processing/processing/issues/5309
1414
X https://github.com/processing/processing4/issues/446
1515
X removed weird double call of installPreviouslyFailed()
1616
X remove unused icon code from ManagerTabs
17+
X implement updateTheme()
18+
_ remove the extra 2-pixel line at the top
19+
_ currently uses prepareGraphics(), do we need to remove that?
1720
_ allow update of the current Mode
1821

1922
_ an incompatible Mode prevents the PDE from quitting after last window is closed
@@ -140,7 +143,6 @@ _ console scroll bar colors
140143
_ https://github.com/processing/processing4/issues/265
141144
_ errors table theme
142145
_ contrib manager theme
143-
_ implement updateTheme()
144146
_ identify coloring for icons
145147
_ how much of theme to inherit
146148
_ generate manager icons

0 commit comments

Comments
 (0)