Skip to content

Commit 2a0bc2b

Browse files
author
Federico Fissore
committed
Splashscreen
1 parent af3c2bd commit 2a0bc2b

File tree

10 files changed

+125
-16
lines changed

10 files changed

+125
-16
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ build/windows/libastylej*
2121
build/windows/arduino-*.zip
2222
build/windows/dist/*.tar.gz
2323
build/windows/dist/*.tar.bz2
24-
build/windows/launch4j-*
24+
build/windows/launch4j-*.tgz
25+
build/windows/launch4j-*.zip
2526
build/windows/launcher/launch4j
2627
build/windows/WinAVR-*.zip
2728
build/macosx/arduino-*.zip
@@ -44,8 +45,5 @@ test-bin
4445
.idea
4546
.DS_Store
4647
.directory
47-
build/windows/launch4j-*
48-
build/windows/launcher/launch4j
49-
build/windows/WinAVR-*.zip
5048
hardware/arduino/avr/libraries/Bridge/examples/XivelyClient/passwords.h
5149
avr-toolchain-*.zip
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Code inspired by this tutorial http://wiki.netbeans.org/Splash_Screen_Beginner_Tutorial. License says "You may modify and use it as you wish."
5+
*
6+
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
7+
*
8+
* Arduino is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21+
*
22+
* As a special exception, you may use this file as part of a free software
23+
* library without restriction. Specifically, if other files instantiate
24+
* templates or use macros or inline functions from this file, or you compile
25+
* this file and link it with other files to produce an executable, this
26+
* file does not by itself cause the resulting executable to be covered by
27+
* the GNU General Public License. This exception does not however
28+
* invalidate any other reasons why the executable file might be covered by
29+
* the GNU General Public License.
30+
*/
31+
32+
package cc.arduino.view;
33+
34+
import java.awt.*;
35+
import java.awt.geom.Rectangle2D;
36+
import java.util.Map;
37+
38+
public class SplashScreenHelper {
39+
40+
private final Map desktopHints;
41+
private SplashScreen splash;
42+
private Rectangle2D.Double splashTextArea;
43+
private Graphics2D splashGraphics;
44+
45+
public SplashScreenHelper(SplashScreen splash) {
46+
this.splash = splash;
47+
Toolkit tk = Toolkit.getDefaultToolkit();
48+
desktopHints = (Map) tk.getDesktopProperty("awt.font.desktophints");
49+
}
50+
51+
public void splashText(String str) {
52+
if (splash == null) {
53+
printText(str);
54+
return;
55+
}
56+
if (!splash.isVisible()) {
57+
return;
58+
}
59+
60+
if (splashTextArea == null) {
61+
// stake out some area for our status information
62+
splashTextArea = new Rectangle2D.Double(0, 300, 520, 30);
63+
64+
// create the Graphics environment for drawing status info
65+
splashGraphics = splash.createGraphics();
66+
67+
if (desktopHints != null) {
68+
splashGraphics.addRenderingHints(desktopHints);
69+
}
70+
}
71+
72+
// erase the last status text
73+
splashGraphics.setPaint(new Color(245, 245, 245));
74+
splashGraphics.fill(splashTextArea);
75+
76+
// draw the text
77+
splashGraphics.setPaint(Color.BLACK);
78+
FontMetrics metrics = splashGraphics.getFontMetrics();
79+
splashGraphics.drawString(str, (int) splashTextArea.getX() + 10, (int) splashTextArea.getY() + (30 - metrics.getHeight()) + 4);
80+
81+
// make sure it's displayed
82+
splash.update();
83+
}
84+
85+
public void close() {
86+
if (splash == null) {
87+
return;
88+
}
89+
splash.close();
90+
}
91+
92+
public void printText(String str) {
93+
System.out.println(str);
94+
}
95+
96+
}

app/src/processing/app/Base.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package processing.app;
2424

