Class GuiGlobals

java.lang.Object
com.simsilica.lemur.GuiGlobals

public class GuiGlobals extends Object
A utility class that sets up some default global behavior for the default GUI elements and provides some common access to things like the AssetManager.

When initialized, GuiGlobals will keep a reference to the AssetManager for use in creating materials, loading fonts, and so on. It will also:

  • Setup the KeyInterceptState for allowing edit fields to intercept key events ahead of the regular input processing.
  • Initialize InputMapper to provide advanced controller input processing.
  • Setup the MouseAppState to provide default mouse listener and picking support for registered pick roots.
  • Setup the FocusManagerState that keeps track of the currently focused component and makes sure transition methods are properly called.
  • Setup the default styles.
  • Sets up the layer based geometry comparators for the default app viewport.

For applications that wish to customize the behavior of GuiGlobals, it is possible to set a custom subclass instead of initializing the default implemenation. Examples of reasons do do this might include using custom materials instead of the default JME materials or otherwise customizing the initialization setup.

  • Constructor Details

  • Method Details

    • initialize

      public static void initialize(Application app)
    • setInstance

      public static void setInstance(GuiGlobals globals)
    • getInstance

      public static GuiGlobals getInstance()
    • isHeadless

      protected boolean isHeadless(Application app)
    • getAssetManager

      protected AssetManager getAssetManager()
    • getIconBase

      protected String getIconBase()
    • setupGuiComparators

      public void setupGuiComparators(ViewPort view)
    • setDefaultStyles

      protected void setDefaultStyles()
    • getStyles

      public Styles getStyles()
    • getInputMapper

      public InputMapper getInputMapper()
    • getAnimationState

      public AnimationState getAnimationState()
    • getPopupState

      public PopupState getPopupState()
    • getFocusManagerState

      public FocusManagerState getFocusManagerState()
    • getFocusNavigationState

      public FocusNavigationState getFocusNavigationState()
    • fixFont

      public void fixFont(BitmapFont font)
      Goes through all of the font page materials and sets alpha test and alpha fall-off.
    • lightFont

      public void lightFont(BitmapFont font)
    • loadFont

      public BitmapFont loadFont(String path)
    • createText2d

      public Text2d createText2d(String fontName)
    • setTextFactory

      public void setTextFactory(Function<String,Text2d> textFactory)
    • getTextFactory

      public Function<String,Text2d> getTextFactory()
    • createMaterial

      public GuiMaterial createMaterial(boolean lit)
    • createMaterial

      public GuiMaterial createMaterial(ColorRGBA color, boolean lit)
    • createMaterial

      public GuiMaterial createMaterial(Texture texture, boolean lit)
    • loadDefaultIcon

      public Texture loadDefaultIcon(String name)
    • loadTexture

      public Texture loadTexture(String path, boolean repeat, boolean generateMips)
    • loadTexture

      public Texture loadTexture(TextureKey key, boolean repeat)
    • srgbaColor

      public ColorRGBA srgbaColor(float r, float g, float b, float a)
      Creates a color from the specified RGBA values as if they were in SRGB space, depending on whether gamma correction is enabled or disabled. If there is no gamma correction then the RGBA values are interpretted literally. If gamma correction is enabled then the values are converted to linear space before returning.
    • srgbaColor

      public ColorRGBA srgbaColor(ColorRGBA srgbColor)
      Creates a color from the specified RGBA values as if they were in SRGB space, depending on whether gamma correction is enabled or disabled. If there is no gamma correction then the RGBA values are interpretted literally. If gamma correction is enabled then the values are converted to linear space before returning.
    • requestFocus

      public void requestFocus(Spatial s)
    • releaseFocus

      public void releaseFocus(Spatial s)
    • getCurrentFocus

      public Spatial getCurrentFocus()
    • addKeyListener

      public void addKeyListener(KeyListener l)
    • removeKeyListener

      public void removeKeyListener(KeyListener l)
    • getCollisionViewPort

      @Deprecated public ViewPort getCollisionViewPort(Spatial s)
      Deprecated.
    • requestCursorEnabled

      public void requestCursorEnabled(Object owner)
      Indicates that the specified owner requires the cursor to be enabled. This is a way of letting multiple separate UI elements manage their need for the cursor. If one particular object indicates that it no longer has a need for the cursor then it can be disabled if no other owners require it. This makes it easier to automatically manage the enabled/disabled state of the picking behavior in the face of complicated UIs.
    • releaseCursorEnabled

      public boolean releaseCursorEnabled(Object owner)
      Releases a previous cursor request for the specified sowner. Returns true if the cursor is still enabled after this call.
    • hasRequestedCursorEnabled

      public boolean hasRequestedCursorEnabled(Object owner)
      Returns true if the specified owner has an active cursor enabled request pending.
    • setMouseEventsEnabled

      @Deprecated public void setMouseEventsEnabled(boolean f)
      Deprecated.
      Use setCursorEventsEnabled() instead.
    • setCursorEventsEnabled

      public void setCursorEventsEnabled(boolean f)
    • setCursorEventsEnabled

      public void setCursorEventsEnabled(boolean f, boolean force)
      The same as setCursorEventsEnabled(f) except that this will force the cursor enabled state even if there are pending requests otherwise. This can be a way to force the enabled/disabled state in the case where an application has not converted to the new request/release approach and/or has a specific need where counting requests will not work.
    • isMouseEventsEnabled

      @Deprecated public boolean isMouseEventsEnabled()
      Deprecated.
      Use isCursorEventsEnabled() instead.
    • isCursorEventsEnabled

      public boolean isCursorEventsEnabled()
    • getScreenCoordinates

      @Deprecated public Vector3f getScreenCoordinates(Spatial relativeTo, Vector3f pos)
      Deprecated.