Skip to main content

Crate denise

Crate denise 

Source
Expand description

Denise — a direct-rendering UI toolkit for systems without a desktop environment.

This crate is the platform-agnostic core. It owns geometry, colour, the pixel buffer contract, input events and damage tracking. It contains no platform code and no unsafe.

Backends implement two traits:

§Frame lifecycle

let mut frame = surface.acquire()?;
// The buffer we just got back may be several frames old. Repaint everything
// that has been damaged since it was last current, not just this frame's damage.
let damage: &[Rect] = tracker.resolve(frame.age());
// ... draw into `frame`, clipped to `damage` ...
drop(frame);
surface.present(damage)?;
tracker.end_frame();

Getting that sequence wrong is the classic double-buffering bug: repaint only the current frame’s damage and every second frame shows stale content.

§Theming

Colours are named by roleRole::Primary, Role::Base100, Role::Error — each with a *Content partner. Theme::pair returns a surface and a foreground that are guaranteed to contrast, and Theme::validate proves it for a custom theme rather than leaving it to be discovered on a panel in daylight. The arithmetic is WCAG relative luminance in integers, so it is identical on x86 and ARM.

§Status

M5 complete, M6 in progress. Everything through M5 has run on real hardware — a Raspberry Pi on DRM/KMS, Windows 11 on ARM64, macOS — not only in CI. See the README for the roadmap.

Re-exports§

pub use angle::TURN;
pub use color::Color;
pub use cursor::CursorPlane;
pub use damage::DamageTracker;
pub use damage::MAX_DAMAGE_RECTS;
pub use damage::MAX_TRACKED_FRAMES;
pub use damage::RectList;
pub use geom::Point;
pub use geom::Rect;
pub use geom::Size;
pub use icon::GRID;
pub use icon::Icon;
pub use icon::Ink;
pub use icon::MAX_ICON_VERTICES;
pub use icon::MAX_SHAPES;
pub use icon::Shape;
pub use input::ElementState;
pub use input::InputEvent;
pub use input::InputSource;
pub use input::KeyCode;
pub use input::Modifiers;
pub use input::PointerButton;
pub use input::TouchId;
pub use paint::Paint;
pub use painter::ClipToken;
pub use painter::Clipped;
pub use painter::Painter;
pub use painter::PainterExt;
pub use painter::Pen;
pub use pixels::AtlasPage;
pub use pixels::ImageRef;
pub use pixels::Mask;
pub use pixels::PixelView;
pub use surface::BufferAge;
pub use surface::Frame;
pub use surface::PixelFormat;
pub use surface::Surface;
pub use surface::SurfaceError;
pub use surface::required_words;
pub use theme::ColorScheme;
pub use theme::Metrics;
pub use theme::Radius;
pub use theme::Role;
pub use theme::Theme;

Modules§

angle
Binary-turn angles and the fixed point the geometry runs in.
color
Straight (non-premultiplied) 8-bit-per-channel colour.
cursor
The hardware cursor plane, for backends that have one.
damage
Dirty-rectangle tracking.
geom
Integer geometry.
icon
Shapes a widget can draw when the font has no glyph for them.
input
Backend-independent input events.
paint
A colour prepared for drawing.
painter
The drawing contract widgets paint through.
pixels
The borrowed buffers a painter is handed.
surface
The pixel buffer contract every backend implements.
theme
Semantic theming.