Skip to main content

ScreenRectangleVisual

Struct ScreenRectangleVisual 

Source
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

Source

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.

Source

pub const fn corner_radius(&self) -> f32

Returns the requested radius, before clamping to the current rectangle.

Source

pub fn set_corner_radius( &mut self, radius: f32, ) -> Result<(), ScreenVisualError>

Sets a finite nonnegative logical radius atomically. Zero means square corners.

Source

pub const fn stroke(&self) -> Option<Stroke>

Returns the optional centered decorative outline in logical pixels.

Source

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.

Source

pub const fn clip(&self) -> ScreenClip

Returns the explicit screen clip, shared by drawing and pointer geometry.

Source

pub fn set_clip(&mut self, clip: ScreenClip)

Replaces the clip without moving content or changing draw order.

Source§

impl ScreenRectangleVisual

Source

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.

Source

pub const fn position(&self) -> LogicalScreenPosition

Returns the rectangle’s top-left position in logical screen pixels.

Source

pub const fn size(&self) -> LogicalScreenVector

Returns the full positive width and height in logical screen pixels.

Source

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.

Source

pub const fn color(&self) -> Color

Returns the normalized straight-linear RGBA fill color.

Source

pub const fn layer(&self) -> Layer

Returns the primary ordering layer within screen content.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_layer(&mut self, layer: Layer)

Replaces the ordering layer within screen content.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Component for ScreenRectangleVisual
where Self: Send + Sync + 'static,

Source§

const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table

A constant indicating the storage type used for this component.
Source§

type Mutability = Mutable

A marker type to assist Bevy with determining if this component is mutable, or immutable. Mutable components will have Component<Mutability = Mutable>, while immutable components will instead have Component<Mutability = Immutable>. Read more
Source§

fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )

Registers required components. Read more
Source§

fn clone_behavior() -> ComponentCloneBehavior

Called when registering this component, allowing to override clone function (or disable cloning altogether) for this component. Read more
Source§

fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>

Returns ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read more
Source§

fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_add ComponentHook for this Component if one is defined.
Source§

fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_insert ComponentHook for this Component if one is defined.
Source§

fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_discard ComponentHook for this Component if one is defined.
Source§

fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_remove ComponentHook for this Component if one is defined.
Source§

fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_despawn ComponentHook for this Component if one is defined.
Source§

fn map_entities<E>(_this: &mut Self, _mapper: &mut E)
where E: EntityMapper,

Maps the entities on this component using the given 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 more
Source§

impl Copy for ScreenRectangleVisual

Source§

impl Debug for ScreenRectangleVisual

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ScreenRectangleVisual

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ScreenRectangleVisual

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<C> Bundle for C
where C: Component,

Source§

fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>

Source§

fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>

Return a iterator over this Bundle’s component ids. This will be None if the component has not been registered.
Source§

impl<C> BundleFromComponents for C
where C: Component,

Source§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>, C: Sized,

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<C> DynamicBundle for C
where C: Component,

Source§

type Effect = ()

An operation on the entity that happens after inserting this bundle.
Source§

unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect

Moves the components out of the bundle. Read more
Source§

unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )

Applies the after-effects of spawning this bundle. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WorldEvent for T
where T: Copy + Send + Sync + 'static,