2525
import cc.arduino.packages.DiscoveryManager;
26+
import cc.arduino.view.SplashScreenHelper;
2627
import processing.app.debug.TargetBoard;
2728
import processing.app.debug.TargetPackage;
2829
import processing.app.debug.TargetPlatform;
@@ -56,6 +57,7 @@
5657
public class Base {
5758

5859
static private boolean commandLine;
60+
public static SplashScreenHelper splashScreenHelper;
5961

6062
// A single instance of the preferences window
6163
Preferences preferencesFrame;
@@ -87,6 +89,8 @@ static public void main(String args[]) throws Exception {
8789
System.setProperty("awt.useSystemAAFontSettings", "on");
8890
System.setProperty("swing.aatext", "true");
8991

92+
splashScreenHelper = new SplashScreenHelper(SplashScreen.getSplashScreen());
93+
9094
BaseNoGui.initLogger();
9195

9296
BaseNoGui.notifier = new GUIUserNotifier();
@@ -221,8 +225,10 @@ public Base(String[] args) throws Exception {
221225
}
222226
}
223227

228+
splashScreenHelper.splashText(_("Initializing packages..."));
224229
BaseNoGui.initPackages();
225-
230+
splashScreenHelper.splashText(_("Preparing boards..."));
231+
226232
// Setup board-dependent variables.
227233
onBoardOrPortChange();
228234

@@ -263,6 +269,7 @@ public Base(String[] args) throws Exception {
263269
Preferences.save();
264270

265271
if (parser.isVerifyOrUploadMode()) {
272+
splashScreenHelper.close();
266273
// Set verbosity for command line build
267274
Preferences.set("build.verbose", "" + parser.isDoVerboseBuild());
268275
Preferences.set("upload.verbose", "" + parser.isDoVerboseUpload());
@@ -290,6 +297,8 @@ public Base(String[] args) throws Exception {
290297
System.exit(0);
291298
}
292299
else if (parser.isGuiMode()) {
300+
splashScreenHelper.splashText(_("Starting..."));
301+
293302
// Check if there were previously opened sketches to be restored
294303
restoreSketches();
295304

build/build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302

303303
<option value="-Xms128M"/>
304304
<option value="-Xmx512M"/>
305+
<option value="-splash:$APP_ROOT/Contents/Java/lib/splash.png"/>
305306

306307
<bundledocument extensions="ino,c,cpp,h"
307308
icon="macosx/template.app/Contents/Resources/pde.icns"

build/linux/dist/arduino

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
CURDIR=`pwd`
44
APPDIR="$(dirname -- "$(readlink -f -- "${0}")" )"
@@ -20,5 +20,11 @@ export LD_LIBRARY_PATH
2020

2121
export PATH="${APPDIR}/java/bin:${PATH}"
2222

23-
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base --curdir $CURDIR "$@"
23+
if [[ "$@" == *"--upload"* || "$@" == *"--upload"* || "$@" == *"--get-pref"* ]] ; then
24+
SPLASH=""
25+
else
26+
SPLASH="-splash:./lib/splash.png"
27+
fi
28+
29+
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel $SPLASH processing.app.Base --curdir $CURDIR "$@"
2430

build/macosx/template.app/Contents/Info.plist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
<key>MainClass</key>
8888
<string>processing.app.Base</string>
8989

90+
<key>SplashFile</key>
91+
<string>$APP_PACKAGE/Contents/Resources/Java/lib/splash.png</string>
92+
9093
<key>JVMVersion</key>
9194
<string>1.6*</string>
9295

build/shared/lib/splash.png

122 KB
Loading

build/shared/revisions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ARDUINO 1.6.2
44
[ide]
55
* In platform.txt, pre and post build hooks can now be specified. Example: recipe.hooks.prebuild.0.pattern=echo "Hello {build.source.path}". Thanks @Wackerbarth
66
* Windows and MacOSX JVM Xmx halved to 512M
7+
* Introduced starting splashscreen with progress status: will be used for notifying user of long running startup tasks
78

89
ARDUINO 1.6.1 - 2015.03.10
910

build/windows/launcher/config.xml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,16 @@
2929
</classPath>
3030
<jre>
3131
<path>java</path>
32-
<minVersion>1.6.0</minVersion>
32+
<minVersion>1.8.0</minVersion>
3333
<maxVersion></maxVersion>
3434
<jdkPreference>preferJre</jdkPreference>
35+
<opt>-splash:./lib/splash.png</opt>
3536
</jre>
36-
<splash>
37-
<file>about.bmp</file>
38-
<waitForWindow>true</waitForWindow>
39-
<timeout>60</timeout>
40-
<timeoutErr>true</timeoutErr>
41-
</splash>
4237
<messages>
4338
<startupErr>An error occurred while starting the application.</startupErr>
4439
<bundledJreErr>This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted.</bundledJreErr>
4540
<jreVersionErr>This application requires at least Java Development Kit</jreVersionErr>
46-
<launcherErr>The registry refers to a nonexistent Java Development Kit installation or the runtime is corrupted.</launcherErr>
41+
<launcherErr>The registry refers to a nonexistent Java Development Kit installation or the runtime is corrupted.</launcherErr>
4742
<instanceAlreadyExistsMsg>An application instance is already running.</instanceAlreadyExistsMsg>
4843
</messages>
4944
</launch4jConfig>

build/windows/launcher/config_debug.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</classPath>
3030
<jre>
3131
<path>java</path>
32-
<minVersion>1.6.0</minVersion>
32+
<minVersion>1.8.0</minVersion>
3333
<maxVersion></maxVersion>
3434
<jdkPreference>preferJre</jdkPreference>
3535
</jre>

0 commit comments

Comments
 (0)