Module: ui.widgets.scrollview

Source: ./ui/widgets/scrollview.reef


Overview

ui/widgets/scrollview.reef - Scrollable container widget Part of reef-stdlib UI module

The ScrollView widget provides a scrollable view into content that may be larger than the visible area. It supports both horizontal and vertical scrolling with optional scrollbars.

ScrollView features:

  • Horizontal and/or vertical scrolling
  • Scrollbars (auto-hide, always visible, or never visible)
  • Smooth scrolling with momentum (optional)
  • Mouse wheel and keyboard navigation
  • Content clipping

Types

ScrollBarPolicy (enum)

Variants:

  • Auto
  • Always
  • Never

ScrollDirection (enum)

Variants:

  • Horizontal
  • Vertical
  • Both

Objects

ScrollView

Extends: widget.Widget

Fields:

Name Type
scroll_x float
scroll_y float
content_width float
content_height float
h_policy ScrollBarPolicy
v_policy ScrollBarPolicy
dragging_h bool
dragging_v bool
drag_start_x float
drag_start_y float
drag_start_scroll float
h_hovered bool
v_hovered bool

proc init(id: widget.WidgetId)

Methods:

override shared fn kind(): string

exclusive proc set_scroll(x: float, y: float)

exclusive proc set_content_size(size: core.Size)

exclusive proc set_h_policy(policy: ScrollBarPolicy)

exclusive proc set_v_policy(policy: ScrollBarPolicy)

exclusive proc scroll_by(dx: float, dy: float)

exclusive proc scroll_to_top()

exclusive proc scroll_to_bottom()

exclusive proc scroll_to_left()

exclusive proc scroll_to_right()

shared fn clone(): ScrollView

D2 (docs/design/2026-09-08-ui-modernization.md): a SHALLOW copy. Setters mutate the receiver (reef-lang#62), so "give me a variant and leave the original alone" has to be asked for explicitly. Referenced objects are shared, not deep-copied.

shared fn preferred_size(content_size: core.Size): core.Size

exclusive proc layout(constraints: layout.Constraints)

override exclusive fn handle_event(e: event.Event): widget.EventResult

override exclusive proc paint(surf: surface.Surface, th: theme.Theme)


Functions

fn scrollbar_auto(): ScrollBarPolicy

fn scrollbar_always(): ScrollBarPolicy

fn scrollbar_never(): ScrollBarPolicy

fn is_scrollbar_auto(p: ScrollBarPolicy): bool

fn is_scrollbar_always(p: ScrollBarPolicy): bool

fn is_scrollbar_never(p: ScrollBarPolicy): bool

fn scroll_horizontal(): ScrollDirection

fn scroll_vertical(): ScrollDirection

fn scroll_both(): ScrollDirection

fn scrollview(): ScrollView

fn scrollview_with_policy(h_policy: ScrollBarPolicy, v_policy: ScrollBarPolicy): ScrollView

fn scrollview_content_size(sv: ScrollView): core.Size

fn scrollview_viewport_size(sv: ScrollView): core.Size

fn scrollview_can_scroll_h(sv: ScrollView): bool

fn scrollview_can_scroll_v(sv: ScrollView): bool

fn scrollview_needs_h_scrollbar(sv: ScrollView): bool

fn scrollview_needs_v_scrollbar(sv: ScrollView): bool

fn scrollview_content_bounds(sv: ScrollView): core.Rect

fn handle_mouse_event(sv: ScrollView, me: event.MouseEvent): widget.EventResult

fn handle_key_event(sv: ScrollView, ke: event.KeyEvent): widget.EventResult

fn get_scrollbar_thumb_color(hovered: bool, colors: theme.ThemeColors): core.Color

fn get_v_thumb_height(sv: ScrollView): float

fn get_h_thumb_width(sv: ScrollView): float

fn get_v_thumb_position(sv: ScrollView, track_height: float): float

fn get_h_thumb_position(sv: ScrollView, track_width: float): float

fn clamp_scroll_x(sv: ScrollView, x: float): float

fn clamp_scroll_y(sv: ScrollView, y: float): float


Procedures

proc start_v_drag(sv: ScrollView, mx: float, my: float)

proc start_h_drag(sv: ScrollView, mx: float, my: float)

proc end_drag(sv: ScrollView)

proc update_v_drag(sv: ScrollView, my: float)

proc update_h_drag(sv: ScrollView, mx: float)

proc update_hover(sv: ScrollView, h_hover: bool, v_hover: bool)

proc paint_vertical_scrollbar(sv: ScrollView, surf: surface.Surface, th: theme.Theme, x: float, y: float, w: float, h: float)

proc paint_horizontal_scrollbar(sv: ScrollView, surf: surface.Surface, th: theme.Theme, x: float, y: float, w: float, h: float)

proc draw_border(surf: surface.Surface, x: float, y: float, w: float, h: float, color: core.Color)


Generated by reefc doc