Skip to main content

Crate ferrokit_core

Crate ferrokit_core 

Source
Expand description

The AppKit layer under ferrokit: apps want that crate.

Places real AppKit views in a window and keeps their frames, focus and keyboard in step with ferrokit’s layout. table::TableModel and text::TextModel, which ferrokit re-exports, are documented here.

Its own API isn’t covered by Ferrokit’s stability promise: apps use what ferrokit re-exports, and the rest may change in any release.

Main thread only. Every function panics off the main thread.

Modules§

sync
Keeping native frame changes and the host’s GPU frame in step (risk 2).
table
A real NSTableView (in its NSScrollView) backed by a typed Rust model.
testing
Helpers for unattended tests: synthetic input posted into the app’s own event queue, and probes of AppKit state. Not for production use.
text
A real NSTextView (in its NSScrollView) as a text editor, plain or rich.

Structs§

Frames
AppKit frames for a clip container (in the content view’s coordinates) and for the view inside it (in the container’s flipped coordinates).
Rect
A rectangle in the host’s logical coordinates: points, origin at the top-left of the window’s content area, y growing downwards.
Rgba
An sRGB colour, components in 0..=1.
Snapshot
RGBA8 pixels, unpremultiplied as AppKit returns them, at backing resolution.
SystemColors
The system’s semantic colours, resolved for the window’s current appearance.
ViewId
Identifies a mounted native view. Chosen by the caller; stable for the view’s lifetime (views are created once and updated in place).

Enums§

AttachError
Why attach failed.
Event
A callback from AppKit for the host framework (see set_event_sink).

Functions§

appearance_generation
Increments whenever the app’s appearance (Dark Mode) or the system colours (accent) change.
attach
Takes the window’s content view. Call once the host window exists.
begin_frame
Starts a host frame. Views not placed between this and end_frame are hidden: they are no longer in the host’s layout.
content_view
The host’s content view (whose layer is the GPU surface).
end_frame
Ends a host frame: hides every view that wasn’t placed during it.
focus
Makes a mounted view the first responder.
focus_host
Gives keyboard focus back to the host’s view.
focused_view
The mounted view containing the first responder, if any.
frames
bounds is where the whole view would be; visible the part that may show (e.g. inside a scroll area). Both are snapped. When the content view isn’t flipped, the clip frame’s y is measured from the bottom.
hide
Hides a view until its next place.
install_edit_menu
Adds a standard Edit menu (Undo, Redo, Cut, Copy, Paste, Select All) with the usual shortcuts, routed to whichever side has focus.
is_attached
Whether attach has succeeded.
is_dark
Whether the app currently resolves to a dark appearance (system setting or app override).
is_mounted
Whether a view with this id is mounted.
is_suppressed
Whether set_suppressed is keeping the view hidden.
mount
Adds view (hidden until first placed). Replaces any view with this id.
observe_appearance
Starts tracking NSApp’s appearance and the system colours, emitting Event::AppearanceChanged on changes. Idempotent; crate::attach calls it, and a standalone app (no host window) calls it directly.
place
Moves a view to the host’s layout. Call while the host draws the frame that shows the slot, so the native change and the GPU frame belong together. bounds: where the whole view would be. visible: the part that may show.
request_redraw
Asks the host for another frame: emits Event::Redraw once per frame (the flag clears at crate::begin_frame). Used while a snapshot swap is in progress and no input event would otherwise cause a redraw.
scale
Device pixels per point for the attached window (1.0 before attaching).
set_accepts_tab
Lets a view keep plain Tab (e.g. a text editor). Ctrl-Tab leaves it.
set_action
Sends control’s action to the event sink as Event::Action(id).
set_event_sink
Where events go. Called on the main thread, from AppKit callbacks.
set_menu_action
Sends a menu item’s action to the event sink as Event::Action(id).
set_suppressed
Records that a view must stay hidden (or may show again). Takes effect at the view’s next place, so the change lands in the same frame the host draws (toggling it immediately showed a one-frame flash in the spike).
snapshot
Renders the mounted view into a bitmap, as it currently looks.
system_colors
Resolves the system colours for the app’s appearance.
unmount
Removes a view from the window (the view is released).
view
The mounted view itself (not its clip container).
views_in
Mounted views whose visible part (as last placed) intersects area.