Skip to content

Commit

Permalink
scene.handleFocus() only takes effect when 2 or more off-screen scene…
Browse files Browse the repository at this point in the history
…s have been instantiated which makes this version of proscene compatible with previous versions. This is beta8
  • Loading branch information
nakednous committed Oct 21, 2016
1 parent d30f661 commit 55857b6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/remixlab/proscene/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public class Scene extends AbstractScene implements PConstants {
protected static Scene lastScene;
protected long lastDisplay;
protected boolean autofocus;
// just to make it compatible with previous versions of proscene
protected static int offScreenScenes;

// Miscellaneous
private boolean prosceniumMissed;
Expand Down Expand Up @@ -221,8 +223,10 @@ public Scene(PApplet p, PGraphics pg, int x, int y) {
if (!isOffscreen()) {
pApplet().registerMethod("pre", this);
pApplet().registerMethod("draw", this);
} else
} else {
offScreenScenes++;
enableAutoFocus();
}
// TODO DROID buggy in desktop, should be tested in Android
if (platform() != Platform.PROCESSING_ANDROID)
pApplet().registerMethod("dispose", this);
Expand Down Expand Up @@ -1395,6 +1399,8 @@ protected boolean displayed() {
* Called by {@link #endDraw()} if {@link #hasAutoFocus()} is {@code true}.
*/
protected void handleFocus() {
if (offScreenScenes < 2)
return;
// Handling focus of non-overlapping scenes is trivial.
// Suppose scn1 and scn2 overlap and also that scn2 is displayed on top of scn1, i.e.,
// scn2.display() is to be called after scn1.display() (which is the key observation).
Expand Down

0 comments on commit 55857b6

Please sign in to comment.