feat: add set_handle method
This commit is contained in:
parent
a9c7c3cdbf
commit
d623bb0079
3 changed files with 22 additions and 4 deletions
|
|
@ -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<Handle> + '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<Handle> + '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<Message>,
|
||||
}
|
||||
|
|
|
|||
19
src/widget/image.rs
Normal file
19
src/widget/image.rs
Normal file
|
|
@ -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<Message: 'static>(id: Id, handle: impl Into<image::Handle>) -> Task<Message> {
|
||||
task::effect(Action::widget(operation::image::set_handle(
|
||||
id,
|
||||
handle.into(),
|
||||
)))
|
||||
}
|
||||
|
|
@ -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};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue