Skip to content

Commit

Permalink
Now compatible with bevy 0.13 (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
Threadzless committed Apr 20, 2024
1 parent 5301ff4 commit 7a1acb3
Show file tree
Hide file tree
Showing 34 changed files with 672 additions and 697 deletions.
1,058 changes: 526 additions & 532 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 21 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "belly"
version = "0.4.0"
edition = "2021"
version = { workspace = true }
edition = { workspace = true }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -15,13 +15,29 @@ members = [
"crates/tagstr",
]

[dependencies]
bevy = "0.12"
embed-doc-image = "0.1"
[workspace.package]
edition = "2021"
version = "0.4.0"


[workspace.dependencies]
bevy = { version = "0.13" }
itertools = { version = "0.10.5" }

tagstr = { path = "crates/tagstr" }
belly_macro = { path = "crates/belly_macro" }
belly_core = { path = "crates/belly_core" }
belly_widgets = { path = "crates/belly_widgets" }
bevy_stylebox = { path = "crates/bevy_stylebox" }


[dependencies]
bevy = { workspace = true }
embed-doc-image = "0.1"
tagstr = { workspace = true }
belly_macro = { workspace = true }
belly_core = { workspace = true }
belly_widgets = { workspace = true }

[[example]]
name = "text_input"
Expand Down
4 changes: 2 additions & 2 deletions crates/belly_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "belly_cli"
version = "0.1.0"
edition = "2021"
version = { workspace = true }
edition = { workspace = true }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion crates/belly_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::{collections::HashMap, fs::File, io::BufReader};

use clap::{Parser, Subcommand};
use rustdoc_json;

use rustdoc_types::{Crate, Id, Item, ItemEnum, ItemKind, Module, Type};
use serde_json::from_reader;

Expand Down
12 changes: 6 additions & 6 deletions crates/belly_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[package]
name = "belly_core"
version = "0.4.0"
edition = "2021"
version = { workspace = true }
edition = { workspace = true }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0"
bevy = "0.12"
bevy_stylebox = { path = "../bevy_stylebox" }
bevy = { workspace = true }
bevy_stylebox = { workspace = true }
cssparser = "0.29.6"
itertools = "0.10.5"
itertools = { workspace = true }
lazy_static = "1.4.0"
roxmltree = "0.16.0"
smallvec = "1.10.0"
thiserror = "1.0.50"
tagstr = { path = "../tagstr" }
tagstr = { workspace = true }
6 changes: 3 additions & 3 deletions crates/belly_core/src/element.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::ecs::component::Tick;
use bevy::ecs::query::WorldQuery;
use bevy::ecs::query::QueryData;
use bevy::ecs::system::{Command, CommandQueue, SystemMeta, SystemParam};
use bevy::ecs::world::unsafe_world_cell::UnsafeWorldCell;
use bevy::ui::UiSystem;
Expand Down Expand Up @@ -133,7 +133,7 @@ impl Element {
#[derive(Resource, Deref, DerefMut, Default)]
pub struct ElementIdIndex(HashMap<Tag, Entity>);

#[derive(WorldQuery)]
#[derive(QueryData)]
pub struct ElementsQuery {
pub entity: Entity,
element: &'static Element,
Expand All @@ -153,7 +153,7 @@ impl Deref for ElementsQueryItem<'_> {
}
}

#[derive(WorldQuery)]
#[derive(QueryData)]
pub struct ChildrenQuery {
children: &'static Children,
}
Expand Down
6 changes: 3 additions & 3 deletions crates/belly_core/src/eml/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy::asset::io::Reader;
use bevy::asset::AsyncReadExt;
use bevy::reflect::TypePath;
use bevy::utils::BoxedFuture;
use bevy::{asset::AssetLoader, prelude::*, reflect::TypeUuid, utils::HashMap};
use bevy::{asset::AssetLoader, prelude::*, utils::HashMap};
use std::sync::Arc;
use tagstr::*;
use thiserror::Error;
Expand Down Expand Up @@ -44,8 +44,8 @@ impl EmlScene {
}
}

