java.lang.Object
io.github.thecsdev.tcdcommons.api.client.gui.TElement
io.github.thecsdev.tcdcommons.api.client.gui.panel.TPanelElement
All Implemented Interfaces:
TParentElement, ITooltipProvider, IEnableStateProvider
Direct Known Subclasses:
TMenuPanel, TRefreshablePanelElement

public class TPanelElement extends TElement
  • Field Details

  • Constructor Details

    • TPanelElement

      public TPanelElement(int x, int y, int width, int height)
  • Method Details

    • getBackgroundColor

      public final int getBackgroundColor()
    • setBackgroundColor

      public void setBackgroundColor(int color)
    • getOutlineColor

      public final int getOutlineColor()
    • setOutlineColor

      public void setOutlineColor(int color)
    • render

      public void render(TDrawContext pencil)
      Description copied from interface: TParentElement
      Renders this GUI element on the screen.
      Specified by:
      render in interface TParentElement
      Specified by:
      render in class TElement
      Parameters:
      pencil - The TDrawContext.
    • postRender

      public void postRender(TDrawContext pencil)
      Overrides:
      postRender in class TElement
    • renderSmoothScroll

      protected final void renderSmoothScroll(float deltaTime)
      Handles smooth scrolling. Needs to be called once every frame from render(TDrawContext).
      Parameters:
      deltaTime - The time elapsed since the last frame.
    • hasScrollFlag

      public final boolean hasScrollFlag(int flagToCheck)
      Used to quickly check for a scroll flag in scrollFlags.
      Parameters:
      flagToCheck - For example SCROLL_HORIZONTAL.
    • isScrollable

      public final boolean isScrollable()
      Returns true if this TPanelElement has scrolling enabled.
    • getScrollFlags

      public final int getScrollFlags()
      Returns the scroll behavior for this TPanelElement.
      See scrollFlags.
    • setScrollFlags

      public void setScrollFlags(int flags)
      Defines the scroll behavior for this TPanelElement.
      See scrollFlags.
      Parameters:
      flags - The scroll settings.
    • getScrollSensitivity

      public final int getScrollSensitivity()
      Returns the input scrollSensitivity.
      See scrollSensitivity.
    • setScrollSensitivity

      public void setScrollSensitivity(int value)
      Parameters:
      value - The sensitivity value.
    • getSmoothScroll

      public final boolean getSmoothScroll()
      When true, the mouse scrolling will be smooth.
    • setSmoothScroll

      public void setSmoothScroll(boolean smoothScroll)
      Parameters:
      smoothScroll - Whether or not scrolling will be smooth.
    • getScrollPadding

      @Beta public final int getScrollPadding()
    • setScrollPadding

      @Beta public void setScrollPadding(int scrollPadding)
    • getHorizontalScrollAmount

      public final double getHorizontalScrollAmount()
      Calculates and returns the horizontal scroll amount.
    • getVerticalScrollAmount

      public final double getVerticalScrollAmount()
      Calculates and returns the vertical scroll amount.
    • __getHorizontalSeCnvElm

      @Internal @Nullable protected final @Nullable Tuple2<Point,Point> __getHorizontalSeCnvElm()
      Get horizontal start-end Points of canvas and elements bounding boxes.
      Used for scroll calculations.
      Returns:
      The bounding-box start-end Points for the canvas and its elements.
    • __getVerticalSeCnvElm

      @Internal @Nullable protected final @Nullable Tuple2<Point,Point> __getVerticalSeCnvElm()
      Get vertical start-end Points of canvas and elements bounding boxes.
      Used for scroll calculations.
      Returns:
      The bounding-box start-end Points for the canvas and its elements.
    • setHorizontalScrollAmount

      public final void setHorizontalScrollAmount(double amount01)
      Sets the horizontal scroll amount.
      Parameters:
      amount01 - The scroll amount in ranging from 0 to 1.
      See Also:
    • setVerticalScrollAmount

      public final void setVerticalScrollAmount(double amount01)
      Sets the vertical scroll amount.
      Parameters:
      amount01 - The scroll amount in ranging from 0 to 1.
      See Also:
    • getHorizontalScrollKnobSize01

      public final double getHorizontalScrollKnobSize01()
      Returns what should be the new knob size for a horizontal TScrollBarWidget.
      Ranges from 0 to 1, one being the maximum knob size.
    • getVerticalScrollKnobSize01

      public final double getVerticalScrollKnobSize01()
      Returns what should be the new knob size for a vertical TScrollBarWidget.
      Ranges from 0 to 1, one being the maximum knob size.
    • scrollToChild

      public final void scrollToChild(TElement child)
      Input enough horizontal and vertical scroll to make a specific child TElement visible on the viewport.
      Parameters:
      child - The child TElement to scroll to.
    • applyScrollDrag

      protected final boolean applyScrollDrag()
      Applies scroll values from scrollDragX and scrollDragY.
      Returns:
      True if the scroll drag values had any scroll to apply, and were then applied.
    • input

      public boolean input(TInputContext inputContext, TInputContext.InputDiscoveryPhase inputPhase)
      Description copied from interface: TParentElement
      An input handler that handles inputs on all possible TInputContext.InputDiscoveryPhases.
      Parameters:
      inputContext - The TInputContext containing information about a given input.
      inputPhase - The current TInputContext.InputDiscoveryPhase.
      See Also:
    • input

      public boolean input(TInputContext inputContext)
      Description copied from interface: TParentElement
      An input handler that handles inputs on the TInputContext.InputDiscoveryPhase.MAIN input phase.
      Specified by:
      input in interface TParentElement
      Overrides:
      input in class TElement
      Parameters:
      inputContext - The TInputContext containing information about a given input.
      See Also:
    • inputSmoothScroll

      public final boolean inputSmoothScroll(int scrollAmount)
      Same as inputScroll(int), but smooth.
      Parameters:
      scrollAmount - The input scroll amount.
    • inputSmoothScroll

      public final boolean inputSmoothScroll(int scrollAmountX, int scrollAmountY)
      Same as inputScroll(int, int), but smooth.
      Parameters:
      scrollAmountX - The horizontal input scroll amount.
      scrollAmountY - The vertical input scroll amount.
    • inputScroll

      public final boolean inputScroll(int scrollAmount)
      Used for inputting scroll input from a mouse wheel.

      Note: Unaffected by getScrollSensitivity(). That only applies to input(TInputContext).

      Parameters:
      scrollAmount - The input scroll amount.
    • inputScroll

      public final boolean inputScroll(int xScrollAmount, int yScrollAmount)
      Used for inputting scroll input from a mouse drag.

      Note: Unaffected by getScrollSensitivity(). That only applies to input(TInputContext).

      Parameters:
      xScrollAmount - The X scroll amount.
      yScrollAmount - The Y scroll amount.
    • inputHorizontalScroll

      public final boolean inputHorizontalScroll(int scrollAmount)
      Scrolls the TPanelElement horizontally.

      Note: Unaffected by getScrollSensitivity(). That only applies to input(TInputContext).

      Parameters:
      scrollAmount - The scroll amount.
    • inputVerticalScroll

      public final boolean inputVerticalScroll(int scrollAmount)
      Scrolls the TPanelElement vertically.

      Note: Unaffected by getScrollSensitivity(). That only applies to input(TInputContext).

      Parameters:
      scrollAmount - The scroll amount.