Revert "provide ID to operation.container in applicable widgets"
This reverts commit 8f9550bcf7c1cebbf90e80683761375406ca6139.
This commit is contained in:
parent
84a6038961
commit
d05ac38159
5 changed files with 51 additions and 226 deletions
|
|
@ -4,7 +4,7 @@ use crate::layout::{self, Layout};
|
|||
use crate::mouse;
|
||||
use crate::overlay;
|
||||
use crate::renderer;
|
||||
use crate::widget::{self, Operation, Tree};
|
||||
use crate::widget::{Operation, Tree};
|
||||
use crate::{
|
||||
Alignment, Clipboard, Element, Length, Padding, Point, Rectangle, Shell,
|
||||
Widget,
|
||||
|
|
@ -13,7 +13,6 @@ use crate::{
|
|||
/// A container that distributes its contents horizontally.
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Row<'a, Message, Renderer> {
|
||||
id: Option<Id>,
|
||||
spacing: u16,
|
||||
padding: Padding,
|
||||
width: Length,
|
||||
|
|
@ -33,7 +32,6 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> {
|
|||
children: Vec<Element<'a, Message, Renderer>>,
|
||||
) -> Self {
|
||||
Row {
|
||||
id: None,
|
||||
spacing: 0,
|
||||
padding: Padding::ZERO,
|
||||
width: Length::Shrink,
|
||||
|
|
@ -43,12 +41,6 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Sets the [`Id`] of the [`Row`].
|
||||
pub fn id(mut self, id: Id) -> Self {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the horizontal spacing _between_ elements.
|
||||
///
|
||||
/// Custom margins per element do not exist in iced. You should use this
|
||||
|
|
@ -145,20 +137,17 @@ where
|
|||
renderer: &Renderer,
|
||||
operation: &mut dyn Operation<Message>,
|
||||
) {
|
||||
operation.container(
|
||||
self.id.as_ref().map(|id| &id.0),
|
||||
&mut |operation| {
|
||||
self.children
|
||||
.iter()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.for_each(|((child, state), layout)| {
|
||||
child
|
||||
.as_widget()
|
||||
.operate(state, layout, renderer, operation);
|
||||
})
|
||||
},
|
||||
);
|
||||
operation.container(None, &mut |operation| {
|
||||
self.children
|
||||
.iter()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.for_each(|((child, state), layout)| {
|
||||
child
|
||||
.as_widget()
|
||||
.operate(state, layout, renderer, operation);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
fn on_event(
|
||||
|
|
@ -262,27 +251,3 @@ where
|
|||
Self::new(row)
|
||||
}
|
||||
}
|
||||
|
||||
/// The identifier of a [`Row`].
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Id(widget::Id);
|
||||
|
||||
impl Id {
|
||||
/// Creates a custom [`Id`].
|
||||
pub fn new(id: impl Into<std::borrow::Cow<'static, str>>) -> Self {
|
||||
Self(widget::Id::new(id))
|
||||
}
|
||||
|
||||
/// Creates a unique [`Id`].
|
||||
///
|
||||
/// This function produces a different [`Id`] every time it is called.
|
||||
pub fn unique() -> Self {
|
||||
Self(widget::Id::unique())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Id> for widget::Id {
|
||||
fn from(id: Id) -> Self {
|
||||
id.0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue