com.badlogic.gdx.scenes.scene2d.ui
Class Window
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.Group
com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table
com.badlogic.gdx.scenes.scene2d.ui.Window
- All Implemented Interfaces:
- Layout
public class Window
- extends Table
A container acting as a dialog or window.
Functionality
A Window is a Table
that can be moved around by touching and dragging its titlebar.It can house
multiple Actor
instances in a table-layout. The difference to a pure Container is that the Window will automatically
set the padding of the layout to respect the width and height of the border patches of its background NinePatch. See
Table
for more information on how Actor instances are laid out when using this class.
A Window can also be set to be modal via a call to setModal(boolean)
, in which case all touch input will go to that
window no matter where the user touched the screen.
Layout
The (preferred) width and height are determined by the values given in the constructor of this class. Please
consult the Table
documentation on how the width and height will be manipulated if the Window is contained in another
Container, a not so common use case. Additionally you can set the (preferred) width and height via a call to
TableLayout#size(int, int)
.
Style
A Window is a Table
displaying a background NinePatch
and its child Actors, clipped to the
Window's area, taking into account the padding as described in the functionality section. Additionally the window will render a
title string in its top border patches. The style is defined via an instance of Window.WindowStyle
, which can be either done
programmatically or via a Skin
.
A Pane's style definition in a skin XML file should look like this:
<window name="name"
titleFont="fontName"
titleFontColor="fontColor"
background="backgroundPatch"/>
- The
name
attribute defines the name of the style which you can later use with
Skin#newWindow(String, Stage, String, int, int, String)
.
- The
titleFont
attribute references a BitmapFont
by name, to be used to render the title string.
*
- The
titleFontColor
attribute references a Color
by name, to be used to render the title string.
- The
background
attribute references a NinePatch
by name, to be used as the Window's background. *
- Author:
- mzechner
Fields inherited from class com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table |
isPressed |
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Group |
batchTransform, children, debug, debugTexture, focusedActor, groups, immutableChildren, immutableGroups, keyboardFocusedActor, lastTouchedChild, localTransform, namesToActors, oldBatchTransform, point, scrollFocusedActor, transform, worldTransform |
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 |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table |
add, align, align, bottom, center, clear, click, columnDefaults, debug, debug, debug, defaults, drawDebug, enableClipping, getAlign, getAllCells, getAllCells, getCell, getCell, getCells, getDebug, getHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getPadBottom, getPadLeft, getPadRight, getPadTop, getPrefHeight, getPrefWidth, getTableLayout, getWidget, getWidgets, getWidgets, height, height, invalidate, invalidateHierarchy, layout, left, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, parse, parse, register, reset, right, row, setActor, setBackground, setClickListener, size, size, stack, top, width, width |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group |
act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, disableDebugging, drawChild, drawChildren, enableDebugging, findActor, focus, getActors, getGroups, keyboardFocus, keyDown, keyTyped, keyUp, removeActor, removeActorRecursive, resetTransform, scrolled, scrollFocus, sortChildren, swapActor, swapActor, toChildCoordinates, touchMoved, unfocusAll, unfocusAll, updateTransform |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Window
public Window(java.lang.String title,
Stage stage,
Skin skin)
Window
public Window(java.lang.String title,
Stage stage,
Window.WindowStyle style)
Window
public Window(java.lang.String name,
java.lang.String title,
Stage stage,
Window.WindowStyle style,
int prefWidth,
int prefHeight)
- Creates a new Window. The width and height are determined by the given parameters.
- Parameters:
name
- the namestage
- the Stage
, used for clippingtitle
- the titleprefWidth
- the (preferred) widthprefHeight
- the (preferred) heightstyle
- the Window.WindowStyle
setStyle
public void setStyle(Window.WindowStyle style)
- Sets the style of this widget.
- Parameters:
style
-
draw
public void draw(SpriteBatch batch,
float parentAlpha)
- Description copied from class:
Actor
- Draws the Actor. The spriteBatch is configured so that the Actor can draw in its parents coordinate system. The parent's
alpha is passed to the method in order for the Actor to multiply it with its own alpha. This will allow
FadeIn
and
other Actions to have an effect even if they are only set on the parent of the Actor.
- Overrides:
draw
in class Table
- Parameters:
batch
- the spritebatch to render withparentAlpha
- the parent's alpha value.
touchDown
public boolean touchDown(float x,
float y,
int pointer)
- Overrides:
touchDown
in class Table
touchUp
public void touchUp(float x,
float y,
int pointer)
- Overrides:
touchUp
in class Table
touchDragged
public void touchDragged(float x,
float y,
int pointer)
- Overrides:
touchDragged
in class Group
hit
public Actor hit(float x,
float y)
- Overrides:
hit
in class Table
setTitle
public void setTitle(java.lang.String title)
- Sets the title of the Window
- Parameters:
title
- the title
getTitle
public java.lang.String getTitle()
- Returns:
- the title of the window
setMovable
public void setMovable(boolean isMovable)
- Sets whether this Window is movable by touch or not. In case it is the user will be able to grab and move the window by its
title bar
- Parameters:
isMovable
- whether the window is movable or not
isMovable
public boolean isMovable()
- Returns:
- whether the window is movable
setModal
public void setModal(boolean isModal)
- Sets whether this Window is modal or not. In case it is it will receive all touch events, no matter where the user touched
the screen.
- Parameters:
isModal
- whether the window is modal or not
isModal
public boolean isModal()
- Returns:
- whether the window is modal
Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)