#[derive(TypeUuid, Clone, TypePath, Asset)]
#[uuid = "f8d22a65-d671-4fa6-ae8f-0dccdb387ddd"]
#[derive(Clone, TypePath, Asset)]
// #[uuid = "f8d22a65-d671-4fa6-ae8f-0dccdb387ddd"]
pub struct EmlAsset {
root: Arc<EmlNode>,
}
Expand Down
9 changes: 5 additions & 4 deletions crates/belly_core/src/eml/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{
tags,
};
use bevy::{
asset::Asset,
ecs::system::{Command, CommandQueue, EntityCommands},
prelude::*,
ui::FocusPolicy,
Expand Down Expand Up @@ -102,9 +101,10 @@ pub struct WidgetContext<'w, 's> {
}

impl<'w, 's> WidgetContext<'w, 's> {
pub fn this<'a>(&'a mut self) -> EntityCommands<'w, 's, 'a> {
pub fn this<'a>(&'a mut self) -> EntityCommands<'a> {
self.commands.entity(self.data.entity)
}

pub fn load<T: Asset>(&self, path: String) -> Handle<T> {
self.asset_server.load(path)
}
Expand All @@ -125,7 +125,8 @@ impl<'w, 's> WidgetContext<'w, 's> {
self.commands.add(command)
}

pub fn insert<'a>(&'a mut self, bundle: impl Bundle) -> EntityCommands<'w, 's, 'a> {
pub fn insert<'a>(&'a mut self, bundle: impl Bundle) -> EntityCommands<'a>
{
let mut commands = self.commands.entity(self.data.entity);
commands.insert(bundle);
commands
Expand Down Expand Up @@ -520,7 +521,7 @@ fn emit_ready_signal(
mut writer: EventWriter<ReadyEvent>,
) {
for req in requests.read().unique() {
writer.send(ReadyEvent(req.0))
writer.send(ReadyEvent(req.0));
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/belly_core/src/eml/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
to,
};
use bevy::{
ecs::query::{QueryItem, WorldQuery},
ecs::query::{QueryItem, QueryData},
prelude::*,
};
use std::any::TypeId;
Expand All @@ -18,7 +18,7 @@ pub trait IntoContent: Sized {
}

pub trait UpdateContent: Sized {
type Query: WorldQuery;
type Query: QueryData;
fn update_content(item: QueryItem<Self::Query>, value: &Self);
}

Expand Down
1 change: 0 additions & 1 deletion crates/belly_core/src/eml/parse.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::asset::{EmlElement, EmlLoader, EmlNode};
use super::Variant;
use crate::{ess::StyleProperty, ElementsError};
use roxmltree;
use std::fmt::Display;
use tagstr::{AsTag, Tag};

Expand Down
2 changes: 1 addition & 1 deletion crates/belly_core/src/eml/variant/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
ess::{ColorFromHexExtension, StyleProperty, StylePropertyMethods},
ElementsError,
};
use bevy::{asset::Asset, prelude::*};
use bevy::prelude::*;

use super::{ApplyCommands, Variant};

Expand Down
13 changes: 7 additions & 6 deletions crates/belly_core/src/ess/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy::{
asset::{io::Reader, AssetLoader, AsyncReadExt},
ecs::system::Command,
prelude::*,
reflect::{TypePath, TypeUuid},
reflect::TypePath,
utils::{hashbrown::hash_map::Keys, BoxedFuture, HashMap},
};
pub use property::*;
Expand Down Expand Up @@ -98,8 +98,8 @@ impl AssetLoader for EssLoader {
}
}

