Skip to main content

Crate masonry_core

Crate masonry_core 

Source
Expand description

Masonry Core provides the base GUI engine for Masonry.

Masonry’s widgets are implemented in the Masonry crate, which re-exports this crate as masonry::core. Most users who wish to use Masonry for creating applications (and UI libraries) should prefer to depend on Masonry directly (i.e. the masonry crate). Masonry’s documentation can be found on docs.rs.

Masonry Core provides:

  • Widget, the trait for GUI widgets in Masonry.
  • Event handling and bubbling, using types from ui-events for interoperability.
  • Communication between parent and child widgets for layout.
  • Compositing of widget’s content (to be rendered using Imaging).
  • Creation of accessibility trees using Accesskit.
  • APIs for widget manipulation (such as WidgetMut).
  • The Action mechanism by which widgets send events to the application.

Details of many of these can be found in the Pass System article.

If you’re writing a library in the Masonry ecosystem, you should depend on masonry_core directly where possible (instead of depending on masonry). This will allow applications using your library to have greater compilation parallelism. Cases where this apply include:

  • Writing an alternative driver for Masonry (alike to Masonry Winit).
  • Writing a library containing one or more custom widget (such as a 2d mapping widget).

Masonry Core can also be used by applications wishing to not use Masonry’s provided set of widgets, so as to have more control. This can be especially useful if you wish to exactly match the appearance of an existing library, or enforce following a specific design guide, which Masonry’s widgets may not always allow. Masonry Core provides a useful shared set of functionality to implement alternative widget libraries. Note that Masonry Core is currently focused primarily on the main Masonry crate itself, as we’re not aware of any projects using Masonry Core as described in this paragraph.

§Feature flags

The following crate feature flags are available:

  • tracy: Enables creating output for the Tracy profiler using tracing-tracy. This can be used by installing Tracy and connecting to a Masonry with this feature enabled.

Re-exports§

pub use imaging;
pub use accesskit;
pub use anymore;
pub use dpi;
pub use parley;
pub use ui_events;
pub use kurbo;
pub use peniko;

Modules§

app
Types needed for running a Masonry app.
core
Basic types and traits Masonry is built on.
doc
Documentation-only module for Masonry core concepts.
layout
Core layout types and traits Masonry is built on.
palette
Palettes with predefined colors.
properties
Core properties.
util
Miscellaneous utility functions.

Macros§

debug_panic
Panic in debug and tracing::error in release mode.