Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Adds an additional display function + bumps core-foundation dependency version #87

Merged
merged 3 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -12,6 +12,6 @@ default = []
elcapitan = []

[dependencies]
libc = "0.2"
core-foundation = "0.3"
bitflags = "0.9"
core-foundation = "0.4"
libc = "0.2"
1 change: 1 addition & 0 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}
}