Skip to main content

Crate bevy_pages

Crate bevy_pages 

Source
Expand description

§bevy_pages


Buy Me A Coffee

A lightweight and elegant framework to upgrade your Bevy UI experience.


crates.io docs.rs Following released Bevy versions


This is a crate extending bevy to add support for XML-based UI pages. Kinda like an HTML page, but supercharged and with XML.

§Features

  • 🪽 Lightweight: Bevy is already huge enough. This crate only enables actually necessary features and has a minimal set of dependencies.

  • ⚡ Fast: The only existent overhead is parsing the XML files, which is already very fast. Widgets and internal systems are written with ECS-filtering and optimized queries.

  • 📜 Expressive: Use the power of XML to create interactive UIs with ease. You can even have multiple pages activated at once and use custom CSS-like <Styles></Styles>.

  • ✒️ Fully documented: I added my signature #[warn(missing_docs)] and you can also look at the official guide to learn more about the framework.

  • 👁️ Built-in Auto-Completion: Use the official XSD Schema to enable auto-completion inside your favorite IDE.

  • 🔥 Integrated Hot-Reloading: Use the hot-reload feature to enable integrated asset hot-reloading.

  • ✨ Extended Widget Catalog: The framework has a set of basic and advanced widgets with optimal performance and customizability:

    • <Node></Node>
    • <Button></Button>
    • <Text></Text>
    • <Checkbox/>
    • <Divider/>
    • <Slider/>
    • <Dropdown></Dropdown>
    • <ScrollView></ScrollView>
    • <ProgressBar/>
    • <TextInput/>
    • <Tooltip></Tooltip>
    • <Image/>
    • <Switch/>
    • <Notifier/>

§Getting Started

After adding bevy_pages to your project, you can start coding your XML pages.

An XML page roughly looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Page
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/DraftedDev/bevy_pages/master/schema.xsd">
    <Text>Hello World!</Text>
</Page>

NOTE: If you have issues with the remote schema.xsd, you are free to download it locally and link it in your XML.

You will also need to add the PagesPlugin to your app and use the PageManager to spawn and manage your page:

fn spawn_my_page(mut commands: Commands, assets: Res<AssetServer>, mut manager: ResMut<PageManager>) {
    let handle = assets.load("my_page.xml");

    manager.spawn("my_page", handle);
    // Pages are inactive by default
    manager.set_active("my_page", true);
}

See more in this Tutorial.

§Learning Resources

§Bevy Support

The following table shows the supported bevy versions:

bevybevy_pages
0.190.1.0 - latest

Modules§

element
Contains the basic element structures for a clean UI.
events
Contains UI events and event handling systems.
loader
Contains the page asset loader.
manager
Contains the PageManager resource and related systems to manage UI pages.
page
Contains the Page struct for core UI work.
parser
Contains XML parsing functionality.
props
Contains the Properties struct.
utils
Contains utility functionality.
widgets
Contains custom widget functionality.

Macros§

set_if_changed
Mutates target only if its value differs from compare.
set_missing_attrs
Macro to set missing XML attributes.

Structs§

PagesPlugin
The main plugin for bevy_pages.