1mod app;
5mod buffer;
6pub use buffer::BufferStats;
7#[doc(hidden)]
8pub mod branch;
9mod builders;
10mod control;
11pub mod each;
12pub use each::{Each, EachBuilder, each};
13mod input;
14mod plan;
15pub use plan::{Plan, PlanInstance, PlanPart, plan};
16pub mod list;
17pub use app::{App, Error, Mounted, Result, Scope, Settle, UiStats, WeakScope, Widget};
18pub use builders::*;
19pub use control::{When, when};
20pub use glory_render::{
21 Current, DismissReason, Event, EventKind, FieldPart, FocusMode, FormAction, FormControl,
22 GridCommand, InputAssist, InputAutofill, InputEdit, InputEditCapture, InputEditIntent,
23 InputEditRejection, InputMode, ItemPosition, Layer, LayerPlacement, LinkOpen, Navigation,
24 NavigationPanel, NavigationPanelCommand, Orientation, Purpose, RangeCommand, RangeValue, Role,
25 ScrollAxes, ScrollCommand, ScrollMetrics, ScrollMovement, SelectionDirection, SemanticId,
26 Semantics, SliderValue, SpinValue, TextKind, TextSelection,
27};
28pub use list::{List, list};
29
30impl<W: Widget> Widget for Option<W> {
31 fn is_empty(&self) -> bool {
32 self.is_none()
33 }
34 fn compose(&mut self, _: &glory_core::Scope) -> Result<Option<Box<dyn Widget>>> {
35 Ok(self.take().map(|value| Box::new(value) as Box<dyn Widget>))
36 }
37}
38
39#[doc(hidden)]
41pub struct Missing;
42
43pub struct Deferred<F>(Option<F>);
45pub fn defer<F, W>(factory: F) -> Deferred<F>
46where
47 F: FnOnce() -> W + 'static,
48 W: Widget,
49{
50 Deferred(Some(factory))
51}
52impl<F, W> Widget for Deferred<F>
53where
54 F: FnOnce() -> W + 'static,
55 W: Widget,
56{
57 fn compose(&mut self, _: &glory_core::Scope) -> Result<Option<Box<dyn Widget>>> {
58 let factory = self.0.take().ok_or(Error::Gone)?;
59 Ok(Some(Box::new(factory())))
60 }
61}
62
63impl<W: Widget + ?Sized> Widget for Box<W> {
64 fn is_empty(&self) -> bool {
65 (**self).is_empty()
66 }
67 fn compose(&mut self, scope: &glory_core::Scope) -> Result<Option<Box<dyn Widget>>> {
68 (**self).compose(scope)
69 }
70 fn native_host(&self) -> Option<std::any::TypeId> {
71 (**self).native_host()
72 }
73 fn mount_host(
74 &mut self,
75 scope: &glory_core::Scope,
76 host: &mut dyn std::any::Any,
77 ) -> Result<bool> {
78 (**self).mount_host(scope, host)
79 }
80 fn static_plan(&mut self) -> Result<Plan> {
81 (**self).static_plan()
82 }
83 fn build(&mut self, scope: &Scope) -> Result {
84 (**self).build(scope)
85 }
86}