diff --git a/src/widget/button/image.rs b/src/widget/button/image.rs index a0508aaf..d430d245 100644 --- a/src/widget/button/image.rs +++ b/src/widget/button/image.rs @@ -14,7 +14,7 @@ pub type Button<'a, Message> = Builder<'a, Message, Image<'a, Handle, Message>>; /// A button constructed from an image handle, using image button styling. pub fn image<'a, Message>(handle: impl Into + 'a) -> Button<'a, Message> { Button::new(Image { - image: widget::image(handle).border_radius([9.0; 4]), + image: widget::image::image(handle).border_radius([9.0; 4]), selected: false, on_remove: None, }) @@ -22,7 +22,7 @@ pub fn image<'a, Message>(handle: impl Into + 'a) -> Button<'a, Message> /// The image variant of a button. pub struct Image<'a, Handle, Message> { - image: widget::Image<'a, Handle>, + image: widget::image::Image<'a, Handle>, selected: bool, on_remove: Option, } diff --git a/src/widget/image.rs b/src/widget/image.rs new file mode 100644 index 00000000..ac7355ed --- /dev/null +++ b/src/widget/image.rs @@ -0,0 +1,19 @@ +#[doc(inline)] +pub use iced::widget::{image, image::*, Image}; + +#[cfg(feature = "winit")] +use { + crate::app::Task, + iced_accessibility::Id, + iced_core::widget::operation, + iced_runtime::{task, Action}, +}; + +#[cfg(feature = "winit")] +/// Produces a [`Task`] that sets a new [`Handle`] to the [`Image`] with the given [`Id`]. +pub fn set_handle(id: Id, handle: impl Into) -> Task { + task::effect(Action::widget(operation::image::set_handle( + id, + handle.into(), + ))) +} diff --git a/src/widget/mod.rs b/src/widget/mod.rs index 06dd4e85..482f1174 100644 --- a/src/widget/mod.rs +++ b/src/widget/mod.rs @@ -62,8 +62,7 @@ pub use iced::widget::{container, Container}; #[doc(inline)] pub use iced::widget::{horizontal_space, vertical_space, Space}; -#[doc(inline)] -pub use iced::widget::{image, Image}; +pub mod image; #[doc(inline)] pub use iced::widget::{lazy, Lazy};