From 2aca17ee082a78c3feb0d7b975bc408861105274 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 14 Mar 2006 02:22:18 +0000 Subject: [PATCH] Have the WindowSlider wait two frames before starting to slide the window onto the screen. In general the first frame is thrown off by the time it takes to construct the window (which may be substantial) and the second might take a while laying it out. After that though, we can smoothly slide things onto the screen, and so we do. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3942 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/jme/effect/WindowSlider.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/jme/effect/WindowSlider.java b/src/java/com/threerings/jme/effect/WindowSlider.java index fb237a3c1..7d3103b1f 100644 --- a/src/java/com/threerings/jme/effect/WindowSlider.java +++ b/src/java/com/threerings/jme/effect/WindowSlider.java @@ -60,6 +60,21 @@ public class WindowSlider extends Node _mode = mode; _window = window; _tfunc = new LinearTimeFunction(start, end, duration); + + // skip two frames by default as that generally handles the normal + // window layout process + _skipTicks = 2; + } + + /** + * Allows some number of ticks to be skipped to give the window that is + * being slid a chance to be layed out before we start keeping track of + * time. The layout may be expensive and cause the frame rate to drop for a + * frame or two, thus booching our smooth sliding onto the screen. + */ + public void setSkipTicks (int skipTicks) + { + _skipTicks = skipTicks; } // documentation inherited @@ -67,6 +82,11 @@ public class WindowSlider extends Node { super.updateGeometricState(time, initiator); + // skip ticks as long as we need to + if (_skipTicks-- > 0) { + return; + } + if (_mode % 2 == 1) { _window.setLocation((int)_tfunc.getValue(time), _window.getY()); } else { @@ -87,7 +107,7 @@ public class WindowSlider extends Node getParent().detachChild(this); } - protected int _mode; + protected int _mode, _skipTicks; protected BWindow _window; protected TimeFunction _tfunc; }