DrawListMut

Struct DrawListMut 

Source
pub struct DrawListMut<'ui> { /* private fields */ }
Expand description

Object implementing the custom draw API.

Called from [Ui::get_window_draw_list], [Ui::get_background_draw_list] or [Ui::get_foreground_draw_list]. No more than one instance of this structure can live in a program at the same time. The program will panic on creating a second instance.

Implementations§

Source§

impl<'ui> DrawListMut<'ui>

Drawing functions

Source

pub fn channels_split<F: FnOnce(&ChannelsSplit<'ui>)>( &'ui self, channels_count: u32, f: F, )

Split draw into multiple channels and merge automatically at the end of the closure.

Source

pub fn add_line<C>( &'ui self, p1: impl Into<ImVec2>, p2: impl Into<ImVec2>, c: C, ) -> Line<'ui>
where C: Into<ImColor32>,

Returns a line from point p1 to p2 with color c.

Source

pub fn add_rect<C>( &'ui self, p1: impl Into<ImVec2>, p2: impl Into<ImVec2>, c: C, ) -> Rect<'ui>
where C: Into<ImColor32>,

Returns a rectangle whose upper-left corner is at point p1 and lower-right corner is at point p2, with color c.

Source

pub fn add_rect_filled_multicolor<C1, C2, C3, C4>( &self, p1: impl Into<ImVec2>, p2: impl Into<ImVec2>, col_upr_left: C1, col_upr_right: C2, col_bot_right: C3, col_bot_left: C4, )
where C1: Into<ImColor32>, C2: Into<ImColor32>, C3: Into<ImColor32>, C4: Into<ImColor32>,

Draw a filled rectangle with per-corner colors (counter-clockwise from upper-left).

Source

pub fn add_circle<C>( &'ui self, center: impl Into<ImVec2>, radius: f32, color: C, ) -> Circle<'ui>
where C: Into<ImColor32>,

Returns a circle with the given center, radius and color.

Source

pub fn add_bezier_curve( &'ui self, pos0: impl Into<ImVec2>, cp0: impl Into<ImVec2>, cp1: impl Into<ImVec2>, pos1: impl Into<ImVec2>, color: impl Into<ImColor32>, ) -> BezierCurve<'ui>

Returns a Bezier curve stretching from pos0 to pos1, whose curvature is defined by cp0 and cp1.

Source

pub fn add_triangle<C>( &'ui self, p1: impl Into<ImVec2>, p2: impl Into<ImVec2>, p3: impl Into<ImVec2>, c: C, ) -> Triangle<'ui>
where C: Into<ImColor32>,

Returns a triangle with the given 3 vertices p1, p2 and p3 and color c.

Source

pub fn add_polyline<C, P>(&'ui self, points: Vec<P>, c: C) -> Polyline<'ui>
where C: Into<ImColor32>, P: Into<ImVec2>,

Returns a polygonal line. If filled is rendered as a convex polygon, if not filled is drawn as a line specified by [Polyline::thickness] (default 1.0)

Source

pub fn path_clear(&self)

Clear the current path (i.e. start a new path).

Source

pub fn path_line_to(&self, pos: impl Into<ImVec2>)

Add a point to the current path.

Source

pub fn path_line_to_merge_duplicate(&self, pos: impl Into<ImVec2>)

Add a point to the current path, merging duplicate points.

Source

pub fn path_arc_to( &self, center: impl Into<ImVec2>, radius: f32, a_min: f32, a_max: f32, num_segments: i32, )

Add an arc to the current path.

Source

pub fn path_arc_to_fast( &self, center: impl Into<ImVec2>, radius: f32, a_min_of_12: i32, a_max_of_12: i32, )

Add an arc to the current path using fast precomputed angles.

Source

pub fn path_rect( &self, rect_min: impl Into<ImVec2>, rect_max: impl Into<ImVec2>, rounding: f32, flags: DrawFlags, )

Add a rectangle to the current path.

Source

pub fn path_elliptical_arc_to( &self, center: impl Into<ImVec2>, radius: impl Into<ImVec2>, rot: f32, a_min: f32, a_max: f32, num_segments: i32, )

Add an elliptical arc to the current path.

Source

pub fn path_bezier_quadratic_curve_to( &self, p2: impl Into<ImVec2>, p3: impl Into<ImVec2>, num_segments: i32, )

Add a quadratic bezier curve to the current path.

Source

pub fn path_bezier_cubic_curve_to( &self, p2: impl Into<ImVec2>, p3: impl Into<ImVec2>, p4: impl Into<ImVec2>, num_segments: i32, )

Add a cubic bezier curve to the current path.

Source

pub fn path_stroke( &self, color: impl Into<ImColor32>, flags: DrawFlags, thickness: f32, )

Stroke the current path with the specified color and thickness.

Source

pub fn path_fill_convex(&self, color: impl Into<ImColor32>)

Fill the current path as a convex polygon.

Source

pub fn add_text( &self, pos: impl Into<ImVec2>, col: impl Into<ImColor32>, text: impl AsRef<str>, )

Draw a text whose upper-left corner is at point pos.

Source

pub fn add_text_with_font( &self, font: &Font, font_size: f32, pos: impl Into<ImVec2>, col: impl Into<ImColor32>, text: impl AsRef<str>, wrap_width: f32, cpu_fine_clip_rect: Option<[f32; 4]>, )

Draw text with an explicit font and optional fine CPU clip rectangle.

This mirrors Dear ImGui’s ImDrawList::AddText(ImFont*, ...) overload.

Source

pub fn push_texture(&self, texture: impl Into<TextureRef>)

Push a texture on the drawlist texture stack (ImGui 1.92+)

While pushed, image and primitives will use this texture unless otherwise specified.

Example:

let dl = ui.get_window_draw_list();
let tex = texture::TextureId::new(1);
dl.push_texture(tex);
dl.add_image(tex, [10.0,10.0], [110.0,110.0], [0.0,0.0], [1.0,1.0], Color::WHITE);
dl.pop_texture();
Source

pub fn pop_texture(&self)

Pop the last texture from the drawlist texture stack (ImGui 1.92+)

Source

pub fn push_clip_rect( &self, clip_rect_min: impl Into<ImVec2>, clip_rect_max: impl Into<ImVec2>, intersect_with_current: bool, )

Push a clip rectangle, optionally intersecting with the current clip rect.

Source

pub fn push_clip_rect_full_screen(&self)

Push a full-screen clip rectangle.

Source

pub fn pop_clip_rect(&self)

Pop the last clip rectangle.

Source

pub fn clip_rect_min(&self) -> [f32; 2]

Get current minimum clip rectangle point.

Source

pub fn clip_rect_max(&self) -> [f32; 2]

Get current maximum clip rectangle point.

Source

pub fn with_clip_rect<F>( &self, clip_rect_min: impl Into<ImVec2>, clip_rect_max: impl Into<ImVec2>, f: F, )
where F: FnOnce(),

Convenience: push a clip rect, run f, pop.

Source

pub fn add_image( &self, texture: impl Into<TextureRef>, p_min: impl Into<ImVec2>, p_max: impl Into<ImVec2>, uv_min: impl Into<ImVec2>, uv_max: impl Into<ImVec2>, col: impl Into<ImColor32>, )

Add an image quad (axis-aligned). Tint via col.

Source

pub fn add_image_quad( &self, texture: impl Into<TextureRef>, p1: impl Into<ImVec2>, p2: impl Into<ImVec2>, p3: impl Into<ImVec2>, p4: impl Into<ImVec2>, uv1: impl Into<ImVec2>, uv2: impl Into<ImVec2>, uv3: impl Into<ImVec2>, uv4: impl Into<ImVec2>, col: impl Into<ImColor32>, )

Add an image with 4 arbitrary corners.

Source

pub fn add_image_rounded( &self, texture: impl Into<TextureRef>, p_min: impl Into<ImVec2>, p_max: impl Into<ImVec2>, uv_min: impl Into<ImVec2>, uv_max: impl Into<ImVec2>, col: impl Into<ImColor32>, rounding: f32, flags: DrawFlags, )

Add an axis-aligned rounded image.

Source

pub fn add_quad<C>( &self, p1: impl Into<ImVec2>, p2: impl Into<ImVec2>, p3: impl Into<ImVec2>, p4: impl Into<ImVec2>, col: C, thickness: f32, )
where C: Into<ImColor32>,

Draw a quadrilateral outline given four points.

Source

pub fn add_quad_filled<C>( &self, p1: impl Into<ImVec2>, p2: impl Into<ImVec2>, p3: impl Into<ImVec2>, p4: impl Into<ImVec2>, col: C, )
where C: Into<ImColor32>,

Draw a filled quadrilateral given four points.

Source

pub fn add_ngon<C>( &self, center: impl Into<ImVec2>, radius: f32, col: C, num_segments: i32, thickness: f32, )
where C: Into<ImColor32>,

Draw a regular n-gon outline.

Source

pub fn add_ngon_filled<C>( &self, center: impl Into<ImVec2>, radius: f32, col: C, num_segments: i32, )
where C: Into<ImColor32>,

Draw a filled regular n-gon.

Source

pub fn add_ellipse<C>( &self, center: impl Into<ImVec2>, radius: impl Into<ImVec2>, col: C, rot: f32, num_segments: i32, thickness: f32, )
where C: Into<ImColor32>,

Draw an ellipse outline.

Source

pub fn add_ellipse_filled<C>( &self, center: impl Into<ImVec2>, radius: impl Into<ImVec2>, col: C, rot: f32, num_segments: i32, )
where C: Into<ImColor32>,

Draw a filled ellipse.

Source

pub fn add_bezier_quadratic<C>( &self, p1: impl Into<ImVec2>, p2: impl Into<ImVec2>, p3: impl Into<ImVec2>, col: C, thickness: f32, num_segments: i32, )
where C: Into<ImColor32>,

Draw a quadratic Bezier curve directly.

Source

pub fn add_concave_poly_filled<C, P>(&self, points: &[P], col: C)
where C: Into<ImColor32>, P: Copy + Into<ImVec2>,

Fill a concave polygon (Dear ImGui 1.92+).

Source

pub fn path_fill_concave(&self, color: impl Into<ImColor32>)

Fill the current path as a concave polygon (Dear ImGui 1.92+).

Source

pub unsafe fn add_callback( &self, callback: ImDrawCallback, userdata: *mut c_void, userdata_size: usize, )

Insert a raw draw callback.

Safety: The callback must be an extern "C" function compatible with ImDrawCallback. The provided userdata must remain valid until the draw list is executed by the renderer. If you allocate memory and store its pointer in userdata, you are responsible for reclaiming it from within the callback or otherwise ensuring no leaks occur. Note that callbacks are only invoked if the draw list is actually rendered.

Source

pub fn add_draw_cmd(&self)

Insert a new draw command (forces a new draw call boundary).

Source

pub fn clone_output(&self) -> OwnedDrawList

Clone the current draw list output into an owned, independent copy.

The returned draw list is heap-allocated by Dear ImGui and will be destroyed on drop.

Source§

impl<'ui> DrawListMut<'ui>

Source

pub fn add_callback_safe<F: FnOnce() + 'static>( &'ui self, callback: F, ) -> Callback<'ui, F>

Safe variant: add a Rust callback (executed when the draw list is rendered). Note: if the draw list is never rendered, the callback will not run and its resources won’t be reclaimed.

Source§

impl<'ui> DrawListMut<'ui>

Source

pub unsafe fn prim_reserve(&self, idx_count: i32, vtx_count: i32)

Unsafe low-level geometry API: reserve index and vertex space.

Safety: Caller must write exactly the reserved amount using PrimWrite* and ensure valid topology.

Source

pub unsafe fn prim_unreserve(&self, idx_count: i32, vtx_count: i32)

Unsafe low-level geometry API: unreserve previously reserved space.

Safety: Must match a prior call to prim_reserve which hasn’t been fully written.

Source

pub unsafe fn prim_rect( &self, a: impl Into<ImVec2>, b: impl Into<ImVec2>, col: impl Into<ImColor32>, )

Unsafe low-level geometry API: append a rectangle primitive with a single color.

Safety: Only use between prim_reserve and completing the reserved writes.

Source

pub unsafe fn prim_rect_uv( &self, a: impl Into<ImVec2>, b: impl Into<ImVec2>, uv_a: impl Into<ImVec2>, uv_b: impl Into<ImVec2>, col: impl Into<ImColor32>, )

Unsafe low-level geometry API: append a rectangle primitive with UVs and color.

Safety: Only use between prim_reserve and completing the reserved writes.

Source

pub unsafe fn prim_quad_uv( &self, a: impl Into<ImVec2>, b: impl Into<ImVec2>, c: impl Into<ImVec2>, d: impl Into<ImVec2>, uv_a: impl Into<ImVec2>, uv_b: impl Into<ImVec2>, uv_c: impl Into<ImVec2>, uv_d: impl Into<ImVec2>, col: impl Into<ImColor32>, )

Unsafe low-level geometry API: append a quad primitive with UVs and color.

Safety: Only use between prim_reserve and completing the reserved writes.

Source

pub unsafe fn prim_write_vtx( &self, pos: impl Into<ImVec2>, uv: impl Into<ImVec2>, col: impl Into<ImColor32>, )

Unsafe low-level geometry API: write a vertex.

Safety: Only use to fill space reserved by prim_reserve.

Source

pub unsafe fn prim_write_idx(&self, idx: ImDrawIdx)

Unsafe low-level geometry API: write an index.

Safety: Only use to fill space reserved by prim_reserve.

Source

pub unsafe fn prim_vtx( &self, pos: impl Into<ImVec2>, uv: impl Into<ImVec2>, col: impl Into<ImColor32>, )

Unsafe low-level geometry API: convenience to append one vertex (pos+uv+col).

Safety: Only use between prim_reserve and completing the reserved writes.

Trait Implementations§

Source§

impl Drop for DrawListMut<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'ui> Freeze for DrawListMut<'ui>

§

impl<'ui> RefUnwindSafe for DrawListMut<'ui>

§

impl<'ui> !Send for DrawListMut<'ui>

§

impl<'ui> !Sync for DrawListMut<'ui>

§

impl<'ui> Unpin for DrawListMut<'ui>

§

impl<'ui> UnwindSafe for DrawListMut<'ui>

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