Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bugfixing session

* SoftFullScreen now support choosing a screen-nr
* Renamed assets to dependencies
* Recompiled the menubar-hiding thingie for macosX for 10.4+, universal, 32+64bit
* Introduced unit tests
  • Loading branch information...
commit 86bb12dd5501489a18093b9e95a365e9a64c5022 1 parent ca2cb33
@kritzikratzi authored
View
7 .classpath
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="lib" path="assets/processing-opengl.jar"/>
- <classpathentry kind="lib" path="assets/jogl.jar"/>
- <classpathentry kind="lib" path="assets/processing-core.jar"/>
+ <classpathentry kind="lib" path="dependencies/jogl.jar"/>
+ <classpathentry kind="lib" path="dependencies/processing-core.jar"/>
+ <classpathentry kind="lib" path="dependencies/processing-opengl.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
BIN  assets/processing-core.jar
Binary file not shown
View
BIN  assets/processing-opengl.jar
Binary file not shown
View
10 build.xml
@@ -24,9 +24,9 @@
<property name="sketch.path" value="${user.home}/Documents/Processing" />
<property name="version" value="0.98" />
- <fileset id="cp" includes="assets/*.jar" />
+ <fileset id="cp" includes="dependencies/*.jar" />
<path id="cp">
- <fileset dir="." includes="assets/*.jar" />
+ <fileset dir="." includes="dependencies/*.jar" />
</path>
<!-- empty the binary folder -->
@@ -46,10 +46,10 @@
<!-- create the reference -->
<target name="reference" depends="compile" description="generate reference">
<javadoc bottom="processing fullscreen api library by hansi, 2009. "
- classpath="assets/processing-core.jar; bin"
+ classpath="dependencies/processing-core.jar; bin"
destdir="reference"
verbose="false"
- stylesheetfile="assets/stylesheet.css"
+ stylesheetfile="dependencies/stylesheet.css"
doctitle="Javadocs: Fullscreen API"
public="true" version="false"
windowtitle="Javadocs: Fullscreen API">
@@ -98,7 +98,7 @@
<mkdir dir="fs_src" />
<copy todir="fs_src">
- <fileset dir="." includes="assets/**, examples/**, src/**, docs/**, lib/**" />
+ <fileset dir="." includes="dependencies/**, examples/**, src/**, docs/**, lib/**" />
<fileset dir="." includes="build.xml, COPYING" />
</copy>
View
0  assets/README → dependencies/README
File renamed without changes
View
BIN  assets/jogl.jar → dependencies/jogl.jar
Binary file not shown
View
BIN  dependencies/processing-core.jar
Binary file not shown
View
BIN  dependencies/processing-opengl.jar
Binary file not shown
View
0  assets/stylesheet.css → dependencies/stylesheet.css
File renamed without changes
View
BIN  lib/libhide_menubar.jnilib
Binary file not shown
View
BIN  lib/libjAppleMenuBar.jnilib
Binary file not shown
View
4 src/fullscreen/FullScreen.java
@@ -21,6 +21,7 @@
package fullscreen;
+import java.awt.Color;
import java.awt.Dimension;
import java.awt.DisplayMode;
import java.awt.Frame;
@@ -90,6 +91,7 @@ public FullScreen( final PApplet dad, int screenNr ){
fsFrame = new Frame();
fsFrame.setTitle( dad.frame.getTitle() );
fsFrame.setUndecorated( true );
+ fsFrame.setBackground( Color.black );
if( dad.width > 0 ){
setResolution( dad.width, dad.height );
}
@@ -157,7 +159,7 @@ else if( fullScreen ){
setResolution( 0, 0 );
dad.requestFocus();
- dad.setLocation( 0, 0 );
+ dad.setLocation( ( fsFrame.getWidth() - dad.width ) / 2, ( fsFrame.getHeight() - dad.height ) / 2 );
GLDrawableHelper.reAllocate( this );
GLTextureUpdateHelper.update( this );
View
47 src/fullscreen/NativeOSX.java
@@ -1,47 +0,0 @@
-/*
- Part of the Processing Fullscreen API
-
- Copyright (c) 2006-08 Hansi Raber
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
-*/
-
-package fullscreen;
-
-
-/**
- * This class dynamically hides/shows the menubar on osx systems.<br><br>
- * You won't really need to use this directly.
- *
- * @author hansi
- */
-public class NativeOSX {
-
- static {
- // Ensure native JNI library is loaded
- System.loadLibrary("hide_menubar");
- }
-
- public NativeOSX() {
- }
-
- /**
- * Shows/Hides the menubar on osx
- *
- * @param visibility True for show, false for hide.
- */
- public native void setVisible( boolean visibility );
-}
View
40 src/fullscreen/SoftFullScreen.java
@@ -20,9 +20,12 @@
*/
package fullscreen;
+import japplemenubar.JAppleMenuBar;
+
import java.awt.Color;
import java.awt.Frame;
import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
import processing.core.PApplet;
import processing.core.PConstants;
@@ -48,7 +51,7 @@
public class SoftFullScreen extends FullScreenBase{
// We use this frame to go to fullScreen mode...
Frame fsFrame = new Frame();
- GraphicsDevice fsDevice = fsFrame.getGraphicsConfiguration().getDevice();
+ GraphicsDevice fsDevice;
//AWTEventListener fsKeyListener;
@@ -59,15 +62,35 @@
PApplet dad;
-
/**
* Creates a new softfullscreen object.
*
* @param dad The parent sketch (aka "this")
*/
public SoftFullScreen( PApplet dad ){
+ this( dad, 0 );
+ }
+
+ /**
+ * Creates a new softfullscreen object on a specific screen
+ * (numbering starts at 0)
+ *
+ * @param dad The parent sketch (usually "this")
+ * @param screenNr The screen number.
+ */
+ public SoftFullScreen( PApplet dad, int screenNr ){
super( dad );
- this.dad = dad;
+ this.dad = dad;
+
+ GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
+ if( screenNr >= devices.length ){
+ System.err.println( "FullScreen API: You requested to use screen nr. " + screenNr + ", " );
+ System.err.println( "however, there are only " + devices.length + " screens in your environment. " );
+ System.err.println( "Continuing with screen nr. 0" );
+ screenNr = 0;
+ }
+
+ fsDevice = devices[screenNr];
fsFrame.setTitle( "FullScreen" );
fsFrame.setUndecorated( true );
fsFrame.setBackground( Color.black );
@@ -80,7 +103,6 @@ public SoftFullScreen( PApplet dad ){
registerFrame( fsFrame );
}
-
/**
* Are we in FullScreen mode?
*
@@ -119,16 +141,16 @@ private void setFullScreenImpl( boolean fullScreen ){
else if( fullScreen ){
if( available() ){
// remove applet from processing frame and attach to fsFrame
- fsFrame.setVisible( false );
+ dad.frame.setVisible( false );
fsFrame.add( dad );
dad.requestFocus();
if( PApplet.platform == PConstants.MACOSX ){
- new NativeOSX().setVisible( false );
+ new JAppleMenuBar().setVisible( false );
}
fsFrame.setVisible( true );
- fsFrame.setLocation( 0, 0 );
+ fsFrame.setLocation( fsDevice.getDefaultConfiguration().getBounds().getLocation() );
dad.setLocation( ( fsFrame.getWidth() - dad.width ) / 2, ( fsFrame.getHeight() - dad.height ) / 2 );
GLDrawableHelper.reAllocate( this );
@@ -145,16 +167,16 @@ else if( fullScreen ){
}
else{
// remove applet from fsFrame and attach to processing frame
+ fsFrame.setVisible( false );
fsFrame.removeAll();
dad.frame.add( dad );
dad.setLocation( dad.frame.insets().left, dad.frame.insets().top );
// processing.core.fullscreen_texturehelper.update( dad );
if( PApplet.platform == PConstants.MACOSX ){
- new NativeOSX().setVisible( true );
+ new JAppleMenuBar().setVisible( true );
}
- fsFrame.setVisible( false );
dad.frame.setVisible( true );
dad.requestFocus();
View
148 src/fullscreen/tests/Demo.java
@@ -0,0 +1,148 @@
+package fullscreen.tests;
+
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Insets;
+import java.awt.SystemColor;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import processing.core.PApplet;
+
+/**
+ * This class contains PApplets that can be used to test
+ * the fullscreen-api.
+ *
+ * @author hansi
+ */
+public class Demo{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * This is a simple Sketch using the JAVA-2D renderer
+ * @author hansi
+ *
+ */
+ public static class Simple extends LaunchablePApplet{
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void setup(){
+ size( 400, 400 );
+ }
+
+ @Override
+ public void draw(){
+ noStroke();
+
+ for( int i = 0; i < min( width/2, height/2 ); i+= 20 ){
+ fill( ( i/5 + frameCount )%255 );
+ rect( i, i, width - 2*i, height - 2*i );
+ }
+ }
+
+ }
+
+ /**
+ * This is a PApplet that actually launches itself when instantized.
+ * (That means no trouble with the main-method...)
+ */
+ private static class LaunchablePApplet extends PApplet{
+ private static final long serialVersionUID = 1L;
+
+ public LaunchablePApplet(){
+ // Disable abyssmally slow Sun renderer on OS X 10.5.
+ if ( PApplet.platform == PApplet.MACOSX ){
+ // Only run this on OS X otherwise it can cause a permissions error.
+ // http://dev.processing.org/bugs/show_bug.cgi?id=976
+ System.setProperty("apple.awt.graphics.UseQuartz", "true");
+ }
+
+ Color backgroundColor = Color.BLACK;
+ GraphicsDevice displayDevice = null;
+
+ // try to get the user folder. if running under java web start,
+ // this may cause a security exception if the code is not signed.
+ // http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Integrate;action=display;num=1159386274
+ String folder = null;
+ try {
+ folder = System.getProperty("user.dir");
+ } catch (Exception e) { }
+
+ if (displayDevice == null) {
+ GraphicsEnvironment environment =
+ GraphicsEnvironment.getLocalGraphicsEnvironment();
+ displayDevice = environment.getDefaultScreenDevice();
+ }
+
+ Frame frame = new Frame(displayDevice.getDefaultConfiguration());
+ frame.setResizable(false);
+ frame.setTitle( "Applet" );
+
+ // these are needed before init/start
+ this.frame = frame;
+ this.sketchPath = folder;
+ this.args = new String[]{};
+
+ frame.setLayout(null);
+ frame.add(this);
+ frame.pack();
+ init();
+
+ while (this.defaultSize && !this.finished) {
+ //System.out.println("default size");
+ try {
+ Thread.sleep(5);
+
+ } catch (InterruptedException e) {
+ //System.out.println("interrupt");
+ }
+ }
+ //println("not default size " + this.width + " " + this.height);
+ //println(" (g width/height is " + this.g.width + "x" + this.g.height + ")");
+
+ // if not presenting
+ Insets insets = frame.getInsets();
+
+ int windowW = Math.max(this.width, PApplet.MIN_WINDOW_WIDTH) +
+ insets.left + insets.right;
+ int windowH = Math.max(this.height, PApplet.MIN_WINDOW_HEIGHT) +
+ insets.top + insets.bottom;
+
+ frame.setSize(windowW, windowH);
+
+ // just center on screen
+ frame.setLocation((this.screen.width - this.width) / 2,
+ (this.screen.height - this.height) / 2);
+
+ if (backgroundColor == Color.black) { //BLACK) {
+ // this means no bg color unless specified
+ backgroundColor = SystemColor.control;
+ }
+ frame.setBackground(backgroundColor);
+
+ int usableWindowH = windowH - insets.top - insets.bottom;
+ this.setBounds((windowW - this.width)/2,
+ insets.top + (usableWindowH - this.height)/2,
+ this.width, this.height);
+
+ // !external
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ // handle frame resizing events
+ this.setupFrameResizeListener();
+
+ // all set for rockin
+ if (this.displayable()) {
+ frame.setVisible(true);
+ }
+ this.requestFocus(); // ask for keydowns
+ //System.out.println("exiting main()");
+ }
+}
+}
View
74 src/fullscreen/tests/Tests.java
@@ -0,0 +1,74 @@
+package fullscreen.tests;
+
+import japplemenubar.JAppleMenuBar;
+
+import org.junit.Test;
+
+import processing.core.PApplet;
+
+import fullscreen.FullScreen;
+import fullscreen.SoftFullScreen;
+
+/**
+ * Tests a few things semi-automatically...
+ * @author hansi
+ */
+public class Tests {
+
+ /**
+ * Tests if hiding the menu-bar works on mac-os
+ * @throws InterruptedException
+ */
+ @Test
+ public void testMenuBar() throws InterruptedException{
+ if( PApplet.platform == PApplet.MACOSX ){
+ JAppleMenuBar menuBar = new JAppleMenuBar();
+ menuBar.setVisible( false );
+ Thread.sleep( 500 );
+ menuBar.setVisible( true );
+ }
+ }
+
+ /**
+ * Creates a SoftFullScreen object on screen 0 and 1.
+ */
+ @Test
+ public void softFS() throws Exception{
+ for( int screenNr = 0; screenNr < 2; screenNr ++ ){
+ Demo.Simple sketch = new Demo.Simple();
+ SoftFullScreen fs = new SoftFullScreen( sketch, screenNr );
+ fs.setFullScreen( true );
+
+ Thread.sleep( 2000 );
+ fs.setFullScreen( false );
+
+ Thread.sleep( 2000 );
+
+ sketch.frame.setVisible( false );
+ sketch.stop();
+ sketch.destroy();
+ }
+ // if we haven't crashed until now we're good!
+ }
+
+ /**
+ * Creates the "classic" FS object on screen 0 and 1.
+ */
+ @Test
+ public void classicFS() throws Exception{
+ for( int screenNr = 0; screenNr < 2; screenNr ++ ){
+ Demo.Simple sketch = new Demo.Simple();
+ FullScreen fs = new FullScreen( sketch, screenNr );
+ fs.setFullScreen( true );
+
+ Thread.sleep( 2000 );
+ fs.setFullScreen( false );
+
+ Thread.sleep( 2000 );
+
+ sketch.frame.setVisible( false );
+ sketch.stop();
+ sketch.destroy();
+ }
+ }
+}
View
37 src/japplemenubar/JAppleMenuBar.java
@@ -0,0 +1,37 @@
+/*
+ Part of jAppleMenuBar
+
+ Copyright (c) 2006-09 Hansi Raber
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General
+ Public License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307 USA
+ */
+
+package japplemenubar;
+
+/**
+ * Starting point for the application. General initialization should be done inside
+ * the ApplicationController's init() method. If certain kinds of non-Swing initialization
+ * takes too long, it should happen in a new Thread and off the Swing event dispatch thread (EDT).
+ *
+ * @author hansi
+ */
+public class JAppleMenuBar {
+ static{
+ System.loadLibrary( "jAppleMenuBar" );
+ }
+
+ public native void setVisible( boolean visibility );
+}

0 comments on commit 86bb12d

Please sign in to comment.
Something went wrong with that request. Please try again.