Package arc.scene.ui

Class Dialog

All Implemented Interfaces:
Cullable
Direct Known Subclasses:
BaseDialog, DiscordDialog, KeybindDialog, MapEditorDialog, PaletteDialog

public class Dialog extends Table
A table that can be dragged and act as a modal window. The top padding is used as the window's title height.

The preferred size of a window is the preferred size of the title text and the children as laid out by the table. After adding children to the window, it can be convenient to call WidgetGroup.pack() to size the window to the size of the children.

  • Field Details

    • ignoreTouchDown

      protected InputListener ignoreTouchDown
    • edge

      protected int edge
    • dragging

      protected boolean dragging
    • cont

      public final Table cont
    • buttons

      public final Table buttons
    • title

      public final Label title
    • titleTable

      public final Table titleTable
  • Constructor Details

  • Method Details

    • getStyle

      public Dialog.DialogStyle getStyle()
      Returns the window's style. Modifying the returned style may not have an effect until setStyle(DialogStyle) is called.
    • setStyle

      public void setStyle(Dialog.DialogStyle style)
    • act

      public void act(float delta)
      Description copied from class: Element
      Updates the actor based on time. Typically this is called each frame by Scene.act(float).

      The default implementation calls Action.act(float) on each action and removes actions that are complete.

      Overrides:
      act in class Group
      Parameters:
      delta - Time in seconds since the last frame.
    • draw

      public void draw()
      Description copied from class: WidgetGroup
      If this method is overridden, the super method or WidgetGroup.validate() should be called to ensure the widget group is laid out.
      Overrides:
      draw in class Table
    • drawStageBackground

      protected void drawStageBackground(float x, float y, float width, float height)
    • hit

      public Element hit(float x, float y, boolean touchable)
      Description copied from class: Element
      Returns the deepest actor that contains the specified point and is touchable and visible, or null if no actor was hit. The point is specified in the actor's local coordinate system (0,0 is the bottom left of the actor and width,height is the upper right).

      This method is used to delegate touchDown, mouse, and enter/exit events. If this method returns null, those events will not occur on this Actor.

      The default implementation returns this actor if the point is within this actor's bounds.

      Overrides:
      hit in class Table
      touchable - If true, the hit detection will respect the touchability.
      See Also:
    • centerWindow

      public void centerWindow()
      Centers the dialog in the scene.
    • isMovable

      public boolean isMovable()
    • setMovable

      public void setMovable(boolean isMovable)
    • isModal

      public boolean isModal()
    • setModal

      public void setModal(boolean isModal)
    • setKeepWithinStage

      public void setKeepWithinStage(boolean keepWithinStage)
    • isCentered

      public boolean isCentered()
    • setCentered

      public void setCentered(boolean center)
    • isResizable

      public boolean isResizable()
    • setResizable

      public void setResizable(boolean isResizable)
    • setResizeBorder

      public void setResizeBorder(int resizeBorder)
    • isDragging

      public boolean isDragging()
    • updateScrollFocus

      public void updateScrollFocus()
    • setHideAction

      public static void setHideAction(Prov<Action> prov)
    • setShowAction

      public static void setShowAction(Prov<Action> prov)
    • setScene

      protected void setScene(Scene stage)
      Description copied from class: Element
      Called by the framework when this actor or any parent is added to a group that is in the stage.
      Overrides:
      setScene in class Group
      Parameters:
      stage - May be null if the actor or any parent is no longer in a stage.
    • shown

      public void shown(Runnable run)
      Adds a show() listener.
    • hidden

      public void hidden(Runnable run)
      Adds a hide() listener.
    • resizedShown

      public void resizedShown(Runnable run)
      Runs the callback when this dialog is resized or hidden.
    • resized

      public void resized(Runnable run)
      Adds a scene resize listener.
    • resized

      public void resized(boolean invoke, Runnable run)
      Adds a scene resize listener, optionally invoking it immediately.
    • addCloseButton

      public void addCloseButton()
    • closeOnBack

      public void closeOnBack()
      Adds a listener for back/escape keys to hide this dialog.
    • closeOnBack

      public void closeOnBack(Runnable callback)
    • isShown

      public boolean isShown()
    • show

      public Dialog show(Scene stage, Action action)
      Packs the dialog and adds it to the stage with custom action which can be null for instant show
    • toggle

      public void toggle()
      Shows this dialog if it was hidden, and vice versa.
    • show

      public Dialog show()
    • show

      public Dialog show(Scene stage)
      Packs the dialog and adds it to the stage, centered with default fadeIn action
    • hide

      public void hide(Action action)
      Hides the dialog with the given action and then removes it from the stage.
    • hide

      public void hide()
      Hides the dialog. Called automatically when a button is clicked. The default implementation fades out the dialog over 400 milliseconds.