Skip to content

Commit 1259edd

Browse files
committed
bring back our old os x menu bar hiding friend
1 parent 241f84c commit 1259edd

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

build/macosx/jAppleMenuBar-src.zip

17.7 KB
Binary file not shown.

build/macosx/jAppleMenuBar.url

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[InternetShortcut]
2+
URL=https://github.com/kritzikratzi/jAppleMenuBar
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
Part of the Processing project - http://processing.org
3+
4+
Copyright (c) 2011-12 hansi raber, released under LGPL under agreement
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation, version 2.1.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General
16+
Public License along with this library; if not, write to the
17+
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18+
Boston, MA 02111-1307 USA
19+
*/
20+
package japplemenubar;
21+
22+
import java.io.*;
23+
24+
import processing.core.PApplet;
25+
26+
27+
/**
28+
* Starting point for the application. General initialization should be done
29+
* inside the ApplicationController's init() method. If certain kinds of
30+
* non-Swing initialization takes too long, it should happen in a new Thread
31+
* and off the Swing event dispatch thread (EDT).
32+
*
33+
* @author hansi
34+
*/
35+
public class JAppleMenuBar {
36+
static JAppleMenuBar instance;
37+
static final String FILENAME = "libjAppleMenuBar.jnilib";
38+
39+
static {
40+
try {
41+
File temp = File.createTempFile("processing", "menubar");
42+
temp.delete(); // remove the file itself
43+
temp.mkdirs(); // create a directory out of it
44+
temp.deleteOnExit();
45+
46+
File jnilibFile = new File(temp, FILENAME);
47+
InputStream input = JAppleMenuBar.class.getResourceAsStream(FILENAME);
48+
if (input != null) {
49+
if (PApplet.saveStream(jnilibFile, input)) {
50+
System.load(jnilibFile.getAbsolutePath());
51+
instance = new JAppleMenuBar();
52+
53+
} else {
54+
sadness("Problem saving " + FILENAME + " for full screen use.");
55+
}
56+
} else {
57+
sadness("Could not load " + FILENAME + " from core.jar");
58+
}
59+
} catch (IOException e) {
60+
sadness("Unknown error, here's the stack trace.");
61+
e.printStackTrace();
62+
}
63+
}
64+
65+
66+
static void sadness(String msg) {
67+
System.err.println("Full screen mode disabled. " + msg);
68+
}
69+
70+
71+
// static public void show() {
72+
// instance.setVisible(true);
73+
// }
74+
75+
76+
static public void hide() {
77+
instance.setVisible(false, false);
78+
}
79+
80+
81+
public native void setVisible(boolean visibility, boolean kioskMode);
82+
83+
84+
// public void setVisible(boolean visibility) {
85+
// // Keep original API in-tact. Default kiosk-mode to off.
86+
// setVisible(visibility, false);
87+
// }
88+
}
28.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)