Dirty SceneObjectTips as they're laid out. This was relying on tips being added and laid out before the initial paint.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@299 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Charlie Groves
2007-10-08 23:00:20 +00:00
parent b4417cc330
commit 094e6b1730
2 changed files with 19 additions and 21 deletions
@@ -29,27 +29,27 @@ import java.awt.Composite;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Polygon; import java.awt.Polygon;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Stroke; import java.awt.Stroke;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener; import java.awt.event.MouseMotionListener;
import javax.swing.Icon;
import javax.swing.JFrame;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import javax.swing.Icon;
import javax.swing.JFrame;
import com.samskivert.swing.Controller; import com.samskivert.swing.Controller;
import com.samskivert.swing.RadialMenu; import com.samskivert.swing.RadialMenu;
@@ -57,7 +57,6 @@ import com.samskivert.swing.RuntimeAdjust;
import com.samskivert.swing.event.CommandEvent; import com.samskivert.swing.event.CommandEvent;
import com.samskivert.util.HashIntMap; import com.samskivert.util.HashIntMap;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.media.VirtualMediaPanel; import com.threerings.media.VirtualMediaPanel;
import com.threerings.media.sprite.Sprite; import com.threerings.media.sprite.Sprite;
import com.threerings.media.tile.Tile; import com.threerings.media.tile.Tile;
@@ -66,7 +65,6 @@ import com.threerings.media.tile.TileSet;
import com.threerings.media.util.AStarPathUtil; import com.threerings.media.util.AStarPathUtil;
import com.threerings.media.util.MathUtil; import com.threerings.media.util.MathUtil;
import com.threerings.media.util.Path; import com.threerings.media.util.Path;
import com.threerings.miso.Log; import com.threerings.miso.Log;
import com.threerings.miso.MisoPrefs; import com.threerings.miso.MisoPrefs;
import com.threerings.miso.client.DirtyItemList.DirtyItem; import com.threerings.miso.client.DirtyItemList.DirtyItem;
@@ -1120,8 +1118,8 @@ public class MisoScenePanel extends VirtualMediaPanel
} }
// dirty the tips associated with the hover objects // dirty the tips associated with the hover objects
dirtyTip((SceneObjectTip)_tips.get(oldHover)); dirtyTip(_tips.get(oldHover));
dirtyTip((SceneObjectTip)_tips.get(newHover)); dirtyTip(_tips.get(newHover));
} }
/** /**
@@ -1302,25 +1300,24 @@ public class MisoScenePanel extends VirtualMediaPanel
{ {
// make sure the tips are ready // make sure the tips are ready
if (!_tipsLaidOut) { if (!_tipsLaidOut) {
ArrayList boxlist = new ArrayList(); List<Rectangle> boundaries = new ArrayList<Rectangle>();
for (Iterator iter = _tips.keySet().iterator(); iter.hasNext(); ) { for (Entry<SceneObject, SceneObjectTip> entry : _tips.entrySet()) {
SceneObject scobj = (SceneObject)iter.next(); entry.getValue().layout(gfx, entry.getKey(), _vbounds, boundaries);
SceneObjectTip tip = (SceneObjectTip)_tips.get(scobj); dirtyTip(entry.getValue());
tip.layout(gfx, scobj, _vbounds, boxlist); boundaries.add(entry.getValue().bounds);
boxlist.add(tip.bounds);
} }
_tipsLaidOut = true; _tipsLaidOut = true;
} }
if (checkShowFlag(SHOW_TIPS)) { if (checkShowFlag(SHOW_TIPS)) {
// show all the tips // show all the tips
for (Iterator iter = _tips.values().iterator(); iter.hasNext(); ) { for (SceneObjectTip tip : _tips.values()) {
paintTip(gfx, clip, (SceneObjectTip)iter.next()); paintTip(gfx, clip, tip);
} }
} else { } else {
// show maybe one tip // show maybe one tip
SceneObjectTip tip = (SceneObjectTip)_tips.get(_hobject); SceneObjectTip tip = _tips.get(_hobject);
if (tip != null) { if (tip != null) {
paintTip(gfx, clip, tip); paintTip(gfx, clip, tip);
} }
@@ -1677,7 +1674,8 @@ public class MisoScenePanel extends VirtualMediaPanel
protected Point _hcoords = new Point(); protected Point _hcoords = new Point();
/** Our object tips, indexed by the object that they tip for. */ /** Our object tips, indexed by the object that they tip for. */
protected HashMap _tips = new HashMap(); protected HashMap<SceneObject, SceneObjectTip> _tips =
new HashMap<SceneObject, SceneObjectTip>();
/** Have the tips been laid out? */ /** Have the tips been laid out? */
protected boolean _tipsLaidOut = false; protected boolean _tipsLaidOut = false;
@@ -83,7 +83,7 @@ public class SceneObjectTip extends LabelSausage
* @param othertips other tip boundaries that we should avoid. * @param othertips other tip boundaries that we should avoid.
*/ */
public void layout (Graphics2D gfx, SceneObject tipFor, Rectangle boundary, public void layout (Graphics2D gfx, SceneObject tipFor, Rectangle boundary,
Collection othertips) Collection<Rectangle> othertips)
{ {
layout(gfx, ICON_PAD, EXTRA_PAD); layout(gfx, ICON_PAD, EXTRA_PAD);
bounds = new Rectangle(_size); bounds = new Rectangle(_size);