use a variable instead of a fn for hard-coded check
This commit is contained in:
parent
c984005e9b
commit
1b8a399ebd
1 changed files with 23 additions and 22 deletions
|
|
@ -1,5 +1,27 @@
|
||||||
use winit::window::{CursorIcon, ResizeDirection};
|
use winit::window::{CursorIcon, ResizeDirection};
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
all(
|
||||||
|
unix,
|
||||||
|
not(target_vendor = "apple"),
|
||||||
|
not(target_os = "android"),
|
||||||
|
not(target_os = "emscripten"),
|
||||||
|
),
|
||||||
|
target_os = "windows",
|
||||||
|
))]
|
||||||
|
const DRAG_RESIZE_SUPPORTED: bool = true;
|
||||||
|
|
||||||
|
#[cfg(not(any(
|
||||||
|
all(
|
||||||
|
unix,
|
||||||
|
not(target_vendor = "apple"),
|
||||||
|
not(target_os = "android"),
|
||||||
|
not(target_os = "emscripten"),
|
||||||
|
),
|
||||||
|
target_os = "windows",
|
||||||
|
)))]
|
||||||
|
const DRAG_RESIZE_SUPPORTED: bool = false;
|
||||||
|
|
||||||
/// If supported by winit, returns a closure that implements cursor resize support.
|
/// If supported by winit, returns a closure that implements cursor resize support.
|
||||||
pub fn event_func(
|
pub fn event_func(
|
||||||
window: &dyn winit::window::Window,
|
window: &dyn winit::window::Window,
|
||||||
|
|
@ -12,7 +34,7 @@ pub fn event_func(
|
||||||
) -> bool,
|
) -> bool,
|
||||||
>,
|
>,
|
||||||
> {
|
> {
|
||||||
if drag_resize_supported() {
|
if DRAG_RESIZE_SUPPORTED {
|
||||||
// Keep track of cursor when it is within a resizeable border.
|
// Keep track of cursor when it is within a resizeable border.
|
||||||
let mut cursor_prev_resize_direction = None;
|
let mut cursor_prev_resize_direction = None;
|
||||||
|
|
||||||
|
|
@ -62,27 +84,6 @@ pub fn event_func(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test if the current target should be assumed to have winit drag_resize support
|
|
||||||
const fn drag_resize_supported() -> bool {
|
|
||||||
#[cfg(all(
|
|
||||||
unix,
|
|
||||||
not(target_vendor = "apple"),
|
|
||||||
not(target_os = "android"),
|
|
||||||
not(target_os = "emscripten")
|
|
||||||
))]
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(unreachable_code)]
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the cursor icon that corresponds to the resize direction.
|
/// Get the cursor icon that corresponds to the resize direction.
|
||||||
fn resize_direction_cursor_icon(
|
fn resize_direction_cursor_icon(
|
||||||
resize_direction: Option<ResizeDirection>,
|
resize_direction: Option<ResizeDirection>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue