Added a bevy of interfaces that Sprites can implement to be recognized
by the MediaPanel as sprites that interact in some standard way with the mouse. Modified existing ButtonSprite to work this new way, and it now implements CommandSprite, ArmingSprite, and DisableableSprite. One method name changed. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3362 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -29,10 +29,15 @@ import java.awt.Shape;
|
||||
import com.samskivert.swing.Label;
|
||||
import com.samskivert.swing.util.SwingUtil;
|
||||
|
||||
import com.threerings.media.sprite.action.ArmingSprite;
|
||||
import com.threerings.media.sprite.action.CommandSprite;
|
||||
import com.threerings.media.sprite.action.DisableableSprite;
|
||||
|
||||
/**
|
||||
* A sprite that acts as a button.
|
||||
*/
|
||||
public class ButtonSprite extends Sprite
|
||||
implements CommandSprite, ArmingSprite, DisableableSprite
|
||||
{
|
||||
/** The normal, square button style. */
|
||||
public static final int NORMAL = 0;
|
||||
@@ -188,9 +193,7 @@ public class ButtonSprite extends Sprite
|
||||
_actionCommand = actionCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the action command generated by this button.
|
||||
*/
|
||||
// documentation inherited from interface CommandSprite
|
||||
public String getActionCommand ()
|
||||
{
|
||||
return _actionCommand;
|
||||
@@ -204,9 +207,7 @@ public class ButtonSprite extends Sprite
|
||||
_commandArgument = commandArgument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the command argument generated by this button.
|
||||
*/
|
||||
// documentation inherited from interface CommandSprite
|
||||
public Object getCommandArgument ()
|
||||
{
|
||||
return _commandArgument;
|
||||
@@ -223,19 +224,14 @@ public class ButtonSprite extends Sprite
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not this button is enabled.
|
||||
*/
|
||||
// documentation inherited from interface DisableableSprite
|
||||
public boolean isEnabled ()
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not this button appears pressed
|
||||
* (does not fire an event).
|
||||
*/
|
||||
public void setPressed (boolean pressed)
|
||||
// documentation inherited from interface ArmingSprite
|
||||
public void setArmed (boolean pressed)
|
||||
{
|
||||
if (_pressed != pressed) {
|
||||
_pressed = pressed;
|
||||
@@ -246,7 +242,7 @@ public class ButtonSprite extends Sprite
|
||||
/**
|
||||
* Checks whether or not this button appears pressed.
|
||||
*/
|
||||
public boolean isPressed ()
|
||||
public boolean isArmed ()
|
||||
{
|
||||
return _pressed;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// $Id$
|
||||
|
||||
package com.threerings.media.sprite.action;
|
||||
|
||||
/**
|
||||
* An Action sprite is a sprite that may be pressed to generate an
|
||||
* ActionEvent that will be posted to the Controller hierarchy.
|
||||
*/
|
||||
public interface ActionSprite
|
||||
{
|
||||
/**
|
||||
* @return the action command to submit if this sprite is clicked.
|
||||
*/
|
||||
public String getActionCommand ();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// $Id$
|
||||
|
||||
package com.threerings.media.sprite.action;
|
||||
|
||||
/**
|
||||
* An ActionSprite that wishes to be notified of events when it is armed
|
||||
* or not.
|
||||
*/
|
||||
public interface ArmingSprite extends ActionSprite
|
||||
{
|
||||
/**
|
||||
* Render this sprite such that is is drawn "armed".
|
||||
*/
|
||||
public void setArmed (boolean armed);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// $Id$
|
||||
|
||||
package com.threerings.media.sprite.action;
|
||||
|
||||
/**
|
||||
* Extends CommandSprite to be a sprite that posts CommandEvents to
|
||||
* the Controller hierarchy.
|
||||
*/
|
||||
public interface CommandSprite extends ActionSprite
|
||||
{
|
||||
/**
|
||||
* @return the argument to the action command.
|
||||
*/
|
||||
public Object getCommandArgument();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// $Id$
|
||||
|
||||
package com.threerings.media.sprite.action;
|
||||
|
||||
/**
|
||||
* Indicates a Sprite that may or may not be enabled to receive
|
||||
* action / hover / arming notifications.
|
||||
*/
|
||||
public interface DisableableSprite
|
||||
{
|
||||
/**
|
||||
* @return true if this sprite is currently enabled.
|
||||
*/
|
||||
public boolean isEnabled ();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// $Id$
|
||||
|
||||
package com.threerings.media.sprite.action;
|
||||
|
||||
/**
|
||||
* An interface indicating that a sprite wishes to be notified when
|
||||
* the mouse hovers over it.
|
||||
*/
|
||||
public interface HoverSprite
|
||||
{
|
||||
/**
|
||||
* Set the current hover state.
|
||||
*/
|
||||
public void setHovered (boolean hovered);
|
||||
}
|
||||
Reference in New Issue
Block a user