Class TPanelElement
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
-
Nested Class Summary
Nested classes/interfaces inherited from class io.github.thecsdev.tcdcommons.api.client.gui.TElement
TElement.TElementEvent_ChildAR, TElement.TElementEvent_ContextMenu, TElement.TElementEvent_Moved, TElement.TElementEvent_ParentChanged, TElement.TElementEvent_Resized
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
static final int
static final int
static final int
protected int
static final int
A scroll flag used to define the scrolling behavior forsetScrollFlags(int)
.static final int
A scroll flag used to define the scrolling behavior forsetScrollFlags(int)
.static final int
A scroll flag used to define the scrolling behavior forsetScrollFlags(int)
.protected double
Used byTInputContext.InputType.MOUSE_DRAG
inputs to keep track of decimal scroll drag values.protected double
Used byTInputContext.InputType.MOUSE_DRAG
inputs to keep track of decimal scroll drag values.protected int
Defines the scroll behavior for thisTPanelElement
.
2nd bit -SCROLL_HORIZONTAL
3rd bit -SCROLL_VERTICAL
protected int
protected int
Defines how sensitive scrolling input from mouse and keyboard is going to be.protected double
Used by the smooth scrolling feature to smoothly scroll this panel.protected double
Used by the smooth scrolling feature to smoothly scroll this panel.protected boolean
protected float
Fields inherited from class io.github.thecsdev.tcdcommons.api.client.gui.TElement
alpha, eChildAdded, eChildRemoved, eContextMenu, eMoved, eParentChanged, eResized, height, SP_ALL, SP_INVOKE_EVENT, SP_MOVE_CHILDREN, SP_RELATIVE, SP_UPDATE_TOPMOST, SS_ALL, SS_INVOKE_EVENT, SS_UPDATE_TOPMOST, tooltip, tooltipPositioner, width, x, y, zOffset
Fields inherited from interface io.github.thecsdev.tcdcommons.api.client.gui.TParentElement
MAX_CHILD_NESTING_DEPTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet horizontal start-endPoint
s of canvas and elements bounding boxes.
Used for scroll calculations.Get vertical start-endPoint
s of canvas and elements bounding boxes.
Used for scroll calculations.protected final boolean
Applies scroll values fromscrollDragX
andscrollDragY
.final int
final double
Calculates and returns the horizontal scroll amount.final double
Returns what should be the new knob size for a horizontalTScrollBarWidget
.final int
final int
final int
Makes theTPanelElement
behave as if it has a "padding".final int
final boolean
When true, the mouse scrolling will be smooth.final double
Calculates and returns the vertical scroll amount.final double
Returns what should be the new knob size for a verticalTScrollBarWidget
.final boolean
hasScrollFlag
(int flagToCheck) Used to quickly check for a scroll flag inscrollFlags
.boolean
input
(TInputContext inputContext) An input handler that handles inputs on theTInputContext.InputDiscoveryPhase.MAIN
input phase.boolean
input
(TInputContext inputContext, TInputContext.InputDiscoveryPhase inputPhase) An input handler that handles inputs on all possibleTInputContext.InputDiscoveryPhase
s.final boolean
inputHorizontalScroll
(int scrollAmount) Scrolls theTPanelElement
horizontally.final boolean
inputScroll
(int scrollAmount) Used for inputting scroll input from a mouse wheel.final boolean
inputScroll
(int xScrollAmount, int yScrollAmount) Used for inputting scroll input from a mouse drag.final boolean
inputSmoothScroll
(int scrollAmount) Same asinputScroll(int)
, but smooth.final boolean
inputSmoothScroll
(int scrollAmountX, int scrollAmountY) Same asinputScroll(int, int)
, but smooth.final boolean
inputVerticalScroll
(int scrollAmount) Scrolls theTPanelElement
vertically.final boolean
Returns true if thisTPanelElement
has scrolling enabled.void
postRender
(TDrawContext pencil) void
render
(TDrawContext pencil) Renders this GUI element on the screen.protected final void
renderSmoothScroll
(float deltaTime) Handles smooth scrolling.final void
scrollToChild
(TElement child) Input enough horizontal and vertical scroll to make a specific childTElement
visible on the viewport.void
setBackgroundColor
(int color) final void
setHorizontalScrollAmount
(double amount01) Sets the horizontal scroll amount.void
setOutlineColor
(int color) void
setScrollFlags
(int flags) void
setScrollPadding
(int scrollPadding) void
setScrollSensitivity
(int value) void
setSmoothScroll
(boolean smoothScroll) SetsgetSmoothScroll()
.final void
setVerticalScrollAmount
(double amount01) Sets the vertical scroll amount.Methods inherited from class io.github.thecsdev.tcdcommons.api.client.gui.TElement
canBeAddedTo, createContextMenu, getAlpha, getChildren, getEnabled, getHeight, getItemRenderer, getParent, getParentTElement, getParentTScreen, getTextRenderer, getTooltip, getTooltipPositioner, getWidth, getX, getY, getZIndex, getZOffset, isDragging, isEnabled, isEnabledAndVisible, isFocusable, isFocused, isFocusedOrHovered, isHoverable, isHovered, isVisible, move, moveChildren, next, previous, setAlpha, setPosition, setPosition, setSize, setSize, setTooltip, setZOffset, tick, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.github.thecsdev.tcdcommons.api.client.gui.TParentElement
addChild, addChild, clearChildren, findChild, findLastChild, findParent, findParentTElement, forEachChild, getEndX, getEndY, removeChild, removeChild
-
Field Details
-
COLOR_OUTLINE
public static final int COLOR_OUTLINE- See Also:
-
COLOR_OUTLINE_FOCUSED
public static final int COLOR_OUTLINE_FOCUSED- See Also:
-
COLOR_BACKGROUND
public static final int COLOR_BACKGROUND- See Also:
-
SCROLL_HORIZONTAL
public static final int SCROLL_HORIZONTALA scroll flag used to define the scrolling behavior forsetScrollFlags(int)
.- See Also:
-
SCROLL_VERTICAL
public static final int SCROLL_VERTICALA scroll flag used to define the scrolling behavior forsetScrollFlags(int)
.- See Also:
-
SCROLL_BOTH
public static final int SCROLL_BOTHA scroll flag used to define the scrolling behavior forsetScrollFlags(int)
.- See Also:
-
topmosts
-
scrollFlags
protected int scrollFlagsDefines the scroll behavior for thisTPanelElement
.
2nd bit -SCROLL_HORIZONTAL
3rd bit -SCROLL_VERTICAL
-
scrollSensitivity
protected int scrollSensitivityDefines how sensitive scrolling input from mouse and keyboard is going to be. -
scrollPadding
protected int scrollPadding -
smoothScroll
protected boolean smoothScroll -
smoothScrollSpeed
protected float smoothScrollSpeed -
scrollDragX
protected double scrollDragXUsed byTInputContext.InputType.MOUSE_DRAG
inputs to keep track of decimal scroll drag values. -
scrollDragY
protected double scrollDragYUsed byTInputContext.InputType.MOUSE_DRAG
inputs to keep track of decimal scroll drag values. -
scrollVelocityX
protected double scrollVelocityXUsed by the smooth scrolling feature to smoothly scroll this panel. -
scrollVelocityY
protected double scrollVelocityYUsed by the smooth scrolling feature to smoothly scroll this panel. -
backgroundColor
protected int backgroundColor -
outlineColor
protected int outlineColor -
eScrolledHorizontally
-
eScrolledVertically
-
-
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
Description copied from interface:TParentElement
Renders this GUI element on the screen.- Specified by:
render
in interfaceTParentElement
- Specified by:
render
in classTElement
- Parameters:
pencil
- TheTDrawContext
.
-
postRender
- Overrides:
postRender
in classTElement
-
renderSmoothScroll
protected final void renderSmoothScroll(float deltaTime) Handles smooth scrolling. Needs to be called once every frame fromrender(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 inscrollFlags
.- Parameters:
flagToCheck
- For exampleSCROLL_HORIZONTAL
.
-
isScrollable
public final boolean isScrollable()Returns true if thisTPanelElement
has scrolling enabled. -
getScrollFlags
public final int getScrollFlags() -
setScrollFlags
public void setScrollFlags(int flags) - Parameters:
flags
- The scroll settings.
-
getScrollSensitivity
public final int getScrollSensitivity() -
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) SetsgetSmoothScroll()
.- Parameters:
smoothScroll
- Whether or not scrolling will be smooth.
-
getScrollPadding
@Beta public final int getScrollPadding()Makes theTPanelElement
behave as if it has a "padding". This "padding" applies a "distance" between the parentTPanelElement
and its child "content" elements. -
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
Get horizontal start-endPoint
s of canvas and elements bounding boxes.
Used for scroll calculations.- Returns:
- The bounding-box start-end
Point
s for the canvas and its elements.
-
__getVerticalSeCnvElm
Get vertical start-endPoint
s of canvas and elements bounding boxes.
Used for scroll calculations.- Returns:
- The bounding-box start-end
Point
s 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 horizontalTScrollBarWidget
.
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 verticalTScrollBarWidget
.
Ranges from 0 to 1, one being the maximum knob size. -
scrollToChild
Input enough horizontal and vertical scroll to make a specific childTElement
visible on the viewport.- Parameters:
child
- The childTElement
to scroll to.
-
applyScrollDrag
protected final boolean applyScrollDrag()Applies scroll values fromscrollDragX
andscrollDragY
.- Returns:
- True if the scroll drag values had any scroll to apply, and were then applied.
-
input
Description copied from interface:TParentElement
An input handler that handles inputs on all possibleTInputContext.InputDiscoveryPhase
s.- Parameters:
inputContext
- TheTInputContext
containing information about a given input.inputPhase
- The currentTInputContext.InputDiscoveryPhase
.- See Also:
-
input
Description copied from interface:TParentElement
An input handler that handles inputs on theTInputContext.InputDiscoveryPhase.MAIN
input phase.- Specified by:
input
in interfaceTParentElement
- Overrides:
input
in classTElement
- Parameters:
inputContext
- TheTInputContext
containing information about a given input.- See Also:
-
inputSmoothScroll
public final boolean inputSmoothScroll(int scrollAmount) Same asinputScroll(int)
, but smooth.- Parameters:
scrollAmount
- The input scroll amount.
-
inputSmoothScroll
public final boolean inputSmoothScroll(int scrollAmountX, int scrollAmountY) Same asinputScroll(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 toinput(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 toinput(TInputContext)
.- Parameters:
xScrollAmount
- The X scroll amount.yScrollAmount
- The Y scroll amount.
-
inputHorizontalScroll
public final boolean inputHorizontalScroll(int scrollAmount) Scrolls theTPanelElement
horizontally.Note: Unaffected by
getScrollSensitivity()
. That only applies toinput(TInputContext)
.- Parameters:
scrollAmount
- The scroll amount.
-
inputVerticalScroll
public final boolean inputVerticalScroll(int scrollAmount) Scrolls theTPanelElement
vertically.Note: Unaffected by
getScrollSensitivity()
. That only applies toinput(TInputContext)
.- Parameters:
scrollAmount
- The scroll amount.
-