update to 0.13.1

This commit is contained in:
Rowan Vixen 2024-03-24 22:38:08 -04:00
parent 273660d33d
commit 3e31b27d6e
8 changed files with 876 additions and 933 deletions

1698
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -4,38 +4,25 @@ version = "0.1.0"
edition = "2021"
[dependencies]
bevy = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
dioxus = { git = "https://github.com/ealmloff/dioxus", branch = "fix-event-bubbling", default-features = false, features = [
"macro",
"hooks",
] }
dioxus-rsx = { git = "https://github.com/ealmloff/dioxus", branch = "fix-event-bubbling", default-features = false, features = [
"hot_reload",
], optional = true }
dioxus-hot-reload = { git = "https://github.com/ealmloff/dioxus", branch = "fix-event-bubbling", default-features = false, features = [
"custom_file_watcher",
], optional = true }
bevy_mod_picking = { version = "0.17", default-features = false, features = [
"backend_bevy_ui",
] }
bevy = "0.13.1"
bevy_mod_picking = "0.18.2"
dioxus = "0.4.3"
#dioxus = { git = "https://github.com/ealmloff/dioxus", branch = "fix-event-bubbling", default-features = false, features = [
# "macro",
# "hooks",
#] }
#dioxus-rsx = { git = "https://github.com/ealmloff/dioxus", branch = "fix-event-bubbling", default-features = false, features = [
# "hot_reload",
#], optional = true }
#dioxus-hot-reload = { git = "https://github.com/ealmloff/dioxus", branch = "fix-event-bubbling", default-features = false, features = [
# "custom_file_watcher",
#], optional = true }
#bevy_mod_picking = { version = "0.17", default-features = false, features = [
# "backend_bevy_ui",
#] }
[features]
hot_reload = ["dioxus/hot-reload", "dioxus-rsx", "dioxus-hot-reload"]
[patch.crates-io]
bevy_app = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_asset = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_core = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_ecs = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_hierarchy = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_input = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_math = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_reflect = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_render = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_transform = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_ui = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_utils = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_window = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
#hot_reload = ["dioxus/hot-reload", "dioxus-rsx", "dioxus-hot-reload"]
[[example]]
name = "demo"

View File

@ -1,6 +1,6 @@
use bevy::{prelude::*, reflect::TypeInfo};
use bevy_dioxus::{colors::*, prelude::*};
use bevy_mod_picking::DefaultPickingPlugins;
use bevy_mod_picking::{debug::DebugName, DefaultPickingPlugins};
fn main() {
App::new()
@ -33,7 +33,7 @@ fn Editor(cx: Scope) -> Element {
#[component]
fn SceneTree<'a>(cx: Scope, selected_entity: &'a UseStateSendable<Option<Entity>>) -> Element {
let mut entities = use_query_filtered::<(Entity, DebugName), Without<Node>>(cx);
let mut entities = use_query_filtered::<(Entity, &Name), ()>(cx);
let entities = entities.query();
let mut entities = entities.into_iter().collect::<Vec<_>>();
entities.sort_by_key(|(entity, _)| *entity);
@ -58,13 +58,13 @@ fn SceneTree<'a>(cx: Scope, selected_entity: &'a UseStateSendable<Option<Entity>
}
event.stop_propagation();
},
base_color: if Some(entity) == *selected_entity.read() { Some(VIOLET_700) } else { None },
click_color: if Some(entity) == *selected_entity.read() { Some(VIOLET_400) } else { None },
hover_color: if Some(entity) == *selected_entity.read() { Some(VIOLET_500) } else { None },
match name.name {
Some(name) => format!("{name}"),
_ => format!("Entity ({:?})", name.entity)
}
base_color: VIOLET_700,
click_color: VIOLET_400,
hover_color: VIOLET_500,
//base_color: if Some(entity) == *selected_entity.read() { Some(VIOLET_700) } else { None },
//click_color: if Some(entity) == *selected_entity.read() { Some(VIOLET_400) } else { None },
//hover_color: if Some(entity) == *selected_entity.read() { Some(VIOLET_500) } else { None },
name
}
}
}

View File

