Skip to content

Commit

Permalink
Add features for each sub-module of the zng
Browse files Browse the repository at this point in the history
  • Loading branch information
SamRodri committed Jan 8, 2025
1 parent 80eaff8 commit 01c0a7d
Show file tree
Hide file tree
Showing 37 changed files with 346 additions and 75 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

* Add features for each sub-module of the `zng`. This enabled compile size optimization.

# 0.13.5

Expand Down
5 changes: 5 additions & 0 deletions crates/zng-ext-input/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ repository = "https://github.com/zng-ui/zng"
categories = ["gui"]
keywords = ["gui", "ui", "user-interface", "zng"]

[features]
default = []
# Enable drag&drop.
drag_drop = []

[dependencies]
zng-app-context = { path = "../zng-app-context", version = "0.5.13" }
zng-clone-move = { path = "../zng-clone-move", version = "0.2.5" }
Expand Down
2 changes: 2 additions & 0 deletions crates/zng-ext-input/src/drag_drop.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "drag_drop")]

//! Drag & drop gesture events and service.
use std::{mem, sync::Arc};
Expand Down
6 changes: 6 additions & 0 deletions crates/zng-wgt-input/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ repository = "https://github.com/zng-ui/zng"
categories = ["gui"]
keywords = ["gui", "ui", "user-interface", "zng"]

[features]
default = []

# Enable drag&drop.
drag_drop = ["zng-ext-input/drag_drop"]

[dependencies]
zng-wgt = { path = "../zng-wgt", version = "0.6.4" }
zng-wgt-transform = { path = "../zng-wgt-transform", version = "0.3.4" }
Expand Down
4 changes: 3 additions & 1 deletion crates/zng-wgt-input/src/drag_drop.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! Drag& drop properties, event properties.
#![cfg(feature = "drag_drop")]

