Added code to deal with situations where the SceneViewPanel is smaller
than the IsoSceneView wants to be. Presently we simply center the scene view, but we'll later be adding the ability to set a rectangle on which to focus the scene view when shrunk so that the user can always see their own character. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@992 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneViewPanel.java,v 1.26 2002/01/31 01:07:02 mdb Exp $
|
||||
// $Id: SceneViewPanel.java,v 1.27 2002/02/12 08:53:59 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -105,10 +105,63 @@ public class SceneViewPanel extends AnimatedPanel
|
||||
return _view;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void validate ()
|
||||
{
|
||||
super.validate();
|
||||
|
||||
// figure out our translations
|
||||
Dimension size = getSize();
|
||||
_tx = (_viewmodel.bounds.width - size.width)/2;
|
||||
_ty = (_viewmodel.bounds.height - size.height)/2;
|
||||
}
|
||||
|
||||
/**
|
||||
* We overload this to translate mouse events into the proper
|
||||
* coordinates before they are dispatched to any of the mouse
|
||||
* listeners.
|
||||
*/
|
||||
protected void processMouseEvent (MouseEvent event)
|
||||
{
|
||||
event.translatePoint(_tx, _ty);
|
||||
super.processMouseEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* We overload this to translate mouse events into the proper
|
||||
* coordinates before they are dispatched to any of the mouse
|
||||
* listeners.
|
||||
*/
|
||||
protected void processMouseMotionEvent (MouseEvent event)
|
||||
{
|
||||
event.translatePoint(_tx, _ty);
|
||||
super.processMouseMotionEvent(event);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected void render (Graphics2D gfx)
|
||||
{
|
||||
// translate into happy space
|
||||
gfx.translate(-_tx, -_ty);
|
||||
|
||||
// render the view
|
||||
_view.paint(gfx);
|
||||
|
||||
// give derived classes a chance to render on top of the view
|
||||
renderOnView(gfx);
|
||||
|
||||
// translate back out of happy space
|
||||
gfx.translate(_tx, _ty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an opportunity for derived classes to render things while
|
||||
* under the influence of the proper coordinate translations. This is
|
||||
* called after the view is rendered, so things drawn here appear on
|
||||
* top of the scene view.
|
||||
*/
|
||||
protected void renderOnView (Graphics2D gfx)
|
||||
{
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
@@ -150,4 +203,7 @@ public class SceneViewPanel extends AnimatedPanel
|
||||
|
||||
/** A reference to the active sprite manager. */
|
||||
protected SpriteManager _spritemgr;
|
||||
|
||||
/** Our rendering translation. */
|
||||
protected int _tx, _ty;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user