Expose additional helpers in iced::pure
This commit is contained in:
parent
98750782f3
commit
e50e639b0e
2 changed files with 30 additions and 5 deletions
|
|
@ -141,6 +141,17 @@ where
|
|||
Checkbox::new(is_checked, label, f)
|
||||
}
|
||||
|
||||
pub fn toggler<'a, Message, Renderer>(
|
||||
label: impl Into<Option<String>>,
|
||||
is_checked: bool,
|
||||
f: impl Fn(bool) -> Message + 'a,
|
||||
) -> Toggler<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
Toggler::new(is_checked, label, f)
|
||||
}
|
||||
|
||||
pub fn text_input<'a, Message, Renderer>(
|
||||
placeholder: &str,
|
||||
value: &str,
|
||||
|
|
@ -153,19 +164,18 @@ where
|
|||
TextInput::new(placeholder, value, on_change)
|
||||
}
|
||||
|
||||
pub fn slider<'a, Message, Renderer, T>(
|
||||
pub fn slider<'a, Message, T>(
|
||||
range: std::ops::RangeInclusive<T>,
|
||||
value: T,
|
||||
on_change: impl Fn(T) -> Message + 'a,
|
||||
) -> Slider<'a, T, Message>
|
||||
where
|
||||
Message: Clone,
|
||||
Renderer: iced_native::Renderer,
|
||||
T: Copy + From<u8> + std::cmp::PartialOrd,
|
||||
{
|
||||
Slider::new(range, value, on_change)
|
||||
}
|
||||
|
||||
pub fn image<Handle>(handle: Handle) -> Image<Handle> {
|
||||
Image::new(handle)
|
||||
pub fn image<Handle>(handle: impl Into<Handle>) -> Image<Handle> {
|
||||
Image::new(handle.into())
|
||||
}
|
||||
|
|
|
|||
17
src/pure.rs
17
src/pure.rs
|
|
@ -17,12 +17,27 @@
|
|||
//! [the original widgets]: crate::widget
|
||||
//! [`button::State`]: crate::widget::button::State
|
||||
//! [impure `Application`]: crate::Application
|
||||
pub use iced_pure::{Element as _, Image as _, Text as _, *};
|
||||
pub use iced_pure::{
|
||||
Button as _, Column as _, Element as _, Image as _, Row as _, Text as _, *,
|
||||
};
|
||||
|
||||
/// A generic, pure [`Widget`].
|
||||
pub type Element<'a, Message> =
|
||||
iced_pure::Element<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A pure container widget.
|
||||
pub type Container<'a, Message> =
|
||||
iced_pure::Container<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A pure column widget.
|
||||
pub type Column<'a, Message> = iced_pure::Column<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A pure row widget.
|
||||
pub type Row<'a, Message> = iced_pure::Row<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A pure button widget.
|
||||
pub type Button<'a, Message> = iced_pure::Button<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A pure text widget.
|
||||
pub type Text = iced_pure::Text<crate::Renderer>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue