Expand description
The native layer under ferrokit and
ferrokit-iced: apps want one of those.
Places real AppKit views inside a window whose content is drawn by a GPU
host framework (Iced first). Host-agnostic: it only needs the window’s
raw-window-handle and layout rectangles in the host’s logical points.
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 itsNSScrollView) 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 itsNSScrollView) 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.
- System
Colors - 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§
- Attach
Error - Why
attachfailed. - 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_frameare 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
boundsis where the whole view would be;visiblethe 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
attachhas 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_suppressedis 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::AppearanceChangedon changes. Idempotent;crate::attachcalls 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::Redrawonce per frame (the flag clears atcrate::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 asEvent::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.