Class CardLayout

java.lang.Object
com.blackrook.gui.layout.CardLayout
All Implemented Interfaces:
GUILayout

public class CardLayout extends Object implements GUILayout
A special layout that controls the visibility (and size) of the children on the object using this layout. The children are resized to the parent's width and height
Author:
Matthew Tropiano
  • Field Details

    • objectRef

      protected GUIObject objectRef
      Reference to object bound to this layout.
    • activeCard

      protected String activeCard
      Identifier for the active card.
    • activeIndex

      protected int activeIndex
      Index used for the active card.
  • Constructor Details

    • CardLayout

      public CardLayout(GUIObject objectRef)
      Creates a new CardLayout.
      Parameters:
      objectRef - should be the reference to the object using this layout. Used for triggering child visibility when the active card changes.
  • Method Details

    • setActiveCard

      public void setActiveCard(String activeCard)
      Sets which card is supposed to be visible by an identifier. The object that has this identifier as an attribute will be set as visible. This resets the active index.
      Parameters:
      activeCard - the id to set as the identifier of the active object.
    • setActiveIndex

      public void setActiveIndex(int activeIndex)
      Sets which card is supposed to be visible by its child index. This nullifies the active identifier, if it was in use.
      Parameters:
      activeIndex - the index to set as the active object.
    • getActiveCard

      public String getActiveCard()
      Returns:
      the name of which card is supposed to be visible.
    • getActiveIndex

      public int getActiveIndex()
      Returns:
      the index of which card is supposed to be visible.
    • resizeChild

      public void resizeChild(GUIObject object, int index, int childTotal)
      Description copied from interface: GUILayout
      Called when a child object needs resizing. DO NOT RESIZE THE PARENT OBJECT IN THIS METHOD, AS IT MAY CAUSE AN INFINITE LOOP TO OCCUR.
      Specified by:
      resizeChild in interface GUILayout
      Parameters:
      object - the object to resize.
      index - the child index while traversing through the list of children.
      childTotal - the total number of children.