Let the animated panel handle invalidating the regions exposed by
scrolling so that it can do so with the actual dimensions of the panel (the scene view only knows how big its model wants to be). Changed scrollView to viewWillScroll to more accurately reflect what's going on. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1036 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: AnimatedPanel.java,v 1.12 2002/02/19 04:45:13 mdb Exp $
|
||||
// $Id: AnimatedPanel.java,v 1.13 2002/02/19 05:03:17 mdb Exp $
|
||||
|
||||
package com.threerings.media.animation;
|
||||
|
||||
@@ -159,6 +159,8 @@ public class AnimatedPanel extends Canvas implements AnimatedView
|
||||
// }
|
||||
// _last = now;
|
||||
|
||||
int width = getWidth(), height = getHeight();
|
||||
|
||||
// if scrolling is enabled, determine the scrolling delta to be
|
||||
// used and do the business
|
||||
int dx = 0, dy = 0;
|
||||
@@ -180,6 +182,18 @@ public class AnimatedPanel extends Canvas implements AnimatedView
|
||||
_lasty = ydist;
|
||||
}
|
||||
|
||||
// and add invalid rectangles for the exposed areas
|
||||
if (dx > 0) {
|
||||
invalidRects.add(new Rectangle(width - dx, 0, dx, height));
|
||||
} else if (dx < 0) {
|
||||
invalidRects.add(new Rectangle(0, 0, -dx, height));
|
||||
}
|
||||
if (dy > 0) {
|
||||
invalidRects.add(new Rectangle(0, height - dy, width, dy));
|
||||
} else if (dy < 0) {
|
||||
invalidRects.add(new Rectangle(0, 0, width, -dy));
|
||||
}
|
||||
|
||||
// let our derived classes do whatever they need to do to
|
||||
// prepare to be scrolled
|
||||
viewWillScroll(dx, dy);
|
||||
@@ -208,7 +222,6 @@ public class AnimatedPanel extends Canvas implements AnimatedView
|
||||
createBackBuffer(gc);
|
||||
}
|
||||
|
||||
int width = getWidth(), height = getHeight();
|
||||
Graphics g = null;
|
||||
try {
|
||||
g = _backimg.getGraphics();
|
||||
@@ -236,20 +249,6 @@ public class AnimatedPanel extends Canvas implements AnimatedView
|
||||
if (_stime != 0) {
|
||||
// if it was OK, we may need to do some scrolling
|
||||
g.copyArea(0, 0, width, height, -dx, -dy);
|
||||
|
||||
// and add invalid rectangles for the exposed areas
|
||||
if (dx > 0) {
|
||||
invalidRects.add(
|
||||
new Rectangle(width - dx, 0, dx, height));
|
||||
} else if (dx < 0) {
|
||||
invalidRects.add(new Rectangle(0, 0, -dx, height));
|
||||
}
|
||||
if (dy > 0) {
|
||||
invalidRects.add(
|
||||
new Rectangle(0, height - dy, width, dy));
|
||||
} else if (dy < 0) {
|
||||
invalidRects.add(new Rectangle(0, 0, width, -dy));
|
||||
}
|
||||
}
|
||||
|
||||
// iterate through the invalid rectangles, copying those
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: IsoSceneView.java,v 1.99 2002/02/19 04:45:14 mdb Exp $
|
||||
// $Id: IsoSceneView.java,v 1.100 2002/02/19 05:03:17 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -121,14 +121,8 @@ public class IsoSceneView implements SceneView
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls the view by the requested number of pixels. As the view is
|
||||
* not responsible for maintaining the back buffer, this will simply
|
||||
* dirty the regions exposed by scrolling and update the view's
|
||||
* internal offsets. It also instructs the sprite manager to dirty the
|
||||
* scrolled bounds of all sprites in the view.
|
||||
*/
|
||||
public void scrollView (int dx, int dy)
|
||||
// documentation inherited from interface
|
||||
public void viewWillScroll (int dx, int dy)
|
||||
{
|
||||
// adjust our offsets
|
||||
_xoff += dx;
|
||||
@@ -157,28 +151,9 @@ public class IsoSceneView implements SceneView
|
||||
_tiledy -= 1;
|
||||
_yoff += _model.tilehei;
|
||||
}
|
||||
|
||||
// now dirty the exposed regions
|
||||
if (dx > 0) {
|
||||
invalidateRect(
|
||||
new Rectangle(_model.bounds.x + _model.bounds.width - dx,
|
||||
_model.bounds.y, dx, _model.bounds.height));
|
||||
} else if (dx < 0) {
|
||||
invalidateRect(new Rectangle(_model.bounds.x, _model.bounds.y,
|
||||
-dx, _model.bounds.height));
|
||||
}
|
||||
|
||||
if (dy > 0) {
|
||||
invalidateRect(new Rectangle(_model.bounds.x, _model.bounds.y +
|
||||
_model.bounds.height - dy,
|
||||
_model.bounds.width, dy));
|
||||
} else if (dy < 0) {
|
||||
invalidateRect(new Rectangle(_model.bounds.x, _model.bounds.y,
|
||||
_model.bounds.width, -dy));
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
// documentation inherited from interface
|
||||
public void paint (Graphics2D gfx, List invalidRects)
|
||||
{
|
||||
if (_scene == null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneView.java,v 1.25 2002/02/19 01:24:59 mdb Exp $
|
||||
// $Id: SceneView.java,v 1.26 2002/02/19 05:03:17 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -19,13 +19,13 @@ import com.threerings.media.sprite.Path;
|
||||
public interface SceneView
|
||||
{
|
||||
/**
|
||||
* Scrolls the view by the requested number of pixels. As the view is
|
||||
* not responsible for maintaining the back buffer, this will simply
|
||||
* dirty the regions exposed by scrolling and update the view's
|
||||
* internal offsets. It also instructs the sprite manager to dirty the
|
||||
* scrolled bounds of all sprites in the view.
|
||||
* Lets the view know that it will be scrolled by the specified number
|
||||
* of pixels in each direction the next time that {@link #paint} is
|
||||
* called. This is called automatically by the {@link SceneViewPanel}
|
||||
* which takes care of dirtying the regions exposed by the scrolling
|
||||
* and copying the scrollable pixels.
|
||||
*/
|
||||
public void scrollView (int dx, int dy);
|
||||
public void viewWillScroll (int dx, int dy);
|
||||
|
||||
/**
|
||||
* Renders the scene to the given graphics context.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneViewPanel.java,v 1.30 2002/02/19 01:24:59 mdb Exp $
|
||||
// $Id: SceneViewPanel.java,v 1.31 2002/02/19 05:03:17 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -121,7 +121,7 @@ public class SceneViewPanel extends AnimatedPanel
|
||||
*/
|
||||
protected void viewWillScroll (int dx, int dy)
|
||||
{
|
||||
_view.scrollView(dx, dy);
|
||||
_view.viewWillScroll(dx, dy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user