Cairn · module

Cairn.Frame

lean/Cairn/Frame.lean

What crosses the boundary each frame, before encoding. Cairn.Frame.Encode turns it into bytes (see docs/frame.md).

Imports Cairn.UI.Node, Cairn.Input, Cairn.Surface

Order

Structures 7

structure

Cairn.AxNode

lean/Cairn/Frame.lean:31
AxNode : Type
Fields
control : Option ControlRef
role : Role
rect : Rect
label : String
value : String
parent : Option Nat

Index of the parent in the frame's ax array; roots have none.

focused : Bool
selected : Bool
checked : Option Bool
secure : Bool

A secure field (FieldView.secure): the host shows an AXSecureTextField and exposes no value (value is empty).

menu : Option Bool

The control has a menu (Style.menu): some true a menu button (⋯), some false a context menu only. The host gives it AXShowMenu.

Instances

BEq Repr Inhabited

structure

Cairn.TextInput

lean/Cairn/Frame.lean:51
TextInput : Type

Everything NSTextInputClient may ask about the focused field, answered without Lean.

Fields
control : ControlRef
rect : Rect
caret : Rect
text : String
selection : Nat × Nat
marked : Option (Nat × Nat)
textOrigin : Point

The left end of the text's baseline, in window coordinates, after any horizontal scroll: where scalar 0 starts.

secure : Bool

The field is secure (FieldView.secure): text is bullets, and the host turns on secure event input while it has focus.

Instances

Inhabited Repr BEq

structure

Cairn.Canvas

lean/Cairn/Frame.lean:67
Canvas : Type

What one Metal surface (the window, a panel) shows: M1's frame without the app-wide parts.

Fields
size : Size
draws : Array Draw
ax : Array AxNode
textInput : Option TextInput
cursor : Cursor
Instances

Repr Inhabited

structure

Cairn.MenuRecord

lean/Cairn/Frame.lean:84
MenuRecord : Type

One MenuItem, flattened (Frame.ofMenu): parents come before their children, and parent is the index of the enclosing submenu's record.

Fields
kind : MenuKind
label : String
control : Option ControlRef

The item's control (item only).

place : Option ClaimId

The submenu's place claim (submenu only, when it has one).

parent : Option Nat
enabled : Bool
checked : Option Bool
shortcut : Option Shortcut
Instances

Inhabited Repr

structure

Cairn.StatusFrame

lean/Cairn/Frame.lean:98
StatusFrame : Type

What a status item shows: its button and its menu.

Fields
control : ControlRef
symbol : String
title : String
label : String
menu : Array MenuRecord
Instances

Inhabited Repr

structure

Cairn.SurfaceFrame

lean/Cairn/Frame.lean:112
SurfaceFrame : Type

One surface's record. Fields a kind doesn't use stay at their defaults: a window has no anchor or status, a status item no canvas, a hidden surface neither.

Fields
place : ClaimId
shown : Bool
title : String

The window's title.

anchor : Anchor

A panel's placement.

screen : ScreenChoice
minSize : Size

The window's smallest content size (App.minSize); 0 × 0 for other kinds.

canvas : Canvas

A window's or panel's content. A panel's size is Lean's: its width and laid-out height.

status : StatusFrame

A status item's button and menu. For the window, the control menu open now (UI.menu): control its owner and menu its records, no records when none is open. For the menu bar (Surface.menuBar), its items in menu.

Instances

Inhabited Repr

structure

Cairn.Frame

lean/Cairn/Frame.lean:134
Frame : Type

One frame: every surface of the app, in the app's order, then what is the app's as a whole.

Fields
surfaces : Array SurfaceFrame
effects : Array Effect
subs : Array SubCmd

Subscriptions to start and stop, in order (docs/effects.md).

wake : Option Nat

The earliest timer deadline, in the host's monotonic milliseconds: the host sends a clock event no later than this.

Instances

Repr Inhabited

Inductive types 3

inductive

Cairn.Draw

lean/Cairn/Frame.lean:14
Draw : Type
Constructors
rect (r : Rect) (fill : Option Color) (radius : Nat) (border : Option Border) :
  Draw
text (origin : Point) (font : Font) (color : Color) (s : String) : Draw

origin is the left end of the baseline.

pushClip (r : Rect) : Draw
popClip : Draw
shape (r : Rect) (fill : Option Color) (radius : Nat) (border : Option Border)
  (corner : Corner) (shadow : Option Shadow) : Draw

A rounded rect with what rect lacks: continuous corners and a soft shadow painted under it (Style.corner, Style.shadow).

paint (r : Rect) (p : Paint) : Draw

Host-drawn pixels inside r (Style.paint).

image (r dest : Rect) (source : String) : Draw

