libgdx API

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

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.Actor
      extended by com.badlogic.gdx.scenes.scene2d.Group
          extended by com.badlogic.gdx.scenes.scene2d.ui.SplitPane
All Implemented Interfaces:
Layout

public class SplitPane
extends Group
implements Layout

A special container holding two children and allowing to define the space used by each.

Functionality

A SplitPane can embedd to Actor instances (or Widget or Table instances for that matter), separated by a split handle, either vertically or horizontally. Both widgets will be sized so that they take up their respective space within the SplitPane. The handle can be moved via dragging to vary the size available to each widget.

The amount of available space for the first Actor is given between 0 and 1, 0 meaning no space, 1 meaning all the space. The amount of space available for the second Actor is computed as 1 minus the amount available to the second Actor. One can set the value for the first widget via setSplitAmount(float) manually, the amount for the second Actor is derrived automatically. The range of the split amount can be defined via setMinSplitAmount(float) and setMaxSplitAmount(float). The SplitPane will employ scissoring (clipping) to make sure none of the two Actors can render outside of their allocated space.

Note: do not use any of the Group.addActor(Actor) or Group.removeActor(Actor) methods with this class! The embedded Actors are specified at construction time or via #set The embedded Actors will always be resized to fill their entire space within the SplitPane

Layout

The (preferred) width and height of a split pane is determined by the size passed to its constructor. The contained Actor instances size will be set to their respective available area within the split pane.

Style

A SplitPane is a Group displaying two Actor instances either left and right or top and bottom, depending on whether the SplitPane is a horizontal split pane or a vertical split pane. Additionally a NinePatch is used to render the SplitPane handle, either a horizontal or vertical strip. In case the SplitPane is a horizontal one the NinePatch will be stretched vertically, and its width will be the value returned by NinePatch.getTotalWidth(). In case the SplitPane is a vertical one it will be stretched horizontally and its height will be the value returned by NinePatch.getTotalHeight().

A SplitPane's style definition in a skin XML file should look like this:
 <splitpane name="styleName" 
            handle="handlePatch"/>
 
 

Author:
mzechner

Nested Class Summary
static class SplitPane.SplitPaneStyle
          Defines the style of a split pane, see SplitPane
 
Field Summary
 
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
 
Constructor Summary
SplitPane(Actor firstWidget, Actor secondWidget, boolean vertical, Stage stage, Skin skin)
           
SplitPane(Actor firstWidget, Actor secondWidget, boolean vertical, Stage stage, SplitPane.SplitPaneStyle style)
           
SplitPane(Actor firstWidget, Actor secondWidget, boolean vertical, Stage stage, SplitPane.SplitPaneStyle style, java.lang.String name)
          Creates a new SplitPane.
 
Method Summary
 void draw(SpriteBatch batch, float parentAlpha)
          Draws the Actor.
 float getMaxHeight()
           
 float getMaxWidth()
           
 float getMinHeight()
           
 float getMinWidth()
           
 float getPrefHeight()
           
 float getPrefWidth()
           
 float getSplit()
           
 Actor hit(float x, float y)
           
 void invalidate()
          Invalidates the layout, forcing the next call to Layout.layout() to relayout.
 void layout()
          Positions and sizes each child of this actor.
 void setMaxSplitAmount(float maxAmount)
          Sets the maximum split amount
 void setMinSplitAmount(float minAmount)
          Sets the minimum split amount
 void setSplitAmount(float split)
          Sets the split amount
 void setStyle(SplitPane.SplitPaneStyle style)
          Sets the style of this widget.
 void setWidgets(Actor firstWidget, Actor secondWidget)
          Sets the Actor instances embedded in this scroll pane.
 boolean touchDown(float x, float y, int pointer)
           
 void touchDragged(float x, float y, int pointer)
           
 void touchUp(float x, float y, int pointer)
           
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, clear, 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 com.badlogic.gdx.scenes.scene2d.Actor
action, clearActions, isMarkedToRemove, markToRemove, remove, toLocalCoordinates, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SplitPane

public SplitPane(Actor firstWidget,
                 Actor secondWidget,
                 boolean vertical,
                 Stage stage,
                 Skin skin)

SplitPane

public SplitPane(Actor firstWidget,
                 Actor secondWidget,
                 boolean vertical,
                 Stage stage,
                 SplitPane.SplitPaneStyle style)

SplitPane

public SplitPane(Actor firstWidget,
                 Actor secondWidget,
                 boolean vertical,
                 Stage stage,
                 SplitPane.SplitPaneStyle style,
                 java.lang.String name)
Creates a new SplitPane. It's width and height is determined by the prefWidth and prefHeight parameters.

Parameters:
firstWidget - the first Actor
secondWidget - the second Actor
vertical - whether this is a vertical SplitPane or not (horizontal)
stage - the stage, used for clipping
style - the SplitPane.SplitPaneStyle
name - the name
Method Detail

setStyle

public void setStyle(SplitPane.SplitPaneStyle style)
Sets the style of this widget.

Parameters:
style -

layout

public void layout()
Description copied from interface: Layout
Positions and sizes each child of this actor. Subsequent calls will not have any affect unless Layout.invalidate() is called.

Specified by:
layout in interface Layout

invalidate

public void invalidate()
Description copied from interface: Layout
Invalidates the layout, forcing the next call to Layout.layout() to relayout. If an actor is resized or otherwise changed in a way that affects its layout, Layout.invalidate() should be called.

Specified by:
invalidate in interface Layout

getPrefWidth

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

getPrefHeight

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

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

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 Group
Parameters:
batch - the spritebatch to render with
parentAlpha - the parent's alpha value.

touchDown

public boolean touchDown(float x,
                         float y,
                         int pointer)
Overrides:
touchDown in class Group

touchUp

public void touchUp(float x,
                    float y,
                    int pointer)
Overrides:
touchUp in class Group

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 Group

setSplitAmount

public void setSplitAmount(float split)
Sets the split amount

Parameters:
split - the split amount between 0 and 1

getSplit

public float getSplit()
Returns:
the split amount

setMinSplitAmount

public void setMinSplitAmount(float minAmount)
Sets the minimum split amount

Parameters:
minAmount - the minimum split amount

setMaxSplitAmount

public void setMaxSplitAmount(float maxAmount)
Sets the maximum split amount

Parameters:
maxAmount - the maximum split amount

setWidgets

public void setWidgets(Actor firstWidget,
                       Actor secondWidget)
Sets the Actor instances embedded in this scroll pane. Invalidates the new Actor instances if they derrive from Widget

Parameters:
firstWidget - the first Actor

libgdx API

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