Struct imgui::draw_list::DrawListMut [−][src]
pub struct DrawListMut<'ui> { /* fields omitted */ }
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
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
});
}
Drawing functions
Returns a line from point p1
to p2
with color c
.
Returns a rectangle whose upper-left corner is at point p1
and lower-right corner is at point p2
, with color c
.
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.
Returns a triangle with the given 3 vertices p1
, p2
and p3
and color c
.
Returns a circle with the given center
, radius
and color
.
Draw a text whose upper-left corner is at point pos
.
Returns a Bezier curve stretching from pos0
to pos1
, whose
curvature is defined by cp0
and cp1
.
Push a clipping rectangle on the stack, run f
and pop it.
Clip all drawings done within the closure f
in the given
rectangle.
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(im_str!("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();
}
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.