pub struct ScreenRectangleVisual { /* private fields */ }Expand description
A filled rectangle with optional rounded corners and a decorative outline.
The origin is the content area’s top-left, with x increasing rightward and y downward. Finite negative and offscreen positions are allowed. World camera movement, zoom, rotation, and fixed interpolation do not affect this visual. It requires no world-space Transform and may coexist with a world visual on the same entity without controlling that visual.
FrameUpdate may mutate this presentation-only component directly. Extraction samples its current values, excludes disabled entities, and draws screen rectangles after all world visuals. Within screen content, lower layer and draw-order depth draw first; stable source identity breaks remaining ties. Visibility does not automatically capture or route input. No window or GPU is required to construct, update, or extract the component.
Implementations§
Source§impl ScreenRectangleVisual
impl ScreenRectangleVisual
Sourcepub fn rounded(
position: LogicalScreenPosition,
size: LogicalScreenVector,
color: Color,
radius: f32,
) -> Result<Self, ScreenVisualError>
pub fn rounded( position: LogicalScreenPosition, size: LogicalScreenVector, color: Color, radius: f32, ) -> Result<Self, ScreenVisualError>
Creates a rounded filled rectangle. Radius is in logical pixels and must be finite and nonnegative. Drawing clamps it to half the shorter side.
Sourcepub const fn corner_radius(&self) -> f32
pub const fn corner_radius(&self) -> f32
Returns the requested radius, before clamping to the current rectangle.
Sourcepub fn set_corner_radius(
&mut self,
radius: f32,
) -> Result<(), ScreenVisualError>
pub fn set_corner_radius( &mut self, radius: f32, ) -> Result<(), ScreenVisualError>
Sets a finite nonnegative logical radius atomically. Zero means square corners.
Sourcepub const fn stroke(&self) -> Option<Stroke>
pub const fn stroke(&self) -> Option<Stroke>
Returns the optional centered decorative outline in logical pixels.
Sourcepub fn set_stroke(
&mut self,
stroke: Option<Stroke>,
) -> Result<(), ScreenVisualError>
pub fn set_stroke( &mut self, stroke: Option<Stroke>, ) -> Result<(), ScreenVisualError>
Sets/removes a centered outline. Invalid width/color leaves the visual unchanged. Pointer hits test the rounded fill, not the outline extending beyond it.
Sourcepub const fn clip(&self) -> ScreenClip
pub const fn clip(&self) -> ScreenClip
Returns the explicit screen clip, shared by drawing and pointer geometry.
Sourcepub fn set_clip(&mut self, clip: ScreenClip)
pub fn set_clip(&mut self, clip: ScreenClip)
Replaces the clip without moving content or changing draw order.
Source§impl ScreenRectangleVisual
impl ScreenRectangleVisual
Sourcepub fn new(
position: LogicalScreenPosition,
size: LogicalScreenVector,
color: Color,
) -> Result<Self, ScreenVisualError>
pub fn new( position: LogicalScreenPosition, size: LogicalScreenVector, color: Color, ) -> Result<Self, ScreenVisualError>
Creates a rectangle on the default layer with draw-order depth zero.
Position must be finite, size must be finite and strictly positive on both axes, and color must be normalized straight-linear RGBA. Adding size to position in f32 must produce finite, strictly greater far bounds.
Sourcepub const fn position(&self) -> LogicalScreenPosition
pub const fn position(&self) -> LogicalScreenPosition
Returns the rectangle’s top-left position in logical screen pixels.
Sourcepub const fn size(&self) -> LogicalScreenVector
pub const fn size(&self) -> LogicalScreenVector
Returns the full positive width and height in logical screen pixels.
Sourcepub fn contains_pointer(&self, sample: PointerSample) -> bool
pub fn contains_pointer(&self, sample: PointerSample) -> bool
Tests the current rectangular geometry against an event-time pointer.
Both the rectangle and the sample’s stored viewport use half-open bounds: left/top edges are included, right/bottom excluded. Partially offscreen rectangles can be hit only inside that viewport. The supplied geometry is current; this does not reconstruct historical layout after a resize.
This is allocation-free geometry, not automatic UI routing. Alpha, entity enablement and overlapping draw order are not inspected. The configured clip and rounded fill are respected; the decorative outline is excluded. The caller chooses eligibility and which overlapping target wins.
Sourcepub const fn draw_order_depth(&self) -> f32
pub const fn draw_order_depth(&self) -> f32
Returns the finite ordering depth within the screen layer.
This value controls draw order only; it is not camera projection depth.
Sourcepub fn set_geometry(
&mut self,
position: LogicalScreenPosition,
size: LogicalScreenVector,
) -> Result<(), ScreenVisualError>
pub fn set_geometry( &mut self, position: LogicalScreenPosition, size: LogicalScreenVector, ) -> Result<(), ScreenVisualError>
Replaces position and size together after validating their bounds.
Failure leaves every component value unchanged. Finite offscreen geometry is accepted without clamping.
Sourcepub fn set_position(
&mut self,
position: LogicalScreenPosition,
) -> Result<(), ScreenVisualError>
pub fn set_position( &mut self, position: LogicalScreenPosition, ) -> Result<(), ScreenVisualError>
Replaces the logical top-left position while retaining size.
Invalid or unrepresentable bounds leave the component unchanged.
Sourcepub fn set_size(
&mut self,
size: LogicalScreenVector,
) -> Result<(), ScreenVisualError>
pub fn set_size( &mut self, size: LogicalScreenVector, ) -> Result<(), ScreenVisualError>
Replaces logical width and height while retaining position.
Non-positive size or invalid bounds leave the component unchanged.
Sourcepub fn set_color(&mut self, color: Color) -> Result<(), ScreenVisualError>
pub fn set_color(&mut self, color: Color) -> Result<(), ScreenVisualError>
Replaces normalized straight-linear RGBA color atomically.
A non-finite channel or channel outside 0.0..=1.0 leaves it unchanged.
Sourcepub fn set_draw_order_depth(
&mut self,
depth: f32,
) -> Result<(), ScreenVisualError>
pub fn set_draw_order_depth( &mut self, depth: f32, ) -> Result<(), ScreenVisualError>
Replaces within-layer ordering depth after finite-value validation.
Negative values are allowed. Failure leaves the component unchanged.
Trait Implementations§
Source§impl Clone for ScreenRectangleVisual
impl Clone for ScreenRectangleVisual
Source§impl Component for ScreenRectangleVisual
impl Component for ScreenRectangleVisual
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreimpl Copy for ScreenRectangleVisual
Source§impl Debug for ScreenRectangleVisual
impl Debug for ScreenRectangleVisual
Source§impl PartialEq for ScreenRectangleVisual
impl PartialEq for ScreenRectangleVisual
impl StructuralPartialEq for ScreenRectangleVisual
Auto Trait Implementations§
impl Freeze for ScreenRectangleVisual
impl RefUnwindSafe for ScreenRectangleVisual
impl Send for ScreenRectangleVisual
impl Sync for ScreenRectangleVisual
impl Unpin for ScreenRectangleVisual
impl UnsafeUnpin for ScreenRectangleVisual
impl UnwindSafe for ScreenRectangleVisual
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.