pub enum Primitive<T> {
    Text {
        content: String,
        bounds: Rectangle,
        color: Color,
        size: Pixels,
        line_height: LineHeight,
        font: Font,
        horizontal_alignment: Horizontal,
        vertical_alignment: Vertical,
        shaping: Shaping,
        clip_bounds: Rectangle,
    },
    Paragraph {
        paragraph: Weak,
        position: Point,
        color: Color,
        clip_bounds: Rectangle,
    },
    Editor {
        editor: Weak,
        position: Point,
        color: Color,
        clip_bounds: Rectangle,
    },
    RawText(Raw),
    Quad {
        bounds: Rectangle,
        background: Background,
        border: Border,
        shadow: Shadow,
    },
    Image {
        handle: Handle,
        filter_method: FilterMethod,
        bounds: Rectangle,
    },
    Svg {
        handle: Handle,
        color: Option<Color>,
        bounds: Rectangle,
    },
    Group {
        primitives: Vec<Primitive<T>>,
    },
    Clip {
        bounds: Rectangle,
        content: Box<Primitive<T>>,
    },
    Transform {
        transformation: Transformation,
        content: Box<Primitive<T>>,
    },
    Cache {
        content: Arc<Primitive<T>>,
    },
    Custom(T),
}
Expand description

A rendering primitive.

Variants§

§

Text

Fields

§content: String

The contents of the text.

§bounds: Rectangle

The bounds of the text.

§color: Color

The color of the text.

§size: Pixels

The size of the text in logical pixels.

§line_height: LineHeight

The line height of the text.

§font: Font

The font of the text.

§horizontal_alignment: Horizontal

The horizontal alignment of the text.

§vertical_alignment: Vertical

The vertical alignment of the text.

§shaping: Shaping

The shaping strategy of the text.

§clip_bounds: Rectangle

The clip bounds of the text.

A text primitive

§

Paragraph

Fields

§paragraph: Weak

The paragraph::Weak reference.

§position: Point

The position of the paragraph.

§color: Color

The color of the paragraph.

§clip_bounds: Rectangle

The clip bounds of the paragraph.

A paragraph primitive

§

Editor

Fields

§editor: Weak

The editor::Weak reference.

§position: Point

The position of the editor.

§color: Color

The color of the editor.

§clip_bounds: Rectangle

The clip bounds of the editor.

An editor primitive

§

RawText(Raw)

A raw cosmic-text primitive

§

Quad

Fields

§bounds: Rectangle

The bounds of the quad

§background: Background

The background of the quad

§border: Border

The Border of the quad

§shadow: Shadow

The Shadow of the quad

A quad primitive

§

Image

Fields

§handle: Handle

The handle of the image

§filter_method: FilterMethod

The filter method of the image

§bounds: Rectangle

The bounds of the image

An image primitive

§

Svg

Fields

§handle: Handle

The path of the SVG file

§color: Option<Color>

The Color filter

§bounds: Rectangle

The bounds of the viewport

An SVG primitive

§

Group

Fields

§primitives: Vec<Primitive<T>>

The primitives of the group

A group of primitives

§

Clip

Fields

§bounds: Rectangle

The bounds of the clip

§content: Box<Primitive<T>>

The content of the clip

A clip primitive

§

Transform

Fields

§transformation: Transformation
§content: Box<Primitive<T>>

The primitive to transform

A primitive that applies a Transformation

§

Cache

Fields

§content: Arc<Primitive<T>>

The cached primitive

A cached primitive.

This can be useful if you are implementing a widget where primitive generation is expensive.

§

Custom(T)

A backend-specific primitive.

Implementations§

source§

impl<T> Primitive<T>

source

pub fn group(primitives: Vec<Self>) -> Self

Groups the current Primitive.

source

pub fn clip(self, bounds: Rectangle) -> Self

Clips the current Primitive.

source

pub fn translate(self, translation: Vector) -> Self

Translates the current Primitive.

source

pub fn transform(self, transformation: Transformation) -> Self

Transforms the current Primitive.

Trait Implementations§

source§

impl<T: Clone> Clone for Primitive<T>

source§

fn clone(&self) -> Primitive<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Damage> Damage for Primitive<T>

source§

fn bounds(&self) -> Rectangle

Returns the bounds of the Damage.
source§

impl<T: Debug> Debug for Primitive<T>

source§

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

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

impl<T: PartialEq> PartialEq for Primitive<T>

source§

fn eq(&self, other: &Primitive<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> StructuralPartialEq for Primitive<T>

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Primitive<T>

§

impl<T> Send for Primitive<T>
where T: Sync + Send,

§

impl<T> Sync for Primitive<T>
where T: Sync + Send,

§

impl<T> Unpin for Primitive<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Primitive<T>

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

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

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

§

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

§

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> MaybeSend for T
where T: Send,

source§

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