#![recursion_limit = "256"]
pub mod anim;
pub mod icons;
pub mod kinetic;
mod layout;
pub mod model;
mod outline;
pub mod path;
mod render;
mod runtime;
pub mod source;
mod text;
mod theme;
mod widget;
pub mod widgets;
pub use anim::Animated;
pub use path::{Path, Shape};
#[cfg(not(target_arch = "wasm32"))]
pub use render::gpu;
pub use render::{Bitmap, Color, Pixels, Rect, Shadow, hdr};
pub use runtime::task::{Notifier, Sleep, sleep};
pub use source::{Cache, Latest, cached, polled};
#[cfg(not(target_arch = "wasm32"))]
pub use source::{Wanted, blocking};
pub use wgpu;
#[doc(hidden)]
pub use runtime::{Bench, GpuBench, insets, snapshot};
pub use taffy;
pub use text::{Font, Text, TextLayout};
pub use theme::{Ink, Role, Theme};
pub use web_time::Instant;
pub use widget::{
BuildCx, Element, Event, EventCx, Focus, Handle, Key, Keyboard, Layer, OnChange, PaintCx,
Placement, Scope, State, Widget,
};
#[cfg(doctest)]
#[doc = include_str!("../README.md")]
struct ReadmeDoctests;
#[cfg(doctest)]
#[doc = include_str!("../docs/icons.md")]
struct IconsDoctests;
pub trait App: 'static {
fn view(&self) -> Element;
fn theme(&self) -> Theme {
Theme::default()
}
fn background(&self) -> Color {
self.theme().background
}
fn title(&self) -> String {
"dfui".into()
}
fn fullscreen(&self) -> bool {
false
}
fn zoom(&self) -> f32 {
1.0
}
fn hdr(&self) -> bool {
false
}
}
impl<F: Fn() -> Element + 'static> App for F {
fn view(&self) -> Element {
self()
}
}
pub fn run<A: App>(app: A) {
#[cfg(target_arch = "wasm32")]
std::panic::set_hook(Box::new(|p| {
web_sys::console::error_1(&p.to_string().into())
}));
let event_loop = winit::event_loop::EventLoop::new()
.unwrap_or_else(|e| runtime::startup_failed(&format!("can't start the event loop: {e}")));
runtime::Runtime::new(app).run(event_loop);
}
#[cfg(target_os = "android")]
pub use runtime::android;
#[cfg(target_os = "android")]
pub use winit::platform::android::activity::AndroidApp;
#[cfg(target_os = "android")]
pub fn run_android<A: App>(app: A, android: AndroidApp) {
runtime::activity::run(runtime::Runtime::new(app), android);
}