From 34eca92b758aa6ec8345d31ce872921ffc661cf1 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Wed, 22 Nov 2023 13:59:38 +0000 Subject: [PATCH] Feature flag TaffyLayout widget --- Cargo.toml | 5 +++-- src/view/mod.rs | 8 ++++++-- src/widget/mod.rs | 9 +++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f2191269f..4319c006a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,14 +40,15 @@ default-target = "x86_64-pc-windows-msvc" cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] [features] -default = ["x11"] +default = ["x11", "taffy"] x11 = ["glazier/x11"] wayland = ["glazier/wayland"] +taffy = ["dep:taffy"] [dependencies] xilem_core.workspace = true -taffy = { git = "https://github.com/DioxusLabs/taffy", rev = "7781c70241f7f572130c13106f2a869a9cf80885" } +taffy = { git = "https://github.com/DioxusLabs/taffy", rev = "7781c70241f7f572130c13106f2a869a9cf80885", optional = true } vello = { git = "https://github.com/linebender/vello", rev = "9d7c4f00d8db420337706771a37937e9025e089c" } wgpu = "0.17.0" parley = { git = "https://github.com/dfrg/parley", rev = "2371bf4b702ec91edee2d58ffb2d432539580e1e" } diff --git a/src/view/mod.rs b/src/view/mod.rs index da5277265..328056ad6 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -21,7 +21,7 @@ mod text; // mod use_state; mod linear_layout; mod list; -mod taffy_layout; + #[allow(clippy::module_inception)] mod view; @@ -30,5 +30,9 @@ pub use xilem_core::{Id, IdPath, VecSplice}; pub use button::button; pub use linear_layout::{h_stack, v_stack, LinearLayout}; pub use list::{list, List}; -pub use taffy_layout::{div, flex_column, flex_row, TaffyLayout}; pub use view::{Adapt, AdaptState, Cx, Memoize, View, ViewMarker, ViewSequence}; + +#[cfg(feature = "taffy")] +mod taffy_layout; +#[cfg(feature = "taffy")] +pub use taffy_layout::{div, flex_column, flex_row, TaffyLayout}; diff --git a/src/widget/mod.rs b/src/widget/mod.rs index 9ed209006..1dee87cda 100644 --- a/src/widget/mod.rs +++ b/src/widget/mod.rs @@ -21,7 +21,7 @@ mod core; mod linear_layout; mod piet_scene_helpers; mod raw_event; -mod taffy_layout; + //mod scroll_view; mod text; #[allow(clippy::module_inception)] @@ -34,6 +34,11 @@ pub use button::Button; pub use contexts::{AccessCx, CxState, EventCx, LayoutCx, LifeCycleCx, PaintCx, UpdateCx}; pub use linear_layout::LinearLayout; pub use raw_event::{Event, LifeCycle, MouseEvent, ViewContext}; -pub use taffy_layout::TaffyLayout; + pub use text::TextWidget; pub use widget::{AnyWidget, Widget}; + +#[cfg(feature = "taffy")] +mod taffy_layout; +#[cfg(feature = "taffy")] +pub use taffy_layout::TaffyLayout;