Skip to content

Commit

Permalink
document mint impls
Browse files Browse the repository at this point in the history
  • Loading branch information
jabuwu committed Oct 24, 2022
1 parent 9d99a38 commit ce45ae8
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 25 deletions.
2 changes: 2 additions & 0 deletions src/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ pub mod atlas {
c_ptr!(c_atlas_page, spAtlasPage);
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl AtlasPage {
pub fn size(&self) -> Vector2<i32> {
Expand Down Expand Up @@ -367,6 +368,7 @@ pub mod atlas {
}
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl AtlasRegion {
pub fn position(&self) -> Vector2<i32> {
Expand Down
45 changes: 23 additions & 22 deletions src/bone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,6 @@ impl Bone {
}
}

#[cfg(feature = "mint")]
pub fn update_world_transform_with2(
&mut self,
position: mint::Vector2<f32>,
rotation: f32,
scale: mint::Vector2<f32>,
shear: mint::Vector2<f32>,
) {
unsafe {
spBone_updateWorldTransformWith(
self.c_ptr(),
position.x,
position.y,
rotation,
scale.x,
scale.y,
shear.x,
shear.y,
);
}
}

pub fn update_applied_transform(&mut self) {
unsafe {
spBone_updateAppliedTransform(self.c_ptr());
Expand Down Expand Up @@ -243,6 +221,7 @@ impl Bone {
c_ptr!(c_bone, spBone);
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl Bone {
pub fn position(&self) -> Vector2<f32> {
Expand Down Expand Up @@ -349,6 +328,27 @@ impl Bone {
y: self.world_rotation_y(),
}
}

pub fn update_world_transform_with2(
&mut self,
position: mint::Vector2<f32>,
rotation: f32,
scale: mint::Vector2<f32>,
shear: mint::Vector2<f32>,
) {
unsafe {
spBone_updateWorldTransformWith(
self.c_ptr(),
position.x,
position.y,
rotation,
scale.x,
scale.y,
shear.x,
shear.y,
);
}
}
}

c_handle_decl!(
Expand Down Expand Up @@ -411,6 +411,7 @@ impl BoneData {
c_accessor_tmp_ptr_optional!(parent, parent_mut, parent, BoneData, spBoneData);
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl BoneData {
pub fn position(&self) -> Vector2<f32> {
Expand Down
6 changes: 6 additions & 0 deletions src/bounding_box_attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ impl BoundingBoxAttachment {
c_accessor_color!(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!();
}
9 changes: 6 additions & 3 deletions src/c_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,13 @@ macro_rules! c_vertex_attachment_accessors {
verticesCount
);

// TODO: accessor for timelineAttachment
};
}

macro_rules! c_vertex_attachment_accessors_mint {
() => {
/// Gets the vertices of the attachment as a Vector2 slice.
#[cfg(feature = "mint")]
pub fn vertices2(&self) -> &[mint::Vector2<f32>] {
unsafe {
std::slice::from_raw_parts(
Expand All @@ -777,8 +782,6 @@ macro_rules! c_vertex_attachment_accessors {
.unwrap()
}
}

// TODO: accessor for timelineAttachment
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/mesh_attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl MeshAttachment {
// TODO: sequence accessor
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl MeshAttachment {
pub fn size(&self) -> Vector2<f32> {
Expand All @@ -78,4 +79,6 @@ impl MeshAttachment {
y: self.height(),
}
}

c_vertex_attachment_accessors_mint!();
}
6 changes: 6 additions & 0 deletions src/path_attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ impl PathAttachment {
c_accessor_passthrough!(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!();
}
1 change: 1 addition & 0 deletions src/point_attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl PointAttachment {
c_ptr!(c_point_attachment, spPointAttachment);
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl PointAttachment {
pub fn position(&self) -> Vector2<f32> {
Expand Down
1 change: 1 addition & 0 deletions src/region_attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl RegionAttachment {
// TODO: sequence accessor
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl RegionAttachment {
pub fn position(&self) -> Vector2<f32> {
Expand Down
1 change: 1 addition & 0 deletions src/skeleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ impl Skeleton {
c_ptr!(c_skeleton, spSkeleton);
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl Skeleton {
pub fn position(&self) -> Vector2<f32> {
Expand Down
1 change: 1 addition & 0 deletions src/skeleton_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl SkeletonData {
// TODO: accessors and methods for the arrays in spSkeletonData
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl SkeletonData {
pub fn position(&self) -> Vector2<f32> {
Expand Down
1 change: 1 addition & 0 deletions src/texture_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl TextureRegion {
c_ptr!(c_texture_region, spTextureRegion);
}

/// Functions available if using the `mint` feature.
#[cfg(feature = "mint")]
impl TextureRegion {
pub fn uvs(&self) -> (Vector2<f32>, Vector2<f32>) {
Expand Down

0 comments on commit ce45ae8

Please sign in to comment.