Only bound our view's coordinates if the view model is configured for a

bounded view.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1522 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-06-21 00:04:41 +00:00
parent cabfc118cb
commit a42e485d06
2 changed files with 16 additions and 11 deletions
@@ -1,5 +1,5 @@
// //
// $Id: IsoSceneViewModel.java,v 1.25 2002/06/17 18:01:47 shaper Exp $ // $Id: IsoSceneViewModel.java,v 1.26 2002/06/21 00:04:41 mdb Exp $
package com.threerings.miso.scene; package com.threerings.miso.scene;
@@ -37,6 +37,10 @@ public class IsoSceneViewModel
/** Size of the view in tile count. */ /** Size of the view in tile count. */
public int scenevwid, scenevhei; public int scenevwid, scenevhei;
/** Whether or not this view can extend beyond the bounds defined by
* the view width and height. True if it cannot, false if it can. */
public boolean bounded = true;
/** The bounds of the view in screen pixel coordinates. */ /** The bounds of the view in screen pixel coordinates. */
public Rectangle bounds; public Rectangle bounds;
@@ -1,5 +1,5 @@
// //
// $Id: SceneViewPanel.java,v 1.42 2002/06/20 07:50:33 mdb Exp $ // $Id: SceneViewPanel.java,v 1.43 2002/06/21 00:04:41 mdb Exp $
package com.threerings.miso.scene; package com.threerings.miso.scene;
@@ -143,15 +143,16 @@ public class SceneViewPanel extends VirtualMediaPanel
// documentation inherited // documentation inherited
public void setViewLocation (int x, int y) public void setViewLocation (int x, int y)
{ {
// make sure no one tries to set our view location outside the // if we're bounded, make sure no one tries to set our view
// bounds defined by the view model // location outside the bounds defined by the view model
int minx = _viewmodel.bounds.x, if (_viewmodel.bounded) {
maxx = _viewmodel.bounds.width-getWidth(); int minx = _viewmodel.bounds.x,
int miny = _viewmodel.bounds.y, maxx = _viewmodel.bounds.width-getWidth();
maxy = _viewmodel.bounds.height-getHeight(); int miny = _viewmodel.bounds.y,
if (x < minx) { x = minx; } else if (x > maxx) { x = maxx; } maxy = _viewmodel.bounds.height-getHeight();
if (y < miny) { y = miny; } else if (y > maxy) { y = maxy; } if (x < minx) { x = minx; } else if (x > maxx) { x = maxx; }
if (y < miny) { y = miny; } else if (y > maxy) { y = maxy; }
}
super.setViewLocation(x, y); super.setViewLocation(x, y);
} }