#![allow(clippy::needless_doctest_main)]
#![doc(html_favicon_url = "https://raw.githubusercontent.com/zng-ui/zng/main/examples/image/res/zng-logo-icon.png")]
#![doc(html_logo_url = "https://raw.githubusercontent.com/zng-ui/zng/main/examples/image/res/zng-logo.png")]
#![warn(unused_extern_crates)]
#![warn(missing_docs)]
#[doc(hidden)]
#[allow(unused_extern_crates)]
extern crate self as zng;
#[doc(hidden)]
pub use zng_app::__proc_macro_util;
pub use zng_clone_move::{async_clmv, async_clmv_fn, async_clmv_fn_once, clmv};
pub mod access;
pub mod ansi_text;
pub mod app;
pub mod button;
pub mod checkerboard;
pub mod clipboard;
pub mod color;
pub mod config;
pub mod container;
pub mod data_context;
pub mod data_view;
pub mod dialog;
pub mod env;
pub mod event;
pub mod focus;
pub mod font;
pub mod fs_watcher;
pub mod gesture;
pub mod grid;
pub mod handler;
pub mod hot_reload;
pub mod icon;
pub mod image;
pub mod keyboard;
pub mod l10n;
pub mod label;
pub mod layer;
pub mod layout;
pub mod markdown;
pub mod menu;
pub mod mouse;
pub mod panel;
pub mod pointer_capture;
pub mod popup;
pub mod render;
pub mod rule_line;
pub mod scroll;
pub mod selectable;
pub mod stack;
pub mod state_map;
pub mod style;
pub mod task;
pub mod text;
pub mod text_input;
pub mod third_party;
pub mod timer;
pub mod tip;
pub mod toggle;
pub mod touch;
pub mod undo;
pub mod update;
pub mod var;
pub mod view_process;
pub mod widget;
pub mod window;
pub mod wrap;
pub struct APP;
impl std::ops::Deref for APP {
type Target = zng_app::APP;
fn deref(&self) -> &Self::Target {
&zng_app::APP
}
}
pub mod prelude {
#[doc(no_inline)]
pub use crate::__prelude::*;
}
mod __prelude {
pub use crate::APP;
pub use crate::{color, gesture, keyboard, layout, mouse, task, timer, touch, widget};
pub use zng_task::rayon::prelude::{
FromParallelIterator as _, IndexedParallelIterator as _, IntoParallelIterator as _, IntoParallelRefIterator as _,
IntoParallelRefMutIterator as _, ParallelBridge as _, ParallelDrainFull as _, ParallelDrainRange as _, ParallelExtend as _,
ParallelIterator as _, ParallelSlice as _, ParallelSliceMut as _, ParallelString as _,
};
pub use zng_task::io::{
AsyncBufRead as _, AsyncRead as _, AsyncReadExt as _, AsyncSeek as _, AsyncSeekExt as _, AsyncWrite as _, AsyncWriteExt as _,
};
#[allow(deprecated)]
pub use zng_app::widget::node::UiNodeVec;
pub use zng_app::{
event::{AnyEventArgs as _, CommandInfoExt as _, CommandNameExt as _, CommandParam, EventArgs as _},
handler::{app_hn, app_hn_once, async_app_hn, async_app_hn_once, async_hn, async_hn_once, hn, hn_once},
shortcut::{shortcut, CommandShortcutExt as _},
widget::{
easing,
node::{ui_vec, UiNode, UiNodeList, UiNodeListChain as _, UiVec},
AnyVarSubscribe as _, VarLayout as _, VarSubscribe as _, WidgetId, WIDGET,
},
window::{WindowId, WINDOW},
INSTANT,
};
pub use zng_app::widget::inspector::WidgetInfoInspectorExt as _;
pub use zng_var::{
context_var, expr_var, getter_var, merge_var, state_var, var, var_from, when_var, AnyVar as _, AnyWeakVar as _, IntoValue, IntoVar,
Var, VarValue, WeakVar as _,
};
pub use crate::var::animation::easing;
pub use zng_layout::unit::{
Align, AngleUnits as _, ByteUnits as _, DipToPx as _, FactorUnits as _, Layout1d as _, Layout2d as _, Length, LengthUnits as _,
LineFromTuplesBuilder as _, PxToDip as _, RectFromTuplesBuilder as _, ResolutionUnits as _, TimeUnits as _,
};
pub use zng_txt::{formatx, ToTxt as _, Txt};
pub use zng_clone_move::{async_clmv, async_clmv_fn, async_clmv_fn_once, clmv};
pub use zng_color::{colors, hex, hsl, hsla, hsv, hsva, light_dark, rgb, rgba, web_colors, LightDarkVarExt as _, MixAdjust as _};
pub use zng_ext_clipboard::CLIPBOARD;
pub use zng_ext_config::CONFIG;
pub use zng_ext_font::{FontStretch, FontStyle, FontWeight};
pub use zng_ext_image::ImageSource;
pub use zng_wgt_image::Image;
pub use zng_ext_input::{
focus::{cmd::CommandFocusExt as _, iter::IterFocusableExt as _, WidgetInfoFocusExt as _, FOCUS},
gesture::{CommandShortcutMatchesExt as _, HeadlessAppGestureExt as _},
keyboard::HeadlessAppKeyboardExt as _,
mouse::WidgetInfoMouseExt as _,
};
pub use zng_ext_l10n::{l10n, lang, L10N};
pub use zng_wgt_text::lang;
pub use zng_ext_undo::{CommandUndoExt as _, REDO_CMD, UNDO, UNDO_CMD};
pub use zng_ext_window::{
AppRunWindowExt as _, HeadlessAppWindowExt as _, WINDOW_Ext as _, WidgetInfoImeArea as _, WindowCloseRequestedArgs, WindowIcon,
WINDOWS,
};
pub use zng_wgt::{CommandIconExt as _, Wgt, ICONS};
pub use crate::text;
pub use zng_wgt_text::Text;
pub use zng_wgt_text_input::{selectable::SelectableText, TextInput};
pub use crate::window;
pub use zng_wgt_window::Window;
pub use zng_wgt_container::Container;
pub use zng_wgt_button::Button;
pub use zng_wgt_data::{data, DATA};
pub use crate::grid;
pub use zng_wgt_grid::Grid;
pub use crate::layer;
pub use zng_wgt_layer::{AnchorMode, LayerIndex, LAYERS};
pub use crate::popup;
pub use zng_wgt_layer::popup::POPUP;
pub use crate::menu;
pub use zng_wgt_menu::{
context::{context_menu, context_menu_fn, ContextMenu},
sub::SubMenu,
Menu,
};
pub use zng_wgt_rule_line::hr::Hr;
pub use zng_wgt_scroll::{Scroll, SCROLL};
pub use crate::toggle;
pub use zng_wgt_toggle::Toggle;
pub use crate::tip;
pub use zng_wgt_tooltip::{tooltip, tooltip_fn, Tip};
pub use zng_wgt::{wgt_fn, WidgetFn};
pub use zng_wgt_style::{style_fn, Style};
pub use zng_wgt_stack::{Stack, StackDirection};
pub use zng_wgt_wrap::Wrap;
pub use zng_wgt_data_view::{DataView, DataViewArgs};
pub use zng_wgt_settings::SettingBuilderEditorExt as _;
pub use crate::dialog;
pub use zng_wgt_dialog::DIALOG;
}
pub mod prelude_wgt {
#[doc(no_inline)]
pub use crate::__prelude_wgt::*;
}
mod __prelude_wgt {
#[allow(deprecated)]
pub use zng_app::widget::node::UiNodeVec;
pub use zng_app::{
event::{
command, event, event_args, AnyEventArgs as _, Command, CommandHandle, CommandInfoExt as _, CommandNameExt as _, CommandParam,
Event, EventArgs as _, EventHandle, EventHandles, EventPropagationHandle,
},
handler::{app_hn, app_hn_once, async_app_hn, async_app_hn_once, async_hn, async_hn_once, hn, hn_once, AppHandler, WidgetHandler},
render::{FrameBuilder, FrameUpdate, FrameValue, FrameValueKey, FrameValueUpdate, SpatialFrameId, TransformStyle},
shortcut::{shortcut, CommandShortcutExt as _, Shortcut, ShortcutFilter, Shortcuts},
timer::{DeadlineHandle, DeadlineVar, TimerHandle, TimerVar, TIMERS},
update::{EventUpdate, UpdateDeliveryList, UpdateOp, WidgetUpdates, UPDATES},
widget::{
base::{WidgetBase, WidgetImpl},
border::{BorderSides, BorderStyle, CornerRadius, CornerRadiusFit, LineOrientation, LineStyle, BORDER},
builder::{property_id, NestGroup, WidgetBuilder, WidgetBuilding},
easing,
info::{
InteractionPath, Interactivity, Visibility, WidgetBorderInfo, WidgetBoundsInfo, WidgetInfo, WidgetInfoBuilder,
WidgetLayout, WidgetMeasure, WidgetPath,
},
node::{
match_node, match_node_leaf, match_node_list, match_node_typed, match_widget, ui_vec, ArcNode, ArcNodeList, BoxedUiNode,
BoxedUiNodeList, EditableUiNodeList, EditableUiNodeListRef, FillUiNode, NilUiNode, PanelList, SortingList, UiNode,
UiNodeList, UiNodeListChain as _, UiNodeListObserver, UiNodeOp, UiVec, ZIndex, SORTING_LIST,
},
property, ui_node, widget, widget_impl, widget_mixin, widget_set, AnyVarSubscribe as _, VarLayout as _, VarSubscribe as _,
WidgetId, WidgetUpdateMode, WIDGET,
},
window::{MonitorId, WindowId, WINDOW},
DInstant, Deadline, INSTANT,
};
pub use zng_var::{
context_var, expr_var, getter_var, impl_from_and_into_var, merge_var, response_done_var, response_var, state_var, var, when_var,
AnyVar as _, AnyWeakVar as _, ArcVar, BoxedVar, ContextVar, IntoValue, IntoVar, LocalVar, ReadOnlyArcVar, ResponderVar,
ResponseVar, Var, VarCapability, VarHandle, VarHandles, VarValue, WeakVar as _,
};
pub use zng_layout::{
context::{LayoutDirection, LayoutMetrics, DIRECTION_VAR, LAYOUT},
unit::{
Align, AngleDegree, AngleGradian, AngleRadian, AngleUnits as _, ByteUnits as _, Dip, DipBox, DipPoint, DipRect, DipSideOffsets,
DipSize, DipToPx as _, DipVector, Factor, Factor2d, FactorPercent, FactorSideOffsets, FactorUnits as _, Layout1d as _,
Layout2d as _, LayoutAxis, Length, LengthUnits as _, Line, LineFromTuplesBuilder as _, Point, Px, PxBox, PxConstraints,
PxConstraints2d, PxCornerRadius, PxLine, PxPoint, PxRect, PxSideOffsets, PxSize, PxToDip as _, PxTransform, PxVector, Rect,
RectFromTuplesBuilder as _, ResolutionUnits as _, SideOffsets, Size, TimeUnits as _, Transform, Vector,
},
};
pub use zng_txt::{formatx, ToTxt as _, Txt};
pub use zng_clone_move::{async_clmv, async_clmv_fn, async_clmv_fn_once, clmv};
pub use crate::task;
pub use zng_app_context::{app_local, context_local, CaptureFilter, ContextLocal, ContextValueSet, LocalContext, RunOnDrop};
pub use crate::state_map;
pub use zng_state_map::{static_id, OwnedStateMap, StateId, StateMapMut, StateMapRef};
pub use zng_wgt::prelude::{IdEntry, IdMap, IdSet};
pub use zng_wgt::{wgt_fn, WidgetFn};
pub use zng_color::{
colors, gradient, hex, hsl, hsla, hsv, hsva, light_dark, rgb, rgba, web_colors, ColorScheme, Hsla, Hsva, LightDark, MixAdjust as _,
MixBlendMode, Rgba,
};
pub use zng_wgt::node::{
bind_state, border_node, command_property, event_property, event_state, event_state2, event_state3, event_state4, fill_node,
list_presenter, presenter, presenter_opt, widget_state_get_state, widget_state_is_state, with_context_blend, with_context_local,
with_context_local_init, with_context_var, with_context_var_init, with_widget_state, with_widget_state_modify,
};
pub use zng_ext_window::WidgetInfoBuilderImeArea as _;
#[cfg(hot_reload)]
pub use crate::hot_reload::hot_node;
}
mod defaults {
use zng_app::{AppExtended, AppExtension};
use zng_ext_clipboard::ClipboardManager;
use zng_ext_config::ConfigManager;
use zng_ext_font::FontManager;
use zng_ext_fs_watcher::FsWatcherManager;
use zng_ext_image::ImageManager;
use zng_ext_input::{
focus::FocusManager, gesture::GestureManager, keyboard::KeyboardManager, mouse::MouseManager,
pointer_capture::PointerCaptureManager, touch::TouchManager,
};
use zng_ext_l10n::L10nManager;
use zng_ext_undo::UndoManager;
use zng_ext_window::WindowManager;
use crate::default_editors;
#[cfg(feature = "dyn_app_extension")]
macro_rules! DefaultsAppExtended {
() => {
AppExtended<Vec<Box<dyn zng_app::AppExtensionBoxed>>>
}
}
#[cfg(not(feature = "dyn_app_extension"))]
macro_rules! DefaultsAppExtended {
() => {
AppExtended<impl AppExtension>
}
}
impl super::APP {
pub fn defaults(&self) -> DefaultsAppExtended![] {
let r = self
.minimal()
.extend(FsWatcherManager::default())
.extend(ConfigManager::default())
.extend(L10nManager::default())
.extend(PointerCaptureManager::default())
.extend(MouseManager::default())
.extend(TouchManager::default())
.extend(KeyboardManager::default())
.extend(GestureManager::default())
.extend(WindowManager::default())
.extend(FontManager::default())
.extend(FocusManager::default())
.extend(ImageManager::default())
.extend(ClipboardManager::default())
.extend(UndoManager::default());
#[cfg(all(view, view_prebuilt))]
tracing::debug!(r#"both "view" and "view_prebuilt" enabled, will use only one, indeterminate witch"#);
#[cfg(single_instance)]
let r = r.extend(zng_ext_single_instance::SingleInstanceManager::default());
#[cfg(hot_reload)]
let r = r.extend(zng_ext_hot_reload::HotReloadManager::default());
#[cfg(any(
feature = "material_icons_outlined",
feature = "material_icons_filled",
feature = "material_icons_rounded",
feature = "material_icons_sharp",
))]
let r = r.extend(zng_wgt_material_icons::MaterialIconsManager);
r.extend(DefaultsInit {})
}
}
struct DefaultsInit {}
impl AppExtension for DefaultsInit {
fn init(&mut self) {
zng_wgt::EDITORS.register_fallback(zng_wgt::WidgetFn::new(default_editors::handler));
tracing::debug!("defaults init, var_editor set");
zng_ext_window::WINDOWS.register_root_extender(|a| {
let child = a.root;
#[cfg(feature = "inspector")]
let child = zng_wgt_inspector::inspector(child, zng_wgt_inspector::live_inspector(true));
child
});
tracing::debug!("defaults init, root_extender set");
#[cfg(any(target_os = "android", target_os = "ios"))]
{
zng_ext_window::WINDOWS.register_open_nested_handler(crate::window::default_mobile_nested_open_handler);
tracing::debug!("defaults init, open_nested_handler set");
}
crate::third_party::setup_default_view();
tracing::debug!("defaults init, third_party set");
zng_wgt_settings::handle_settings_cmd();
tracing::debug!("defaults init, settings set");
#[cfg(single_instance)]
{
crate::app::APP_INSTANCE_EVENT
.on_pre_event(crate::handler::app_hn!(|args: &crate::app::AppInstanceArgs, _| {
use crate::window::*;
if !args.is_current() && WINDOWS.focused_window_id().is_none() {
for w in WINDOWS.widget_trees() {
if w.is_rendered()
&& WINDOWS.mode(w.window_id()) == Ok(WindowMode::Headed)
&& WINDOWS.focus(w.window_id()).is_ok()
{
break;
}
}
}
}))
.perm();
tracing::debug!("defaults init, single_instance set");
}
}
fn deinit(&mut self) {
#[cfg(all(view_prebuilt, any(target_os = "macos", target_os = "ios")))]
if std::env::var("=").is_ok() {
crate::view_process::prebuilt::run_same_process(|| unreachable!());
}
}
}
}
#[doc = include_str!("../../README.md")]
#[cfg(doctest)]
pub mod read_me_test {}
mod default_editors {
use zng::{
prelude::*,
text_input,
widget::{
node::{BoxedUiNode, NilUiNode},
EditorRequestArgs,
},
};
pub fn handler(args: EditorRequestArgs) -> BoxedUiNode {
if let Some(txt) = args.value::<Txt>() {
return TextInput! {
txt;
}
.boxed();
}
if let Some(s) = args.value::<String>() {
return TextInput! {
txt = s.map_bidi(|s| Txt::from_str(s), |t: &Txt| t.to_string());
}
.boxed();
}
if let Some(c) = args.value::<char>() {
return TextInput! {
txt_parse::<char> = c;
style_fn = text_input::FieldStyle!();
}
.boxed();
}
if let Some(checked) = args.value::<bool>() {
return Toggle! {
style_fn = toggle::CheckStyle!();
checked;
}
.boxed();
}
macro_rules! parse {
($($ty:ty),+ $(,)?) => {
$(
if let Some(n) = args.value::<$ty>() {
return TextInput! {
txt_parse::<$ty> = n;
style_fn = text_input::FieldStyle!();
}
.boxed();
}
)+
}
}
parse! {
u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, f32, f64,
}
NilUiNode.boxed()
}
}