@ -4,7 +4,7 @@ use crate::{
};
use bevy::{
asset::AssetServer,
ecs::{entity::Entity, system::Command, world::World},
ecs::{entity::{Entity, EntityHashMap}, system::Command, world::World},
hierarchy::{BuildWorldChildren, Children, DespawnRecursive, Parent},
prelude::default,
render::{color::Color, view::Visibility},
@ -15,7 +15,7 @@ use bevy::{
widget::TextFlags,
*,
},
utils::{EntityHashMap, HashMap},
utils::HashMap,
};
use dioxus::core::{
BorrowedAttributeValue, ElementId, Mutation, Mutations, Template, TemplateAttribute,
@ -25,7 +25,7 @@ use dioxus::core::{
pub fn apply_mutations(
mutations: Mutations,
element_id_to_bevy_ui_entity: &mut HashMap<ElementId, Entity>,
bevy_ui_entity_to_element_id: &mut EntityHashMap<Entity, ElementId>,
bevy_ui_entity_to_element_id: &mut EntityHashMap<ElementId>,
templates: &mut HashMap<String, BevyTemplate>,
root_entity: Entity,
world: &mut World,

View File

@ -3,7 +3,7 @@ use bevy::{
ecs::{
component::ComponentId,
event::{Event, EventIterator, Events, ManualEventReader},
query::ReadOnlyWorldQuery,
query::{QueryData, QueryFilter, ReadOnlyQueryData, WorldQuery},
system::{Query, Resource, SystemState},
world::World,
},
@ -89,15 +89,15 @@ pub fn use_resource<T: Resource>(cx: &ScopeState) -> &T {
pub fn use_query<Q>(cx: &ScopeState) -> UseQuery<'_, Q, ()>
where
Q: ReadOnlyWorldQuery,
Q: ReadOnlyQueryData,
{
use_query_filtered(cx)
}
pub fn use_query_filtered<Q, F>(cx: &ScopeState) -> UseQuery<'_, Q, F>
where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
Q: ReadOnlyQueryData,
F: ReadOnlyQueryData + QueryFilter,
{
let world = EcsContext::get_world(cx);
@ -128,15 +128,15 @@ pub fn use_event_reader<E: Event>(cx: &ScopeState) -> EventIterator<'_, E> {
event_reader.read(events)
}
pub struct UseQuery<'a, Q: ReadOnlyWorldQuery + 'static, F: ReadOnlyWorldQuery + 'static> {
pub struct UseQuery<'a, Q: ReadOnlyQueryData + 'static, F: ReadOnlyQueryData + QueryFilter + 'static> {
system_state: SystemState<Query<'static, 'static, Q, F>>,
world_ref: &'a World,
}
impl<'a, Q, F> UseQuery<'a, Q, F>
where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
Q: ReadOnlyQueryData,
F: ReadOnlyQueryData + QueryFilter,
{
pub fn query(&mut self) -> Query<Q, F> {
self.system_state.get(self.world_ref)

View File

@ -1,7 +1,7 @@
use bevy::{
ecs::{
component::Component,
entity::Entity,
entity::{Entity, EntityHashSet},
event::{Event, EventWriter, Events, ManualEventReader},
system::{Local, Query, Resource},
world::World,
@ -9,7 +9,6 @@ use bevy::{
hierarchy::Parent,
prelude::EntityWorldMut,
ui::RelativeCursorPosition,
utils::EntityHashSet,
};
use bevy_mod_picking::events::{Click, Down, Out, Over, Pointer, Up};
use dioxus::core::ScopeState;
@ -166,12 +165,12 @@ fn bubble_event_helper<T: Component>(target_entity: &mut Entity, world: &World)
pub fn generate_mouse_enter_leave_events(
entities: Query<(Entity, &RelativeCursorPosition)>,
mut previous_over: Local<EntityHashSet<Entity>>,
mut over: Local<EntityHashSet<Entity>>,
mut previous_over: Local<EntityHashSet>,
mut over: Local<EntityHashSet>,
mut enter: EventWriter<MouseEnter>,
mut leave: EventWriter<MouseExit>,
) {
mem::swap::<EntityHashSet<Entity>>(&mut previous_over, &mut over);
mem::swap::<EntityHashSet>(&mut previous_over, &mut over);
over.clear();
for (entity, relative_cursor_position) in &entities {

View File

@ -1,3 +1,4 @@
#![feature(trait_alias)]
mod apply_mutations;
pub mod colors;
mod deferred_system;
@ -20,10 +21,10 @@ use self::{
};
use bevy::{
app::{App, Last, Plugin, PreUpdate},
ecs::{bundle::Bundle, component::Component, entity::Entity, schedule::IntoSystemConfigs},
ecs::{bundle::Bundle, component::Component, entity::{Entity, EntityHashMap}, schedule::IntoSystemConfigs},
prelude::Deref,
ui::{node_bundles::NodeBundle, ui_focus_system},
utils::{EntityHashMap, HashMap},
utils::HashMap,
};
use dioxus::core::{Element, ElementId, Scope, VirtualDom};
@ -32,7 +33,7 @@ pub mod prelude {
pub use super::ecs_hooks::{
use_event_reader, use_query, use_query_filtered, use_resource, use_world,
};
pub use super::elements::*;
pub use super::elements::dioxus_elements;
pub use super::use_state_sendable::*;
pub use super::{DioxusUiBundle, DioxusUiPlugin, DioxusUiRoot};
pub use bevy_mod_picking::pointer::PointerButton;
@ -80,7 +81,7 @@ struct UiContext {
struct UiRoot {
virtual_dom: VirtualDom,
element_id_to_bevy_ui_entity: HashMap<ElementId, Entity>,
bevy_ui_entity_to_element_id: EntityHashMap<Entity, ElementId>,
bevy_ui_entity_to_element_id: EntityHashMap<ElementId>,
templates: HashMap<String, BevyTemplate>,
needs_rebuild: bool,
}

View File

@ -2,7 +2,7 @@ use bevy::{
asset::{AssetPath, AssetServer},
math::Quat,
render::{color::Color, view::Visibility},
text::{Text, TextAlignment},
text::{JustifyText, Text},
transform::components::Transform,
ui::*,
};
@ -188,13 +188,13 @@ pub fn set_attribute(
style.direction = Direction::RightToLeft;
}
("text_multiline_alignment", "left") if text.is_some() => {
text.unwrap().alignment = TextAlignment::Left;
text.unwrap().justify = JustifyText::Left;
}
("text_multiline_alignment", "center") if text.is_some() => {
text.unwrap().alignment = TextAlignment::Center;
text.unwrap().justify = JustifyText::Center;
}
("text_multiline_alignment", "right") if text.is_some() => {
text.unwrap().alignment = TextAlignment::Right;
text.unwrap().justify = JustifyText::Right;
}
("text_size", value) if text.is_some() => {
text.unwrap().sections[0].style.font_size = parse_f32(value);