//! Drag&drop properties, event properties.
use zng_ext_input::drag_drop::{
DragEndArgs, DragHoveredArgs, DragStartArgs, DropArgs, WidgetInfoBuilderDragDropExt as _, DRAG_END_EVENT, DRAG_HOVERED_EVENT,
Expand Down
178 changes: 148 additions & 30 deletions crates/zng/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,39 @@ categories = ["gui"]
keywords = ["gui", "ui", "user-interface", "zng"]

[features]
default = ["ipc", "debug_default", "view_software", "crash_handler"]
default = [
"ipc",
"debug_default",
"view_software",
"crash_handler",
"crash_handler_debug",
"window",
"third_party",
"third_party_default",
"checkerboard",
"clipboard",
"color_filter",
"config",
"data_context",
"data_view",
"dialog",
"drag_drop",
"fs_watcher",
"grid",
"image",
"markdown",
"menu",
"progress",
"rule_line",
"scroll",
"slider",
"toggle",
"stack",
"text_input",
"tooltip",
"undo",
"wrap",
]

# Include the default view-process implementation.
#
Expand Down Expand Up @@ -101,7 +133,10 @@ single_instance = ["dep:zng-ext-single-instance"]
# Builds with this feature spawn a crash monitor-process for each app-process.
#
# Only enables in `not(any(target_arch = "wasm32", target_os = "android"))` builds.
crash_handler = ["zng-app/crash_handler", "zng-wgt-inspector/crash_handler"]
crash_handler = ["zng-app/crash_handler"]

# Enable debug crash handler view.
crash_handler_debug = ["zng-wgt-inspector/crash_handler", "window"]

# Instrument every widget outer-most node to trace UI methods.
trace_widget = ["zng-app/trace_widget", "zng-wgt-style/trace_widget"]
Expand Down Expand Up @@ -195,6 +230,89 @@ android_game_activity = ["zng-view?/android_game_activity"]
# See `https://docs.rs/winit/latest/winit/platform/android/` for more details.
android_native_activity = ["zng-view?/android_native_activity"]

# Enable window, monitor services, widgets and properties.
window = ["dep:zng-ext-window", "dep:zng-wgt-window"]

# Enable third-party license service and types.
third_party = []

# Enable default third-party licenses default view.
third_party_default = ["window"]

# Enable ANSI text widget.
#
# Not enabled by default.
ansi_text = ["dep:zng-wgt-ansi-text"]

# Enable checkerboard widget.
checkerboard = ["dep:zng-wgt-checkerboard"]

# Enable clipboard service.
clipboard = ["dep:zng-ext-clipboard"]

# Enable color filter properties.
color_filter = ["dep:zng-wgt-filter"]

# Enable file system watcher service.
fs_watcher = ["dep:zng-ext-fs-watcher"]

# Enable the configuration service.
config = ["dep:zng-ext-config"]

# Enable data context service and properties.
data_context = ["dep:zng-wgt-data"]

# Enable data view widget.
data_view = ["dep:zng-wgt-data-view"]

# Enable modal dialog overlay widget and service.
dialog = ["dep:zng-wgt-dialog"]

# Enable drag&drop.
drag_drop = ["zng-ext-input/drag_drop", "zng-wgt-input/drag_drop"]

# Enable grid widget.
grid = ["dep:zng-wgt-grid"]

# Enable image service and widget.
image = ["dep:zng-ext-image", "dep:zng-wgt-image"]

# Enable markdown widget.
markdown = ["dep:zng-wgt-markdown"]

# Enable menu widgets.
menu = ["dep:zng-wgt-menu"]

# Enable progress indicator widgets.
progress = ["dep:zng-wgt-progress"]

# Enable rule line widgets.
rule_line = ["dep:zng-wgt-rule-line"]

# Enable scroll widget.
scroll = ["dep:zng-wgt-scroll"]

# Enable toggle widgets.
toggle = ["dep:zng-wgt-toggle"]

# Enable slider widget.
slider = ["dep:zng-wgt-slider"]

# Enable stack widget.
stack = ["dep:zng-wgt-stack"]

# Enable text input widgets.
text_input = ["dep:zng-wgt-text-input"]

# Enable tooltip widget.
tooltip = ["dep:zng-wgt-tooltip"]

# Enable undo/redo service.
undo = ["dep:zng-ext-undo", "dep:zng-wgt-undo-history", "dep:zng-wgt-undo"]

# Enable wrap widget.
wrap = ["dep:zng-wgt-wrap"]

[dependencies]
# foundation
zng-clone-move = { path = "../zng-clone-move", version = "0.2.5" }
Expand All @@ -210,55 +328,55 @@ zng-unique-id = { path = "../zng-unique-id", version = "0.4.8" }

# app
zng-app = { path = "../zng-app", version = "0.14.4", default-features = false }
zng-ext-fs-watcher = { path = "../zng-ext-fs-watcher", version = "0.3.4" }
zng-ext-config = { path = "../zng-ext-config", version = "0.4.4", default-features = false }
zng-ext-fs-watcher = { path = "../zng-ext-fs-watcher", version = "0.3.4", optional = true }
zng-ext-config = { path = "../zng-ext-config", version = "0.4.4", default-features = false, optional = true }
zng-ext-font = { path = "../zng-ext-font", version = "0.5.5" }
zng-ext-l10n = { path = "../zng-ext-l10n", version = "0.6.4", features = ["tar"] }
zng-ext-image = { path = "../zng-ext-image", version = "0.3.4" }
zng-ext-image = { path = "../zng-ext-image", version = "0.3.4", optional = true }
zng-ext-svg = { path = "../zng-ext-svg", version = "0.2.4", optional = true }
zng-ext-clipboard = { path = "../zng-ext-clipboard", version = "0.3.4" }
zng-ext-window = { path = "../zng-ext-window", version = "0.4.4" }
zng-ext-clipboard = { path = "../zng-ext-clipboard", version = "0.3.4", optional = true }
zng-ext-window = { path = "../zng-ext-window", version = "0.4.4", optional = true }
zng-ext-input = { path = "../zng-ext-input", version = "0.6.4" }
zng-ext-undo = { path = "../zng-ext-undo", version = "0.3.4" }
zng-ext-undo = { path = "../zng-ext-undo", version = "0.3.4", optional = true }
zng-ext-hot-reload = { path = "../zng-ext-hot-reload", version = "0.2.4", optional = true }

# widgets
zng-wgt = { path = "../zng-wgt", version = "0.6.4" }
zng-wgt-access = { path = "../zng-wgt-access", version = "0.3.4" }
zng-wgt-transform = { path = "../zng-wgt-transform", version = "0.3.4" }
zng-wgt-input = { path = "../zng-wgt-input", version = "0.3.4" }
zng-wgt-data = { path = "../zng-wgt-data", version = "0.3.4" }
zng-wgt-filter = { path = "../zng-wgt-filter", version = "0.3.4" }
zng-wgt-data = { path = "../zng-wgt-data", version = "0.3.4", optional = true }
zng-wgt-filter = { path = "../zng-wgt-filter", version = "0.3.4", optional = true }
zng-wgt-size-offset = { path = "../zng-wgt-size-offset", version = "0.3.4" }
zng-wgt-container = { path = "../zng-wgt-container", version = "0.5.4" }
zng-wgt-undo = { path = "../zng-wgt-undo", version = "0.3.4" }
zng-wgt-data-view = { path = "../zng-wgt-data-view", version = "0.4.4" }
zng-wgt-undo = { path = "../zng-wgt-undo", version = "0.3.4", optional = true }
zng-wgt-data-view = { path = "../zng-wgt-data-view", version = "0.4.4", optional = true }
zng-wgt-fill = { path = "../zng-wgt-fill", version = "0.3.4" }
zng-wgt-style = { path = "../zng-wgt-style", version = "0.4.4" }
zng-wgt-checkerboard = { path = "../zng-wgt-checkerboard", version = "0.4.4" }
zng-wgt-window = { path = "../zng-wgt-window", version = "0.7.5" }
zng-wgt-checkerboard = { path = "../zng-wgt-checkerboard", version = "0.4.4", optional = true }
zng-wgt-window = { path = "../zng-wgt-window", version = "0.7.5", optional = true }
zng-wgt-layer = { path = "../zng-wgt-layer", version = "0.4.4" }
zng-wgt-undo-history = { path = "../zng-wgt-undo-history", version = "0.4.5" }
zng-wgt-image = { path = "../zng-wgt-image", version = "0.4.5" }
zng-wgt-undo-history = { path = "../zng-wgt-undo-history", version = "0.4.5", optional = true }
zng-wgt-image = { path = "../zng-wgt-image", version = "0.4.5", optional = true }
zng-wgt-text = { path = "../zng-wgt-text", version = "0.5.5" }
zng-wgt-text-input = { path = "../zng-wgt-text-input", version = "0.5.5" }
zng-wgt-text-input = { path = "../zng-wgt-text-input", version = "0.5.5", optional = true }
zng-wgt-button = { path = "../zng-wgt-button", version = "0.5.5" }
zng-wgt-stack = { path = "../zng-wgt-stack", version = "0.4.4" }
zng-wgt-stack = { path = "../zng-wgt-stack", version = "0.4.4", optional = true }
zng-wgt-panel = { path = "../zng-wgt-panel", version = "0.4.5" }
zng-wgt-grid = { path = "../zng-wgt-grid", version = "0.4.4" }
zng-wgt-wrap = { path = "../zng-wgt-wrap", version = "0.4.5" }
zng-wgt-rule-line = { path = "../zng-wgt-rule-line", version = "0.4.5" }
zng-wgt-toggle = { path = "../zng-wgt-toggle", version = "0.4.5" }
zng-wgt-menu = { path = "../zng-wgt-menu", version = "0.4.5" }
zng-wgt-scroll = { path = "../zng-wgt-scroll", version = "0.5.4" }
zng-wgt-ansi-text = { path = "../zng-wgt-ansi-text", version = "0.4.5" }
zng-wgt-tooltip = { path = "../zng-wgt-tooltip", version = "0.5.5" }
zng-wgt-markdown = { path = "../zng-wgt-markdown", version = "0.4.5" }
zng-wgt-grid = { path = "../zng-wgt-grid", version = "0.4.4", optional = true }
zng-wgt-wrap = { path = "../zng-wgt-wrap", version = "0.4.5", optional = true }
zng-wgt-rule-line = { path = "../zng-wgt-rule-line", version = "0.4.5", optional = true }
zng-wgt-toggle = { path = "../zng-wgt-toggle", version = "0.4.5", optional = true }
zng-wgt-menu = { path = "../zng-wgt-menu", version = "0.4.5", optional = true }
zng-wgt-scroll = { path = "../zng-wgt-scroll", version = "0.5.4", optional = true }
zng-wgt-ansi-text = { path = "../zng-wgt-ansi-text", version = "0.4.5", optional = true }
zng-wgt-tooltip = { path = "../zng-wgt-tooltip", version = "0.5.5", optional = true }
zng-wgt-markdown = { path = "../zng-wgt-markdown", version = "0.4.5", optional = true }
zng-wgt-inspector = { path = "../zng-wgt-inspector", version = "0.3.5" }
zng-wgt-settings = { path = "../zng-wgt-settings", version = "0.2.5" }
zng-wgt-dialog = { path = "../zng-wgt-dialog", version = "0.2.5" }
zng-wgt-progress = { path = "../zng-wgt-progress", version = "0.2.5" }
zng-wgt-slider = { path = "../zng-wgt-slider", version = "0.2.4" }
zng-wgt-dialog = { path = "../zng-wgt-dialog", version = "0.2.5", optional = true }
zng-wgt-progress = { path = "../zng-wgt-progress", version = "0.2.5", optional = true }
zng-wgt-slider = { path = "../zng-wgt-slider", version = "0.2.4", optional = true }

zng-wgt-material-icons = { path = "../zng-wgt-material-icons", version = "0.4.5", default-features = false, optional = true }
zng-ext-single-instance = { path = "../zng-ext-single-instance", version = "0.4.4", optional = true }
Expand Down
2 changes: 2 additions & 0 deletions crates/zng/src/ansi_text.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "ansi_text")]

