mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 23:01:30 +11:00
Add mouse hiding and more cursors for Cocoa
This commit is contained in:
parent
677e69fd3a
commit
e294441049
|
@ -630,30 +630,29 @@ impl Window {
|
||||||
|
|
||||||
pub fn set_cursor(&self, cursor: MouseCursor) {
|
pub fn set_cursor(&self, cursor: MouseCursor) {
|
||||||
let cursor_name = match cursor {
|
let cursor_name = match cursor {
|
||||||
MouseCursor::Arrow => "arrowCursor",
|
MouseCursor::Arrow | MouseCursor::Default => "arrowCursor",
|
||||||
|
MouseCursor::Hand => "pointingHandCursor",
|
||||||
|
MouseCursor::Grabbing | MouseCursor::Grab => "closedHandCursor",
|
||||||
MouseCursor::Text => "IBeamCursor",
|
MouseCursor::Text => "IBeamCursor",
|
||||||
MouseCursor::ContextMenu => "contextualMenuCursor",
|
MouseCursor::VerticalText => "IBeamCursorForVerticalLayout",
|
||||||
MouseCursor::Copy => "dragCopyCursor",
|
MouseCursor::Copy => "dragCopyCursor",
|
||||||
MouseCursor::Crosshair => "crosshairCursor",
|
|
||||||
MouseCursor::Default => "arrowCursor",
|
|
||||||
MouseCursor::Grabbing => "openHandCursor",
|
|
||||||
MouseCursor::Hand | MouseCursor::Grab => "pointingHandCursor",
|
|
||||||
MouseCursor::NoDrop => "operationNotAllowedCursor",
|
|
||||||
MouseCursor::NotAllowed => "operationNotAllowedCursor",
|
|
||||||
MouseCursor::Alias => "dragLinkCursor",
|
MouseCursor::Alias => "dragLinkCursor",
|
||||||
|
MouseCursor::NotAllowed | MouseCursor::NoDrop => "operationNotAllowedCursor",
|
||||||
|
MouseCursor::ContextMenu => "contextualMenuCursor",
|
||||||
/// Resize cursors
|
MouseCursor::Crosshair => "crosshairCursor",
|
||||||
MouseCursor::EResize | MouseCursor::NResize |
|
MouseCursor::EResize => "resizeRightCursor",
|
||||||
MouseCursor::NeResize | MouseCursor::NwResize |
|
MouseCursor::NResize => "resizeUpCursor",
|
||||||
MouseCursor::SResize | MouseCursor::SeResize |
|
MouseCursor::WResize => "resizeLeftCursor",
|
||||||
MouseCursor::SwResize | MouseCursor::WResize |
|
MouseCursor::SResize => "resizeDownCursor",
|
||||||
MouseCursor::EwResize | MouseCursor::ColResize |
|
MouseCursor::EwResize | MouseCursor::ColResize => "resizeLeftRightCursor",
|
||||||
MouseCursor::NsResize | MouseCursor::RowResize |
|
MouseCursor::NsResize | MouseCursor::RowResize => "resizeUpDownCursor",
|
||||||
MouseCursor::NwseResize | MouseCursor::NeswResize => "arrowCursor",
|
|
||||||
|
|
||||||
/// TODO: Find appropriate OSX cursors
|
/// TODO: Find appropriate OSX cursors
|
||||||
MouseCursor::Cell | MouseCursor::VerticalText | MouseCursor::NoneCursor |
|
MouseCursor::NeResize | MouseCursor::NwResize |
|
||||||
|
MouseCursor::SeResize | MouseCursor::SwResize |
|
||||||
|
MouseCursor::NwseResize | MouseCursor::NeswResize |
|
||||||
|
|
||||||
|
MouseCursor::Cell | MouseCursor::NoneCursor |
|
||||||
MouseCursor::Wait | MouseCursor::Progress | MouseCursor::Help |
|
MouseCursor::Wait | MouseCursor::Progress | MouseCursor::Help |
|
||||||
MouseCursor::Move | MouseCursor::AllScroll | MouseCursor::ZoomIn |
|
MouseCursor::Move | MouseCursor::AllScroll | MouseCursor::ZoomIn |
|
||||||
MouseCursor::ZoomOut => "arrowCursor",
|
MouseCursor::ZoomOut => "arrowCursor",
|
||||||
|
@ -668,7 +667,20 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
||||||
unimplemented!();
|
let cls = Class::get("NSCursor").unwrap();
|
||||||
|
match state {
|
||||||
|
CursorState::Normal => {
|
||||||
|
let _: () = unsafe { msg_send![cls, unhide] };
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
CursorState::Hide => {
|
||||||
|
let _: () = unsafe { msg_send![cls, hide] };
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
CursorState::Grab => {
|
||||||
|
Err("Mouse grabbing is unimplemented".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
|
|
Loading…
Reference in a new issue