Module: reefvision.widgets.window
Source: ./reefvision/widgets/window.reef
Overview
reefvision.widgets.window — framed Group (design §5 / object-rewrite §5)
object Window extends view.Group. Outer bounds include the frame. Children use client-relative coords (0,0 = top-left inside the frame). Client inset is 1 cell on each side; the title bar reuses the top frame row.
Chrome: drag title to move; bottom-right grip to resize (min + clamp). Optional system controls are ONE title-cap block (order left→right): ┤ _ + x ├ (maximized shows = instead of +; close is lowercase x) _ minimize → CMD_MINIMIZE
- maximize → CMD_MAXIMIZE (toggle restore) x close → CMD_CLOSE Glyphs always use the title style (never a focused/highlight style). Esc emits event_command(CMD_CLOSE) when the client does not consume the key.
Usage: let win = new window.Window(cell.rect(4, 2, 40, 12), "Tools") win.set_closable(true) win.add(new button.Button(cell.rect(2, 2, 10, 1), "OK", event.CMD_OK()))
Types
WindowDragMode (enum)
Variants:
NoneMoveResize
WindowState (enum)
Variants:
NormalMinimizedMaximized
Objects
Window
Extends: view.Group
Fields:
| Name | Type |
|---|---|
title |
string |
is_active |
bool |
closable |
bool |
minimizable |
bool |
maximizable |
bool |
state |
WindowState |
restore_x |
int |
restore_y |
int |
restore_w |
int |
restore_h |
int |
has_restore |
bool |
client_ox |
int |
client_oy |
int |
drag_mode |
WindowDragMode |
drag_grab_x |
int |
drag_grab_y |
int |
drag_orig_x |
int |
drag_orig_y |
int |
drag_orig_w |
int |
drag_orig_h |
int |
clamp |
cell.Rect |
center_on_resize |
bool |
proc init(bounds: cell.Rect, title: string)
Methods:
shared fn title(): string
shared fn is_active(): bool
shared fn is_closable(): bool
shared fn is_minimizable(): bool
shared fn is_maximizable(): bool
shared fn is_minimized(): bool
shared fn is_maximized(): bool
shared fn is_dragging(): bool
shared fn center_on_resize(): bool
exclusive proc set_title(title: string)
exclusive proc set_active(is_active: bool)
exclusive proc set_visible(visible: bool)
exclusive proc set_closable(closable: bool)
exclusive proc set_minimizable(minimizable: bool)
exclusive proc set_maximizable(maximizable: bool)
exclusive proc set_bounds(bounds: cell.Rect)
exclusive proc set_clamp(clamp: cell.Rect)
exclusive proc set_center_on_resize(on: bool)
exclusive proc center_in(area: cell.Rect)
exclusive proc reclamp_to(area: cell.Rect)
Keep the window reachable after a terminal resize:
- size is capped to the content area (not below min when possible)
- origin is shifted so the title row intersects the area
- if still impossible (tiny area), pin to area top-left
exclusive proc save_restore()
exclusive proc minimize()
exclusive proc restore()
exclusive proc maximize(content: cell.Rect)
exclusive proc toggle_maximize(content: cell.Rect)
override exclusive proc draw(buf: cell.CellBuffer, abs: cell.Rect, clip: cell.Rect, focused: bool, th: theme.Theme)
override exclusive fn handle_event(e: event.Event): view.EventResult
Functions
fn window_min_w(): int
fn window_min_h(): int
fn client_size(outer: cell.Rect): cell.Rect
fn drag_move_bounds(orig: cell.Rect, grab_x: int, grab_y: int, mx: int, my: int, clamp: cell.Rect): cell.Rect
Pure: new outer rect after move drag (grab = mouse at press, mx/my = now).
fn drag_resize_bounds(orig: cell.Rect, grab_x: int, grab_y: int, mx: int, my: int, clamp: cell.Rect): cell.Rect
Pure: resize from bottom-right (grab = mouse at press on BR corner).
fn is_title_bar(outer: cell.Rect, x: int, y: int): bool
fn is_resize_grip(outer: cell.Rect, x: int, y: int): bool
fn drag_mode_is_none(m: WindowDragMode): bool
fn drag_mode_is_move(m: WindowDragMode): bool
fn drag_mode_is_resize(m: WindowDragMode): bool
fn is_left_press(e: event.Event): bool
fn is_left_release(e: event.Event): bool
fn is_left_drag(e: event.Event): bool
fn sys_btn_count(w: Window): int
fn sys_block_width(w: Window): int
fn sys_block_x0(outer: cell.Rect, w: Window): int
fn sys_glyph_x(outer: cell.Rect, w: Window, kind: int): int
fn is_close_button(w: Window, outer: cell.Rect, x: int, y: int): bool
fn is_max_button(w: Window, outer: cell.Rect, x: int, y: int): bool
fn is_min_button(w: Window, outer: cell.Rect, x: int, y: int): bool
fn is_any_sys_button(w: Window, outer: cell.Rect, x: int, y: int): bool
Procedures
proc draw_sys_block(buf: cell.CellBuffer, outer: cell.Rect, clip: cell.Rect, w: Window, frame_st: cell.Style, glyph_st: cell.Style, bx: theme.BoxGlyphs)
Generated by reefc doc