diff --git a/app/src/processing/app/ui/WebFrame.java b/app/src/processing/app/ui/WebFrame.java index 376007e68..797abc9e1 100644 --- a/app/src/processing/app/ui/WebFrame.java +++ b/app/src/processing/app/ui/WebFrame.java @@ -21,6 +21,7 @@ package processing.app.ui; +import java.awt.Container; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -46,10 +47,10 @@ public class WebFrame extends JFrame { boolean ready; - public WebFrame(File file, int width) throws IOException { + public WebFrame(File file, int width, Container panel) throws IOException { // Need to use the URL version so that relative paths work for images // https://github.com/processing/processing/issues/3494 - URL fileUrl = file.toURI().toURL(); //.toExternalForm(); + URL fileUrl = file.toURI().toURL(); requestContentHeight(width, fileUrl); editorPane = new JEditorPane(); @@ -68,7 +69,14 @@ public class WebFrame extends JFrame { editorPane.setEditable(false); // set height to something generic editorPane.setPreferredSize(new Dimension(width, width)); - getContentPane().add(editorPane); + + //getContentPane().add(editorPane); + Container pain = getContentPane(); + pain.setLayout(new BoxLayout(pain, BoxLayout.Y_AXIS)); + pain.add(editorPane); + if (panel != null) { + pain.add(panel); + } Toolkit.registerWindowCloseKeys(getRootPane(), new ActionListener() { @Override diff --git a/app/src/processing/app/ui/Welcome.java b/app/src/processing/app/ui/Welcome.java index c0b38d198..9f7485516 100644 --- a/app/src/processing/app/ui/Welcome.java +++ b/app/src/processing/app/ui/Welcome.java @@ -21,54 +21,114 @@ package processing.app.ui; +import java.awt.Color; import java.awt.EventQueue; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.io.File; import java.io.IOException; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComponent; + import processing.app.Base; import processing.app.Language; import processing.app.Platform; import processing.app.Preferences; import processing.core.PApplet; -import processing.data.StringDict; -public class Welcome extends WebFrame { +public class Welcome { Base base; + WebFrame view; public Welcome(Base base, boolean sketchbook) throws IOException { - super(getIndexFile(sketchbook), 400); this.base = base; - //addStyle("#new_sketchbook { background-color: rgb(0, 255, 0); }"); - setVisible(true); - } + // TODO this should live inside theme or somewhere modifiable + Font dialogFont = Toolkit.getSansFont(14, Font.PLAIN); - public void handleSubmit(StringDict dict) { - // sketchbook = "create_new" or "use_existing" - // show_each_time = "on" or - //dict.print(); + JComponent panel = Box.createHorizontalBox(); + panel.setBackground(new Color(245, 245, 245)); + Toolkit.setBorder(panel, 15, 20, 15, 20); - String sketchbookAction = dict.get("sketchbook", null); - if ("create_new".equals(sketchbookAction)) { - // open file dialog - // on affirmative selection, update sketchbook folder -// String path = Preferences.getSketchbookPath() + "3"; -// File folder = new File(path); -// folder.mkdirs(); - File folder = new File(Preferences.getSketchbookPath()).getParentFile(); - PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"), - "sketchbookCallback", folder, - this, this); - } + //panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); + //panel.add(Box.createHorizontalStrut(20)); + JCheckBox checkbox = new JCheckBox("Show this message on startup"); + checkbox.setFont(dialogFont); + // handles the Help menu invocation, and also the pref not existing + checkbox.setSelected("true".equals(Preferences.get("welcome.show"))); + checkbox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + Preferences.setBoolean("welcome.show", true); + } else if (e.getStateChange() == ItemEvent.DESELECTED) { + Preferences.setBoolean("welcome.show", false); + } + } + }); + panel.add(checkbox); - // If un-checked, the key won't be in the dict, so null will be passed - boolean keepShowing = "on".equals(dict.get("show_each_time", null)); - Preferences.setBoolean("welcome.show", keepShowing); - Preferences.save(); + panel.add(Box.createHorizontalGlue()); - handleClose(); + JButton button = new JButton("Get Started"); + button.setFont(Toolkit.getSansFont(14, Font.PLAIN)); + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + view.handleClose(); + } + }); + panel.add(button); + //panel.add(Box.createHorizontalGlue()); + + view = new WebFrame(getIndexFile(sketchbook), 425, panel) { + /* + @Override + public void handleSubmit(StringDict dict) { + String sketchbookAction = dict.get("sketchbook", null); + if ("create_new".equals(sketchbookAction)) { + File folder = new File(Preferences.getSketchbookPath()).getParentFile(); + PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"), + "sketchbookCallback", folder, + this, this); + } + +// // If un-checked, the key won't be in the dict, so null will be passed +// boolean keepShowing = "on".equals(dict.get("show_each_time", null)); +// Preferences.setBoolean("welcome.show", keepShowing); +// Preferences.save(); + handleClose(); + } + */ + + @Override + public void handleLink(String link) { + // The link will already have the full URL prefix + if (link.endsWith("#sketchbook")) { + File folder = new File(Preferences.getSketchbookPath()).getParentFile(); + PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"), + "sketchbookCallback", folder, + this, this); + } else { + super.handleLink(link); + } + } + + @Override + public void handleClose() { + Preferences.setBoolean("welcome.seen", true); + Preferences.save(); + super.handleClose(); + } + }; + view.setVisible(true); } @@ -77,16 +137,17 @@ public class Welcome extends WebFrame { if (folder != null) { if (base != null) { base.setSketchbookFolder(folder); - } else { - System.out.println("user selected " + folder); +// } else { +// System.out.println("user selected " + folder); } } } - public void handleClose() { - dispose(); - } +// @Override +// public void handleClose() { +// dispose(); +// } static private File getIndexFile(boolean sketchbook) { @@ -120,11 +181,7 @@ public class Welcome extends WebFrame { EventQueue.invokeLater(new Runnable() { public void run() { try { - new Welcome(null, true) { - public void handleClose() { - System.exit(0); - } - }; + new Welcome(null, true); } catch (IOException e) { e.printStackTrace(); } diff --git a/build/shared/lib/welcome/style.css b/build/shared/lib/welcome/style.css index 75f557f20..72b363733 100644 --- a/build/shared/lib/welcome/style.css +++ b/build/shared/lib/welcome/style.css @@ -4,7 +4,8 @@ } body { - padding: 20px; + padding-left: 20px; + padding-right: 20px; font-family: "Processing Sans Pro", sans-serif; } @@ -14,11 +15,6 @@ h1 { font-family: "Processing Sans Pro", sans-serif; font-size: 1.3em; /*16px;*/ font-weight: normal; -/* - font-size: 1.15em; - font-family: "Processing Sans Pro", sans-serif; - font-weight: 600; -*/ } p, td { diff --git a/java/src/processing/mode/java/JavaEditor.java b/java/src/processing/mode/java/JavaEditor.java index a502aba90..10c825027 100644 --- a/java/src/processing/mode/java/JavaEditor.java +++ b/java/src/processing/mode/java/JavaEditor.java @@ -264,7 +264,7 @@ public class JavaEditor extends Editor { item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { - new Welcome2(base, Preferences.getSketchbookPath().equals(Preferences.getOldSketchbookPath())); + new Welcome(base, Preferences.getSketchbookPath().equals(Preferences.getOldSketchbookPath())); } catch (IOException ioe) { Messages.showWarning("Unwelcome Error", "Please report this error to\n" + diff --git a/todo.txt b/todo.txt index 0d5e3ff09..ab19586e8 100755 --- a/todo.txt +++ b/todo.txt @@ -7,17 +7,17 @@ X https://github.com/processing/processing/pull/5263 welcome -_ just remove the welcome dialog; but what should the default behavior be? -_ or should it only show up for people who have used <=2 but not 3? +o just remove the welcome dialog; but what should the default behavior be? +o or should it only show up for people who have used <=2 but not 3? +X click "show this welcome" text to check/uncheck the box +X https://github.com/processing/processing/issues/3912 +X submit the form (as if 'get started' clicked) when closing the window +X whether hitting ESC or the close box on the window +X https://github.com/processing/processing/issues/3911 _ Welcome dialog rewritten in Swing _ https://github.com/processing/processing/pull/5210 _ Welcome screen doesn't size properly for HiDPI screens _ https://github.com/processing/processing/issues/4896 -_ click "show this welcome" text to check/uncheck the box -_ https://github.com/processing/processing/issues/3912 -_ submit the form (as if 'get started' clicked) when closing the window -_ whether hitting ESC or the close box on the window -_ https://github.com/processing/processing/issues/3911 manager