Skip to main content

Crate bevy_pf

Crate bevy_pf 

Source
Expand description

§bevy_pf — a XAML / WPF-like UI framework for Bevy

Write UI in XAML — inline via the xaml! macro, or in .xaml files — and instantiate it as bevy_ui entities, with WPF-style layout panels, resources and styles, and the common WPF control set.

use bevy::prelude::*;
use bevy_pf::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(PfUiPlugin)
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);
    commands.spawn_xaml(xaml!(
        r#"<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                       Margin="24" Spacing="8">
             <TextBlock Text="Hello from XAML" FontSize="28" FontWeight="Bold"/>
             <Button x:Name="Go" Content="Click me" Width="140"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"/>
           </StackPanel>"#
    ));
}

Re-exports§

pub use app_theme::AppTheme;
pub use app_theme::PfAppTheme;
pub use app_theme::PfAppThemeRefs;
pub use app_theme::app_theme;
pub use app_theme::set_user_app_theme;
pub use asset::XamlAsset;
pub use asset::XamlView;
pub use binding::Bindable;
pub use binding::BoundValue;
pub use binding::DataContext;
pub use binding::DataContextScope;
pub use binding::PfBindings;
pub use binding::SelectionMatch;
pub use components::ButtonVisual;
pub use components::PfAttachedProps;
pub use components::PfElementKind;
pub use components::PfName;
pub use components::XamlNames;
pub use device::DeviceIdiom;
pub use device::DevicePlatform;
pub use device::PfDevice;
pub use dynamic::PfApplicationResources;
pub use dynamic::PfDynamicResources;
pub use dynamic::PfResources;
pub use dynamic::merge_application_resources;
pub use dynamic::set_application_resources_dict;
pub use error::PfError;
pub use events::PfEventAppExt;
pub use events::PfEventHandlers;
pub use events::PfPointerInfo;
pub use hit_test::PfHitFilter;
pub use hit_test::PfHitTest;
pub use hit_test::PfHitTestVisible;
pub use instantiate::InstantiateResult;
pub use instantiate::XamlEnv;
pub use instantiate::instantiate_document;
pub use instantiate::instantiate_document_env;
pub use instantiate::set_application_resources;
pub use focus_nav::PfFocusDir;
pub use focus_nav::PfFocusNav;
pub use focus_nav::PfFocusScope;
pub use focus_nav::activate_control;
pub use items::PfItemsSource;
pub use overlay::PfPlacement;
pub use overlay::PfPopup;
pub use overlay::PfToolTip;
pub use plugin::PfCommandsExt;
pub use plugin::PfUiPlugin;
pub use provider::PfPropertyStore;
pub use provider::PropertyTarget;
pub use provider::ValueSource;
pub use triggers::PfTriggers;
pub use bevy_pf_xaml as xaml_ast;

Modules§

animation
Storyboards: WPF’s animation system.
app_theme
The app theme and MAUI’s {AppThemeBinding} markup extension.
asset
Runtime .xaml asset loading with hot reload.
behaviors
Interactivity behaviors — the Microsoft.Xaml.Behaviors surface (<b:Interaction.Triggers>).
binding
Data binding: {Binding Path=...} against a reflected view-model.
caret
Caret blinking.
components
ECS components attached to XAML-instantiated entities.
convert
Conversions from bevy_pf_xaml value types into Bevy types.
device
The device the app is running on, and MAUI’s {OnPlatform} / {OnIdiom}.
dialog
WPF MessageBox-style modal dialogs.
dynamic
Application-level resources and deferred {DynamicResource} lookup.
error
events
The pointer-event surface: WPF code-behind event attributes (MouseDown="OnPickUp") route to Rust handlers registered by name — the code-behind analog for drag/drop, hit feedback, and custom interaction.
focus_nav
Directional focus navigation and programmatic activation — the input-agnostic layer that lets a gamepad (or a TV remote, or a test) drive a bevy_pf UI.
fonts
The built-in UI font family and WPF font-family resolution.
hit_test
Asking “what UI is under this point?” from an ordinary system.
icons
Vector icon set for PackIcon / SymbolIcon / FontIcon (MaterialDesignInXaml PackIcon, MahApps IconPacks, WinUI SymbolIcon equivalents).
instantiate
Instantiate a parsed XamlDocument into a bevy_ui entity tree.
items
ItemsSource + DataTemplate: data-driven item generation for ListBox, ItemsControl, and ComboBox.
layout
bevy_pf’s layout system: WPF’s Measure/Arrange, ported from the dotnet/wpf source rather than approximated with a CSS layout engine.
navigation
WPF-style navigation: Frame, the journal, and page-navigating Hyperlinks.
overlay
The popup overlay layer: a top-Z root hosting dropdowns, tooltips, and (later) menus, positioned against their anchor elements after layout.
perf
Performance tuning for GUI-first applications.
plugin
The Bevy plugin and the Commands extension for spawning XAML.
prelude
provider
The per-entity value-provider store: WPF’s dependency-property precedence model, sized for the properties bevy_pf manages dynamically.
query
Finding XAML elements from any Bevy system.
resources
WPF-style resources: ResourceDictionary values, Style with setters, and parsing of resource elements (<SolidColorBrush x:Key="..."/>, <Style TargetType="Button">, <x:Double x:Key="..">42</x:Double>, …).
selector
Selector-based styling: <Style Selector="Button.danger:pointerover">.
shapes
WPF Shapes (Rectangle, Ellipse, Line, Polyline, Polygon, Path) rendered with CPU vector rasterization (tiny-skia) into UI image nodes.
themes
Built-in themes: popular palettes as swappable resource dictionaries.
toast
Toast / Snackbar / Growl notifications (MaterialDesign Snackbar, HandyControl Growl, Notifications.Wpf equivalents).
triggers
Runtime evaluation of Style.Triggers.
util
Small cross-platform utilities.

Macros§

include_xaml
Validate and embed an external .xaml file at compile time.
xaml
Validate and embed a XAML string literal at compile time.

Structs§

XamlScene
A validated XAML scene, ready to be spawned into a Bevy world.

Derive Macros§

Bindable
Derive equality-checked, per-property-notifying setters for a view-model — the INotifyPropertyChanged boilerplate, generated.