Update objc2 version (#2936)

* Upgrade to objc2 v0.4.0 and icrate v0.0.3

* Fix `touchBar` method

* Use ClassType::alloc

* Use #[method_id(...)] functionality in declare_class!
This commit is contained in:
Mads Marquart 2023-07-29 00:33:03 +02:00 committed by GitHub
parent ae7497e18f
commit e33d2bee6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 815 additions and 793 deletions

View file

@ -2,10 +2,10 @@ use std::ffi::c_void;
use std::num::NonZeroIsize;
use std::ptr;
use objc2::foundation::{NSObject, NSPoint, NSRect};
use objc2::rc::{Id, Shared};
use icrate::Foundation::{NSObject, NSPoint, NSRect};
use objc2::rc::Id;
use objc2::runtime::Object;
use objc2::{extern_class, extern_methods, msg_send_id, ClassType};
use objc2::{extern_class, extern_methods, mutability, ClassType};
use super::{NSCursor, NSResponder, NSTextInputContext, NSWindow};
@ -16,6 +16,7 @@ extern_class!(
unsafe impl ClassType for NSView {
#[inherits(NSObject)]
type Super = NSResponder;
type Mutability = mutability::InteriorMutable;
}
);
@ -31,47 +32,45 @@ extern_class!(
extern_methods!(
/// Getter methods
unsafe impl NSView {
#[sel(frame)]
#[method(frame)]
pub fn frame(&self) -> NSRect;
#[sel(bounds)]
#[method(bounds)]
pub fn bounds(&self) -> NSRect;
#[method_id(inputContext)]
pub fn inputContext(
&self,
// _mtm: MainThreadMarker,
) -> Option<Id<NSTextInputContext, Shared>> {
unsafe { msg_send_id![self, inputContext] }
}
) -> Option<Id<NSTextInputContext>>;
#[sel(visibleRect)]
#[method(visibleRect)]
pub fn visibleRect(&self) -> NSRect;
#[sel(hasMarkedText)]
#[method(hasMarkedText)]
pub fn hasMarkedText(&self) -> bool;
#[sel(convertPoint:fromView:)]
#[method(convertPoint:fromView:)]
pub fn convertPoint_fromView(&self, point: NSPoint, view: Option<&NSView>) -> NSPoint;
pub fn window(&self) -> Option<Id<NSWindow, Shared>> {
unsafe { msg_send_id![self, window] }
}
#[method_id(window)]
pub fn window(&self) -> Option<Id<NSWindow>>;
}
unsafe impl NSView {
#[sel(setWantsBestResolutionOpenGLSurface:)]
#[method(setWantsBestResolutionOpenGLSurface:)]
pub fn setWantsBestResolutionOpenGLSurface(&self, value: bool);
#[sel(setWantsLayer:)]
#[method(setWantsLayer:)]
pub fn setWantsLayer(&self, wants_layer: bool);
#[sel(setPostsFrameChangedNotifications:)]
#[method(setPostsFrameChangedNotifications:)]
pub fn setPostsFrameChangedNotifications(&self, value: bool);
#[sel(removeTrackingRect:)]
#[method(removeTrackingRect:)]
pub fn removeTrackingRect(&self, tag: NSTrackingRectTag);
#[sel(addTrackingRect:owner:userData:assumeInside:)]
#[method(addTrackingRect:owner:userData:assumeInside:)]
unsafe fn inner_addTrackingRect(
&self,
rect: NSRect,
@ -86,11 +85,11 @@ extern_methods!(
.expect("failed creating tracking rect")
}
#[sel(addCursorRect:cursor:)]
#[method(addCursorRect:cursor:)]
// NSCursor safe to take by shared reference since it is already immutable
pub fn addCursorRect(&self, rect: NSRect, cursor: &NSCursor);
#[sel(setHidden:)]
#[method(setHidden:)]
pub fn setHidden(&self, hidden: bool);
}
);