Skip to content

Commit

Permalink
Updated to bevy 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
Lommix committed Nov 30, 2024
1 parent cd13eb3 commit eaa1847
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 418 deletions.
495 changes: 158 additions & 337 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/bevy_hui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy_hui"
authors = ["Lorenz Mielke"]
version = "0.1.0-rc.1"
version = "0.1.0"
edition = "2021"
description = "pseudo Html templating ui crate for the bevy-engine."
keywords = ["bevy", "ui", "xml", "html", "dsl"]
Expand All @@ -17,7 +17,7 @@ opt-level = 1
opt-level = 3

[dependencies]
bevy = { version = "0.15.0-rc.3", default-features = false, features = [
bevy = { version = "0.15", default-features = false, features = [
"bevy_render",
"bevy_ui",
"bevy_asset",
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_hui/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl<'w, 's> TemplateBuilder<'w, 's> {
// spawn image
NodeType::Image => {
self.cmd.entity(entity).insert((
UiImage {
ImageNode {
image: node
.src
.as_ref()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_hui/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn compile_node(
trigger: Trigger<CompileNodeEvent>,
mut cmd: Commands,
mut nodes: Query<(&mut HtmlStyle, &TemplateScope)>,
mut images: Query<&mut UiImage>,
mut images: Query<&mut ImageNode>,
mut tags: Query<&mut Tags>,
expressions: Query<&TemplateExpresions>,
contexts: Query<&TemplateProperties>,
Expand Down
27 changes: 19 additions & 8 deletions crates/bevy_hui/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ use crate::prelude::*;
use crate::util::{SlotId, SlotMap};
use bevy::ecs::system::EntityCommands;
use bevy::prelude::*;
use bevy::ui::widget::NodeImageMode;
use bevy::utils::HashMap;

#[derive(Debug, Default)]
#[derive(Debug, Default, Reflect)]
#[reflect]
pub enum NodeType {
#[default]
Node,
Expand All @@ -18,7 +20,8 @@ pub enum NodeType {
}

/// a single nodes data
#[derive(Debug, Default)]
#[derive(Debug, Default, Reflect)]
#[reflect]
pub struct XNode {
pub uuid: u64,
pub src: Option<String>,
Expand All @@ -33,12 +36,14 @@ pub struct XNode {
pub event_listener: Vec<Action>,
pub content_id: SlotId,
pub node_type: NodeType,
#[reflect(ignore)]
pub children: Vec<XNode>,
}

/// holds a parsed template
/// can be build as UI.
#[derive(Debug, Asset, TypePath)]
#[derive(Debug, Asset, Reflect)]
#[reflect]
pub struct HtmlTemplate {
pub name: Option<String>,
pub properties: HashMap<String, String>,
Expand Down Expand Up @@ -126,7 +131,8 @@ impl Action {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Reflect)]
#[reflect]
pub enum StyleAttr {
Display(Display),
Position(PositionType),
Expand Down Expand Up @@ -189,10 +195,9 @@ pub enum StyleAttr {
Background(Color),

// -----
// @todo: blocks reflect, rethink
Hover(Box<StyleAttr>),
Pressed(Box<StyleAttr>),
Active(Box<StyleAttr>),
Hover(#[reflect(ignore)] Box<StyleAttr>),
Pressed(#[reflect(ignore)] Box<StyleAttr>),
Active(#[reflect(ignore)] Box<StyleAttr>),

// -----
// animations
Expand All @@ -203,3 +208,9 @@ pub enum StyleAttr {
// image
ImageScaleMode(NodeImageMode),
}

impl Default for StyleAttr {
fn default() -> Self {
StyleAttr::Display(Display::None)
}
}
Loading

0 comments on commit eaa1847

Please sign in to comment.