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>

source

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

Split into channels_count drawing channels. At the end of the closure, the channels are merged. The objects are then drawn in the increasing order of their channel number, and not in the order they were called.

Example
fn custom_drawing(ui: &Ui) {
    let draw_list = ui.get_window_draw_list();
    draw_list.channels_split(2, |channels| {
        channels.set_current(1);
        // ... Draw channel 1
        channels.set_current(0);
        // ... Draw channel 0
    });
}
source§

impl<'ui> DrawListMut<'ui>

Drawing functions

source

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

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

source

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

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 add_rect<C>( &'ui self, p1: impl Into<Vector2<f32>>, p2: impl Into<Vector2<f32>>, 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<Vector2<f32>>, p2: impl Into<Vector2<f32>>, 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 rectangle whose upper-left corner is at point p1 and lower-right corner is at point p2. The remains parameters are the respective color of the corners in the counter-clockwise starting from the upper-left corner first.

source

pub fn add_triangle<C>( &'ui self, p1: impl Into<Vector2<f32>>, p2: impl Into<Vector2<f32>>, p3: impl Into<Vector2<f32>>, 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_circle<C>( &'ui self, center: impl Into<Vector2<f32>>, radius: f32, color: C ) -> Circle<'ui>where C: Into<ImColor32>,

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

source

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

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

source

pub fn add_bezier_curve( &'ui self, pos0: impl Into<Vector2<f32>>, cp0: impl Into<Vector2<f32>>, cp1: impl Into<Vector2<f32>>, pos1: impl Into<Vector2<f32>>, 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 with_clip_rect<F>( &self, min: impl Into<Vector2<f32>>, max: impl Into<Vector2<f32>>, f: F )where F: FnOnce(),

Push a clipping rectangle on the stack, run f and pop it.

Clip all drawings done within the closure f in the given rectangle.

source

pub fn with_clip_rect_intersect<F>( &self, min: impl Into<Vector2<f32>>, max: impl Into<Vector2<f32>>, f: F )where F: FnOnce(),

Push a clipping rectangle on the stack, run f and pop it.

Clip all drawings done within the closure f in the given rectangle. Intersect with all clipping rectangle previously on the stack.

source§

impl<'ui> DrawListMut<'ui>

source

pub fn add_image( &'ui self, texture_id: TextureId, p_min: impl Into<Vector2<f32>>, p_max: impl Into<Vector2<f32>> ) -> Image<'_>

Draw the specified image in the rect specified by p_min to p_max.

Examples
fn custom_button(ui: &Ui, img_id: TextureId) {
    // Invisible button is good widget to customise with image
    ui.invisible_button("custom_button", [100.0, 20.0]);

    // Get draw list and draw image over invisible button
    let draw_list = ui.get_window_draw_list();
    draw_list
        .add_image(img_id, ui.item_rect_min(), ui.item_rect_max())
        .build();
}
source

pub fn add_image_quad( &'ui self, texture_id: TextureId, p1: impl Into<Vector2<f32>>, p2: impl Into<Vector2<f32>>, p3: impl Into<Vector2<f32>>, p4: impl Into<Vector2<f32>> ) -> ImageQuad<'_>

Draw the specified image to a quad with the specified coordinates. Similar to DrawListMut::add_image but this method is able to draw non-rectangle images.

source

pub fn add_image_rounded( &'ui self, texture_id: TextureId, p_min: impl Into<Vector2<f32>>, p_max: impl Into<Vector2<f32>>, rounding: f32 ) -> ImageRounded<'_>

Draw the speciied image, with rounded corners

source

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

Draw the specified callback.

Note: if this DrawList is never rendered the callback will leak because DearImGui does not provide a method to clean registered callbacks.

Trait Implementations§

source§

impl<'ui> Drop for DrawListMut<'ui>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.