//! ANSI text widget.
//!
//! This widget displays text styled using [ANSI escape codes], commonly used to style terminal text.
Expand Down
21 changes: 16 additions & 5 deletions crates/zng/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,22 +551,33 @@ pub use zng_ext_single_instance::{AppInstanceArgs, APP_INSTANCE_EVENT};
pub mod crash_handler {
pub use zng_app::crash_handler::{crash_handler_config, BacktraceFrame, CrashArgs, CrashConfig, CrashError, CrashPanic};

#[cfg(feature = "crash_handler_debug")]
pub use zng_wgt_inspector::crash_handler::debug_dialog;

crash_handler_config!(|cfg| {
use crate::prelude::*;
cfg.default_dialog(|args| {
if let Some(c) = &args.dialog_crash {
eprintln!("DEBUG CRASH DIALOG ALSO CRASHED");
eprintln!(" {}", c.message());
eprintln!("ORIGINAL APP CRASH");
eprintln!(" {}", args.latest().message());
args.exit(0xBADC0DE)
}

APP.defaults()
.run_window(async_clmv!(args, { zng_wgt_inspector::crash_handler::debug_dialog(args) }));
} else {
#[cfg(feature = "crash_handler_debug")]
{
use crate::prelude::*;
APP.defaults()
.run_window(async_clmv!(args, { zng_wgt_inspector::crash_handler::debug_dialog(args) }));
}

#[cfg(not(feature = "crash_handler_debug"))]
{
eprintln!(
"app crashed {}\n\nbuild with feature = \"crash_handler_debug\" to se the debug crash dialog",
args.latest().message()
);
}
}
args.exit(0)
});
});
Expand Down
2 changes: 2 additions & 0 deletions crates/zng/src/checkerboard.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "checkerboard")]

