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 classListFileChooser.Styledefines styles for the widgets of aListFileChooserNested classes/interfaces inherited from class net.dermetfan.gdx.scenes.scene2d.ui.FileChooser
FileChooser.ListenerNested 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.ClickListenerbackButtonListenergoes back to thepreviousdirectorycom.badlogic.gdx.scenes.scene2d.utils.ClickListenercancelButtonListenercom.badlogic.gdx.scenes.scene2d.utils.ClickListenerchooseButtonListenercom.badlogic.gdx.scenes.scene2d.utils.ChangeListenercontentsListenerenables/disableschooseButtonandopenButtoncom.badlogic.gdx.scenes.scene2d.InputListenerkeyControlsListenerkey controls ofcontentscom.badlogic.gdx.scenes.scene2d.utils.ClickListeneropenButtonListenergoes into the currently marked foldercom.badlogic.gdx.scenes.scene2d.utils.ClickListenerparentButtonListenercom.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListenerpathFieldListenerif it exists, this open the file at the givenabsolutepath if it is not a folder,goes intoit otherwise,Fields inherited from class net.dermetfan.gdx.scenes.scene2d.ui.FileChooser
handlingFileFilterFields 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 voidbuild()Override this if you want to adjust thelayout.protected voidbuildWidgets()Override this if you want to adjust all the Widgets.com.badlogic.gdx.files.FileHandlecurrentlySelected()com.badlogic.gdx.scenes.scene2d.ui.ButtongetBackButton()com.badlogic.gdx.scenes.scene2d.ui.ButtongetCancelButton()com.badlogic.gdx.scenes.scene2d.ui.ButtongetChooseButton()com.badlogic.gdx.scenes.scene2d.ui.List<java.lang.String>getContents()com.badlogic.gdx.scenes.scene2d.ui.ScrollPanegetContentsPane()com.badlogic.gdx.files.FileHandlegetDirectory()com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle>getFileHistory()com.badlogic.gdx.scenes.scene2d.ui.ButtongetOpenButton()com.badlogic.gdx.scenes.scene2d.ui.ButtongetParentButton()com.badlogic.gdx.scenes.scene2d.ui.TextFieldgetPathField()ListFileChooser.StylegetStyle()voidrefresh()refreshes thecontentsprotected voidscan(com.badlogic.gdx.files.FileHandle dir)populatescontentswith the children ofdirectoryvoidsetBackButton(com.badlogic.gdx.scenes.scene2d.ui.Button backButton)voidsetCancelButton(com.badlogic.gdx.scenes.scene2d.ui.Button cancelButton)voidsetChooseButton(com.badlogic.gdx.scenes.scene2d.ui.Button chooseButton)voidsetContents(com.badlogic.gdx.scenes.scene2d.ui.List<java.lang.String> contents)voidsetContentsPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane contentsPane)voidsetDirectoriesChoosable(boolean directoriesChoosable)buildsif necessaryvoidsetDirectory(com.badlogic.gdx.files.FileHandle dir)setdirectoryand adds it tofileHistoryvoidsetDirectory(com.badlogic.gdx.files.FileHandle dir, boolean addToHistory)setsdirectoryand updates all things that need to be updatedvoidsetFileHistory(com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle> fileHistory)voidsetFileType(com.badlogic.gdx.Files.FileType fileType)voidsetOpenButton(com.badlogic.gdx.scenes.scene2d.ui.Button openButton)voidsetParentButton(com.badlogic.gdx.scenes.scene2d.ui.Button parentButton)voidsetPathField(com.badlogic.gdx.scenes.scene2d.ui.TextField pathField)voidsetStyle(ListFileChooser.Style style)Methods inherited from class net.dermetfan.gdx.scenes.scene2d.ui.FileChooser
getFileFilter, getHandlingFileFilter, getListener, isDirectoriesChoosable, isNewFilesChoosable, isShowHidden, setFileFilter, setListener, setNewFilesChoosable, setShowHiddenMethods 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, topMethods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
childrenChanged, getMaxHeight, getMaxWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validateMethods 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, toStringMethods 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, toFrontMethods 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 givenabsolutepath if it is not a folder,goes intoit 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 thepreviousdirectory -
parentButtonListener
public final com.badlogic.gdx.scenes.scene2d.utils.ClickListener parentButtonListener -
contentsListener
public final com.badlogic.gdx.scenes.scene2d.utils.ChangeListener contentsListenerenables/disableschooseButtonandopenButton -
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,cancelButtonandopenButtonifFileChooser.isDirectoriesChoosable()is true.- Specified by:
buildin classFileChooser
-
refresh
public void refresh()refreshes thecontents -
scan
protected void scan(com.badlogic.gdx.files.FileHandle dir)populatescontentswith 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)setdirectoryand adds it tofileHistory- See Also:
setDirectory(FileHandle, boolean)
-
setDirectory
public void setDirectory(com.badlogic.gdx.files.FileHandle dir, boolean addToHistory)setsdirectoryand 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- thebackButtonto 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- thecancelButtonto 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- thechooseButtonto 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- thecontentsto 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- thecontentsPaneto 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- thefileHistoryto 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- theopenButtonto 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- theparentButtonto 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- thepathFieldto set
-
setDirectoriesChoosable
public void setDirectoriesChoosable(boolean directoriesChoosable)buildsif necessary- Overrides:
setDirectoriesChoosablein classFileChooser- Parameters:
directoriesChoosable- theFileChooser.directoriesChoosableto set
-
getStyle
- Returns:
- the
style
-
setStyle
- Parameters:
style- thestyleto set and use for all widgets
-