The image the host holds for source, scaled to dest and painted only inside r (Style.image; dest is Frame.imageDest's). Nothing if the host holds no image for it.

Instances

Repr BEq Inhabited

inductive

Cairn.MenuKind

lean/Cairn/Frame.lean:78
MenuKind : Type

The kind of a menu record: MenuItem's constructors.

Constructors
item : MenuKind
info : MenuKind
submenu : MenuKind
separator : MenuKind
Instances

Inhabited Repr

inductive

Cairn.SurfaceKind

lean/Cairn/Frame.lean:106
SurfaceKind : Type
Constructors
window : SurfaceKind
panel : SurfaceKind
statusItem : SurfaceKind
menuBar : SurfaceKind
Instances

Inhabited Repr

Definitions 8

def

Cairn.Canvas.empty

lean/Cairn/Frame.lean:75
empty : Canvas
def

Cairn.Frame.single

lean/Cairn/Frame.lean:147
single (c : Canvas) (effects : Array Effect := #[]) (subs : Array SubCmd := #[])
  (wake : Option Nat := none) : Frame

A frame with one window (place 0) showing c: M1's frame.

def

Cairn.Frame.window

lean/Cairn/Frame.lean:152
window (f : Frame) : Canvas

The first window's canvas; empty when the frame has no window.

def

Cairn.Frame.size

lean/Cairn/Frame.lean:155
size (f : Frame) : Size
def

Cairn.Frame.draws

lean/Cairn/Frame.lean:156
draws (f : Frame) : Array Draw
def

Cairn.Frame.ax

lean/Cairn/Frame.lean:157
ax (f : Frame) : Array AxNode
def

Cairn.Frame.textInput

lean/Cairn/Frame.lean:158
textInput (f : Frame) : Option TextInput
def

Cairn.Frame.cursor

lean/Cairn/Frame.lean:159
cursor (f : Frame) : Cursor

Instances 25

instance

Cairn.instReprDraw

lean/Cairn/Frame.lean:29
instReprDraw : Repr Draw
instance

Cairn.instBEqDraw

lean/Cairn/Frame.lean:29
instBEqDraw : BEq Draw
instance

Cairn.instInhabitedDraw

lean/Cairn/Frame.lean:29
instInhabitedDraw : Inhabited Draw
instance

Cairn.instBEqAxNode

lean/Cairn/Frame.lean:48
instBEqAxNode : BEq AxNode
instance

Cairn.instReprAxNode

lean/Cairn/Frame.lean:48
instReprAxNode : Repr AxNode
instance

Cairn.instInhabitedAxNode

lean/Cairn/Frame.lean:48
instInhabitedAxNode : Inhabited AxNode
instance

Cairn.instInhabitedTextInput

lean/Cairn/Frame.lean:64
instInhabitedTextInput : Inhabited TextInput
instance

Cairn.instReprTextInput

lean/Cairn/Frame.lean:64
instReprTextInput : Repr TextInput
instance

Cairn.instBEqTextInput

lean/Cairn/Frame.lean:64
instBEqTextInput : BEq TextInput
instance

Cairn.instReprCanvas

lean/Cairn/Frame.lean:73
instReprCanvas : Repr Canvas
instance

Cairn.instInhabitedCanvas

lean/Cairn/Frame.lean:73
instInhabitedCanvas : Inhabited Canvas
instance

Cairn.instDecidableEqMenuKind

lean/Cairn/Frame.lean:80
instDecidableEqMenuKind : DecidableEq MenuKind
instance

Cairn.instInhabitedMenuKind

lean/Cairn/Frame.lean:80
instInhabitedMenuKind : Inhabited MenuKind
instance

Cairn.instReprMenuKind

lean/Cairn/Frame.lean:80
instReprMenuKind : Repr MenuKind
instance

Cairn.instInhabitedMenuRecord

lean/Cairn/Frame.lean:95
instInhabitedMenuRecord : Inhabited MenuRecord
instance

Cairn.instReprMenuRecord

lean/Cairn/Frame.lean:95
instReprMenuRecord : Repr MenuRecord
instance

Cairn.instInhabitedStatusFrame

lean/Cairn/Frame.lean:104
instInhabitedStatusFrame : Inhabited StatusFrame
instance

Cairn.instReprStatusFrame

lean/Cairn/Frame.lean:104
instReprStatusFrame : Repr StatusFrame
instance

Cairn.instInhabitedSurfaceKind

lean/Cairn/Frame.lean:108
instInhabitedSurfaceKind : Inhabited SurfaceKind
instance

Cairn.instDecidableEqSurfaceKind

lean/Cairn/Frame.lean:108
instDecidableEqSurfaceKind : DecidableEq SurfaceKind
instance

Cairn.instReprSurfaceKind

lean/Cairn/Frame.lean:108
instReprSurfaceKind : Repr SurfaceKind
instance

Cairn.instInhabitedSurfaceFrame

lean/Cairn/Frame.lean:130
instInhabitedSurfaceFrame : Inhabited SurfaceFrame
instance

Cairn.instReprSurfaceFrame

lean/Cairn/Frame.lean:130
instReprSurfaceFrame : Repr SurfaceFrame
instance

Cairn.instReprFrame

lean/Cairn/Frame.lean:142
instReprFrame : Repr Frame
instance

Cairn.instInhabitedFrame

lean/Cairn/Frame.lean:142
instInhabitedFrame : Inhabited Frame