From a42e485d06152f18ca3b9b1bf393026b8ac88053 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 21 Jun 2002 00:04:41 +0000 Subject: [PATCH] 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 --- .../miso/client/IsoSceneViewModel.java | 6 +++++- .../miso/client/SceneViewPanel.java | 21 ++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/java/com/threerings/miso/client/IsoSceneViewModel.java b/src/java/com/threerings/miso/client/IsoSceneViewModel.java index 7d570e56b..56e81cc26 100644 --- a/src/java/com/threerings/miso/client/IsoSceneViewModel.java +++ b/src/java/com/threerings/miso/client/IsoSceneViewModel.java @@ -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; @@ -37,6 +37,10 @@ public class IsoSceneViewModel /** Size of the view in tile count. */ 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. */ public Rectangle bounds; diff --git a/src/java/com/threerings/miso/client/SceneViewPanel.java b/src/java/com/threerings/miso/client/SceneViewPanel.java index 3293c7b69..864bb6f75 100644 --- a/src/java/com/threerings/miso/client/SceneViewPanel.java +++ b/src/java/com/threerings/miso/client/SceneViewPanel.java @@ -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; @@ -143,15 +143,16 @@ public class SceneViewPanel extends VirtualMediaPanel // documentation inherited public void setViewLocation (int x, int y) { - // make sure no one tries to set our view location outside the - // bounds defined by the view model - int minx = _viewmodel.bounds.x, - maxx = _viewmodel.bounds.width-getWidth(); - int miny = _viewmodel.bounds.y, - maxy = _viewmodel.bounds.height-getHeight(); - if (x < minx) { x = minx; } else if (x > maxx) { x = maxx; } - if (y < miny) { y = miny; } else if (y > maxy) { y = maxy; } - + // if we're bounded, make sure no one tries to set our view + // location outside the bounds defined by the view model + if (_viewmodel.bounded) { + int minx = _viewmodel.bounds.x, + maxx = _viewmodel.bounds.width-getWidth(); + int miny = _viewmodel.bounds.y, + maxy = _viewmodel.bounds.height-getHeight(); + 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); }