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>
impl<'a> DrawContext<'a>
pub fn frame(&mut self) -> &mut Frame
pub fn layer<'b>(&'b mut self) -> DrawLayer<'a, 'b>
sourcepub fn draw_layer(&mut self, f: impl FnOnce(&mut DrawContext<'_>))
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
.
sourcepub fn draw_quad(&mut self)
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>§
pub fn clear(&mut self)
pub fn depth(&self) -> f32
pub fn clip(&self) -> Option<Rect>
pub fn draw(&mut self, primitive: impl Into<PrimitiveKind>)
pub fn draw_primitive(&mut self, primitive: Primitive)
pub fn layer(&mut self) -> Layer<'_>
pub fn draw_layer(&mut self, f: impl FnOnce(&mut Frame))
pub fn primitives(&self) -> &[Primitive]
Trait Implementations§
source§impl<'a> Context for DrawContext<'a>
impl<'a> Context for DrawContext<'a>
fn stylesheet(&self) -> &Stylesheet
fn state(&self) -> &NodeState
fn state_mut(&mut self) -> &mut NodeState
fn renderer(&self) -> &dyn Renderer
fn selectors(&self) -> &StyleSelectors
fn event_sink(&self) -> &EventSink
fn image_cache(&self) -> &ImageCache
fn image_cache_mut(&mut self) -> &mut ImageCache
fn get_style_attribute(&self, key: &str) -> Option<StyleAttribute>
fn get_style_attribute_specificity( &self, key: &str ) -> Option<(StyleAttribute, StyleSpecificity)>
fn get_style<T: FromStyleAttribute + 'static>(&mut self, key: &str) -> Option<T>
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
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.
fn style_group<T: FromStyleAttribute + Default + 'static>( &mut self, primary_key: &str, secondary_key: &str ) -> T
fn get_style_range(&mut self, key: &str, range: Range<f32>) -> Option<f32>
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
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
fn style_range_group( &mut self, primary_key: &str, secondary_key: &str, range: Range<f32> ) -> f32
fn downcast_renderer<T: Renderer>(&self) -> Option<&T>
fn load_image(&mut self, source: &ImageSource) -> ImageHandle
fn active(&self) -> bool
fn hovered(&self) -> bool
fn focused(&self) -> bool
fn focus(&mut self)
fn unfocus(&mut self)
fn activate(&mut self)
fn deactivate(&mut self)
fn local_rect(&self) -> Rect
fn rect(&self) -> Rect
fn size(&self) -> Vec2
fn request_redraw(&mut self)
fn send_event(&self, event: impl Any + SendSync)
fn delta_time(&self) -> f32
source§impl<'a> Deref for DrawContext<'a>
impl<'a> Deref for DrawContext<'a>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> Styleable<T> for T
impl<T> Styleable<T> for T
source§fn styled(self) -> Styled<T>
fn styled(self) -> Styled<T>
Converts the
self
into a Styled<Self>
value.source§fn attr_trans(
self,
key: &str,
value: impl Into<StyleAttributeValue>,
transition: impl Into<StyleTransition>
) -> Styled<T>
fn attr_trans( self, key: &str, value: impl Into<StyleAttributeValue>, transition: impl Into<StyleTransition> ) -> Styled<T>
Adds an attribute with a transition.