diff -r c15830ac2701 javafx-ui-quantum/src/com/sun/javafx/tk/quantum/OverlayWarning.java --- a/javafx-ui-quantum/src/com/sun/javafx/tk/quantum/OverlayWarning.java Wed Mar 07 04:49:51 2012 -0800 +++ b/javafx-ui-quantum/src/com/sun/javafx/tk/quantum/OverlayWarning.java Thu Mar 08 21:38:17 2012 -0500 @@ -25,7 +25,7 @@ import java.util.Locale; import java.util.ResourceBundle; -/* +/** * @author Morris Meyer */ public class OverlayWarning { @@ -50,13 +50,17 @@ private Group sceneRoot; private SequentialTransition overlayTransition; private AbstractPainter painter; + private boolean warningTransition; public OverlayWarning(final ViewScene vs) { view = vs; sceneRoot = createOverlayGroup(); painter = view.getPen().getPainter(); + + Scene.impl_setAllowPGAccess(true); painter.setOverlayRoot((NGNode)sceneRoot.impl_getPGNode()); + Scene.impl_setAllowPGAccess(false); PauseTransition pause = new PauseTransition(Duration.millis(4000)); FadeTransition fade = new FadeTransition(Duration.millis(1000), sceneRoot); @@ -74,8 +78,37 @@ } }); } + + protected ViewScene getView() { + return view; + } + + protected final void setView(ViewScene vs) { + if (painter != null) { + painter.setRenderOverlay(false); + view.entireSceneNeedsRepaint(); + } + + view = vs; + painter = vs.getPen().getPainter(); + + Scene.impl_setAllowPGAccess(true); + painter.setOverlayRoot((NGNode)sceneRoot.impl_getPGNode()); + Scene.impl_setAllowPGAccess(false); + + painter.setRenderOverlay(true); + view.entireSceneNeedsRepaint(); + + overlayTransition.setOnFinished(new EventHandler() { + @Override public void handle(ActionEvent event) { + painter.setRenderOverlay(false); + view.entireSceneNeedsRepaint(); + } + }); + } protected void warn() { + warningTransition = true; painter.setRenderOverlay(true); overlayTransition.play(); } @@ -88,13 +121,22 @@ painter.setRenderOverlay(false); view.entireSceneNeedsRepaint(); + warningTransition = false; } } + + protected boolean inWarningTransition() { + return warningTransition; + } + + private Text text; + private Rectangle background; + private Group root; private Group createOverlayGroup() { final Scene scene = new Scene(new Group()); final Font font = new Font(Font.getDefault().getFamily(), FONTSIZE); - final Text text = new Text(); + text = new Text(); final Rectangle2D screenBounds = javafx.stage.Screen.getPrimary().getBounds(); scene.setFill(null); @@ -109,17 +151,17 @@ text.setStyle(TEXT_CSS); text.setTextAlignment(TextAlignment.CENTER); - final Rectangle background = createBackground(text, screenBounds); + background = createBackground(text, screenBounds); - Group root = (Group)scene.getRoot(); + root = (Group)scene.getRoot(); root.getChildren().add(background); root.getChildren().add(text); - // TODO - needs to be thread-safe - see RT-13813 + Scene.impl_setAllowPGAccess(true); text.impl_updatePG(); background.impl_updatePG(); root.impl_updatePG(); - + Scene.impl_setAllowPGAccess(false); return root; } diff -r c15830ac2701 javafx-ui-quantum/src/com/sun/javafx/tk/quantum/ViewScene.java --- a/javafx-ui-quantum/src/com/sun/javafx/tk/quantum/ViewScene.java Wed Mar 07 04:49:51 2012 -0800 +++ b/javafx-ui-quantum/src/com/sun/javafx/tk/quantum/ViewScene.java Thu Mar 08 21:38:17 2012 -0500 @@ -18,8 +18,6 @@ import com.sun.javafx.geom.CameraImpl; import com.sun.javafx.sg.PGNode; import com.sun.javafx.sg.prism.NGNode; -import com.sun.prism.GraphicsPipeline; -import com.sun.prism.ResourceFactory; public class ViewScene extends GlassScene { diff -r c15830ac2701 javafx-ui-quantum/src/com/sun/javafx/tk/quantum/WindowStage.java --- a/javafx-ui-quantum/src/com/sun/javafx/tk/quantum/WindowStage.java Wed Mar 07 04:49:51 2012 -0800 +++ b/javafx-ui-quantum/src/com/sun/javafx/tk/quantum/WindowStage.java Thu Mar 08 21:38:17 2012 -0500 @@ -420,7 +420,7 @@ return (stageListener != null); } - boolean isVisible() { + @Override boolean isVisible() { return platformWindow.isVisible(); } @@ -499,8 +499,12 @@ exitFullScreen(); } else { v.enterFullscreen(false, false, false); - warning = new OverlayWarning((ViewScene)scene); - warning.warn(); + if (warning != null && warning.inWarningTransition()) { + warning.setView((ViewScene)scene); + } else { + warning = new OverlayWarning((ViewScene)scene); + warning.warn(); + } } } else { if (warning != null) { @@ -511,6 +515,10 @@ } // Reset flag once we are done process fullscreen fullScreenFromUserEvent = false; + } else if (!isVisible() && warning != null) { + // if the window is closed - re-open with fresh warning + warning.cancel(); + warning = null; } } diff -r c15830ac2701 toys/HelloWorld/src/helloworld/HelloFullscreenSceneChange.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toys/HelloWorld/src/helloworld/HelloFullscreenSceneChange.java Thu Mar 08 21:38:17 2012 -0500 @@ -0,0 +1,50 @@ +package helloworld; + +import javafx.application.Application; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Rectangle2D; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.paint.Color; +import javafx.stage.Screen; +import javafx.stage.Stage; + + +public class HelloFullscreenSceneChange extends Application { + + Stage stage; + + public static void main(String[] args) { + Application.launch(args); + } + + @Override + public void start(Stage primaryStage) { + stage = primaryStage; + Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds(); + primaryStage.setFullScreen(true); + Group root = new Group(); + Group root2 = new Group(); + final Scene scene1 = new Scene(root, Color.BLUE); + final Scene scene2 = new Scene(root2, Color.RED); + Button btn = new Button(); + btn.setText("New Scene"); + btn.setLayoutX(screenBounds.getWidth() / 2); + btn.setLayoutY(screenBounds.getHeight() / 2 + 100); + btn.setOnAction(new EventHandler() { + + public void handle(ActionEvent event) { + stage.setScene(scene2); + } + }); + root.getChildren().add(btn); + stage.setScene(scene1); + primaryStage.show(); + } + + private void setStage(Scene aScene){ + stage.setScene(aScene); + } +}