Skip to main content

OverlayShapeItem

Struct OverlayShapeItem 

Source
pub struct OverlayShapeItem {
Show 22 fields pub position: [f32; 2], pub size: [f32; 2], pub shape: OverlayShape, pub fill: OverlayFill, pub opacity: f32, pub border_colour: [f32; 4], pub border_width: f32, pub border_mode: BorderMode, pub z_order: i32, pub texture: Option<OverlayTextureId>, pub shadow_colour: [f32; 4], pub shadow_radius: f32, pub shadow_offset: [f32; 2], pub animation: OverlayAnimation, pub backdrop_blur: f32, pub clip_mask_id: Option<u32>, pub clip_id: Option<u32>, pub rotation: f32, pub nine_slice: Option<NineSlice>, pub texture_transform: TextureTransform, pub shadow_inset: bool, pub animations: OverlayAnimations,
}
Expand description

A screen-space overlay shape rendered with a signed-distance function.

Each item becomes a single bounding quad on the GPU. The fragment shader evaluates an SDF to produce anti-aliased fill, border, and discard regions.

fill controls the interior colour. Use OverlayFill::Solid for a flat colour or OverlayFill::LinearGradient for a two-colour gradient.

When texture is set the shape samples the uploaded image as its fill. In that case fill must be OverlayFill::Solid; the solid colour acts as a tint multiplied with each texel. Use [1.0, 1.0, 1.0, 1.0] for no tint. The SDF boundary, border, and AA apply the same way regardless of fill mode.

§Examples

// Rounded-rect panel background.
let panel = OverlayShapeItem {
    position: [20.0, 20.0],
    size: [300.0, 200.0],
    shape: OverlayShape::Rect { corner_radius: 8.0 },
    fill: OverlayFill::Solid([0.1, 0.1, 0.1, 0.85]),
    border_width: 1.0,
    border_colour: [0.4, 0.4, 0.4, 1.0],
    ..Default::default()
};

// Circle with a left-to-right gradient.
let grad_dot = OverlayShapeItem {
    position: [100.0, 100.0],
    size: [60.0, 60.0],
    shape: OverlayShape::Circle,
    fill: OverlayFill::LinearGradient {
        start_colour: [0.0, 0.4, 1.0, 1.0],
        end_colour: [0.0, 1.0, 0.5, 1.0],
        angle: 0.0,
    },
    ..Default::default()
};

Fields§

§position: [f32; 2]

Top-left position in logical pixels from the viewport top-left.

§size: [f32; 2]

Width and height in logical pixels.

§shape: OverlayShape

Which SDF shape to render.

§fill: OverlayFill

Fill style: solid colour or linear gradient.

When texture is Some only OverlayFill::Solid is used; the colour becomes a tint multiplied with each texture sample.

§opacity: f32

Overall opacity multiplier applied to both fill and border. Range 0.0-1.0.

§border_colour: [f32; 4]

RGBA border colour in linear float format.

§border_width: f32

Border thickness in logical pixels. 0.0 disables the border.

§border_mode: BorderMode

Where the border sits relative to the shape edge. Default: Inset.

§z_order: i32

Draw order relative to other shapes. Lower values render first (further back).

§texture: Option<OverlayTextureId>

Optional texture fill. When set the shape samples the image uploaded via DeviceResources::upload_overlay_texture, clipped by the SDF boundary. fill acts as a tint when this is Some.

§shadow_colour: [f32; 4]

RGBA colour of the outer shadow/glow halo. Default: transparent (no shadow).

§shadow_radius: f32

Blur spread of the shadow in logical pixels. 0.0 disables the shadow.

§shadow_offset: [f32; 2]

Offset of the shadow centre from the shape centre in logical pixels. Positive X shifts right, positive Y shifts down. Default: [0.0, 0.0].

§animation: OverlayAnimation

Opacity animation. Resolved each frame during prepare() using OverlayFrame::time. Default: OverlayAnimation::None.

§backdrop_blur: f32

Backdrop blur radius in logical pixels. When greater than zero the scene content behind the shape is blurred (frosted glass effect) and the fill colour is composited on top as a tint. 0.0 disables the effect. Only active in render paths where the renderer owns the command encoder (render, render_viewport); in paint/paint_to paths blur shapes fall back to a regular solid fill.

§clip_mask_id: Option<u32>

Marks this shape as a clip mask. The shape itself is not drawn; its bounding box defines a clipping rectangle for any shape whose clip_id equals this value. None means the shape is not a mask.

Used for scroll containers, masked panels, and composite widgets. Only the solid (non-textured, non-blur) shape path participates in clipping; textured and backdrop-blur shapes ignore both clip_id and clip_mask_id.

Current limitation: the clip uses the mask shape’s axis-aligned bounding box, not its SDF. For Rect and RoundedRect masks this matches the visible bounds; for Circle, Ellipse, and other curved shapes the clip is the enclosing square/rectangle.

§clip_id: Option<u32>

When set, this shape is clipped to the bounding box of the mask shape whose clip_mask_id matches this value. Fragments outside the mask’s bounding rect are discarded. None means the shape is drawn unclipped. If no mask with the matching id is present in the frame, the shape is also drawn unclipped.

§rotation: f32

Rotation around the shape centre in radians. Positive rotates counter-clockwise in math coordinates. 0.0 keeps the default orientation. Applies to fill, border, shadow, and gradient direction; the bounding box (position + size) stays axis-aligned, so the rotated shape is drawn inside the unrotated box.

§nine_slice: Option<NineSlice>

9-slice texture sampling for the shape’s texture fill. When None the texture stretches to fill the bounding box (default).

§texture_transform: TextureTransform

Affine transform applied to the texture sample before lookup. Lets a single texture pan, scale, rotate, tile, and flip independently of the shape it fills. Ignored when nine_slice is also set on the same shape.

§shadow_inset: bool

When true, the existing shadow_* fields render as an inset (inner) shadow that fades from the edge inward instead of an outer drop shadow. Default false (outer shadow, the legacy behaviour).

Use for pressed buttons, dropdowns, text inputs, scroll wells, and other recessed UI surfaces.

A shape currently carries either an outer or an inner shadow, not both at once. Stackable outer + inner shadow layers are planned for a follow-up phase.

§animations: OverlayAnimations

Multi-channel animation tracks for position, size, fill, border_colour, rotation, and opacity. Each Some track replaces the matching field on the item for the frame. The opacity track takes precedence over the legacy Self::animation field when both are set.

Implementations§

Source§

impl OverlayShapeItem

Source

pub fn distance(&self, point: [f32; 2]) -> f32

Signed distance from a screen-space point to the shape boundary.

The point is in logical pixels from the top-left of the viewport (the same coordinate space as position). Negative values mean the point is inside the shape; positive values mean it is outside.

This evaluates the same SDF used by the GPU shader, so the boundary matches what is rendered on screen (ignoring sub-pixel AA).

Source

pub fn contains(&self, point: [f32; 2]) -> bool

Returns true if the screen-space point falls inside the shape boundary.

The point is in logical pixels from the top-left of the viewport. Equivalent to self.distance(point) <= 0.0.

Trait Implementations§

Source§

impl Clone for OverlayShapeItem

Source§

fn clone(&self) -> OverlayShapeItem

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 Debug for OverlayShapeItem

Source§

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

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

impl Default for OverlayShapeItem

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<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> Downcast for T
where T: Any,

Source§

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

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

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

Converts &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> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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