libgdx API

com.badlogic.gdx.scenes.scene2d.ui
Class Widget

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.Actor
      extended by com.badlogic.gdx.scenes.scene2d.ui.Widget
All Implemented Interfaces:
Layout
Direct Known Subclasses:
ComboBox, Image, Label, List, Slider, TextField

public abstract class Widget
extends Actor
implements Layout

Base class for all UI widgets. A widget implements the Layout interface which has a couple of features.

A widget has a preferred width and height which it will use if possible, e.g. if it is not in a Table or a SplitPane or a ScrollPane. In case it is contained in one of the aforementioned containers, the preferred width and height will be used to guide the layouting mechanism employed by those containers.

A widget can be invalidated, e.g. by a Container changing its available space in the layout, in which case it will layout itself at the next oportunity to do so.

Invalidation can also be triggered manually via a call to invalidate() or invalidateHierarchy(). The former will tell the Widget to only invalidate itself. The later will also invalidate all the widget's parents. The later mechanism is used in case the widget was modified and the container it is contained in must relayout itself due to this modification as well.

Author:
mzechner

Field Summary
protected  boolean invalidated
           
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, touchable, visible, width, x, y
 
Constructor Summary
Widget()
          Creates a new widget without a name or preferred size.
Widget(java.lang.String name)
          Creates a new widget with the preferred width and height
 
Method Summary
 float getMaxHeight()
           
 float getMaxWidth()
           
 float getMinHeight()
           
 float getMinWidth()
           
 Actor hit(float x, float y)
           
 void invalidate()
          Invalidates this widget, causing it to relayout itself at the next oportunity.
 void invalidateHierarchy()
          Invalidates this widget and all its parents, causing all involved widgets to relayout themselves at the next oportunity.
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
act, action, clearActions, draw, isMarkedToRemove, keyDown, keyTyped, keyUp, markToRemove, remove, scrolled, toLocalCoordinates, toString, touchDown, touchDragged, touchMoved, touchUp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.badlogic.gdx.scenes.scene2d.Layout
getPrefHeight, getPrefWidth, layout
 

Field Detail

invalidated

protected boolean invalidated
Constructor Detail

Widget

public Widget()
Creates a new widget without a name or preferred size.


Widget

public Widget(java.lang.String name)
Creates a new widget with the preferred width and height

Parameters:
name - the name
Method Detail

getMinWidth

public float getMinWidth()
Specified by:
getMinWidth in interface Layout

getMinHeight

public float getMinHeight()
Specified by:
getMinHeight in interface Layout

getMaxWidth

public float getMaxWidth()
Specified by:
getMaxWidth in interface Layout

getMaxHeight

public float getMaxHeight()
Specified by:
getMaxHeight in interface Layout

invalidate

public void invalidate()
Invalidates this widget, causing it to relayout itself at the next oportunity.

Specified by:
invalidate in interface Layout

invalidateHierarchy

public void invalidateHierarchy()
Invalidates this widget and all its parents, causing all involved widgets to relayout themselves at the next oportunity.


hit

public Actor hit(float x,
                 float y)
Specified by:
hit in class Actor

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)