Class ListFileChooser
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.Group
com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
com.badlogic.gdx.scenes.scene2d.ui.Table
net.dermetfan.gdx.scenes.scene2d.ui.FileChooser
net.dermetfan.gdx.scenes.scene2d.ui.ListFileChooser
- All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Cullable
,com.badlogic.gdx.scenes.scene2d.utils.Layout
public class ListFileChooser extends FileChooser
A
TextField
showing the pathField
of the currently browsed folder with backButton
and parentButton
buttons.
There's a scrollable
List
under those showing the contents of the currently browsed folder and chooseButton
and cancelButton
buttons.
If directories can be chosen
, a openButton
button is added so that the user is able to go into folders.
Files can be filtered
.
Use the listener
to get user input.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ListFileChooser.Style
defines styles for the widgets of aListFileChooser
Nested classes/interfaces inherited from class net.dermetfan.gdx.scenes.scene2d.ui.FileChooser
FileChooser.Listener
Nested classes/interfaces inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table
com.badlogic.gdx.scenes.scene2d.ui.Table.Debug, com.badlogic.gdx.scenes.scene2d.ui.Table.DebugRect
-
Field Summary
Fields Modifier and Type Field Description com.badlogic.gdx.scenes.scene2d.utils.ClickListener
backButtonListener
goes back to theprevious
directory
com.badlogic.gdx.scenes.scene2d.utils.ClickListener
cancelButtonListener
com.badlogic.gdx.scenes.scene2d.utils.ClickListener
chooseButtonListener
com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
contentsListener
enables/disables
chooseButton
andopenButton
com.badlogic.gdx.scenes.scene2d.InputListener
keyControlsListener
key controls ofcontents
com.badlogic.gdx.scenes.scene2d.utils.ClickListener
openButtonListener
goes into the currently marked foldercom.badlogic.gdx.scenes.scene2d.utils.ClickListener
parentButtonListener
com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener
pathFieldListener
if it exists, this open the file at the givenabsolute
path if it is not a folder,goes into
it otherwise,Fields inherited from class net.dermetfan.gdx.scenes.scene2d.ui.FileChooser
handlingFileFilter
Fields inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table
backgroundBottom, backgroundLeft, backgroundRight, backgroundTop, debugActorColor, debugCellColor, debugTableColor
-
Constructor Summary
Constructors Constructor Description ListFileChooser(com.badlogic.gdx.scenes.scene2d.ui.Skin skin, java.lang.String styleName, FileChooser.Listener listener)
The ui skin file needs an entry for this class; see https://bitbucket.org/dermetfan/libgdx-utils/issue/3ListFileChooser(com.badlogic.gdx.scenes.scene2d.ui.Skin skin, FileChooser.Listener listener)
The ui skin file needs an entry for this class; see https://bitbucket.org/dermetfan/libgdx-utils/issue/3ListFileChooser(ListFileChooser.Style style, FileChooser.Listener listener)
-
Method Summary
Modifier and Type Method Description protected void
build()
Override this if you want to adjust thelayout
.protected void
buildWidgets()
Override this if you want to adjust all the Widgets.com.badlogic.gdx.files.FileHandle
currentlySelected()
com.badlogic.gdx.scenes.scene2d.ui.Button
getBackButton()
com.badlogic.gdx.scenes.scene2d.ui.Button
getCancelButton()
com.badlogic.gdx.scenes.scene2d.ui.Button
getChooseButton()
com.badlogic.gdx.scenes.scene2d.ui.List<java.lang.String>
getContents()
com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
getContentsPane()
com.badlogic.gdx.files.FileHandle
getDirectory()
com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle>
getFileHistory()
com.badlogic.gdx.scenes.scene2d.ui.Button
getOpenButton()
com.badlogic.gdx.scenes.scene2d.ui.Button
getParentButton()
com.badlogic.gdx.scenes.scene2d.ui.TextField
getPathField()
ListFileChooser.Style
getStyle()
void
refresh()
refreshes thecontents
protected void
scan(com.badlogic.gdx.files.FileHandle dir)
populatescontents
with the children ofdirectory
void
setBackButton(com.badlogic.gdx.scenes.scene2d.ui.Button backButton)
void
setCancelButton(com.badlogic.gdx.scenes.scene2d.ui.Button cancelButton)
void
setChooseButton(com.badlogic.gdx.scenes.scene2d.ui.Button chooseButton)
void
setContents(com.badlogic.gdx.scenes.scene2d.ui.List<java.lang.String> contents)
void
setContentsPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane contentsPane)
void
setDirectoriesChoosable(boolean directoriesChoosable)
builds
if necessaryvoid
setDirectory(com.badlogic.gdx.files.FileHandle dir)
setdirectory
and adds it tofileHistory
void
setDirectory(com.badlogic.gdx.files.FileHandle dir, boolean addToHistory)
setsdirectory
and updates all things that need to be updatedvoid
setFileHistory(com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle> fileHistory)
void
setFileType(com.badlogic.gdx.Files.FileType fileType)
void
setOpenButton(com.badlogic.gdx.scenes.scene2d.ui.Button openButton)
void
setParentButton(com.badlogic.gdx.scenes.scene2d.ui.Button parentButton)
void
setPathField(com.badlogic.gdx.scenes.scene2d.ui.TextField pathField)
void
setStyle(ListFileChooser.Style style)
Methods inherited from class net.dermetfan.gdx.scenes.scene2d.ui.FileChooser
getFileFilter, getHandlingFileFilter, getListener, isDirectoriesChoosable, isNewFilesChoosable, isShowHidden, setFileFilter, setListener, setNewFilesChoosable, setShowHidden
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Table
add, add, add, add, add, add, add, align, background, background, bottom, center, clearChildren, clip, clip, columnDefaults, debug, debug, debugActor, debugAll, debugCell, debugTable, defaults, draw, drawBackground, drawDebug, drawDebugBounds, getAlign, getBackground, getCell, getCells, getClip, getColumnMinWidth, getColumnPrefWidth, getColumns, getColumnWidth, getMinHeight, getMinWidth, getPadBottom, getPadBottomValue, getPadLeft, getPadLeftValue, getPadRight, getPadRightValue, getPadTop, getPadTopValue, getPadX, getPadY, getPrefHeight, getPrefWidth, getRow, getRowHeight, getRowMinHeight, getRowPrefHeight, getRows, getSkin, getTableDebug, hit, invalidate, layout, left, pad, pad, pad, pad, padBottom, padBottom, padLeft, padLeft, padRight, padRight, padTop, padTop, removeActor, removeActor, removeActorAt, reset, right, row, setBackground, setBackground, setClip, setDebug, setRound, setSkin, stack, top
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
childrenChanged, getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, applyTransform, clear, computeTransform, drawChildren, drawDebugChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, resetTransform, resetTransform, setCullingArea, setDebug, setStage, setTransform, swapActor, swapActor, toString
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
pathFieldListener
public final com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener pathFieldListenerif it exists, this open the file at the givenabsolute
path if it is not a folder,goes into
it otherwise, -
chooseButtonListener
public final com.badlogic.gdx.scenes.scene2d.utils.ClickListener chooseButtonListener -
openButtonListener
public final com.badlogic.gdx.scenes.scene2d.utils.ClickListener openButtonListenergoes into the currently marked folder -
cancelButtonListener
public final com.badlogic.gdx.scenes.scene2d.utils.ClickListener cancelButtonListener- See Also:
FileChooser.Listener.cancel()
-
backButtonListener
public final com.badlogic.gdx.scenes.scene2d.utils.ClickListener backButtonListenergoes back to theprevious
directory
-
parentButtonListener
public final com.badlogic.gdx.scenes.scene2d.utils.ClickListener parentButtonListener -
contentsListener
public final com.badlogic.gdx.scenes.scene2d.utils.ChangeListener contentsListenerenables/disables
chooseButton
andopenButton
-
keyControlsListener
public final com.badlogic.gdx.scenes.scene2d.InputListener keyControlsListenerkey controls ofcontents
-
-
Constructor Details
-
ListFileChooser
public ListFileChooser(com.badlogic.gdx.scenes.scene2d.ui.Skin skin, FileChooser.Listener listener)The ui skin file needs an entry for this class; see https://bitbucket.org/dermetfan/libgdx-utils/issue/3 -
ListFileChooser
public ListFileChooser(com.badlogic.gdx.scenes.scene2d.ui.Skin skin, java.lang.String styleName, FileChooser.Listener listener)The ui skin file needs an entry for this class; see https://bitbucket.org/dermetfan/libgdx-utils/issue/3 -
ListFileChooser
-
-
Method Details
-
setFileType
public void setFileType(com.badlogic.gdx.Files.FileType fileType) -
buildWidgets
protected void buildWidgets()Override this if you want to adjust all the Widgets. Be careful though! -
build
protected void build()Override this if you want to adjust thelayout
. Clears thisListFileChooser
's children and addsbackButton
,pathField
,parentButton
,contentsPane
,chooseButton
,cancelButton
andopenButton
ifFileChooser.isDirectoriesChoosable()
is true.- Specified by:
build
in classFileChooser
-
refresh
public void refresh()refreshes thecontents
-
scan
protected void scan(com.badlogic.gdx.files.FileHandle dir)populatescontents
with the children ofdirectory
-
currentlySelected
public com.badlogic.gdx.files.FileHandle currentlySelected()- Returns:
- the file currently selected in
contents
-
setDirectory
public void setDirectory(com.badlogic.gdx.files.FileHandle dir)setdirectory
and adds it tofileHistory
- See Also:
setDirectory(FileHandle, boolean)
-
setDirectory
public void setDirectory(com.badlogic.gdx.files.FileHandle dir, boolean addToHistory)setsdirectory
and updates all things that need to be updated -
getBackButton
public com.badlogic.gdx.scenes.scene2d.ui.Button getBackButton()- Returns:
- the
backButton
-
setBackButton
public void setBackButton(com.badlogic.gdx.scenes.scene2d.ui.Button backButton)- Parameters:
backButton
- thebackButton
to set
-
getCancelButton
public com.badlogic.gdx.scenes.scene2d.ui.Button getCancelButton()- Returns:
- the
cancelButton
-
setCancelButton
public void setCancelButton(com.badlogic.gdx.scenes.scene2d.ui.Button cancelButton)- Parameters:
cancelButton
- thecancelButton
to set
-
getChooseButton
public com.badlogic.gdx.scenes.scene2d.ui.Button getChooseButton()- Returns:
- the
chooseButton
-
setChooseButton
public void setChooseButton(com.badlogic.gdx.scenes.scene2d.ui.Button chooseButton)- Parameters:
chooseButton
- thechooseButton
to set
-
getContents
public com.badlogic.gdx.scenes.scene2d.ui.List<java.lang.String> getContents()- Returns:
- the
contents
-
setContents
public void setContents(com.badlogic.gdx.scenes.scene2d.ui.List<java.lang.String> contents)- Parameters:
contents
- thecontents
to set
-
getContentsPane
public com.badlogic.gdx.scenes.scene2d.ui.ScrollPane getContentsPane()- Returns:
- the
contentsPane
-
setContentsPane
public void setContentsPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane contentsPane)- Parameters:
contentsPane
- thecontentsPane
to set
-
getDirectory
public com.badlogic.gdx.files.FileHandle getDirectory()- Returns:
- the
directory
-
getFileHistory
public com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle> getFileHistory()- Returns:
- the
fileHistory
-
setFileHistory
public void setFileHistory(com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle> fileHistory)- Parameters:
fileHistory
- thefileHistory
to set
-
getOpenButton
public com.badlogic.gdx.scenes.scene2d.ui.Button getOpenButton()- Returns:
- the
openButton
-
setOpenButton
public void setOpenButton(com.badlogic.gdx.scenes.scene2d.ui.Button openButton)- Parameters:
openButton
- theopenButton
to set
-
getParentButton
public com.badlogic.gdx.scenes.scene2d.ui.Button getParentButton()- Returns:
- the
parentButton
-
setParentButton
public void setParentButton(com.badlogic.gdx.scenes.scene2d.ui.Button parentButton)- Parameters:
parentButton
- theparentButton
to set
-
getPathField
public com.badlogic.gdx.scenes.scene2d.ui.TextField getPathField()- Returns:
- the
pathField
-
setPathField
public void setPathField(com.badlogic.gdx.scenes.scene2d.ui.TextField pathField)- Parameters:
pathField
- thepathField
to set
-
setDirectoriesChoosable
public void setDirectoriesChoosable(boolean directoriesChoosable)builds
if necessary- Overrides:
setDirectoriesChoosable
in classFileChooser
- Parameters:
directoriesChoosable
- theFileChooser.directoriesChoosable
to set
-
getStyle
- Returns:
- the
style
-
setStyle
- Parameters:
style
- thestyle
to set and use for all widgets
-