-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
42 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,22 @@ | ||
use super::*; | ||
use objc::{ | ||
runtime::{Class, Object}, | ||
*, | ||
}; | ||
use std::ptr::{addr_of_mut, null_mut}; | ||
|
||
#[link(name = "AppKit", kind = "framework")] | ||
extern "C" { | ||
#[link_name = "OBJC_CLASS_$_NSColor"] | ||
static OBJC_CLASS__NSColor: Class; | ||
|
||
#[link_name = "OBJC_CLASS_$_NSColorSpace"] | ||
static OBJC_CLASS__NSColorSpace: Class; | ||
} | ||
use objc2_app_kit::{NSColor, NSColorSpace}; | ||
use std::ptr::null_mut; | ||
|
||
pub fn accent() -> Option<Color> { | ||
unsafe { | ||
let accent: *mut Object = msg_send![&OBJC_CLASS__NSColor, controlAccentColor]; | ||
let color_space: *mut Object = msg_send![&OBJC_CLASS__NSColorSpace, genericRGBColorSpace]; | ||
let accent: *mut Object = msg_send![accent, colorUsingColorSpace: color_space]; | ||
let mut r: f64 = 0.0; | ||
let mut g: f64 = 0.0; | ||
let mut b: f64 = 0.0; | ||
let _: () = msg_send![accent, getRed:addr_of_mut!(r) green:addr_of_mut!(g) blue:addr_of_mut!(b) alpha:null_mut::<f64>()]; | ||
Some(Color { | ||
r: (r * 255.0) as u8, | ||
g: (g * 255.0) as u8, | ||
b: (b * 255.0) as u8, | ||
let accent = NSColor::controlAccentColor(); | ||
let color_space = NSColorSpace::genericRGBColorSpace(); | ||
let accent = accent.colorUsingColorSpace(&color_space); | ||
accent.map(|accent| { | ||
let mut r: f64 = 0.0; | ||
let mut g: f64 = 0.0; | ||
let mut b: f64 = 0.0; | ||
accent.getRed_green_blue_alpha(&mut r, &mut g, &mut b, null_mut()); | ||
Color { | ||
r: (r * 255.0) as u8, | ||
g: (g * 255.0) as u8, | ||
b: (b * 255.0) as u8, | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters