Browse files

minimize/restore functionality, thanks jeff!

  • Loading branch information...
1 parent b150245 commit 672b61b74293b1894bdaee79b4dd71e947270d0a @kritzikratzi committed Mar 23, 2010
Showing with 48 additions and 2 deletions.
  1. +48 −2 src/fullscreen/SoftFullScreen.java
View
50 src/fullscreen/SoftFullScreen.java
@@ -29,6 +29,9 @@
import processing.core.PApplet;
import processing.core.PConstants;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
/**
* Creates a new softfullscreen object. <br>
@@ -90,9 +93,20 @@ public SoftFullScreen( PApplet dad, int screenNr ){
screenNr = 0;
}
- fsDevice = devices[screenNr];
+ fsDevice = devices[screenNr];
+ WindowListener listener = new WindowAdapter(){
+ public void windowDeiconified( WindowEvent w ){
+ if( isFullScreen() && PApplet.platform == PConstants.MACOSX ){
+ new JAppleMenuBar().setVisible( false );
+ }
+
+ }
+ };
+
fsFrame = new Frame( fsDevice.getDefaultConfiguration() );
- fsFrame.setTitle( dad.frame == null? "":dad.frame.getTitle() );
+ fsFrame.addWindowListener(listener);
+ fsFrame.setTitle( dad.frame == null? "":dad.frame.getTitle() );
+ fsFrame.setIconImage( dad.frame.getIconImage() );
fsFrame.setUndecorated( true );
fsFrame.setBackground( Color.black );
fsFrame.setLayout( null );
@@ -113,6 +127,38 @@ public boolean isFullScreen(){
return fsFrame.isVisible();
}
+ /**
+ * Allow for minimizing the frame
+ */
+ public void minimize(){
+ if( isFullScreen() ){
+ if( PApplet.platform == PConstants.MACOSX ){
+ new JAppleMenuBar().setVisible( true );
+ }
+ fsFrame.setState( Frame.ICONIFIED );
+ }
+ else{
+ dad.frame.setState( Frame.ICONIFIED );
+ }
+ }
+
+ /**
+ * Restores the frame after it has been minimized.
+ * If it wasn't minimized this doesn't do much!
+ */
+ public void restore(){
+ if( isFullScreen() ){
+ fsFrame.setState( Frame.NORMAL );
+
+ if( PApplet.platform == PConstants.MACOSX ){
+ new JAppleMenuBar().setVisible( false );
+ }
+ }
+ else{
+ dad.frame.setState( Frame.NORMAL );
+ }
+ }
+
/**
* FullScreen is only available is applications, not in applets!

0 comments on commit 672b61b

Please sign in to comment.