use crate::event::PhysicalKey;
#[allow(unused)] use crate::event::{EventCx, EventState};
use crate::geom::Offset;
use crate::window::icon::Icon;
use std::any::{Any, TypeId};
use std::fmt::Debug;
#[derive(Copy, Clone, Debug)]
pub struct Activate(pub Option<PhysicalKey>);
#[derive(Copy, Clone, Debug)]
pub struct IncrementStep;
#[derive(Copy, Clone, Debug)]
pub struct DecrementStep;
#[derive(Copy, Clone, Debug)]
pub struct SetValueF64(pub f64);
#[derive(Clone, Debug)]
pub struct SetValueText(pub String);
#[derive(Clone, Debug)]
pub struct ReplaceSelectedText(pub String);
#[derive(Clone, Debug)]
pub struct SetIndex(pub usize);
#[derive(Clone, Debug)]
pub struct Expand;
#[derive(Clone, Debug)]
pub struct Collapse;
#[derive(Clone, Debug)]
pub struct Select;
#[derive(Clone, Debug)]
pub struct SetScrollOffset(pub Offset);
#[derive(Clone, Debug)]
pub struct SetWindowTitle(pub String);
#[derive(Clone, Debug)]
pub struct SetWindowIcon(pub Option<Icon>);
trait AnyDebug: Any + Debug {}
impl<T: Any + Debug> AnyDebug for T {}
#[derive(Debug)]
pub struct Erased(Box<dyn AnyDebug>, bool);
impl Erased {
pub fn new<V: Any + Debug>(v: V) -> Self {
Erased(Box::new(v), false)
}
pub fn is<T: 'static>(&self) -> bool {
(&*self.0 as &dyn Any).is::<T>()
}
pub fn type_id(&self) -> TypeId {
(&*self.0 as &dyn Any).type_id()
}
pub fn downcast<T: 'static>(self) -> Result<Box<T>, Box<dyn Any>> {
(self.0 as Box<dyn Any>).downcast::<T>()
}
pub fn downcast_ref<T: 'static>(&self) -> Option<&T> {
(&*self.0 as &dyn Any).downcast_ref::<T>()
}
pub(crate) fn debug(&self) -> &dyn Debug {
&self.0
}
pub(crate) fn set_sent(&mut self) {
self.1 = true;
}
pub(crate) fn is_sent(&self) -> bool {
self.1
}
}
trait AnySendDebug: AnyDebug + Send {}
impl<T: Any + Send + Debug> AnySendDebug for T {}
#[derive(Debug)]
pub(crate) struct SendErased(Box<dyn AnySendDebug>);
impl SendErased {
pub fn new<V: Any + Send + Debug>(v: V) -> Self {
SendErased(Box::new(v))
}
pub fn into_erased(self) -> Erased {
Erased(self.0, false)
}
}