WIP
This commit is contained in:
parent
426aeb7c5e
commit
27a80a1c94
4 changed files with 27 additions and 25 deletions
|
@ -125,6 +125,7 @@ impl Event {
|
||||||
button,
|
button,
|
||||||
position: vec2f(
|
position: vec2f(
|
||||||
native_event.locationInWindow().x as f32,
|
native_event.locationInWindow().x as f32,
|
||||||
|
// MacOS screen coordinates are relative to bottom left
|
||||||
window_height - native_event.locationInWindow().y as f32,
|
window_height - native_event.locationInWindow().y as f32,
|
||||||
),
|
),
|
||||||
modifiers: read_modifiers(native_event),
|
modifiers: read_modifiers(native_event),
|
||||||
|
@ -150,6 +151,7 @@ impl Event {
|
||||||
button,
|
button,
|
||||||
position: vec2f(
|
position: vec2f(
|
||||||
native_event.locationInWindow().x as f32,
|
native_event.locationInWindow().x as f32,
|
||||||
|
// MacOS view coordinates are relative to bottom left
|
||||||
window_height - native_event.locationInWindow().y as f32,
|
window_height - native_event.locationInWindow().y as f32,
|
||||||
),
|
),
|
||||||
modifiers: read_modifiers(native_event),
|
modifiers: read_modifiers(native_event),
|
||||||
|
|
|
@ -697,27 +697,20 @@ impl platform::Platform for MacPlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_cursor_style(&self, style: CursorStyle, window_id: usize, screen_position: &Vector2F) {
|
fn set_cursor_style(&self, style: CursorStyle, window_id: usize, screen_position: &Vector2F) {
|
||||||
let top_most = Window::window_id_under(screen_position);
|
if Some(window_id) == Window::window_id_under(screen_position) {
|
||||||
if top_most.is_none() {
|
dbg!(screen_position, style);
|
||||||
return;
|
unsafe {
|
||||||
}
|
let cursor: id = match style {
|
||||||
if top_most.unwrap() != window_id {
|
CursorStyle::Arrow => msg_send![class!(NSCursor), arrowCursor],
|
||||||
return;
|
CursorStyle::ResizeLeftRight => {
|
||||||
}
|
msg_send![class!(NSCursor), resizeLeftRightCursor]
|
||||||
|
}
|
||||||
dbg!(top_most.unwrap(), window_id);
|
CursorStyle::ResizeUpDown => msg_send![class!(NSCursor), resizeUpDownCursor],
|
||||||
|
CursorStyle::PointingHand => msg_send![class!(NSCursor), pointingHandCursor],
|
||||||
dbg!(style);
|
CursorStyle::IBeam => msg_send![class!(NSCursor), IBeamCursor],
|
||||||
|
};
|
||||||
unsafe {
|
let _: () = msg_send![cursor, set];
|
||||||
let cursor: id = match style {
|
}
|
||||||
CursorStyle::Arrow => msg_send![class!(NSCursor), arrowCursor],
|
|
||||||
CursorStyle::ResizeLeftRight => msg_send![class!(NSCursor), resizeLeftRightCursor],
|
|
||||||
CursorStyle::ResizeUpDown => msg_send![class!(NSCursor), resizeUpDownCursor],
|
|
||||||
CursorStyle::PointingHand => msg_send![class!(NSCursor), pointingHandCursor],
|
|
||||||
CursorStyle::IBeam => msg_send![class!(NSCursor), IBeamCursor],
|
|
||||||
};
|
|
||||||
let _: () = msg_send![cursor, set];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ use std::{
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::geometry::Vector2FExt;
|
||||||
|
|
||||||
const WINDOW_STATE_IVAR: &str = "windowState";
|
const WINDOW_STATE_IVAR: &str = "windowState";
|
||||||
|
|
||||||
static mut WINDOW_CLASS: *const Class = ptr::null();
|
static mut WINDOW_CLASS: *const Class = ptr::null();
|
||||||
|
@ -564,11 +566,13 @@ impl Window {
|
||||||
unsafe {
|
unsafe {
|
||||||
let app = NSApplication::sharedApplication(nil);
|
let app = NSApplication::sharedApplication(nil);
|
||||||
|
|
||||||
let point = NSPoint::new(screen_position.x() as f64, screen_position.y() as f64);
|
let point = screen_position.to_ns_point();
|
||||||
let window_number: NSInteger = msg_send![class!(NSWindow), windowNumberAtPoint:point belowWindowWithWindowNumber:0 as NSInteger];
|
let window_number: NSInteger = msg_send![class!(NSWindow), windowNumberAtPoint:point belowWindowWithWindowNumber:0];
|
||||||
|
|
||||||
// For some reason this API doesn't work when our two windows are on top of each other
|
// For some reason this API doesn't work when our two windows are on top of each other
|
||||||
let top_most_window: id = msg_send![app, windowWithWindowNumber: window_number];
|
let top_most_window: id = msg_send![app, windowWithWindowNumber: window_number];
|
||||||
dbg!(top_most_window);
|
|
||||||
|
// dbg!(top_most_window);
|
||||||
let is_panel: BOOL = msg_send![top_most_window, isKindOfClass: PANEL_CLASS];
|
let is_panel: BOOL = msg_send![top_most_window, isKindOfClass: PANEL_CLASS];
|
||||||
let is_window: BOOL = msg_send![top_most_window, isKindOfClass: WINDOW_CLASS];
|
let is_window: BOOL = msg_send![top_most_window, isKindOfClass: WINDOW_CLASS];
|
||||||
if is_panel | is_window {
|
if is_panel | is_window {
|
||||||
|
@ -779,7 +783,7 @@ impl platform::Window for Window {
|
||||||
fn screen_position(&self, view_position: &Vector2F) -> Vector2F {
|
fn screen_position(&self, view_position: &Vector2F) -> Vector2F {
|
||||||
let self_borrow = self.0.borrow_mut();
|
let self_borrow = self.0.borrow_mut();
|
||||||
unsafe {
|
unsafe {
|
||||||
let point = NSPoint::new(view_position.x() as f64, view_position.y() as f64);
|
let point = view_position.to_ns_point();
|
||||||
let screen_point: NSPoint =
|
let screen_point: NSPoint =
|
||||||
msg_send![self_borrow.native_window, convertPointToScreen: point];
|
msg_send![self_borrow.native_window, convertPointToScreen: point];
|
||||||
vec2f(screen_point.x as f32, screen_point.y as f32)
|
vec2f(screen_point.x as f32, screen_point.y as f32)
|
||||||
|
|
|
@ -317,6 +317,9 @@ impl Presenter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbg!("*******");
|
||||||
|
dbg!(position);
|
||||||
|
dbg!(event_reused);
|
||||||
if let Some(screen_position) = cx.screen_position(self.window_id, position) {
|
if let Some(screen_position) = cx.screen_position(self.window_id, position) {
|
||||||
cx.platform().set_cursor_style(
|
cx.platform().set_cursor_style(
|
||||||
style_to_assign,
|
style_to_assign,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue