Skip to content

UIScrollView Class

Definition

Namespace: Brine2D.UI

Scrollable container for UI components that exceed visible area.

C#
public class UIScrollView : Brine2D.UI.IUIComponent, Brine2D.UI.IAnchoredUIComponent

Inheritance System.Object → UIScrollView

Implements IUIComponent, IAnchoredUIComponent

Properties
Anchor The screen anchor point this component is positioned relative to.
AnchorOffset Pixel offset from the resolved anchor point.
AutoFitContent When true, ContentHeight and ContentWidth are automatically recalculated via FitContentToChildren() every time a child is added or removed. This is the recommended setting for dynamic lists. Defaults to false to preserve the previous manual behaviour.
BackgroundColor Background color.
BackgroundTexture Optional nine-slice background texture. When set, replaces the solid BackgroundColor fill.
BackgroundTextureBorder Nine-slice border insets \(texels\) for BackgroundTexture.
BackgroundTextureTint Tint color applied to BackgroundTexture. Defaults to white.
BorderColor Border color.
ContentHeight Total content height \(can be larger than Size\.Y for scrolling\).
ContentWidth Total content width \(can be larger than Size\.X for horizontal scrolling\).
FocusColor Color of the focus ring drawn around the scroll view when it has keyboard focus.
IsFocused Whether this scroll view currently has keyboard focus.
LastKnownScreenSize Last screen size pushed by UICanvas. Used when propagating to children added after this scroll view is already on a canvas.
MinScrollbarThumbSize Minimum scrollbar thumb size in pixels.
ScrollbarColor Scrollbar color.
ScrollbarHoverColor Scrollbar hover color.
ScrollbarTrackColor Scrollbar track \(background behind the thumb\) color.
ScrollbarWidth Width of the scrollbar.
ScrollOffset Current scroll offset \(0 = top/left\).
ScrollSpeed Scroll speed multiplier for mouse wheel.
ShowHorizontalScrollbar Whether to show horizontal scrollbar.
ShowVerticalScrollbar Whether to show vertical scrollbar.
Methods
AddChild\(IUIComponent\) Adds a child component to the scroll view. Child positions are relative to the scroll view's content area.
ClearChildren() Removes all child components.
EndScrollbarDrag() Called by UICanvas when scrollbar thumb drag ends.
FitContentToChildren() Expands ContentHeight and ContentWidth to fit all current children based on their Position and Size. Call this after finishing layout so scrolling bounds are set correctly.
GetChildren() Gets all child components.
HandlePageScroll\(float\) Scrolls by one page \(the visible height\) in the given direction. Positive direction scrolls down; negative scrolls up.
HandleScroll\(float\) Called by UICanvas to handle scroll wheel input.
IsChildVisible\(IUIComponent, Vector2, Vector2\) Checks whether a child \(with its Position already translated to screen space\) overlaps the visible clip region. Must be called after the screen-space position has been applied.
IsOverHorizontalScrollbar\(Vector2\) Returns whether the given screen position is over the horizontal scrollbar thumb.
IsOverHorizontalScrollbarTrack\(Vector2\) Returns whether the given screen position is over the horizontal scrollbar track area \(the full scrollbar row, including the thumb\).
IsOverVerticalScrollbar\(Vector2\) Returns whether the given screen position is over the vertical scrollbar thumb.
IsOverVerticalScrollbarTrack\(Vector2\) Returns whether the given screen position is over the vertical scrollbar track area \(the full scrollbar column, including the thumb\).
JumpScrollToHorizontal\(float\) Jumps the horizontal scroll position proportionally to where the given screen-space X falls within the track \(left of track = scroll left, right = scroll right\).
JumpScrollToVertical\(float\) Jumps the vertical scroll position proportionally to where the given screen-space Y falls within the track \(top of track = scroll top, bottom = scroll bottom\).
RemoveChild\(IUIComponent\) Removes a child component.
ScrollToBottom() Scrolls to the very bottom of the content.
ScrollToChild\(IUIComponent\) Scrolls to make the specified child visible.
ScrollToTop() Scrolls to the very top of the content.
SetFocused\(bool\) Called by UICanvas to set keyboard focus on this scroll view.
StartScrollbarDrag\(Vector2, bool\) Called by UICanvas when scrollbar thumb drag begins.
UpdateScrollbarDrag\(Vector2\) Called by UICanvas each frame while scrollbar thumb is being dragged.
UpdateScrollbarHover\(Vector2\) Called by UICanvas each frame to update scrollbar hover state.
Events
OnFocusGained Event fired when this scroll view gains keyboard focus.
OnFocusLost Event fired when this scroll view loses keyboard focus.
OnScrollChanged Fired whenever ScrollOffset changes, with the new offset as the argument.