1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::{
    c::{spAttachment, spBoundingBoxAttachment, spVertexAttachment},
    c_interface::{NewFromPtr, SyncPtr},
};

/// An attachment made up of vertices for use in collision detection, hitboxes, etc.
///
/// [Spine API Reference](http://esotericsoftware.com/spine-api-reference#BoundingBoxAttachment)
#[derive(Debug)]
pub struct BoundingBoxAttachment {
    c_bounding_box_attachment: SyncPtr<spBoundingBoxAttachment>,
}

impl NewFromPtr<spBoundingBoxAttachment> for BoundingBoxAttachment {
    unsafe fn new_from_ptr(c_bounding_box_attachment: *mut spBoundingBoxAttachment) -> Self {
        Self {
            c_bounding_box_attachment: SyncPtr(c_bounding_box_attachment),
        }
    }
}

impl BoundingBoxAttachment {
    fn attachment(&self) -> &spAttachment {
        unsafe { &self.c_ptr_ref().super_0.super_0 }
    }

    fn vertex_attachment(&self) -> &spVertexAttachment {
        unsafe { &self.c_ptr_ref().super_0 }
    }

    c_attachment_accessors!();
    c_vertex_attachment_accessors!();
    c_accessor_color!(
        /// The color of the bounding box as it was in Spine, or a default color if nonessential
        /// data was not exported. Bounding boxes are not usually rendered at runtime.
        color,
        color
    );
    c_ptr!(c_bounding_box_attachment, spBoundingBoxAttachment);
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl BoundingBoxAttachment {
    c_vertex_attachment_accessors_mint!();
}