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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use crate::{
    c::{c_float, spAttachment, spPathAttachment, spVertexAttachment},
    c_interface::{NewFromPtr, SyncPtr},
};

/// An attachment of vertices forming a Bezier curve.
///
/// [Spine API Reference](http://esotericsoftware.com/spine-api-reference#PathAttachment)
#[derive(Debug)]
pub struct PathAttachment {
    c_path_attachment: SyncPtr<spPathAttachment>,
}

impl NewFromPtr<spPathAttachment> for PathAttachment {
    unsafe fn new_from_ptr(c_path_attachment: *mut spPathAttachment) -> Self {
        Self {
            c_path_attachment: SyncPtr(c_path_attachment),
        }
    }
}

impl PathAttachment {
    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_bool_mut!(
        /// If `true, the start and end knots are connected.
        closed,
        /// Set closed, see [`closed`](`Self::closed`).
        set_closed,
        closed
    );
    c_accessor_color_mut!(
        /// The color of the path as it was in Spine, or a default color if nonessential data was
        /// not exported. Paths are not usually rendered at runtime.
        color,
        color_mut,
        color
    );
    c_accessor_bool_mut!(
        /// If `true`, additional calculations are performed to make computing positions along the
        /// path more accurate and movement along the path have a constant speed.
        constant_speed,
        set_constant_speed,
        constantSpeed
    );
    // TODO: do not use passthrough
    c_accessor_passthrough!(
        /// The lengths along the path in the setup pose from the start of the path to the end of
        /// each Bezier curve.
        lengths,
        lengths,
        *mut c_float
    );
    c_ptr!(c_path_attachment, spPathAttachment);
}

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