DrawCall

Struct DrawCall 

Source
pub struct DrawCall<IsAbsolute> { /* private fields */ }

Implementations§

Source§

impl<T> DrawCall<T>

Source

pub fn new(pos: Pair<Pos>, kind: DrawCallKind) -> Self

Examples found in repository?
examples/03_element.rs (lines 33-36)
31fn center(text: String) -> Element {
32    Box::new(move |area| {
33        area.push_all(vec![DrawCall::new(
34            area.center_rect(text.rect()).pos,
35            DrawCallKind::PrintLine(text.limit_size(area.size())),
36        )]);
37    })
38}
More examples
Hide additional examples
examples/01_hello_world.rs (lines 21-24)
19fn view(_model: &Model, area: &mut Area) {
20    area.push_all(vec![
21        DrawCall::new(
22            Pair::fill(0),
23            DrawCallKind::SetStyle(ContentStyle::new().magenta().bold()),
24        ),
25        DrawCall::new(
26            Pair::fill(0),
27            DrawCallKind::PrintLine("hello world! :3".limit_size(area.size())),
28        ),
29    ]);
30}
examples/04_counter.rs (lines 33-36)
30fn center(style: ContentStyle, text: String) -> Element {
31    Box::new(move |area| {
32        area.push_all(vec![
33            DrawCall::new(
34                area.center_rect(text.rect()).pos,
35                DrawCallKind::SetStyle(style),
36            ),
37            DrawCall::new(
38                area.center_rect(text.rect()).pos,
39                DrawCallKind::PrintLine(text.limit_size(area.size())),
40            ),
41        ]);
42    })
43}
examples/02_centered.rs (line 24)
15fn view(_model: &Model, area: &mut Area) {
16    let text_0 = "this text is centered!".limit_size(area.size());
17    let text_1 = "try resizing the window ^.^".limit_size(area.size());
18
19    // `center_size` returns a position in the center of the `Area` according to a passed in size.
20    let pos_0 = area.center_rect(text_0.rect()).pos;
21    let pos_1 = area.center_rect(text_1.rect()).pos.map_y(|y| y + 1);
22
23    area.push_all(vec![
24        DrawCall::new(pos_0, DrawCallKind::PrintLine(text_0)),
25        DrawCall::new(pos_1, DrawCallKind::PrintLine(text_1)),
26    ]);
27}
Source

pub fn pos(&self) -> Pair<Pos>

Source

pub fn kind(&self) -> &DrawCallKind

Source

pub fn rect(&self) -> Rect

Source

pub fn size(&self) -> Pair<Size>

Source§

impl DrawCall<NonAbsolute>

Source

pub fn to_absolute(&self, rect: Rect) -> Option<DrawCall<Absolute>>

Trait Implementations§

Source§

impl<IsAbsolute: Clone> Clone for DrawCall<IsAbsolute>

Source§

fn clone(&self) -> DrawCall<IsAbsolute>

Returns a duplicate 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<IsAbsolute: Debug> Debug for DrawCall<IsAbsolute>

Source§

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

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

impl<IsAbsolute: PartialEq> PartialEq for DrawCall<IsAbsolute>

Source§

fn eq(&self, other: &DrawCall<IsAbsolute>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<IsAbsolute: Eq> Eq for DrawCall<IsAbsolute>

Source§

impl<IsAbsolute> StructuralPartialEq for DrawCall<IsAbsolute>

Auto Trait Implementations§

§

impl<IsAbsolute> Freeze for DrawCall<IsAbsolute>

§

impl<IsAbsolute> RefUnwindSafe for DrawCall<IsAbsolute>
where IsAbsolute: RefUnwindSafe,

§

impl<IsAbsolute> Send for DrawCall<IsAbsolute>
where IsAbsolute: Send,

§

impl<IsAbsolute> Sync for DrawCall<IsAbsolute>
where IsAbsolute: Sync,

§

impl<IsAbsolute> Unpin for DrawCall<IsAbsolute>
where IsAbsolute: Unpin,

§

impl<IsAbsolute> UnwindSafe for DrawCall<IsAbsolute>
where IsAbsolute: UnwindSafe,

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