Struct ori_core::DrawContext

source ·
pub struct DrawContext<'a> {
    pub style: &'a Stylesheet,
    pub state: &'a mut NodeState,
    pub frame: &'a mut Frame,
    pub renderer: &'a dyn Renderer,
    pub selectors: &'a StyleSelectors,
    pub event_sink: &'a EventSink,
    pub image_cache: &'a mut ImageCache,
}

Fields§

§style: &'a Stylesheet§state: &'a mut NodeState§frame: &'a mut Frame§renderer: &'a dyn Renderer§selectors: &'a StyleSelectors§event_sink: &'a EventSink§image_cache: &'a mut ImageCache

Implementations§

source§

impl<'a> DrawContext<'a>

source

pub fn frame(&mut self) -> &mut Frame

source

pub fn layer<'b>(&'b mut self) -> DrawLayer<'a, 'b>

source

pub fn draw_layer(&mut self, f: impl FnOnce(&mut DrawContext<'_>))

Runs the given callback on a new layer offset by the given amount.

offset should almost always be 1.0.

source

pub fn draw_quad(&mut self)

Draws the quad at the current layout rect.

This will use the following style attributes:

  • background-color: The background color of the quad.
  • border-radius: The border radius of the quad overwritten by the more specific attributes.
  • border-top-left-radius: The top left border radius of the quad.
  • border-top-right-radius: The top right border radius of the quad.
  • border-bottom-right-radius: The bottom right border radius of the quad.
  • border-bottom-left-radius: The bottom left border radius of the quad.
  • border-width: The border width of the quad.

Methods from Deref<Target = Frame>§

source

pub fn clear(&mut self)

source

pub fn depth(&self) -> f32

source

pub fn clip(&self) -> Option<Rect>

source

pub fn draw(&mut self, primitive: impl Into<PrimitiveKind>)

source

pub fn draw_primitive(&mut self, primitive: Primitive)

source

pub fn layer(&mut self) -> Layer<'_>

source

pub fn draw_layer(&mut self, f: impl FnOnce(&mut Frame))

source

pub fn primitives(&self) -> &[Primitive]

Trait Implementations§

source§

impl<'a> Context for DrawContext<'a>

source§

fn stylesheet(&self) -> &Stylesheet

source§

fn state(&self) -> &NodeState

source§

fn state_mut(&mut self) -> &mut NodeState

source§

fn renderer(&self) -> &dyn Renderer

source§

fn selectors(&self) -> &StyleSelectors

source§

fn event_sink(&self) -> &EventSink

source§

fn image_cache(&self) -> &ImageCache

source§

fn image_cache_mut(&mut self) -> &mut ImageCache

source§

fn get_style_attribute(&self, key: &str) -> Option<StyleAttribute>

source§

fn get_style_attribute_specificity( &self, key: &str ) -> Option<(StyleAttribute, StyleSpecificity)>

source§

fn get_style<T: FromStyleAttribute + 'static>(&mut self, key: &str) -> Option<T>

source§

fn get_style_specificity<T: FromStyleAttribute + 'static>( &mut self, key: &str ) -> Option<(T, StyleSpecificity)>

source§

fn style<T: FromStyleAttribute + Default + 'static>(&mut self, key: &str) -> T

Get the value of a style attribute, if it has a transition, the value will be interpolated between the current value and the new value.
source§

fn style_group<T: FromStyleAttribute + Default + 'static>( &mut self, primary_key: &str, secondary_key: &str ) -> T

source§

fn get_style_range(&mut self, key: &str, range: Range<f32>) -> Option<f32>

source§

fn get_style_range_specificity( &mut self, key: &str, range: Range<f32> ) -> Option<(f32, StyleSpecificity)>

source§

fn style_range(&mut self, key: &str, range: Range<f32>) -> f32

Get the value of a style attribute, if it has a transition, the value will be interpolated between the current value and the new value. Read more
source§

fn style_range_group( &mut self, primary_key: &str, secondary_key: &str, range: Range<f32> ) -> f32

source§

fn downcast_renderer<T: Renderer>(&self) -> Option<&T>

source§

fn load_image(&mut self, source: &ImageSource) -> ImageHandle

source§

fn active(&self) -> bool

source§

fn hovered(&self) -> bool

source§

fn focused(&self) -> bool

source§

fn focus(&mut self)

source§

fn unfocus(&mut self)

source§

fn activate(&mut self)

source§

fn deactivate(&mut self)

source§

fn local_rect(&self) -> Rect

source§

fn rect(&self) -> Rect

source§

fn size(&self) -> Vec2

source§

fn request_redraw(&mut self)

source§

fn send_event(&self, event: impl Any + SendSync)

source§

fn delta_time(&self) -> f32

source§

impl<'a> Deref for DrawContext<'a>

§

type Target = Frame

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a> DerefMut for DrawContext<'a>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for DrawContext<'a>

§

impl<'a> !Send for DrawContext<'a>

§

impl<'a> !Sync for DrawContext<'a>

§

impl<'a> Unpin for DrawContext<'a>

§

impl<'a> !UnwindSafe for DrawContext<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> 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 Twhere 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 = mem::align_of::<T>()

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

source§

fn styled(self) -> Styled<T>

Converts the self into a Styled<Self> value.
source§

fn class(self, class: impl AsRef<str>) -> Styled<T>

Adds a class.
source§

fn attr(self, key: &str, value: impl StyleAttributeBuilder) -> Styled<T>

Adds an attribute.
source§

fn attr_trans( self, key: &str, value: impl Into<StyleAttributeValue>, transition: impl Into<StyleTransition> ) -> Styled<T>

Adds an attribute with a transition.
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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> 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
source§

impl<T> SendSync for T

source§

impl<T> Sendable for T