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 enum
Controls the behavior for clicks outside the specified popup. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Positions the specified spatial so that it is in the center of the GUI.boolean
Moves the specified GUI element so that it is the most on the screen that it can be based on the current GUI size.protected void
cleanup
(Application app) Called after the app state is detached or during application shutdown if the state is still attached.protected void
close
(com.simsilica.lemur.event.PopupState.PopupEntry entry) void
closePopup
(Spatial popup) Closes a previously opened popup.protected Geometry
createBlocker
(float z, ColorRGBA backgroundColor) protected GuiMaterial
createBlockerMaterial
(ColorRGBA color) protected com.simsilica.lemur.event.PopupState.PopupEntry
Returns 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 float
Calcules that maximum Z value given the current contents of the GUI node.protected float
protected float
boolean
protected void
initialize
(Application app) Called during initialization once the app state is attached and before onEnable() is called.boolean
Returns true if the specified Spatial is still an active popup.protected void
Called when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.protected void
onEnable()
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.void
setGuiNode
(Node guiNode) Sets the GUI node that will be used to display the option panel.void
showModalPopup
(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.void
showModalPopup
(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.void
showModalPopup
(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.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.void
Shows the specified spatial on the GUI node with a background blocker geometry that will automatically close the spatial when clicked.void
showPopup
(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.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.void
update
(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
-
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:BaseAppState
Called during initialization once the app state is attached and before onEnable() is called.- Specified by:
initialize
in classBaseAppState
- Parameters:
app
- the application
-
cleanup
Description copied from class:BaseAppState
Called 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:
cleanup
in classBaseAppState
- Parameters:
app
- the application
-
onEnable
protected void onEnable()Description copied from class:BaseAppState
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.- Specified by:
onEnable
in classBaseAppState
-
update
public void update(float tpf) Description copied from interface:AppState
Called to update theAppState
. This method will be called every render pass if theAppState
is both attached and enabled.- Specified by:
update
in interfaceAppState
- Overrides:
update
in classBaseAppState
- Parameters:
tpf
- Time since the last call to update(), in seconds.
-
onDisable
protected void onDisable()Description copied from class:BaseAppState
Called 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:
onDisable
in classBaseAppState
-