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
impl<'ui> DrawListMut<'ui>
Drawing functions
Sourcepub fn channels_split<F: FnOnce(&ChannelsSplit<'ui>)>(
&'ui self,
channels_count: u32,
f: F,
)
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.
Sourcepub fn add_line<C>(
&'ui self,
p1: impl Into<ImVec2>,
p2: impl Into<ImVec2>,
c: C,
) -> Line<'ui>where
C: Into<ImColor32>,
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.
Sourcepub fn add_rect<C>(
&'ui self,
p1: impl Into<ImVec2>,
p2: impl Into<ImVec2>,
c: C,
) -> Rect<'ui>where
C: Into<ImColor32>,
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.
Sourcepub 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,
)
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, )
Draw a filled rectangle with per-corner colors (counter-clockwise from upper-left).
Sourcepub fn add_circle<C>(
&'ui self,
center: impl Into<ImVec2>,
radius: f32,
color: C,
) -> Circle<'ui>where
C: Into<ImColor32>,
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.
Sourcepub 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>
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.
Sourcepub 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>,
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.
Sourcepub fn add_polyline<C, P>(&'ui self, points: Vec<P>, c: C) -> Polyline<'ui>
pub fn add_polyline<C, P>(&'ui self, points: Vec<P>, c: C) -> Polyline<'ui>
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)
Sourcepub fn path_clear(&self)
pub fn path_clear(&self)
Clear the current path (i.e. start a new path).
Sourcepub fn path_line_to(&self, pos: impl Into<ImVec2>)
pub fn path_line_to(&self, pos: impl Into<ImVec2>)
Add a point to the current path.
Sourcepub fn path_line_to_merge_duplicate(&self, pos: impl Into<ImVec2>)
pub fn path_line_to_merge_duplicate(&self, pos: impl Into<ImVec2>)
Add a point to the current path, merging duplicate points.
Sourcepub fn path_arc_to(
&self,
center: impl Into<ImVec2>,
radius: f32,
a_min: f32,
a_max: f32,
num_segments: i32,
)
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.
Sourcepub fn path_arc_to_fast(
&self,
center: impl Into<ImVec2>,
radius: f32,
a_min_of_12: i32,
a_max_of_12: i32,
)
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.
Sourcepub fn path_rect(
&self,
rect_min: impl Into<ImVec2>,
rect_max: impl Into<ImVec2>,
rounding: f32,
flags: DrawFlags,
)
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.
Sourcepub 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,
)
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.
Sourcepub fn path_bezier_quadratic_curve_to(
&self,
p2: impl Into<ImVec2>,
p3: impl Into<ImVec2>,
num_segments: i32,
)
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.
Sourcepub fn path_bezier_cubic_curve_to(
&self,
p2: impl Into<ImVec2>,
p3: impl Into<ImVec2>,
p4: impl Into<ImVec2>,
num_segments: i32,
)
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.
Sourcepub fn path_stroke(
&self,
color: impl Into<ImColor32>,
flags: DrawFlags,
thickness: f32,
)
pub fn path_stroke( &self, color: impl Into<ImColor32>, flags: DrawFlags, thickness: f32, )
Stroke the current path with the specified color and thickness.
Sourcepub fn path_fill_convex(&self, color: impl Into<ImColor32>)
pub fn path_fill_convex(&self, color: impl Into<ImColor32>)
Fill the current path as a convex polygon.
Sourcepub fn add_text(
&self,
pos: impl Into<ImVec2>,
col: impl Into<ImColor32>,
text: impl AsRef<str>,
)
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.
Sourcepub 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]>,
)
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.
Sourcepub fn push_texture(&self, texture: impl Into<TextureRef>)
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();Sourcepub fn pop_texture(&self)
pub fn pop_texture(&self)
Pop the last texture from the drawlist texture stack (ImGui 1.92+)
Sourcepub fn push_clip_rect(
&self,
clip_rect_min: impl Into<ImVec2>,
clip_rect_max: impl Into<ImVec2>,
intersect_with_current: bool,
)
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.
Sourcepub fn push_clip_rect_full_screen(&self)
pub fn push_clip_rect_full_screen(&self)
Push a full-screen clip rectangle.
Sourcepub fn pop_clip_rect(&self)
pub fn pop_clip_rect(&self)
Pop the last clip rectangle.
Sourcepub fn clip_rect_min(&self) -> [f32; 2]
pub fn clip_rect_min(&self) -> [f32; 2]
Get current minimum clip rectangle point.
Sourcepub fn clip_rect_max(&self) -> [f32; 2]
pub fn clip_rect_max(&self) -> [f32; 2]
Get current maximum clip rectangle point.
Sourcepub fn with_clip_rect<F>(
&self,
clip_rect_min: impl Into<ImVec2>,
clip_rect_max: impl Into<ImVec2>,
f: F,
)where
F: FnOnce(),
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.
Sourcepub 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>,
)
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.
Sourcepub 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>,
)
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.
Sourcepub 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,
)
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.
Sourcepub 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>,
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.
Sourcepub 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>,
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.
Sourcepub fn add_ngon<C>(
&self,
center: impl Into<ImVec2>,
radius: f32,
col: C,
num_segments: i32,
thickness: f32,
)where
C: Into<ImColor32>,
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.
Sourcepub fn add_ngon_filled<C>(
&self,
center: impl Into<ImVec2>,
radius: f32,
col: C,
num_segments: i32,
)where
C: Into<ImColor32>,
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.
Sourcepub 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>,
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.
Sourcepub 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>,
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.
Sourcepub 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>,
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.
Sourcepub fn add_concave_poly_filled<C, P>(&self, points: &[P], col: C)
pub fn add_concave_poly_filled<C, P>(&self, points: &[P], col: C)
Fill a concave polygon (Dear ImGui 1.92+).
Sourcepub fn path_fill_concave(&self, color: impl Into<ImColor32>)
pub fn path_fill_concave(&self, color: impl Into<ImColor32>)
Fill the current path as a concave polygon (Dear ImGui 1.92+).
Sourcepub unsafe fn add_callback(
&self,
callback: ImDrawCallback,
userdata: *mut c_void,
userdata_size: usize,
)
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.
Sourcepub fn add_draw_cmd(&self)
pub fn add_draw_cmd(&self)
Insert a new draw command (forces a new draw call boundary).
Sourcepub fn clone_output(&self) -> OwnedDrawList
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>
impl<'ui> DrawListMut<'ui>
Sourcepub fn add_callback_safe<F: FnOnce() + 'static>(
&'ui self,
callback: F,
) -> Callback<'ui, F>
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>
impl<'ui> DrawListMut<'ui>
Sourcepub unsafe fn prim_reserve(&self, idx_count: i32, vtx_count: i32)
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.
Sourcepub unsafe fn prim_unreserve(&self, idx_count: i32, vtx_count: i32)
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.
Sourcepub unsafe fn prim_rect(
&self,
a: impl Into<ImVec2>,
b: impl Into<ImVec2>,
col: impl Into<ImColor32>,
)
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.
Sourcepub 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>,
)
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.
Sourcepub 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>,
)
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.
Sourcepub unsafe fn prim_write_vtx(
&self,
pos: impl Into<ImVec2>,
uv: impl Into<ImVec2>,
col: impl Into<ImColor32>,
)
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.
Sourcepub unsafe fn prim_write_idx(&self, idx: ImDrawIdx)
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.