bevy_ui compilation (#19858)
# Objective - `bevy_ui` has errors and warnings when building independently ## Solution - properly use the `bevy_ui_picking_backend` feature ## Testing `cargo build -p bevy_ui`
This commit is contained in:
parent
795e273a9a
commit
8e12b1f0b2
@ -1,7 +1,4 @@
|
||||
use crate::{
|
||||
picking_backend::clip_check_recursive, ui_transform::UiGlobalTransform, ComputedNode,
|
||||
ComputedNodeTarget, Node, UiStack,
|
||||
};
|
||||
use crate::{ui_transform::UiGlobalTransform, ComputedNode, ComputedNodeTarget, Node, UiStack};
|
||||
use bevy_ecs::{
|
||||
change_detection::DetectChangesMut,
|
||||
entity::{ContainsEntity, Entity},
|
||||
@ -322,3 +319,27 @@ pub fn ui_focus_system(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Walk up the tree child-to-parent checking that `point` is not clipped by any ancestor node.
|
||||
pub fn clip_check_recursive(
|
||||
point: Vec2,
|
||||
entity: Entity,
|
||||
clipping_query: &Query<'_, '_, (&ComputedNode, &UiGlobalTransform, &Node)>,
|
||||
child_of_query: &Query<&ChildOf>,
|
||||
) -> bool {
|
||||
if let Ok(child_of) = child_of_query.get(entity) {
|
||||
let parent = child_of.0;
|
||||
if let Ok((computed_node, transform, node)) = clipping_query.get(parent) {
|
||||
if !computed_node
|
||||
.resolve_clip_rect(node.overflow, node.overflow_clip_margin)
|
||||
.contains(transform.inverse().transform_point2(point))
|
||||
{
|
||||
// The point is clipped and should be ignored by picking
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return clip_check_recursive(point, parent, clipping_query, child_of_query);
|
||||
}
|
||||
// Reached root, point unclipped by all ancestors
|
||||
true
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#![deny(missing_docs)]
|
||||
|
||||
use crate::{prelude::*, ui_transform::UiGlobalTransform, UiStack};
|
||||
use crate::{clip_check_recursive, prelude::*, ui_transform::UiGlobalTransform, UiStack};
|
||||
use bevy_app::prelude::*;
|
||||
use bevy_ecs::{prelude::*, query::QueryData};
|
||||
use bevy_math::Vec2;
|
||||
@ -252,27 +252,3 @@ pub fn ui_picking(
|
||||
output.write(PointerHits::new(*pointer, picks, order));
|
||||
}
|
||||
}
|
||||
|
||||
/// Walk up the tree child-to-parent checking that `point` is not clipped by any ancestor node.
|
||||
pub fn clip_check_recursive(
|
||||
point: Vec2,
|
||||
entity: Entity,
|
||||
clipping_query: &Query<'_, '_, (&ComputedNode, &UiGlobalTransform, &Node)>,
|
||||
child_of_query: &Query<&ChildOf>,
|
||||
) -> bool {
|
||||
if let Ok(child_of) = child_of_query.get(entity) {
|
||||
let parent = child_of.0;
|
||||
if let Ok((computed_node, transform, node)) = clipping_query.get(parent) {
|
||||
if !computed_node
|
||||
.resolve_clip_rect(node.overflow, node.overflow_clip_margin)
|
||||
.contains(transform.inverse().transform_point2(point))
|
||||
{
|
||||
// The point is clipped and should be ignored by picking
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return clip_check_recursive(point, parent, clipping_query, child_of_query);
|
||||
}
|
||||
// Reached root, point unclipped by all ancestors
|
||||
true
|
||||
}
|
||||
|
@ -2,22 +2,32 @@ use bevy_asset::Assets;
|
||||
use bevy_ecs::{
|
||||
component::Component,
|
||||
entity::Entity,
|
||||
event::EventReader,
|
||||
query::{Changed, Or},
|
||||
reflect::ReflectComponent,
|
||||
system::{Commands, Query, Res, ResMut},
|
||||
system::{Query, ResMut},
|
||||
};
|
||||
#[cfg(feature = "bevy_ui_picking_backend")]
|
||||
use bevy_ecs::{
|
||||
event::EventReader,
|
||||
system::{Commands, Res},
|
||||
};
|
||||
use bevy_image::{Image, ToExtents};
|
||||
use bevy_math::{Rect, UVec2};
|
||||
#[cfg(feature = "bevy_ui_picking_backend")]
|
||||
use bevy_math::Rect;
|
||||
use bevy_math::UVec2;
|
||||
#[cfg(feature = "bevy_ui_picking_backend")]
|
||||
use bevy_picking::{
|
||||
events::PointerState,
|
||||
hover::HoverMap,
|
||||
pointer::{Location, PointerId, PointerInput, PointerLocation},
|
||||
};
|
||||
#[cfg(feature = "bevy_ui_picking_backend")]
|
||||
use bevy_platform::collections::HashMap;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_render::camera::{Camera, NormalizedRenderTarget};
|
||||
use bevy_render::camera::Camera;
|
||||
#[cfg(feature = "bevy_ui_picking_backend")]
|
||||
use bevy_render::camera::NormalizedRenderTarget;
|
||||
#[cfg(feature = "bevy_ui_picking_backend")]
|
||||
use bevy_transform::components::GlobalTransform;
|
||||
#[cfg(feature = "bevy_ui_picking_backend")]
|
||||
use uuid::Uuid;
|
||||
|
Loading…
Reference in New Issue
Block a user