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
This commit is contained in:
Michael Bayne
2006-03-14 02:22:18 +00:00
parent 196799d842
commit 2aca17ee08
@@ -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;
}