Refactor macOS cursor code (#2463)

This commit is contained in:
Mads Marquart 2022-09-02 21:02:40 +02:00 committed by GitHub
parent e517e468f8
commit 29419d6c38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 352 additions and 222 deletions

View file

@ -1,7 +1,7 @@
use objc2::foundation::NSObject;
use objc2::{extern_class, ClassType};
use objc2::foundation::{NSObject, NSRect};
use objc2::{extern_class, extern_methods, ClassType};
use super::NSResponder;
use super::{NSCursor, NSResponder};
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
@ -12,3 +12,17 @@ extern_class!(
type Super = NSResponder;
}
);
extern_methods!(
/// Getter methods
unsafe impl NSView {
#[sel(bounds)]
pub fn bounds(&self) -> NSRect;
}
unsafe impl NSView {
#[sel(addCursorRect:cursor:)]
// NSCursor safe to take by shared reference since it is already immutable
pub fn addCursorRect(&self, rect: NSRect, cursor: &NSCursor);
}
);