Skip to main content

Crate denise_macos

Crate denise_macos 

Source
Expand description

An embeddable Cocoa view backend for Denise.

Not a way to ship Denise on a Mac — denise-winit already previews on one, and a desktop application should use a desktop toolkit. This exists for the same reason the Win32 control does: an existing Cocoa application that wants a Denise panel inside it, next to its own views, with the host owning the window and the run loop.

use denise::Size;
use denise_macos::ViewSurface;

// The host has a view; Denise has a surface the size of its backing store.
let mut surface = ViewSurface::new(Size::new(800, 480), 2.0)?;

§What is different from the bare-metal backends

  • The host owns the run loop. There is no run function here. AppKit decides when to draw and Denise answers, which is the opposite of the DRM backend where Denise decides and the display follows.
  • Damage is real. setNeedsDisplayInRect: genuinely limits what gets composited, unlike a DRM page flip where the whole buffer goes regardless. So the rectangles the tree produces are worth passing on rather than rounding up to the whole view.
  • Points are not pixels. A Retina view is 2 physical pixels per point. Denise lays out in physical pixels throughout — the conversion happens once, at this edge, and nothing above it needs the scale factor to hit-test.
  • There is already a cursor. The host’s window system draws one, so the composited sprite must stay off: Ui::show_cursor(false), which since M5 is a decision that sticks rather than one the next mouse move overrides.

Structs§

DeniseView
An NSView that draws a Denise surface and forwards Cocoa input to it.
ViewState
The view’s mutable state. Reachable through DeniseView::state.
ViewSurface
A pixel buffer a Cocoa view draws from.

Enums§

Error
Failures from this backend.

Traits§

ViewDelegate
What the application implements to put something in the view.

Functions§

key_code
The key position for an NSEvent keyCode, or Unidentified carrying the raw code.