use std::{cmp::Ordering, fmt, hash::Hash, sync::Arc};
mod component;
pub mod compose;
pub mod drag;
mod engine;
mod event;
mod focus;
pub mod geometry;
mod hover;
mod modal;
#[derive(Clone)]
pub enum ChildId {
Static(&'static str),
Dynamic(Arc<str>),
}
impl ChildId {
#[must_use]
pub fn as_str(&self) -> &str {
match self {
Self::Static(id) => id,
Self::Dynamic(id) => id,
}
}
}
impl From<&'static str> for ChildId {
fn from(id: &'static str) -> Self {
Self::Static(id)
}
}
impl From<String> for ChildId {
fn from(id: String) -> Self {
Self::Dynamic(Arc::from(id))
}
}
impl From<Arc<str>> for ChildId {
fn from(id: Arc<str>) -> Self {
Self::Dynamic(id)
}
}
impl From<&ChildId> for ChildId {
fn from(id: &ChildId) -> Self {
id.clone()
}
}
impl PartialEq for ChildId {
fn eq(&self, other: &Self) -> bool {
self.as_str() == other.as_str()
}
}
impl Eq for ChildId {}
impl PartialOrd for ChildId {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for ChildId {
fn cmp(&self, other: &Self) -> Ordering {
self.as_str().cmp(other.as_str())
}
}
impl Hash for ChildId {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.as_str().hash(state);
}
}
impl PartialEq<&str> for ChildId {
fn eq(&self, other: &&str) -> bool {
self.as_str() == *other
}
}
impl PartialEq<ChildId> for &str {
fn eq(&self, other: &ChildId) -> bool {
*self == other.as_str()
}
}
impl AsRef<str> for ChildId {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl fmt::Debug for ChildId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.as_str().fmt(f)
}
}
impl fmt::Display for ChildId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.as_str().fmt(f)
}
}
pub use component::{
Component, EventCtx, EventResult, MeasuredComponent, Painter, PopupOptions, PreparedComponent,
RenderCtx, ScopeOptions, Step,
};
pub use compose::{BodyFn, BodySlot, ChildSlots};
pub use drag::{CellOffset, DragOptions, DragPhase, clamp_offset, offset_rect};
pub use engine::Ratcn;
#[cfg(all(target_arch = "wasm32", feature = "ratzilla"))]
pub use event::BrowserEventError;
pub(crate) use event::MouseTracker;
pub use event::{
Event, KeyChord, KeyCode, KeyEvent, Modifiers, MouseButton, MouseEvent, MouseKind,
ScrollDirection, Unsupported,
};
pub use focus::{FocusState, TabWrap};
pub use geometry::{is_border, wrapped_height};
pub use hover::HoverState;
pub use modal::{ModalOpenError, ModalState};