From 7cebd0cc44692b724149a186354ab3d2d1ca22f0 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 1 Aug 2023 16:16:35 +0200 Subject: [PATCH] Make CGFloat invisible to outside crates --- examples/raytracing/renderer.rs | 2 +- src/lib.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/raytracing/renderer.rs b/examples/raytracing/renderer.rs index 2522a3c..84aa8f8 100644 --- a/examples/raytracing/renderer.rs +++ b/examples/raytracing/renderer.rs @@ -265,7 +265,7 @@ impl Renderer { frame_index: 0, uniform_buffer_index: 0, uniform_buffer_offset: 0, - size: CGSize::new(1024 as CGFloat, 1024 as CGFloat), + size: CGSize::new(1024.0, 1024.0), semaphore: Semaphore::new((MAX_FRAMES_IN_FLIGHT - 2) as usize), instance_buffer, queue, diff --git a/src/lib.rs b/src/lib.rs index 4999076..802580b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,8 +29,8 @@ use std::{ }; use foreign_types::ForeignType; -pub(crate) use icrate::Foundation::NSRange; -pub use icrate::Foundation::{CGFloat, NSSize as CGSize}; +pub use icrate::Foundation::NSSize as CGSize; +pub(crate) use icrate::Foundation::{CGFloat, NSRange}; pub(crate) use objc2::encode::{Encode, Encoding, RefEncode}; use objc2::runtime::{AnyObject, Bool, Protocol}; @@ -498,11 +498,13 @@ impl MetalLayerRef { unsafe { msg_send![self, nextDrawable] } } - pub fn contents_scale(&self) -> CGFloat { - unsafe { msg_send![self, contentsScale] } + pub fn contents_scale(&self) -> f64 { + let res: CGFloat = unsafe { msg_send![self, contentsScale] }; + res as f64 } - pub fn set_contents_scale(&self, scale: CGFloat) { + pub fn set_contents_scale(&self, scale: f64) { + let scale = scale as CGFloat; unsafe { msg_send![self, setContentsScale: scale] } }