Skip to main content

AlphaMask

Struct AlphaMask 

Source
pub struct AlphaMask { /* private fields */ }
Expand description

The alpha mask of an element: a CompositionSurfaceBrush that shows the alpha of what the element draws, for a DropShadow.Mask and other composition effects.

The element embeds one and forwards to it: get from its get_alpha_mask, update_if_available at the end of its render (WinUI’s NotifyRenderContent).

As in WinUI the brush is created on the first request and stays the same object for the life of the element; its surface is an image of the element’s own drawing at the scale of its transform to the window and of the scaling of the window (WinUI’s realization scale), with the colour dropped (black with the alpha, as an alpha-only texture is sampled). The image is drawn again each time the element draws its content again, so it follows the text, the geometry, the source and the size; while the element has no size, is not visible or is not in a tree, the brush has no surface and paints nothing. Its Stretch is Fill, so a visual of the size of the element shows the mask over itself.

Implementations§

Source§

impl AlphaMask

Source

pub fn new() -> Self

Source

pub fn get(&self, element: &Visual) -> Option<Rc<CompositionBrush>>

GetAlphaMask: the brush of the mask of element, created on the first call and drawn at once when the element can be drawn (WinUI’s AlphaMask::Ensure). None when no compositor is available for the element.

Source

pub fn is_present(&self) -> bool

Whether the brush was created.

Source

pub fn is_connected(&self) -> bool

Whether the brush shows an image of the element.

Source

pub fn update_if_available(&self, element: &Visual)

Draws the mask of element again when the brush was created (WinUI’s AlphaMask::UpdateIfAvailable, called by the render walk for an element whose content is drawn again): an element with a size, in a tree and visible gets a new image; otherwise the brush loses its surface.

Source

pub fn hide(&self)

Takes the surface from the brush (WinUI’s AlphaMask::Hide): the element is not drawn, so its mask is empty.

Trait Implementations§

Source§

impl Default for AlphaMask

Source§

fn default() -> Self

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

impl Drop for AlphaMask

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.