//! Checkerboard visual widget.
//!
//! The widget appearance can be configured on it or in any parent widget, by default it looks like
Expand Down
2 changes: 2 additions & 0 deletions crates/zng/src/clipboard.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "clipboard")]

//! Clipboard service, commands and other types.
//!
//! This module provides the [`CLIPBOARD`] service and clipboard related commands and command handlers.
Expand Down
1 change: 1 addition & 0 deletions crates/zng/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub use zng_wgt::{accent_color, base_color, color_scheme};
pub use zng_wgt_fill::node::flood;

/// Color filter types and properties.
#[cfg(feature = "color_filter")]
pub mod filter {
pub use zng_color::filter::{ColorMatrix, Filter, RenderFilter};

Expand Down
3 changes: 3 additions & 0 deletions crates/zng/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "config")]

//! Config service, sources and other types.
//!
//! The configuration service [`CONFIG`] separates config using from config writing. A config
Expand Down Expand Up @@ -92,6 +94,7 @@ pub use zng_ext_config::{
ReadOnlyConfig, SwapConfig, SwitchConfig, CONFIG,
};

#[cfg(feature = "window")]
pub use zng_wgt_window::{save_state_node, SaveState};

#[cfg(feature = "ron")]
Expand Down
2 changes: 2 additions & 0 deletions crates/zng/src/data_context.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "data_context")]

//! Data context service and properties.
//!
//! The [`data`](fn@data) property can be set on a widget to any type that can be used in variables ([`VarValue`]). The
Expand Down
4 changes: 3 additions & 1 deletion crates/zng/src/data_view.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! Data view widgets and nodes.
#![cfg(feature = "data_view")]

//! Data view widget.
//!
//! The [`DataView!`](struct@DataView) widget can be used to dynamically presents data from a variable, unlike
//! the [`widget::node::presenter`](crate::widget::node::presenter) node the generated UI can be retained
Expand Down
2 changes: 2 additions & 0 deletions crates/zng/src/dialog.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "dialog")]

//! Modal dialog overlay widget and service.
//!
//! The [`DIALOG`] service provides custom and modal native dialogs.
Expand Down
2 changes: 2 additions & 0 deletions crates/zng/src/drag_drop.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "drag_drop")]

//! Drag&drop service, types and events.
//!
//! The example below defines a window that shows the current dragging data that has entered any of the app windows.
Expand Down
2 changes: 2 additions & 0 deletions crates/zng/src/fs_watcher.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "fs_watcher")]

//! File system watcher service and other types.
//!
//! The [`WATCHER`] service can be used to get notifications when a file or directory is modified. It also provides
Expand Down
2 changes: 2 additions & 0 deletions crates/zng/src/grid.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "grid")]

//! Grid layout widgets.
//!
//! The [`Grid!`](struct@Grid) layout widget that defines a grid using column and row widgets and then size and position
Expand Down
2 changes: 2 additions & 0 deletions crates/zng/src/image.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "image")]

//! Images service, widget and other types.
//!
//! # Image
Expand Down
Loading

0 comments on commit 01c0a7d

Please sign in to comment.