Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from ycysdf/bevy-0.13
Browse files Browse the repository at this point in the history
Bevy 0.13
  • Loading branch information
ycysdf authored Mar 10, 2024
2 parents 1e73040 + 24a76d2 commit 24c351e
Show file tree
Hide file tree
Showing 28 changed files with 338 additions and 76 deletions.
44 changes: 21 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ rxy_web_dom = { workspace = true, optional = true }
[features]
default = ["std", "x_iter_source", "signal"]

#web = ["std", "rxy_web_dom", "tailwind_aliases", "xy_reactive?/web"]
#web = ["std", "tailwind_aliases", "xy_reactive?/web", "rxy_web_dom"]
web = ["std", "rxy_web_dom"]
#web = ["std", "rxy_web_dom"]

std = ["rxy_core/async-channel"]
hooked_collection = ["dep:hooked_collection"]
Expand All @@ -48,9 +46,9 @@ xy_reactive = { path = "crates/xy_reactive", default-features = false }
rxy_web_dom = { path = "crates/rxy_web_dom", default-features = false }

async-channel = { version = "2.1" }
glam = "0.25"
async-broadcast = "0.7.0"
#event-listener = "5.2"
glam = "0.24"
hashbrown = "0.14"
indexmap = "2.1"
once_cell = { version = "1.19", default-features = false }
Expand All @@ -60,7 +58,7 @@ serde = { version = "1", features = ["derive"] }

ahash = { version = "0.8", default-features = false }
# bevy-inspector-egui = "0.21"
bevy_mod_picking = { version = "0.17", default-features = false, features = ["backend_bevy_ui"] }
bevy_mod_picking = { version = "0.18", default-features = false, features = ["backend_bevy_ui"] }
derive_more = "0.99"
drain_filter_polyfill = "0.1"
futures-lite = "1.13"
Expand All @@ -70,23 +68,23 @@ thiserror = "1.0"
smallvec = "1.13"
slotmap = "1"

bevy_app = "0.12"
bevy_asset = { version = "0.12", optional = false }
bevy_core = "0.12"
bevy_derive = "0.12"
bevy_ecs = "0.12"
bevy_hierarchy = "0.12"
bevy_reflect = { version = "0.12" }
bevy_render = "0.12"
bevy_sprite = "0.12"
bevy_tasks = { version = "0.12", features = ["multi-threaded"], optional = false }
bevy_text = { version = "0.12", optional = false }
bevy_transform = { version = "0.12", optional = false }
bevy_ui = { version = "0.12", features = ["bevy_text"] }
bevy_window = { version = "0.12"}
bevy_utils = "0.12"
bevy_a11y = "0.12"
bevy_input = "0.12"
bevy_app = "0.13"
bevy_asset = { version = "0.13", optional = false }
bevy_core = "0.13"
bevy_derive = "0.13"
bevy_ecs = "0.13"
bevy_hierarchy = "0.13"
bevy_reflect = { version = "0.13" }
bevy_render = "0.13"
bevy_sprite = "0.13"
bevy_tasks = { version = "0.13", features = ["multi-threaded"], optional = false }
bevy_text = { version = "0.13", optional = false }
bevy_transform = { version = "0.13", optional = false }
bevy_ui = { version = "0.13", features = ["bevy_text"] }
bevy_utils = "0.13"
bevy_a11y = "0.13"
bevy_input = "0.13"
bevy_window = { version = "0.13"}

count-macro = "0.2.2"
paste = "1"
Expand Down Expand Up @@ -220,7 +218,7 @@ web-sys = { version = "0.3", features = [
] }

