Skip to content

Commit

Permalink
a bit of cleaning and implement updateTheme() in contrib manager
Browse files Browse the repository at this point in the history
  • Loading branch information
benfry committed Mar 12, 2022
1 parent 49393a2 commit 50c16ab
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 51 deletions.
45 changes: 14 additions & 31 deletions app/src/processing/app/contrib/ContributionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import java.net.*;
import java.util.*;

import javax.swing.SwingWorker;

import processing.app.Base;
import processing.app.Language;
import processing.app.Messages;
Expand Down Expand Up @@ -676,79 +674,64 @@ static private void clearRestartFlags(File root) {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


static ManagerFrame managerDialog;
static ManagerFrame managerFrame;


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


static public void updateTheme() {
if (managerFrame != null) {
managerFrame.updateTheme();
}
}


/**
* Show the Library installer window.
*/
static public void openLibraries() {
managerDialog.showFrame(ContributionType.LIBRARY);
managerFrame.showFrame(ContributionType.LIBRARY);
}


/**
* Show the Mode installer window.
*/
static public void openModes() {
managerDialog.showFrame(ContributionType.MODE);
managerFrame.showFrame(ContributionType.MODE);
}


/**
* Show the Tool installer window.
*/
static public void openTools() {
managerDialog.showFrame(ContributionType.TOOL);
managerFrame.showFrame(ContributionType.TOOL);
}


/**
* Show the Examples installer window.
*/
static public void openExamples() {
managerDialog.showFrame(ContributionType.EXAMPLES);
managerFrame.showFrame(ContributionType.EXAMPLES);
}


/**
* Open the updates panel.
*/
static public void openUpdates() {
managerDialog.showFrame(null);
managerFrame.showFrame(null);
}


// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


/*
static int getTypeIndex(ContributionType contributionType) {
int index;
if (contributionType == ContributionType.LIBRARY) {
index = 0;
} else if (contributionType == ContributionType.MODE) {
index = 1;
} else if (contributionType == ContributionType.TOOL) {
index = 2;
} else if (contributionType == ContributionType.EXAMPLES) {
index = 3;
} else {
index = 4;
}
return index;
}
*/
}
7 changes: 5 additions & 2 deletions app/src/processing/app/contrib/ManagerFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void showFrame(ContributionType contributionType) {
private void makeFrame() {
frame = new JFrame(title);
frame.setMinimumSize(Toolkit.zoom(750, 500));
tabs = new ManagerTabs(base);
tabs = new ManagerTabs();

makeAndShowTab(false, true);

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


protected void updateTheme() {
frame.getContentPane().setBackground(Theme.getColor("manager.tab.background"));
Color bgColor = Theme.getColor("manager.tab.background");
frame.getContentPane().setBackground(bgColor);

tabs.updateTheme();
}


Expand Down
38 changes: 21 additions & 17 deletions app/src/processing/app/contrib/ManagerTabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@
import java.util.ArrayList;
import java.util.List;

import javax.swing.*;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import processing.app.Base;
import processing.app.Mode;
import processing.app.ui.Theme;
import processing.app.ui.Toolkit;

Expand Down Expand Up @@ -71,25 +72,35 @@ public class ManagerTabs extends Box {

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

Mode mode;

Font font;
int fontAscent;

Image gradient;

JPanel cardPanel;
CardLayout cardLayout;
Controller controller;

Component currentPanel;


public ManagerTabs(Base base) {
public ManagerTabs() {
super(BoxLayout.Y_AXIS);

// A mode shouldn't actually override these, they're coming from theme.txt.
// But use the default (Java) mode settings just in case.
mode = base.getDefaultMode();
updateTheme();

setBorder(new EmptyBorder(BORDER, BORDER, BORDER, BORDER));

controller = new Controller();
add(controller);

cardLayout = new CardLayout();
cardPanel = new JPanel(cardLayout);
add(cardPanel);
}


protected void updateTheme() {
textColor[SELECTED] = Theme.getColor("manager.tab.text.selected.color");
textColor[UNSELECTED] = Theme.getColor("manager.tab.text.unselected.color");
font = Theme.getFont("manager.tab.text.font");
Expand All @@ -99,14 +110,7 @@ public ManagerTabs(Base base) {

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

setBorder(new EmptyBorder(BORDER, BORDER, BORDER, BORDER));

controller = new Controller();
add(controller);

cardLayout = new CardLayout();
cardPanel = new JPanel(cardLayout);
add(cardPanel);
repaint();
}


Expand Down
2 changes: 2 additions & 0 deletions app/src/processing/app/tools/ThemeSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package processing.app.tools;

import processing.app.*;
import processing.app.contrib.ContributionManager;
import processing.app.ui.Editor;
import processing.app.ui.Theme;
import processing.app.ui.Toolkit;
Expand Down Expand Up @@ -126,6 +127,7 @@ private void setCurrentIndex(int index) {
Util.saveFile(themeContents[index], sketchbookFile);
Theme.load();

ContributionManager.updateTheme();
for (Editor editor : base.getEditors()) {
editor.updateTheme();
//editor.repaint();
Expand Down
4 changes: 3 additions & 1 deletion todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ 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
X implement updateTheme()
_ remove the extra 2-pixel line at the top
_ currently uses prepareGraphics(), do we need to remove that?
_ allow update of the current Mode

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

0 comments on commit 50c16ab

Please sign in to comment.