com.transmote.nest.ui
Class NestButton

java.lang.Object
  extended by java.util.Observable
      extended by com.transmote.nest.events.EventDispatcher
          extended by com.transmote.nest.NestSprite
              extended by com.transmote.nest.ui.NestButton
All Implemented Interfaces:
Observer

public class NestButton
extends NestSprite

NestButton provides a simple button UI element for use within the Nest framework. NestButton allows for a stroke+fill background, a text label, and a PImage to use as the background. To handle a NestButton click, the NestButton's parent should add itself as an observer to the NestButton. The MOUSE_CLICKED event will bubble up from the NestButton to its parent, where it can be handled within handleEvent(). NestSprite buttonContainer = new NestSprite(); NestButton button = new NestButton(width, height, label, font); buttonContainer.addChild(button); // ...within buttonContainer: protected void handleEvent (Event event) { if (event.target() == button && event.type() == MouseEvent.MOUSE_CLICKED) { // respond to click here } }


Field Summary
 float cornerRadius
          Radius of corners.
 int fillColor_down
          ARGB color of button background when button is pressed.
 int fillColor_up
          ARGB color of button background when button is not pressed.
 int rectMode
          As with PApplet.rect(), specifies whether to draw button from upper-left corner or from center.
 int strokeColor_down
          ARGB color of button outline when button is pressed.
 int strokeColor_up
          ARGB color of button outline when button is not pressed.
 int strokeWeight
          Stroke weight of button outline.
 int textColor_down
          ARGB color of text when button is pressed.
 int textColor_up
          ARGB color of text when button is not pressed.
 
Fields inherited from class com.transmote.nest.NestSprite
blendMode, boundsLeft, boundsTop, handleCaptureEvents, height, inFront, inputChildren, inputEnabled, NO_BLEND_MODE, rotationX, rotationY, rotationZ, scaleX, scaleY, scaleZ, visible, width, x, y, z
 
Constructor Summary
NestButton(float width, float height, String label, PFont font)
           
NestButton(float width, float height, String label, PFont font, PImage icon)
           
NestButton(String label, PFont font)
           
 
Method Summary
 PFont getFont()
          Font to use for text label.
 PImage getIcon()
           
 String getLabel()
          Text label that appears within button.
 void setFont(PFont font)
          Font to use for text label.
 void setIcon(PImage icon)
          PImage to use as button.
 void setLabel(String label)
          Text label that appears within button.
 void triggerClick()
          Triggers a MouseEvent.MOUSE_CLICKED event, centered on the button.
 
Methods inherited from class com.transmote.nest.NestSprite
addChild, addChild, bounds, dispatchEvent, dispose, dispose, getChildAt, getChildIndex, globalToLocal, hitTest, hitTest, isDisposed, localToGlobal, mousePt, mouseX, mouseY, numChildren, pApplet, parent, removeChild, removeChild, renderer, screenPt, screenX, screenY, setBounds, setBounds, setChildIndex, setDraw, setDraw, setRenderer, setRenderer, setUpdate, setUpdate, swapChildren, swapChildren
 
Methods inherited from class com.transmote.nest.events.EventDispatcher
addObserver, deleteObserver, dispatchEvent, owner, update
 
Methods inherited from class java.util.Observable
countObservers, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

textColor_up

public int textColor_up
ARGB color of text when button is not pressed.


textColor_down

public int textColor_down
ARGB color of text when button is pressed.


fillColor_up

public int fillColor_up
ARGB color of button background when button is not pressed.


fillColor_down

public int fillColor_down
ARGB color of button background when button is pressed.


strokeColor_up

public int strokeColor_up
ARGB color of button outline when button is not pressed.


strokeColor_down

public int strokeColor_down
ARGB color of button outline when button is pressed.


strokeWeight

public int strokeWeight
Stroke weight of button outline.


cornerRadius

public float cornerRadius
Radius of corners.


rectMode

public int rectMode
As with PApplet.rect(), specifies whether to draw button from upper-left corner or from center.

Constructor Detail

NestButton

public NestButton(String label,
                  PFont font)

NestButton

public NestButton(float width,
                  float height,
                  String label,
                  PFont font)

NestButton

public NestButton(float width,
                  float height,
                  String label,
                  PFont font,
                  PImage icon)
Method Detail

setLabel

public void setLabel(String label)
Text label that appears within button.


getLabel

public String getLabel()
Text label that appears within button.


setFont

public void setFont(PFont font)
Font to use for text label.


getFont

public PFont getFont()
Font to use for text label.


setIcon

public void setIcon(PImage icon)
PImage to use as button. If specified, icon is drawn behind stroke and text.


getIcon

public PImage getIcon()

triggerClick

public void triggerClick()
Triggers a MouseEvent.MOUSE_CLICKED event, centered on the button.



Processing library Nest by Eric Socolofsky. (C) Eric Socolofsky 2011-2013