diff --git a/Cargo.toml b/Cargo.toml index dae4dc4..88c95e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "core-graphics" description = "Bindings to Core Graphics for OS X" homepage = "https://github.com/servo/core-graphics-rs" repository = "https://github.com/servo/core-graphics-rs" -version = "0.8.2" +version = "0.9.0" authors = ["The Servo Project Developers"] license = "MIT / Apache-2.0" @@ -12,6 +12,6 @@ default = [] elcapitan = [] [dependencies] -libc = "0.2" -core-foundation = "0.3" bitflags = "0.9" +core-foundation = "0.4" +libc = "0.2" diff --git a/src/display.rs b/src/display.rs index 5328737..e398730 100644 --- a/src/display.rs +++ b/src/display.rs @@ -76,6 +76,7 @@ extern { pub fn CGDisplayPixelsHigh(display: CGDirectDisplayID) -> libc::size_t; pub fn CGDisplayPixelsWide(display: CGDirectDisplayID) -> libc::size_t; pub fn CGDisplayBounds(display: CGDirectDisplayID) -> CGRect; + pub fn CGDisplayCreateImage(display: CGDirectDisplayID) -> CGImageRef; // mouse stuff pub fn CGDisplayHideCursor(display: CGDirectDisplayID) -> CGError; diff --git a/src/geometry.rs b/src/geometry.rs index 9497fbb..9f165b2 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -85,6 +85,22 @@ impl CGRect { Some(rect) } } + + #[inline] + pub fn is_empty(&self) -> bool { + unsafe { + // I use one, as it seems that `YES` is not available from this crate. + ffi::CGRectIsEmpty(*self) == 1 + } + } + + #[inline] + pub fn is_intersects(&self, other: &CGRect) -> bool { + unsafe { + // I use one, as it seems that `YES` is not available from this crate. + ffi::CGRectIntersectsRect(*self, *other) == 1 + } + } } mod ffi { @@ -97,6 +113,8 @@ mod ffi { pub fn CGRectInset(rect: CGRect, dx: CGFloat, dy: CGFloat) -> CGRect; pub fn CGRectMakeWithDictionaryRepresentation(dict: CFDictionaryRef, rect: *mut CGRect) -> boolean_t; + pub fn CGRectIsEmpty(rect: CGRect) -> boolean_t; + pub fn CGRectIntersectsRect(rect1: CGRect, rect2: CGRect) -> boolean_t; } }