[dev-dependencies]
bevy = { version = "0.12.1", features = [
bevy = { version = "0.13", features = [
"dynamic_linking",
"animation",
"bevy_asset", # "bevy_audio", # "bevy_gilrs",
Expand Down
2 changes: 1 addition & 1 deletion README-zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ MIT License ([LICENSE-MIT](https://github.com/ycysdf/rxy_ui/blob/main/LICENSE-MI
```toml
[dependencies]
rxy_ui = {git = "https://github.com/ycysdf/rxy_ui", features = ["bevy"]}
bevy = {version = "0.12"}
bevy = {version = "0.13"}
```

## 示例
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ But you can specify git repository dependencies
```toml
[dependencies]
rxy_ui = {git = "https://github.com/ycysdf/rxy_ui", features = ["bevy"]}
bevy = {version = "0.12"}
bevy = {version = "0.13"}
```

## Examples
Expand Down
2 changes: 1 addition & 1 deletion crates/rxy_bevy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.1.0"
[dependencies]
#rxy_bevy_element.workspace = true
rxy_bevy_macro.workspace = true
rxy_core = { workspace = true, features = ["common_renderer", "async-channel", "bevy", "xy_reactive", "bevy_reflect"] }
rxy_core = { workspace = true, features = ["common_renderer", "async-channel", "bevy", "xy_reactive", "bevy_reflect", "x_iter_source"] }
xy_reactive = { workspace = true, optional = true, features = ["bevy"] }
rxy_macro.workspace = true
hooked_collection.workspace = true
Expand Down
14 changes: 7 additions & 7 deletions crates/rxy_bevy/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ use std::iter::once;

use bevy_app::PreUpdate;
use bevy_ecs::{
prelude::{Commands, Entity, Res, Resource, World},
prelude::{Commands, Res, Resource, World},
system::SystemId,
};
use bevy_input::{
gamepad::GamepadButton, keyboard::KeyCode, mouse::MouseButton, Input, InputSystem,
};
use bevy_ecs::entity::EntityHashMap;
use bevy_input::{gamepad::GamepadButton, keyboard::KeyCode, mouse::MouseButton, InputSystem, ButtonInput};
use bevy_mod_picking::prelude::*;
use bevy_reflect::Reflect;
use bevy_utils::tracing::error;
use bevy_utils::{all_tuples, EntityHashMap, HashMap};
use bevy_utils::{all_tuples, HashMap};

use rxy_core::{NodeTree, RendererNodeId, RendererWorld};

Expand Down Expand Up @@ -439,6 +438,7 @@ pub enum FocusInputEvent {
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Reflect)]
#[reflect(no_field_bounds)]
pub enum BubblePointerEvent {
Over,
Out,
Expand Down Expand Up @@ -473,7 +473,7 @@ pub enum FocusInputTriggerWay {

type EntityFocusInputEvents<T> =
HashMap<(T, FocusInputTriggerWay), smallvec::SmallVec<[SystemId; 1]>>;
type FocusInputEventsInner<T> = EntityHashMap<Entity, EntityFocusInputEvents<T>>;
type FocusInputEventsInner<T> = EntityHashMap<EntityFocusInputEvents<T>>;

#[derive(Resource)]
pub struct FocusInputEvents<T> {
Expand Down Expand Up @@ -505,7 +505,7 @@ where

pub fn system_handle(
registers: Res<FocusInputEvents<T>>,
event_reader: Res<Input<T>>,
event_reader: Res<ButtonInput<T>>,
focus: Res<FocusedEntity>,
mut commands: Commands,
) {
Expand Down
2 changes: 1 addition & 1 deletion crates/rxy_bevy/src/focusable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Plugin for FocusablePlugin {
FocusableSystemParam::update_focused_state
// .in_set(UiSystem::Interactions)
.after(UiSystem::Focus)
.run_if(resource_changed::<FocusedEntity>()),
.run_if(resource_changed::<FocusedEntity>),
)
.add_systems(
PostUpdate,
Expand Down
1 change: 1 addition & 0 deletions crates/rxy_bevy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub mod prelude {

pub use crate::renderer::common_renderer::*;
pub use crate::renderer::BevyElement;
#[cfg(feature = "style")]
pub use crate::renderer::style::ElementViewStyleExt;

pub use super::all_attrs::{CommonAttrsElementViewBuilder, CommonAttrsViewBuilder};
Expand Down
22 changes: 11 additions & 11 deletions crates/rxy_bevy/src/navigation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use bevy_ecs::query::With;
use bevy_ecs::schedule::IntoSystemConfigs;
use bevy_ecs::system::{Query, Res, ResMut};
use bevy_ecs::{change_detection::DetectChangesMut, entity::Entity, prelude::Resource};
use bevy_input::InputSystem;
use bevy_input::{prelude::KeyCode, Input};
use bevy_input::{ButtonInput, InputSystem};
use bevy_input::prelude::KeyCode;
use bevy_render::view::ViewVisibility;
use bevy_ui::{Interaction, UiStack, UiSystem};

Expand Down Expand Up @@ -54,7 +54,7 @@ impl Default for KeyboardNavigationInput {

/// Should the [`keyboard_navigation_system`] run?
pub(crate) fn tab_pressed(
keyboard_input: Res<Input<KeyCode>>,
keyboard_input: Res<ButtonInput<KeyCode>>,
keyboard_navigation: Res<KeyboardNavigationInput>,
) -> bool {
keyboard_navigation.enabled && keyboard_input.just_pressed(KeyCode::Tab)
Expand All @@ -67,7 +67,7 @@ pub(crate) fn keyboard_navigation_system(
mut focus: ResMut<FocusedEntity>,
mut interactions: Query<&mut Interaction>,
focusables: Query<&ViewVisibility, With<Focusable>>,
keyboard_input: Res<Input<KeyCode>>,
keyboard_input: Res<ButtonInput<KeyCode>>,
ui_stack: Res<UiStack>,
) {
let reverse_order =
Expand Down Expand Up @@ -124,8 +124,8 @@ pub(crate) fn keyboard_navigation_system(
}

/// Should the [`keyboard_click`] system run?
pub(crate) fn trigger_click(keyboard_input: Res<Input<KeyCode>>) -> bool {
keyboard_input.just_pressed(KeyCode::Space) || keyboard_input.just_pressed(KeyCode::Return)
pub(crate) fn trigger_click(keyboard_input: Res<ButtonInput<KeyCode>>) -> bool {
keyboard_input.just_pressed(KeyCode::Space) || keyboard_input.just_pressed(KeyCode::Enter)
}

/// Trigger the [`Focus`] entity to be clicked.
Expand All @@ -136,13 +136,13 @@ pub(crate) fn keyboard_click(mut interactions: Query<&mut Interaction>, focus: R
}

/// Should the [`end_keyboard_click`] system run?
pub(crate) fn trigger_click_end(keyboard_input: Res<Input<KeyCode>>) -> bool {
keyboard_input.just_released(KeyCode::Space) || keyboard_input.just_released(KeyCode::Return)
pub(crate) fn trigger_click_end(keyboard_input: Res<ButtonInput<KeyCode>>) -> bool {
keyboard_input.just_released(KeyCode::Space) || keyboard_input.just_released(KeyCode::Enter)
}

/// Reset the clicked state.
pub(crate) fn end_keyboard_click(mut interactions: Query<&mut Interaction>) {
interactions.for_each_mut(|mut interaction| {
interactions.iter_mut().for_each(|mut interaction| {
if *interaction == Interaction::Pressed {
// The click was triggered by the keyboard, so it doesn't make sense to go to `Interaction::Hovered`.
*interaction = Interaction::None;
Expand Down Expand Up @@ -176,7 +176,7 @@ mod test {
let mut commands = Commands::new(&mut queue, &world);
commands.init_resource::<bevy_a11y::Focus>();
commands.init_resource::<Input<KeyCode>>();
commands.init_resource::<ButtonInput<KeyCode>>();
commands.init_resource::<UiStack>();
let mut children = Vec::new();
Expand Down Expand Up @@ -207,7 +207,7 @@ mod test {
// Simulate pressing shift
let mut keyboard_input =
world.get_resource_mut::<Input<KeyCode>>().expect("keyboard input resource");
world.get_resource_mut::<ButtonInput<KeyCode>>().expect("keyboard input resource");
keyboard_input.press(KeyCode::ShiftLeft);
schedule.run(&mut world);
Expand Down
4 changes: 2 additions & 2 deletions crates/rxy_bevy/src/renderer/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{all_attrs, BevyRenderer, ElementStyleEntityExt, TextStyledElementEnt
use bevy_render::color::Color;
use bevy_render::render_resource::encase::private::RuntimeSizedArray;
use bevy_render::view::Visibility;
use bevy_text::{BreakLineOn, Font, TextAlignment};
use bevy_text::{BreakLineOn, Font, JustifyText};
use bevy_transform::components::Transform;
use bevy_ui::{AlignContent, AlignItems, AlignSelf, BackgroundColor, BorderColor, Direction, FlexDirection, FlexWrap, GridAutoFlow, GridPlacement, GridTrack, JustifyContent, JustifyItems, JustifySelf, Outline, OverflowAxis, PositionType, RepeatedGridTrack, Val, ZIndex};
use bevy_utils::tracing::warn;
Expand Down Expand Up @@ -1360,7 +1360,7 @@ impl ElementAttrType<BevyRenderer> for text_linebreak {
pub struct text_align;

impl ElementAttrType<BevyRenderer> for text_align {
type Value = TextAlignment;
type Value = JustifyText;

const NAME: &'static str = stringify!(text_align);
fn update_value(
Expand Down
2 changes: 1 addition & 1 deletion crates/rxy_bevy/src/renderer/elements/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl TextStyledElementType for element_span {
let Some(mut t) = entity_ref.get_mut::<Text>() else {
return;
};
t.alignment = value;
t.justify = value;
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rxy_bevy/src/renderer/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ macro_rules! define_event_view_builder {
S: IntoSystem<(), (), Marker> + Send + 'static,
Marker: Send + 'static,
{
self.on_just_pressed(KeyCode::Return, system)
self.on_just_pressed(KeyCode::Enter, system)
}

fn on_esc<S, Marker>(
Expand Down
8 changes: 4 additions & 4 deletions crates/rxy_bevy/src/renderer/style/attr_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use super::node_style_state::NodeStyleSheetsState;
use super::{interaction_to_style_interaction, EntityAttrSyncer, StyleEntityRefExt, StyleError};
use super::{EntityWorldRef, Result};
use bevy_ecs::prelude::{Entity, Query};
use bevy_ecs::query::ReadOnlyWorldQuery;
use bevy_ecs::world::{EntityRef, EntityWorldMut, World};
use bevy_ui::Interaction;
use bevy_ecs::query::QueryFilter;
use super::rxy_bevy_crate::{
AttrSetBits, ElementEntityExtraData, ElementEntityWorldMutExt, FocusedEntity, RendererState,
};
Expand Down Expand Up @@ -132,12 +132,12 @@ impl<'a> StateOwnerWithNodeId<'a, '_> for EntityWorldRef<'a> {
}
}

pub struct EntityStyleWorldQuery<'a, 'world, 'state, F: ReadOnlyWorldQuery> {
pub struct EntityStyleWorldQuery<'a, 'world, 'state, F: QueryFilter> {
pub query: Query<'world, 'state, &'a RendererState<NodeStyleSheetsState>, F>,
pub current_entity: Entity,
}

impl<'a, 'world, 'state, F: ReadOnlyWorldQuery> StateOwner<'a, 'a>
impl<'a, 'world, 'state, F: QueryFilter> StateOwner<'a, 'a>
for EntityStyleWorldQuery<'world, 'state, 'a, F>
{
fn get_style_sheets_state(&'a self, entity: Entity) -> Result<&'a NodeStyleSheetsState> {
Expand All @@ -148,7 +148,7 @@ impl<'a, 'world, 'state, F: ReadOnlyWorldQuery> StateOwner<'a, 'a>
}
}

impl<'a, 'world, 'state, F: ReadOnlyWorldQuery> StateOwnerWithNodeId<'a, 'a>
impl<'a, 'world, 'state, F: QueryFilter> StateOwnerWithNodeId<'a, 'a>
for EntityStyleWorldQuery<'world, 'state, 'a, F>
{
fn get_current_entity(&self) -> Entity {
Expand Down
5 changes: 2 additions & 3 deletions crates/rxy_bevy/src/renderer/style/interaction_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ use bevy_derive::{Deref, DerefMut};
use super::attr_iter::{EntityStyleWorldQuery, StateOwnerWithNodeId};
use super::node_style_state::NodeStyleSheetsState;
use super::{Previous};
use bevy_ecs::entity::Entity;
use bevy_ecs::entity::{Entity, EntityHashMap};
use bevy_ecs::prelude::{Changed, Commands, Query, With, World};
use bevy_ecs::system::{Command, ResMut};
use bevy_ui::Interaction;
use bevy_utils::EntityHashMap;
use super::rxy_bevy_crate::{
AttrSetBits, ElementEntityExtraData, FocusedEntity, RendererState,
};
Expand All @@ -15,7 +14,7 @@ use rxy_core::style::{NodeInterStyleAttrInfos, NodeStyleAttrInfos, StyleAttrValu
use crate::attrs::get_attr_by_index;

#[derive(Default, DerefMut, Deref, Debug)]
pub struct SetAttrValuesCommand(EntityHashMap<Entity, Vec<(AttrIndex, Option<StyleAttrValue>)>>);
pub struct SetAttrValuesCommand(EntityHashMap<Vec<(AttrIndex, Option<StyleAttrValue>)>>);

impl SetAttrValuesCommand {
pub fn add(
Expand Down
10 changes: 5 additions & 5 deletions crates/rxy_bevy/src/renderer/tailwind_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy_render::prelude::Visibility;
use bevy_text::{BreakLineOn, TextAlignment};
use bevy_render::view::Visibility;
use bevy_text::{BreakLineOn, JustifyText};
use bevy_ui::{AlignItems, Display, FlexDirection, FlexWrap, JustifyContent, PositionType, Val};
use crate::all_attrs::{
align_items, column_gap, display, flex_direction, flex_grow, flex_shrink, flex_wrap, height,
Expand Down Expand Up @@ -279,15 +279,15 @@ macro_rules! impl_tailwind_attrs {
}
#[inline]
fn text_left(self) -> Self::AddMember<ElementAttr<BevyRenderer, text_align>> {
self.member(ElementAttr::new(TextAlignment::Left.into()))
self.member(ElementAttr::new(JustifyText::Left.into()))
}
#[inline]
fn text_center(self) -> Self::AddMember<ElementAttr<BevyRenderer, text_align>> {
self.member(ElementAttr::new(TextAlignment::Center.into()))
self.member(ElementAttr::new(JustifyText::Center.into()))
}
#[inline]
fn text_right(self) -> Self::AddMember<ElementAttr<BevyRenderer, text_align>> {
self.member(ElementAttr::new(TextAlignment::Right.into()))
self.member(ElementAttr::new(JustifyText::Right.into()))
}

#[inline]
Expand Down
Loading

0 comments on commit 24c351e

Please sign in to comment.