Merge Window::set_cursor_icon() and Window::set_custom_cursor() (#3308)
This commit is contained in:
parent
34dd2cdba9
commit
be4a660011
17 changed files with 165 additions and 159 deletions
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
platform_impl, SendSyncWrapper,
|
||||
};
|
||||
|
||||
pub use crate::cursor::{BadImage, CustomCursor, CustomCursorBuilder, MAX_CURSOR_SIZE};
|
||||
pub use crate::cursor::{BadImage, Cursor, CustomCursor, CustomCursorBuilder, MAX_CURSOR_SIZE};
|
||||
pub use crate::icon::{BadIcon, Icon};
|
||||
|
||||
#[doc(inline)]
|
||||
|
|
@ -1336,30 +1336,17 @@ impl Window {
|
|||
/// Cursor functions.
|
||||
impl Window {
|
||||
/// Modifies the cursor icon of the window.
|
||||
/// Overwrites cursors set in [`Window::set_custom_cursor`].
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **iOS / Android / Orbital:** Unsupported.
|
||||
/// - **Web:** Custom cursors have to be loaded and decoded first, until
|
||||
/// then the previous cursor is shown.
|
||||
#[inline]
|
||||
pub fn set_cursor_icon(&self, cursor: CursorIcon) {
|
||||
pub fn set_cursor(&self, cursor: impl Into<Cursor>) {
|
||||
let cursor = cursor.into();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_cursor_icon(cursor))
|
||||
}
|
||||
|
||||
/// Modifies the cursor icon of the window with a custom cursor.
|
||||
/// Overwrites cursors set in [`Window::set_cursor_icon`].
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **iOS / Android / Orbital:** Unsupported.
|
||||
/// - **Web:** Cursor have to be loaded and decoded first, which introduces
|
||||
/// a delay until cursors are shown.
|
||||
#[inline]
|
||||
pub fn set_custom_cursor(&self, cursor: &CustomCursor) {
|
||||
let cursor = cursor.inner.clone();
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_custom_cursor(cursor))
|
||||
.maybe_queue_on_main(move |w| w.set_cursor(cursor))
|
||||
}
|
||||
|
||||
/// Changes the position of the cursor in window coordinates.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue