refactored window storage;

new helper window events (Destroyed, Created);
clippy + fmt;
This commit is contained in:
Bingus 2023-07-12 19:21:05 -07:00
parent 633f405f3f
commit d53ccc857d
No known key found for this signature in database
GPG key ID: 5F84D2AA40A9F170
56 changed files with 1508 additions and 1819 deletions

View file

@ -1,18 +1,17 @@
use std::collections::hash_map::DefaultHasher;
use std::fmt::{Display, Formatter};
use std::hash::{Hash, Hasher};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
/// The ID of the window.
/// The id of the window.
///
/// Internally Iced uses `window::Id::MAIN` as the first window spawned.
/// Internally Iced reserves `window::Id::MAIN` for the first window spawned.
pub struct Id(u64);
impl Id {
/// The reserved window ID for the primary window in an Iced application.
/// The reserved window [`Id`] for the first window in an Iced application.
pub const MAIN: Self = Id(0);
/// Creates a new unique window ID.
/// Creates a new unique window [`Id`].
pub fn new(id: impl Hash) -> Id {
let mut hasher = DefaultHasher::new();
id.hash(&mut hasher);
@ -20,9 +19,3 @@ impl Id {
Id(hasher.finish())
}
}
impl Display for Id {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "Id({})", self.0)
}
}