chore: re-export iced row and column
This removes the custom row and column implementations and uses the iced ones directly.
This commit is contained in:
parent
a9e0671075
commit
fdf3369cea
20 changed files with 103 additions and 227 deletions
66
src/ext.rs
66
src/ext.rs
|
|
@ -19,72 +19,6 @@ impl<Message: 'static> ElementExt for crate::Element<'_, Message> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Additional methods for the [`Column`] and [`Row`] widgets.
|
||||
pub trait CollectionWidget<'a, Message: 'a>:
|
||||
Widget<Message, crate::Theme, crate::Renderer>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
/// Moves all the elements of `other` into `self`, leaving `other` empty.
|
||||
#[must_use]
|
||||
fn append<E>(self, other: &mut Vec<E>) -> Self
|
||||
where
|
||||
E: Into<crate::Element<'a, Message>>;
|
||||
|
||||
/// Appends all elements in an iterator to the widget.
|
||||
#[must_use]
|
||||
fn extend<E>(mut self, iterator: impl Iterator<Item = E>) -> Self
|
||||
where
|
||||
E: Into<crate::Element<'a, Message>>,
|
||||
{
|
||||
for item in iterator {
|
||||
self = self.push(item.into());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Pushes an element into the widget.
|
||||
#[must_use]
|
||||
fn push(self, element: impl Into<crate::Element<'a, Message>>) -> Self;
|
||||
|
||||
/// Conditionally pushes an element to the widget.
|
||||
#[must_use]
|
||||
fn push_maybe(self, element: Option<impl Into<crate::Element<'a, Message>>>) -> Self {
|
||||
if let Some(element) = element {
|
||||
self.push(element.into())
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Message: 'a> CollectionWidget<'a, Message> for crate::widget::Column<'a, Message> {
|
||||
fn append<E>(self, other: &mut Vec<E>) -> Self
|
||||
where
|
||||
E: Into<crate::Element<'a, Message>>,
|
||||
{
|
||||
self.extend(other.drain(..).map(Into::into))
|
||||
}
|
||||
|
||||
fn push(self, element: impl Into<crate::Element<'a, Message>>) -> Self {
|
||||
self.push(element)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Message: 'a> CollectionWidget<'a, Message> for crate::widget::Row<'a, Message> {
|
||||
fn append<E>(self, other: &mut Vec<E>) -> Self
|
||||
where
|
||||
E: Into<crate::Element<'a, Message>>,
|
||||
{
|
||||
self.extend(other.drain(..).map(Into::into))
|
||||
}
|
||||
|
||||
fn push(self, element: impl Into<crate::Element<'a, Message>>) -> Self {
|
||||
self.push(element)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ColorExt {
|
||||
/// Combines color with background to create appearance of transparency.
|
||||
#[must_use]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue