lumecs 0.0.1

Experimental GUI backed by Bevy ECS + usual suspects
docs.rs failed to build lumecs-0.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

Lumecs

Experimental GUI backed by Bevy ECS + usual suspects

Example

The infamous counter

use lumecs::prelude::*;

struct Counter {
    count: usize,
}

#[derive(Debug, Clone)]
enum Message {
    Increment,
    Decrement,
}

impl Runner<'_> for Counter {
    type M = Message;

    fn update(&mut self, message: Message) {
        match message {
            Message::Increment => self.count = self.count.saturating_add(1),
            Message::Decrement => self.count = self.count.saturating_sub(1),
        }
    }

    fn view(&self) -> impl Widget<'_, Self::M> {
        Root::flex_column()
            .gap(10.0)
            .align_items_center()
            .justify_content_center()
            .child(Text::new(format!("Count: {}", self.count)).font_size(24.0))
            .child(
                Container::flex_row()
                    .gap(10.0)
                    .child(
                        Container::flex()
                            .background_color("#ffcccc")
                            .padding(5.0)
                            .on_click(Message::Decrement)
                            .child(Text::new("Decrement").color("#111111")),
                    )
                    .child(
                        Container::flex()
                            .background_color("#ccffcc")
                            .padding(5.0)
                            .on_click(Message::Increment)
                            .child(Text::new("Increment").color("#111111")),
                    ),
            )
    }
}

fn main() {
    let counter = Counter { count: 0 };

    run(counter).expect("Failed to run the application");
}

Used crates

License