From 199a18951504ce43686138130be0cbab9748503e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 21 Aug 2025 00:07:04 +0200 Subject: [PATCH] Ungate `responsive` from the `lazy` feature flag --- examples/pane_grid/Cargo.toml | 2 +- widget/src/helpers.rs | 21 +++++++++++++++++++-- widget/src/lazy.rs | 2 -- widget/src/lazy/helpers.rs | 20 ++------------------ widget/src/lib.rs | 3 +++ widget/src/{lazy => }/responsive.rs | 1 - 6 files changed, 25 insertions(+), 24 deletions(-) rename widget/src/{lazy => }/responsive.rs (99%) diff --git a/examples/pane_grid/Cargo.toml b/examples/pane_grid/Cargo.toml index fd3e133c..c1756a65 100644 --- a/examples/pane_grid/Cargo.toml +++ b/examples/pane_grid/Cargo.toml @@ -7,4 +7,4 @@ publish = false [dependencies] iced.workspace = true -iced.features = ["debug", "lazy"] +iced.features = ["debug"] diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index a926d2ef..256a9d32 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -6,7 +6,7 @@ use crate::container::{self, Container}; use crate::core; use crate::core::widget::operation::{self, Operation}; use crate::core::window; -use crate::core::{Element, Length, Pixels, Widget}; +use crate::core::{Element, Length, Pixels, Size, Widget}; use crate::float::{self, Float}; use crate::keyed; use crate::overlay; @@ -25,7 +25,9 @@ use crate::text_input::{self, TextInput}; use crate::toggler::{self, Toggler}; use crate::tooltip::{self, Tooltip}; use crate::vertical_slider::{self, VerticalSlider}; -use crate::{Column, Grid, MouseArea, Pin, Row, Sensor, Space, Stack, Themer}; +use crate::{ + Column, Grid, MouseArea, Pin, Responsive, Row, Sensor, Space, Stack, Themer, +}; use std::borrow::Borrow; use std::ops::RangeInclusive; @@ -2140,3 +2142,18 @@ where { Float::new(content) } + +/// Creates a new [`Responsive`] widget with a closure that produces its +/// contents. +/// +/// The `view` closure will be provided with the current [`Size`] of +/// the [`Responsive`] widget and, therefore, can be used to build the +/// contents of the widget in a responsive way. +pub fn responsive<'a, Message, Theme, Renderer>( + f: impl Fn(Size) -> Element<'a, Message, Theme, Renderer> + 'a, +) -> Responsive<'a, Message, Theme, Renderer> +where + Renderer: core::Renderer, +{ + Responsive::new(f) +} diff --git a/widget/src/lazy.rs b/widget/src/lazy.rs index 36edce79..b67ba56c 100644 --- a/widget/src/lazy.rs +++ b/widget/src/lazy.rs @@ -2,11 +2,9 @@ pub(crate) mod helpers; pub mod component; -pub mod responsive; #[allow(deprecated)] pub use component::Component; -pub use responsive::Responsive; mod cache; diff --git a/widget/src/lazy/helpers.rs b/widget/src/lazy/helpers.rs index 52e690ff..7e7601cb 100644 --- a/widget/src/lazy/helpers.rs +++ b/widget/src/lazy/helpers.rs @@ -1,10 +1,10 @@ -use crate::core::{self, Element, Size}; +use crate::core::{self, Element}; use crate::lazy::component; use std::hash::Hash; #[allow(deprecated)] -pub use crate::lazy::{Component, Lazy, Responsive}; +pub use crate::lazy::{Component, Lazy}; /// Creates a new [`Lazy`] widget with the given data `Dependency` and a /// closure that can turn this data into a widget tree. @@ -41,19 +41,3 @@ where { component::view(component) } - -/// Creates a new [`Responsive`] widget with a closure that produces its -/// contents. -/// -/// The `view` closure will be provided with the current [`Size`] of -/// the [`Responsive`] widget and, therefore, can be used to build the -/// contents of the widget in a responsive way. -#[cfg(feature = "lazy")] -pub fn responsive<'a, Message, Theme, Renderer>( - f: impl Fn(Size) -> Element<'a, Message, Theme, Renderer> + 'a, -) -> Responsive<'a, Message, Theme, Renderer> -where - Renderer: core::Renderer, -{ - Responsive::new(f) -} diff --git a/widget/src/lib.rs b/widget/src/lib.rs index d08a92f9..3818c92f 100644 --- a/widget/src/lib.rs +++ b/widget/src/lib.rs @@ -12,6 +12,7 @@ mod action; mod column; mod mouse_area; mod pin; +mod responsive; mod space; mod stack; mod themer; @@ -78,6 +79,8 @@ pub use progress_bar::ProgressBar; #[doc(no_inline)] pub use radio::Radio; #[doc(no_inline)] +pub use responsive::Responsive; +#[doc(no_inline)] pub use row::Row; #[doc(no_inline)] pub use rule::Rule; diff --git a/widget/src/lazy/responsive.rs b/widget/src/responsive.rs similarity index 99% rename from widget/src/lazy/responsive.rs rename to widget/src/responsive.rs index a0b18761..5bae852f 100644 --- a/widget/src/lazy/responsive.rs +++ b/widget/src/responsive.rs @@ -14,7 +14,6 @@ use crate::horizontal_space; /// /// A [`Responsive`] widget will always try to fill all the available space of /// its parent. -#[cfg(feature = "lazy")] #[allow(missing_debug_implementations)] pub struct Responsive< 'a,