pub const SUB_EVENT: &str = "on_event";
pub const SUB_KEY_PRESS: &str = "on_key_press";
pub const SUB_KEY_RELEASE: &str = "on_key_release";
pub const SUB_MODIFIERS_CHANGED: &str = "on_modifiers_changed";
pub const SUB_POINTER_MOVE: &str = "on_pointer_move";
pub const SUB_POINTER_BUTTON: &str = "on_pointer_button";
pub const SUB_POINTER_SCROLL: &str = "on_pointer_scroll";
pub const SUB_POINTER_TOUCH: &str = "on_pointer_touch";
pub const SUB_IME: &str = "on_ime";
pub const SUB_WINDOW_EVENT: &str = "on_window_event";
pub const SUB_WINDOW_OPEN: &str = "on_window_open";
pub const SUB_WINDOW_CLOSE: &str = "on_window_close";
pub const SUB_WINDOW_MOVE: &str = "on_window_move";
pub const SUB_WINDOW_RESIZE: &str = "on_window_resize";
pub const SUB_WINDOW_FOCUS: &str = "on_window_focus";
pub const SUB_WINDOW_UNFOCUS: &str = "on_window_unfocus";
pub const SUB_FILE_DROP: &str = "on_file_drop";
pub const SUB_ANIMATION_FRAME: &str = "on_animation_frame";
pub const SUB_THEME_CHANGE: &str = "on_theme_change";
pub const DEFAULT_WINDOW_TITLE: &str = "Plushie";
pub const DEFAULT_THEME: iced::Theme = iced::Theme::Dark;
pub const MAX_FONT_BYTES: usize = 16 * 1024 * 1024;
pub const MAX_LOADED_FONTS: u32 = 256;
pub static LOADED_FONT_COUNT: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
pub fn try_reserve_font_slot() -> bool {
use std::sync::atomic::Ordering;
let mut current = LOADED_FONT_COUNT.load(Ordering::Relaxed);
loop {
if current >= MAX_LOADED_FONTS {
return false;
}
match LOADED_FONT_COUNT.compare_exchange(
current,
current + 1,
Ordering::Relaxed,
Ordering::Relaxed,
) {
Ok(_) => return true,
Err(actual) => current = actual,
}
}
}