Add "DrawList" prefix to Image/ImageQuad/ImageRounded

Also make their constructions public just in case it leads to neater code in some circumstances
This commit is contained in:
dbr 2021-02-20 20:00:25 +11:00
parent b3a50e6928
commit 1a55b4ae24

View File

@ -309,8 +309,8 @@ impl<'ui> DrawListMut<'ui> {
/// .build(); /// .build();
/// } /// }
/// ``` /// ```
pub fn add_image(&'ui self, texture_id: TextureId, p_min: [f32; 2], p_max: [f32; 2]) -> Image { pub fn add_image(&'ui self, texture_id: TextureId, p_min: [f32; 2], p_max: [f32; 2]) -> DrawListImage {
Image::new(self, texture_id, p_min, p_max) DrawListImage::new(self, texture_id, p_min, p_max)
} }
/// Draw the specified image to a quad with the specified /// Draw the specified image to a quad with the specified
@ -323,8 +323,8 @@ impl<'ui> DrawListMut<'ui> {
p2: [f32; 2], p2: [f32; 2],
p3: [f32; 2], p3: [f32; 2],
p4: [f32; 2], p4: [f32; 2],
) -> ImageQuad { ) -> DrawListImageQuad {
ImageQuad::new(self, texture_id, p1, p2, p3, p4) DrawListImageQuad::new(self, texture_id, p1, p2, p3, p4)
} }
/// Draw the speciied image, with rounded corners /// Draw the speciied image, with rounded corners
@ -334,8 +334,8 @@ impl<'ui> DrawListMut<'ui> {
p_min: [f32; 2], p_min: [f32; 2],
p_max: [f32; 2], p_max: [f32; 2],
rounding: f32, rounding: f32,
) -> ImageRounded { ) -> DrawListImageRounded {
ImageRounded::new(self, texture_id, p_min, p_max, rounding) DrawListImageRounded::new(self, texture_id, p_min, p_max, rounding)
} }
} }
@ -696,7 +696,7 @@ impl<'ui> BezierCurve<'ui> {
/// Represents a image about to be drawn /// Represents a image about to be drawn
#[must_use = "should call .build() to draw the object"] #[must_use = "should call .build() to draw the object"]
pub struct Image<'ui> { pub struct DrawListImage<'ui> {
texture_id: TextureId, texture_id: TextureId,
p_min: [f32; 2], p_min: [f32; 2],
p_max: [f32; 2], p_max: [f32; 2],
@ -706,8 +706,9 @@ pub struct Image<'ui> {
draw_list: &'ui DrawListMut<'ui>, draw_list: &'ui DrawListMut<'ui>,
} }
impl<'ui> Image<'ui> { impl<'ui> DrawListImage<'ui> {
fn new( /// Typically constructed by [`DrawListMut::add_image`]
pub fn new(
draw_list: &'ui DrawListMut, draw_list: &'ui DrawListMut,
texture_id: TextureId, texture_id: TextureId,
p_min: [f32; 2], p_min: [f32; 2],
@ -764,7 +765,7 @@ impl<'ui> Image<'ui> {
/// Represents a image about to be drawn /// Represents a image about to be drawn
#[must_use = "should call .build() to draw the object"] #[must_use = "should call .build() to draw the object"]
pub struct ImageQuad<'ui> { pub struct DrawListImageQuad<'ui> {
texture_id: TextureId, texture_id: TextureId,
p1: [f32; 2], p1: [f32; 2],
p2: [f32; 2], p2: [f32; 2],
@ -778,8 +779,9 @@ pub struct ImageQuad<'ui> {
draw_list: &'ui DrawListMut<'ui>, draw_list: &'ui DrawListMut<'ui>,
} }
impl<'ui> ImageQuad<'ui> { impl<'ui> DrawListImageQuad<'ui> {
fn new( /// Typically constructed by [`DrawListMut::add_image_quad`]
pub fn new(
draw_list: &'ui DrawListMut, draw_list: &'ui DrawListMut,
texture_id: TextureId, texture_id: TextureId,
p1: [f32; 2], p1: [f32; 2],
@ -849,9 +851,10 @@ impl<'ui> ImageQuad<'ui> {
} }
} }
/// Represents a image about to be drawn /// Represents a image about to be drawn. Similar to [`DrawListImage`] but
/// with corners rounded with a given radius
#[must_use = "should call .build() to draw the object"] #[must_use = "should call .build() to draw the object"]
pub struct ImageRounded<'ui> { pub struct DrawListImageRounded<'ui> {
texture_id: TextureId, texture_id: TextureId,
p_min: [f32; 2], p_min: [f32; 2],
p_max: [f32; 2], p_max: [f32; 2],
@ -863,8 +866,9 @@ pub struct ImageRounded<'ui> {
draw_list: &'ui DrawListMut<'ui>, draw_list: &'ui DrawListMut<'ui>,
} }
impl<'ui> ImageRounded<'ui> { impl<'ui> DrawListImageRounded<'ui> {
fn new( /// Typically constructed by [`DrawListMut::add_image_rounded`]
pub fn new(
draw_list: &'ui DrawListMut, draw_list: &'ui DrawListMut,
texture_id: TextureId, texture_id: TextureId,
p_min: [f32; 2], p_min: [f32; 2],