Package com.simsilica.lemur.event
Class PopupState
java.lang.Object
com.jme3.app.state.BaseAppState
com.simsilica.lemur.event.PopupState
- All Implemented Interfaces:
AppState
Provides modal-style popup support where a single UI element can
essentially 'take over' the screen. The single pop-up will be the
only thing that can receive events. Outside mouse clicks will either
close the panel or be ignored depending on how the popup was configured
when opened.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumControls the behavior for clicks outside the specified popup. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidPositions the specified spatial so that it is in the center of the GUI.booleanMoves the specified GUI element so that it is the most on the screen that it can be based on the current GUI size.protected voidcleanup(Application app) Called after the app state is detached or during application shutdown if the state is still attached.protected voidclose(com.simsilica.lemur.event.PopupState.PopupEntry entry) voidclosePopup(Spatial popup) Closes a previously opened popup.protected GeometrycreateBlocker(float z, ColorRGBA backgroundColor) protected GuiMaterialcreateBlockerMaterial(ColorRGBA color) protected com.simsilica.lemur.event.PopupState.PopupEntryReturns the GUI node that will be used to display the option panel.Returns the size of the screen based on the app's main camera size and the current scale of the guiNode.protected floatCalcules that maximum Z value given the current contents of the GUI node.protected floatprotected floatbooleanprotected voidinitialize(Application app) Called during initialization once the app state is attached and before onEnable() is called.booleanReturns true if the specified Spatial is still an active popup.protected voidCalled when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.protected voidonEnable()Called when the state is fully enabled, ie: is attached and isEnabled() is true or when the setEnabled() status changes after the state is attached.screenToGui(Vector3f screen) Converts a screen coordinate into a properly scaled GUI coordinate.voidsetGuiNode(Node guiNode) Sets the GUI node that will be used to display the option panel.voidshowModalPopup(Spatial popup) Shows the specified spatial on the GUI node with a background blocker geometry that will consume all mouse events until the popup has been closed.voidshowModalPopup(Spatial popup, ColorRGBA backgroundColor) Shows the specified spatial on the GUI node with a background blocker geometry that will consume all mouse events until the popup has been closed.voidshowModalPopup(Spatial popup, Command<? super PopupState> closeCommand) Shows the specified spatial on the GUI node with a background blocker geometry that will consume all mouse events until the popup has been closed.voidshowModalPopup(Spatial popup, Command<? super PopupState> closeCommand, ColorRGBA backgroundColor) Shows the specified spatial on the GUI node with a background blocker geometry that will consume all mouse events until the popup has been closed.voidShows the specified spatial on the GUI node with a background blocker geometry that will automatically close the spatial when clicked.voidshowPopup(Spatial popup, Command<? super PopupState> closeCommand) Shows the specified spatial on the GUI node with a background blocker geometry that will automatically close the spatial when clicked.voidshowPopup(Spatial popup, PopupState.ClickMode clickMode, Command<? super PopupState> closeCommand, ColorRGBA backgroundColor) Shows the specified popup on the GUI node with the specified click mode determining how background mouse events will be handled.voidupdate(float tpf) Called to update theAppState.Methods inherited from class com.jme3.app.state.BaseAppState
cleanup, getApplication, getId, getState, getState, getState, getState, getStateManager, initialize, isEnabled, isInitialized, postRender, render, setEnabled, setId, stateAttached, stateDetached
-
Constructor Details
-
PopupState
public PopupState() -
PopupState
-
-
Method Details
-
hasActivePopups
public boolean hasActivePopups() -
showPopup
Shows the specified spatial on the GUI node with a background blocker geometry that will automatically close the spatial when clicked. -
showPopup
Shows the specified spatial on the GUI node with a background blocker geometry that will automatically close the spatial when clicked. -
showModalPopup
Shows the specified spatial on the GUI node with a background blocker geometry that will consume all mouse events until the popup has been closed. -
showModalPopup
Shows the specified spatial on the GUI node with a background blocker geometry that will consume all mouse events until the popup has been closed. -
showModalPopup
Shows the specified spatial on the GUI node with a background blocker geometry that will consume all mouse events until the popup has been closed. -
showModalPopup
public void showModalPopup(Spatial popup, Command<? super PopupState> closeCommand, ColorRGBA backgroundColor) Shows the specified spatial on the GUI node with a background blocker geometry that will consume all mouse events until the popup has been closed. -
showPopup
public void showPopup(Spatial popup, PopupState.ClickMode clickMode, Command<? super PopupState> closeCommand, ColorRGBA backgroundColor) Shows the specified popup on the GUI node with the specified click mode determining how background mouse events will be handled. An optional closeCommand will be called when the popup is closed. An optional background color will be used for the background 'blocker' geometry. -
isPopup
Returns true if the specified Spatial is still an active popup. -
closePopup
Closes a previously opened popup. Throws IllegalArgumentException if the specified popup is not open. -
close
protected void close(com.simsilica.lemur.event.PopupState.PopupEntry entry) -
getEntry
-
getMaxGuiZ
protected float getMaxGuiZ()Calcules that maximum Z value given the current contents of the GUI node. -
getMaxZ
-
getMinZ
-
createBlockerMaterial
-
createBlocker
-
getGuiSize
Returns the size of the screen based on the app's main camera size and the current scale of the guiNode. -
centerInGui
Positions the specified spatial so that it is in the center of the GUI. -
clampToGui
Moves the specified GUI element so that it is the most on the screen that it can be based on the current GUI size. Returns true if the spatial was actually moved. -
setGuiNode
Sets the GUI node that will be used to display the option panel. By default, this is SimpleApplication.getGuiNode(). -
getGuiNode
Returns the GUI node that will be used to display the option panel. By default, this is SimpleApplication.getGuiNode(). -
screenToGui
Converts a screen coordinate into a properly scaled GUI coordinate. -
initialize
Description copied from class:BaseAppStateCalled during initialization once the app state is attached and before onEnable() is called.- Specified by:
initializein classBaseAppState- Parameters:
app- the application
-
cleanup
Description copied from class:BaseAppStateCalled after the app state is detached or during application shutdown if the state is still attached. onDisable() is called before this cleanup() method if the state is enabled at the time of cleanup.- Specified by:
cleanupin classBaseAppState- Parameters:
app- the application
-
onEnable
protected void onEnable()Description copied from class:BaseAppStateCalled when the state is fully enabled, ie: is attached and isEnabled() is true or when the setEnabled() status changes after the state is attached.- Specified by:
onEnablein classBaseAppState
-
update
public void update(float tpf) Description copied from interface:AppStateCalled to update theAppState. This method will be called every render pass if theAppStateis both attached and enabled.- Specified by:
updatein interfaceAppState- Overrides:
updatein classBaseAppState- Parameters:
tpf- Time since the last call to update(), in seconds.
-
onDisable
protected void onDisable()Description copied from class:BaseAppStateCalled when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.- Specified by:
onDisablein classBaseAppState
-