#![expect(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 drag_drop;
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 progress;
pub mod render;
pub mod rule_line;
pub mod scroll;
pub mod selectable;
pub mod slider;
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 _,
};
pub use zng_app::{
INSTANT,
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::{CommandShortcutExt as _, shortcut},
widget::{
AnyVarSubscribe as _, VarLayout as _, VarSubscribe as _, WIDGET, WidgetId, easing,
node::{UiNode, UiNodeList, UiNodeListChain as _, UiVec, ui_vec},
},
window::{WINDOW, WindowId},
};
pub use zng_app::widget::inspector::WidgetInfoInspectorExt as _;
pub use zng_var::{
AnyVar as _, AnyWeakVar as _, IntoValue, IntoVar, Var, VarValue, WeakVar as _, context_var, expr_var, getter_var, merge_var,
state_var, var, var_from, when_var,
};
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::{ToTxt as _, Txt, formatx};
pub use zng_clone_move::{async_clmv, async_clmv_fn, async_clmv_fn_once, clmv};
pub use zng_color::{LightDarkVarExt as _, MixAdjust as _, colors, hex, hsl, hsla, hsv, hsva, light_dark, rgb, rgba, web_colors};
#[cfg(feature = "clipboard")]
pub use zng_ext_clipboard::CLIPBOARD;
#[cfg(feature = "config")]
pub use zng_ext_config::CONFIG;
pub use zng_ext_font::{FontStretch, FontStyle, FontWeight};
#[cfg(feature = "image")]
pub use zng_ext_image::ImageSource;
#[cfg(feature = "image")]
pub use zng_wgt_image::Image;
pub use zng_ext_input::{
focus::{FOCUS, WidgetInfoFocusExt as _, cmd::CommandFocusExt as _, iter::IterFocusableExt as _},
gesture::{CommandShortcutMatchesExt as _, HeadlessAppGestureExt as _},
keyboard::HeadlessAppKeyboardExt as _,
mouse::WidgetInfoMouseExt as _,
};
pub use zng_ext_l10n::{L10N, l10n, lang};
pub use zng_wgt_text::lang;
#[cfg(feature = "undo")]
pub use zng_ext_undo::{CommandUndoExt as _, REDO_CMD, UNDO, UNDO_CMD};
#[cfg(feature = "window")]
pub use zng_ext_window::{
AppRunWindowExt as _, HeadlessAppWindowExt as _, WINDOW_Ext as _, WINDOWS, WidgetInfoImeArea as _, WindowCloseRequestedArgs,
WindowIcon,
};
pub use zng_wgt::{CommandIconExt as _, ICONS, Wgt};
pub use crate::text;
pub use zng_wgt_text::Text;
#[cfg(feature = "text_input")]
pub use zng_wgt_text_input::{TextInput, selectable::SelectableText};
#[cfg(feature = "window")]
pub use crate::window;
#[cfg(feature = "window")]
pub use zng_wgt_window::Window;
pub use zng_wgt_container::Container;
#[cfg(feature = "button")]
pub use zng_wgt_button::Button;
#[cfg(feature = "data_context")]
pub use zng_wgt_data::{DATA, data};
#[cfg(feature = "grid")]
pub use crate::grid;
#[cfg(feature = "grid")]
pub use zng_wgt_grid::Grid;
pub use crate::layer;
pub use zng_wgt_layer::{AnchorMode, LAYERS, LayerIndex};
pub use crate::popup;
pub use zng_wgt_layer::popup::POPUP;
#[cfg(feature = "menu")]
pub use crate::menu;
#[cfg(feature = "menu")]
pub use zng_wgt_menu::{
Menu,
context::{ContextMenu, context_menu, context_menu_fn},
sub::SubMenu,
};
#[cfg(feature = "rule_line")]
pub use zng_wgt_rule_line::hr::Hr;
#[cfg(feature = "scroll")]
pub use zng_wgt_scroll::{SCROLL, Scroll};
#[cfg(feature = "toggle")]
pub use crate::toggle;
#[cfg(feature = "toggle")]
pub use zng_wgt_toggle::Toggle;
#[cfg(feature = "tooltip")]
pub use crate::tip;
#[cfg(feature = "tooltip")]
pub use zng_wgt_tooltip::{Tip, tooltip, tooltip_fn};
pub use zng_wgt::{WidgetFn, wgt_fn};
pub use zng_wgt_style::{Style, style_fn};
#[cfg(feature = "stack")]
pub use zng_wgt_stack::{Stack, StackDirection};
#[cfg(feature = "wrap")]
pub use zng_wgt_wrap::Wrap;
#[cfg(feature = "data_view")]
pub use zng_wgt_data_view::{DataView, DataViewArgs};
#[cfg(feature = "settings_editor")]
pub use zng_wgt_settings::SettingBuilderEditorExt as _;
#[cfg(feature = "dialog")]
pub use crate::dialog;
#[cfg(feature = "dialog")]
pub use zng_wgt_dialog::DIALOG;
}
pub mod prelude_wgt {
#[doc(no_inline)]
pub use crate::__prelude_wgt::*;
}
mod __prelude_wgt {
pub use zng_app::{
DInstant, Deadline, INSTANT,
event::{
AnyEventArgs as _, Command, CommandHandle, CommandInfoExt as _, CommandNameExt as _, CommandParam, Event, EventArgs as _,
EventHandle, EventHandles, EventPropagationHandle, command, event, event_args,
},
handler::{AppHandler, WidgetHandler, app_hn, app_hn_once, async_app_hn, async_app_hn_once, async_hn, async_hn_once, hn, hn_once},
render::{FrameBuilder, FrameUpdate, FrameValue, FrameValueKey, FrameValueUpdate, SpatialFrameId, TransformStyle},
shortcut::{CommandShortcutExt as _, Shortcut, ShortcutFilter, Shortcuts, shortcut},
timer::{DeadlineHandle, DeadlineVar, TIMERS, TimerHandle, TimerVar},
update::{EventUpdate, UPDATES, UpdateDeliveryList, UpdateOp, WidgetUpdates},
widget::{
AnyVarSubscribe as _, VarLayout as _, VarSubscribe as _, WIDGET, WidgetId, WidgetUpdateMode,
base::{WidgetBase, WidgetImpl},
border::{BORDER, BorderSides, BorderStyle, CornerRadius, CornerRadiusFit, LineOrientation, LineStyle},
builder::{NestGroup, WidgetBuilder, WidgetBuilding, property_id},
easing,
info::{
InteractionPath, Interactivity, Visibility, WidgetBorderInfo, WidgetBoundsInfo, WidgetInfo, WidgetInfoBuilder,
WidgetLayout, WidgetMeasure, WidgetPath,
},
node::{
ArcNode, ArcNodeList, BoxedUiNode, BoxedUiNodeList, EditableUiNodeList, EditableUiNodeListRef, FillUiNode, NilUiNode,
PanelList, SORTING_LIST, SortingList, UiNode, UiNodeList, UiNodeListChain as _, UiNodeListObserver, UiNodeOp, UiVec,
ZIndex, match_node, match_node_leaf, match_node_list, match_node_typed, match_widget, ui_vec,
},
property, ui_node, widget, widget_impl, widget_mixin, widget_set,
},
window::{MonitorId, WINDOW, WindowId},
};
pub use zng_var::{
AnyVar as _, AnyWeakVar as _, ArcVar, BoxedVar, ContextVar, IntoValue, IntoVar, LocalVar, ReadOnlyArcVar, ResponderVar,
ResponseVar, Var, VarCapability, VarHandle, VarHandles, VarValue, WeakVar as _, context_var, expr_var, getter_var,
impl_from_and_into_var, merge_var, response_done_var, response_var, state_var, var, when_var,
};
pub use zng_layout::{
context::{DIRECTION_VAR, LAYOUT, LayoutDirection, LayoutMetrics},
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::{ToTxt as _, Txt, formatx};
pub use zng_clone_move::{async_clmv, async_clmv_fn, async_clmv_fn_once, clmv};
pub use crate::task;
pub use zng_app_context::{CaptureFilter, ContextLocal, ContextValueSet, LocalContext, RunOnDrop, app_local, context_local};
pub use crate::state_map;
pub use zng_state_map::{OwnedStateMap, StateId, StateMapMut, StateMapRef, static_id};
pub use zng_wgt::prelude::{IdEntry, IdMap, IdSet};
pub use zng_wgt::{WidgetFn, wgt_fn};
pub use zng_color::{
ColorScheme, Hsla, Hsva, LightDark, MixAdjust as _, MixBlendMode, Rgba, colors, gradient, hex, hsl, hsla, hsv, hsva, light_dark,
rgb, rgba, web_colors,
};
pub use zng_wgt::node::{
bind_state, bind_state_init, 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,
};
#[cfg(feature = "window")]
pub use zng_ext_window::WidgetInfoBuilderImeArea as _;
#[cfg(hot_reload)]
pub use crate::hot_reload::hot_node;
}
mod defaults {
use zng_app::{AppExtended, AppExtension};
#[cfg(feature = "clipboard")]
use zng_ext_clipboard::ClipboardManager;
#[cfg(feature = "config")]
use zng_ext_config::ConfigManager;
use zng_ext_font::FontManager;
#[cfg(feature = "fs_watcher")]
use zng_ext_fs_watcher::FsWatcherManager;
#[cfg(feature = "image")]
use zng_ext_image::ImageManager;
use zng_ext_input::{
focus::FocusManager, gesture::GestureManager, keyboard::KeyboardManager, mouse::MouseManager,
pointer_capture::PointerCaptureManager, touch::TouchManager,
};
#[cfg(feature = "drag_drop")]
use zng_ext_input::drag_drop::DragDropManager;
use zng_ext_l10n::L10nManager;
#[cfg(feature = "undo")]
use zng_ext_undo::UndoManager;
#[cfg(feature = "window")]
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();
#[cfg(feature = "fs_watcher")]
let r = r.extend(FsWatcherManager::default());
#[cfg(feature = "config")]
let r = r.extend(ConfigManager::default());
let r = r.extend(L10nManager::default());
let r = r.extend(PointerCaptureManager::default());
let r = r.extend(MouseManager::default());
let r = r.extend(TouchManager::default());
let r = r.extend(KeyboardManager::default());
let r = r.extend(GestureManager::default());
#[cfg(feature = "window")]
let r = r.extend(WindowManager::default());
let r = r.extend(FontManager::default());
let r = r.extend(FocusManager::default());
#[cfg(feature = "drag_drop")]
let r = r.extend(DragDropManager::default());
#[cfg(feature = "image")]
let r = r.extend(ImageManager::default());
#[cfg(feature = "clipboard")]
let r = r.extend(ClipboardManager::default());
#[cfg(feature = "undo")]
let r = r.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);
#[cfg(feature = "svg")]
let r = r.extend(zng_ext_svg::SvgManager::default());
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");
#[cfg(feature = "window")]
{
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");
}
#[cfg(all(feature = "third_party_default", feature = "third_party"))]
{
crate::third_party::setup_default_view();
tracing::debug!("defaults init, third_party set");
}
#[cfg(feature = "settings_editor")]
{
zng_wgt_settings::handle_settings_cmd();
tracing::debug!("defaults init, settings set");
}
#[cfg(all(single_instance, feature = "window"))]
{
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::*,
widget::{
EditorRequestArgs,
node::{BoxedUiNode, NilUiNode},
},
};
pub fn handler(args: EditorRequestArgs) -> BoxedUiNode {
#[cfg(feature = "text_input")]
if let Some(txt) = args.value::<Txt>() {
return TextInput! {
txt;
}
.boxed();
}
#[cfg(feature = "text_input")]
if let Some(s) = args.value::<String>() {
return TextInput! {
txt = s.map_bidi(|s| Txt::from_str(s), |t: &Txt| t.to_string());
}
.boxed();
}
#[cfg(feature = "text_input")]
if let Some(c) = args.value::<char>() {
return TextInput! {
txt_parse::<char> = c;
style_fn = crate::text_input::FieldStyle!();
}
.boxed();
}
#[cfg(feature = "toggle")]
if let Some(checked) = args.value::<bool>() {
return Toggle! {
style_fn = toggle::CheckStyle!();
checked;
}
.boxed();
}
macro_rules! parse {
($($ty:ty),+ $(,)?) => {
$(
#[cfg(feature = "text_input")]
if let Some(n) = args.value::<$ty>() {
return TextInput! {
txt_parse::<$ty> = n;
style_fn = crate::text_input::FieldStyle!();
}
.boxed();
}
)+
}
}
parse! {
u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, f32, f64,
}
let _ = args;
NilUiNode.boxed()
}
}