#[derive(Default, TypeUuid, TypePath, Asset)]
#[uuid = "93767098-caca-4f2b-b1d3-cdc91919be75"]
#[derive(Default, TypePath, Asset)]
// #[uuid = "93767098-caca-4f2b-b1d3-cdc91919be75"]
pub struct StyleSheet {
weight: usize,
rules: Vec<StyleRule>,
Expand Down Expand Up @@ -200,8 +200,8 @@ impl StyleSheet {
default: true,
}
}
pub fn add_rule(&mut self, mut rule: StyleRule) {
rule.selector.index = SelectorIndex::new(self.rules.len());
pub fn add_rule(&mut self, rule: StyleRule) {
// rule.selector.index = SelectorIndex::new(self.rules.len());
self.rules.push(rule);
}

Expand Down Expand Up @@ -286,7 +286,8 @@ fn process_styles_system(
}
}
}
}
},
_ => { info!("Unused") }
}
}
if styles_changed {
Expand Down
2 changes: 1 addition & 1 deletion crates/belly_core/src/ess/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ pub fn parse_style_property_value<T: AsRef<str>>(value: T) -> Result<StyleProper
mod tests {
use std::str::FromStr;

use crate::ess::{ExtractProperty, PropertyValue, StylePropertyToken, TransformProperty};
use crate::ess::{ExtractProperty, PropertyValue, TransformProperty};

use super::*;
use bevy::utils::HashMap;
Expand Down
44 changes: 22 additions & 22 deletions crates/belly_core/src/ess/property/impls/stylebox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ use bevy_stylebox::*;
use tagstr::tag;

compound_style_property! {
#[doc = " Specify how to fill the element with region of image sliced by 9 parts."]
#[doc = " The `stylebox` property is shorthand property for:"]
#[doc = " - `stylebox-source` specifies the source of the image"]
#[doc = " - `stylebox-slice` specifies how to slice the image"]
#[doc = " - `stylebox-region` specifies the region of the image"]
#[doc = " - `stylebox-width` specifies how to resize edges"]
#[doc = " - `stylebox-modulate` specifies what color the image should be multiplied by"]
#[doc = " "]
#[doc = " The format of property is:"]
#[doc = " ```css"]
#[doc = " source, slice, width, region, modulate"]
#[doc = " ```"]
#[doc = " Every tail element is optional (you can omit `modulate` for example. If you do,"]
#[doc = " you can ompit `region` then. And so on.)"]
#[doc = " "]
#[doc = " Example:"]
#[doc = " ```css"]
#[doc = " stylebox: \"background.png\", 16px 12px, 100%, 0px, blue"]
#[doc = " stylebox: \"background.png\", 5px 20%"]
#[doc = " ```"]
#[doc = " <!-- @property-type=source, slice, region, width, modulate -->"]
#[doc = " <!-- @property-category=Stylebox -->"]
/// Specify how to fill the element with region of image sliced by 9 parts.
/// The `stylebox` property is shorthand property for:
/// - `stylebox-source` specifies the source of the image
/// - `stylebox-slice` specifies how to slice the image
/// - `stylebox-region` specifies the region of the image
/// - `stylebox-width` specifies how to resize edges
/// - `stylebox-modulate` specifies what color the image should be multiplied by
///
/// The format of property is:
/// ```css
/// source, slice, width, region, modulate
/// ```
/// Every tail element is optional (you can omit `modulate` for example. If you do,
/// you can ompit `region` then. And so on.)
///
/// Example:
/// ```css
/// stylebox: "background.png", 16px 12px, 100%, 0px, blue
/// stylebox: "background.png", 5px 20%
/// ```
/// <!-- @property-type=source, slice, region, width, modulate -->
/// <!-- @property-category=Stylebox -->
StyleboxProperty("stylebox", value) {
let props = match value {
Variant::String(unparsed) => StyleProperty::try_from(unparsed)?,
Expand Down
7 changes: 4 additions & 3 deletions crates/belly_core/src/ess/property/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ use crate::{
ess::{ElementsBranch, StyleSheet, Styles},
ElementsError,
};
use bevy::ecs::query::{QueryData, QueryFilter};
use bevy::ui::UiSystem;
use bevy::{
ecs::query::{QueryItem, ReadOnlyWorldQuery, WorldQuery},
ecs::query::QueryItem,
prelude::*,
utils::HashMap,
};
Expand Down Expand Up @@ -199,9 +200,9 @@ pub trait Property: Default + Sized + Send + Sync + 'static {
/// The item value type to be applied by property.
type Item: Default + Any + Send + Sync;
/// Which components should be queried when applying the modification. Check [`WorldQuery`] for more.
type Components: WorldQuery;
type Components: QueryData;
/// Filters conditions to be applied when querying entities by this property. Check [`WorldQuery`] for more.
type Filters: ReadOnlyWorldQuery;
type Filters: QueryFilter;
/// Associate [`PropertyParser`] with [`Property`]
type Parser: PropertyParser<Self::Item>;

Expand Down
10 changes: 0 additions & 10 deletions crates/belly_core/src/ess/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ impl Neg for SelectorWeight {
}
}

#[derive(Default, Debug)]
pub struct SelectorIndex(usize);

impl SelectorIndex {
pub fn new(value: usize) -> SelectorIndex {
SelectorIndex(value)
}
}

#[derive(Debug)]
pub enum SelectorElement {
AnyChild,
Expand Down Expand Up @@ -244,7 +235,6 @@ impl<'a> SelectorEntry<'a> {

#[derive(Default, Debug)]
pub struct Selector {
pub index: SelectorIndex,
pub weight: SelectorWeight,
pub elements: SelectorElements,
}
Expand Down
Loading

0 comments on commit 7a1acb3

Please sign in to comment.