Skip to main content

Canvas

Struct Canvas 

Source
pub struct Canvas {
    rect: Rect,
    response: Response,
    diagram: ShapeIdx,
    pan: Camera,
    moves: Vec<Move>,
}
Expand description

One canvas frame as the pointer left it: the rect it was laid out in, the moves it read for the session to apply, and the raw input the session resolves. A value rather than a borrow of the view, so the frame can call the editor between reading its input and painting.

Fields§

§rect: Rect§response: Response§diagram: ShapeIdx

Where the diagram is painted, reserved as the canvas is laid out.

§pan: Camera§moves: Vec<Move>

Implementations§

Source§

impl Canvas

Source

pub fn viewport(&self) -> Rect

The screen rect this frame paints into.

Source

pub fn moves(&mut self) -> Vec<Move>

What the pointer did to the camera this frame — a drag pan, a wheel notch, a pinch — in the order it happened, for the session to apply before the pointer is resolved.

Source

pub fn input(&self, ui: &Ui, glass: &[Rect]) -> Input

What the pointer and the keys did this frame, as the core resolves them: the pointer’s motions and button edges while it is over the canvas or holding a press that began there, its leaving otherwise, and a pan in progress, which owns the pointer.

Presses that began on a toolbar button never arrive: holding one — whose screen point maps to some world position — must not arm a canvas affordance. egui keeps that promise for chrome in a layer of its own; for chrome the host draws in the canvas’s layer it counts the canvas as hovered on the press and not on the release, so the host names the rects of such chrome as glass, and a press on one is not taken either.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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