Module: reefvision.view

Source: ./reefvision/view.reef


Overview

reefvision.view — View/Group object engine: bounds, clip, draw walk, focus

Design: docs/design/2026-08-23-reefvision-object-rewrite.md §4.

Retained-mode widget tree. Concrete widgets extend View and override draw / handle_event / wants_focus. Insertion is Group.add(v: View). Identity is the object reference; widgets have no slot or id.

Usage: let g = new view.Group(cell.rect(0, 0, 40, 10)) g.add(new button.Button(cell.rect(1, 1, 10, 1), "OK", event.CMD_OK())) g.draw(buf, cell.rect(0, 0, 40, 10), clip, false, th)

Pure geometry + cells: no curses, no host TTY I/O in this module.


Types

EventResult

Fields:

Name Type
handled bool
command int

Objects

View

Fields:

Name Type
bounds cell.Rect
visible bool
enabled bool

proc init(bounds: cell.Rect)

Methods:

shared fn wants_focus(): bool

shared fn captures_mouse(): bool

ListBox / TextArea scrollbar-thumb drag captures until release.

exclusive proc draw(buf: cell.CellBuffer, abs: cell.Rect, clip: cell.Rect, focused: bool, th: theme.Theme)

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

Group

Extends: View

Fields:

Name Type
children [View]
focused_idx int

proc init(bounds: cell.Rect)

Methods:

exclusive proc add(v: View)

exclusive proc ensure_focus()

exclusive fn focus_next(): bool

exclusive fn focus_prev(): bool

override exclusive proc draw(buf: cell.CellBuffer, abs: cell.Rect, clip: cell.Rect, focused: bool, th: theme.Theme)

exclusive fn dispatch_mouse(e: event.Event, origin: cell.Point): EventResult

Mouse: scrollbar-drag capture, then back-to-front hit-test in origin's space. Focus a hit child that wants_focus; deliver with coords relative to origin so child.bounds matches. Window passes the client origin.

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


Functions

fn event_ignored(): EventResult

fn event_handled(): EventResult

fn event_command(cmd: int): EventResult

fn rect_offset(r: cell.Rect, dx: int, dy: int): cell.Rect

fn view_abs_origin(bounds: cell.Rect, parent_abs: cell.Point): cell.Point

fn view_abs_bounds(bounds: cell.Rect, parent_abs: cell.Point): cell.Rect

fn child_can_focus(v: View): bool

fn is_tab_key(e: event.Event): bool

fn is_backtab_key(e: event.Event): bool

fn mouse_in_origin(e: event.Event, origin: cell.Point): event.Event

Screen mouse → the coordinate space of origin (child.bounds live here).

fn group_child_count(g: Group): int

fn group_focused_idx(g: Group): int

fn group_focus_next(g: Group): bool

fn group_focus_prev(g: Group): bool


Procedures

proc group_set_focus_idx(g: Group, idx: int)

proc group_ensure_focus(g: Group)


Generated by reefc doc