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
|
|
@ -8,7 +8,7 @@ use crate::overlay;
|
||||||
use crate::renderer;
|
use crate::renderer;
|
||||||
use crate::touch;
|
use crate::touch;
|
||||||
use crate::widget::tree::{self, Tree};
|
use crate::widget::tree::{self, Tree};
|
||||||
use crate::widget::{self, Operation};
|
use crate::widget::Operation;
|
||||||
use crate::{
|
use crate::{
|
||||||
Background, Clipboard, Color, Element, Layout, Length, Padding, Point,
|
Background, Clipboard, Color, Element, Layout, Length, Padding, Point,
|
||||||
Rectangle, Shell, Vector, Widget,
|
Rectangle, Shell, Vector, Widget,
|
||||||
|
|
@ -56,7 +56,6 @@ where
|
||||||
Renderer: crate::Renderer,
|
Renderer: crate::Renderer,
|
||||||
Renderer::Theme: StyleSheet,
|
Renderer::Theme: StyleSheet,
|
||||||
{
|
{
|
||||||
id: Option<Id>,
|
|
||||||
content: Element<'a, Message, Renderer>,
|
content: Element<'a, Message, Renderer>,
|
||||||
on_press: Option<Message>,
|
on_press: Option<Message>,
|
||||||
width: Length,
|
width: Length,
|
||||||
|
|
@ -73,7 +72,6 @@ where
|
||||||
/// Creates a new [`Button`] with the given content.
|
/// Creates a new [`Button`] with the given content.
|
||||||
pub fn new(content: impl Into<Element<'a, Message, Renderer>>) -> Self {
|
pub fn new(content: impl Into<Element<'a, Message, Renderer>>) -> Self {
|
||||||
Button {
|
Button {
|
||||||
id: None,
|
|
||||||
content: content.into(),
|
content: content.into(),
|
||||||
on_press: None,
|
on_press: None,
|
||||||
width: Length::Shrink,
|
width: Length::Shrink,
|
||||||
|
|
@ -83,12 +81,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the [`Id`] of the [`Button`].
|
|
||||||
pub fn id(mut self, id: Id) -> Self {
|
|
||||||
self.id = Some(id);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the width of the [`Button`].
|
/// Sets the width of the [`Button`].
|
||||||
pub fn width(mut self, width: Length) -> Self {
|
pub fn width(mut self, width: Length) -> Self {
|
||||||
self.width = width;
|
self.width = width;
|
||||||
|
|
@ -180,17 +172,14 @@ where
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
operation: &mut dyn Operation<Message>,
|
operation: &mut dyn Operation<Message>,
|
||||||
) {
|
) {
|
||||||
operation.container(
|
operation.container(None, &mut |operation| {
|
||||||
self.id.as_ref().map(|id| &id.0),
|
self.content.as_widget().operate(
|
||||||
&mut |operation| {
|
&mut tree.children[0],
|
||||||
self.content.as_widget().operate(
|
layout.children().next().unwrap(),
|
||||||
&mut tree.children[0],
|
renderer,
|
||||||
layout.children().next().unwrap(),
|
operation,
|
||||||
renderer,
|
);
|
||||||
operation,
|
});
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(
|
fn on_event(
|
||||||
|
|
@ -464,27 +453,3 @@ pub fn mouse_interaction(
|
||||||
mouse::Interaction::default()
|
mouse::Interaction::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The identifier of a [`Button`].
|
|
||||||
#[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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::layout;
|
||||||
use crate::mouse;
|
use crate::mouse;
|
||||||
use crate::overlay;
|
use crate::overlay;
|
||||||
use crate::renderer;
|
use crate::renderer;
|
||||||
use crate::widget::{self, Operation, Tree};
|
use crate::widget::{Operation, Tree};
|
||||||
use crate::{
|
use crate::{
|
||||||
Alignment, Clipboard, Element, Layout, Length, Padding, Point, Rectangle,
|
Alignment, Clipboard, Element, Layout, Length, Padding, Point, Rectangle,
|
||||||
Shell, Widget,
|
Shell, Widget,
|
||||||
|
|
@ -13,7 +13,6 @@ use crate::{
|
||||||
/// A container that distributes its contents vertically.
|
/// A container that distributes its contents vertically.
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Column<'a, Message, Renderer> {
|
pub struct Column<'a, Message, Renderer> {
|
||||||
id: Option<Id>,
|
|
||||||
spacing: u16,
|
spacing: u16,
|
||||||
padding: Padding,
|
padding: Padding,
|
||||||
width: Length,
|
width: Length,
|
||||||
|
|
@ -34,7 +33,6 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
|
||||||
children: Vec<Element<'a, Message, Renderer>>,
|
children: Vec<Element<'a, Message, Renderer>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Column {
|
Column {
|
||||||
id: None,
|
|
||||||
spacing: 0,
|
spacing: 0,
|
||||||
padding: Padding::ZERO,
|
padding: Padding::ZERO,
|
||||||
width: Length::Shrink,
|
width: Length::Shrink,
|
||||||
|
|
@ -45,12 +43,6 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the [`Id`] of the [`Column`].
|
|
||||||
pub fn id(mut self, id: Id) -> Self {
|
|
||||||
self.id = Some(id);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the vertical spacing _between_ elements.
|
/// Sets the vertical spacing _between_ elements.
|
||||||
///
|
///
|
||||||
/// Custom margins per element do not exist in iced. You should use this
|
/// Custom margins per element do not exist in iced. You should use this
|
||||||
|
|
@ -156,20 +148,17 @@ where
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
operation: &mut dyn Operation<Message>,
|
operation: &mut dyn Operation<Message>,
|
||||||
) {
|
) {
|
||||||
operation.container(
|
operation.container(None, &mut |operation| {
|
||||||
self.id.as_ref().map(|id| &id.0),
|
self.children
|
||||||
&mut |operation| {
|
.iter()
|
||||||
self.children
|
.zip(&mut tree.children)
|
||||||
.iter()
|
.zip(layout.children())
|
||||||
.zip(&mut tree.children)
|
.for_each(|((child, state), layout)| {
|
||||||
.zip(layout.children())
|
child
|
||||||
.for_each(|((child, state), layout)| {
|
.as_widget()
|
||||||
child
|
.operate(state, layout, renderer, operation);
|
||||||
.as_widget()
|
})
|
||||||
.operate(state, layout, renderer, operation);
|
});
|
||||||
})
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(
|
fn on_event(
|
||||||
|
|
@ -273,27 +262,3 @@ where
|
||||||
Self::new(column)
|
Self::new(column)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The identifier of a [`Column`].
|
|
||||||
#[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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::layout;
|
||||||
use crate::mouse;
|
use crate::mouse;
|
||||||
use crate::overlay;
|
use crate::overlay;
|
||||||
use crate::renderer;
|
use crate::renderer;
|
||||||
use crate::widget::{self, Operation, Tree};
|
use crate::widget::{Operation, Tree};
|
||||||
use crate::{
|
use crate::{
|
||||||
Background, Clipboard, Color, Element, Layout, Length, Padding, Point,
|
Background, Clipboard, Color, Element, Layout, Length, Padding, Point,
|
||||||
Rectangle, Shell, Widget,
|
Rectangle, Shell, Widget,
|
||||||
|
|
@ -24,7 +24,6 @@ where
|
||||||
Renderer: crate::Renderer,
|
Renderer: crate::Renderer,
|
||||||
Renderer::Theme: StyleSheet,
|
Renderer::Theme: StyleSheet,
|
||||||
{
|
{
|
||||||
id: Option<Id>,
|
|
||||||
padding: Padding,
|
padding: Padding,
|
||||||
width: Length,
|
width: Length,
|
||||||
height: Length,
|
height: Length,
|
||||||
|
|
@ -47,7 +46,6 @@ where
|
||||||
T: Into<Element<'a, Message, Renderer>>,
|
T: Into<Element<'a, Message, Renderer>>,
|
||||||
{
|
{
|
||||||
Container {
|
Container {
|
||||||
id: None,
|
|
||||||
padding: Padding::ZERO,
|
padding: Padding::ZERO,
|
||||||
width: Length::Shrink,
|
width: Length::Shrink,
|
||||||
height: Length::Shrink,
|
height: Length::Shrink,
|
||||||
|
|
@ -60,12 +58,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the [`Id`] of the [`Container`].
|
|
||||||
pub fn id(mut self, id: Id) -> Self {
|
|
||||||
self.id = Some(id);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the [`Padding`] of the [`Container`].
|
/// Sets the [`Padding`] of the [`Container`].
|
||||||
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
|
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
|
||||||
self.padding = padding.into();
|
self.padding = padding.into();
|
||||||
|
|
@ -180,17 +172,14 @@ where
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
operation: &mut dyn Operation<Message>,
|
operation: &mut dyn Operation<Message>,
|
||||||
) {
|
) {
|
||||||
operation.container(
|
operation.container(None, &mut |operation| {
|
||||||
self.id.as_ref().map(|id| &id.0),
|
self.content.as_widget().operate(
|
||||||
&mut |operation| {
|
&mut tree.children[0],
|
||||||
self.content.as_widget().operate(
|
layout.children().next().unwrap(),
|
||||||
&mut tree.children[0],
|
renderer,
|
||||||
layout.children().next().unwrap(),
|
operation,
|
||||||
renderer,
|
);
|
||||||
operation,
|
});
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(
|
fn on_event(
|
||||||
|
|
@ -344,27 +333,3 @@ pub fn draw_background<Renderer>(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The identifier of a [`Container`].
|
|
||||||
#[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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,6 @@ where
|
||||||
Renderer: crate::Renderer,
|
Renderer: crate::Renderer,
|
||||||
Renderer::Theme: StyleSheet + container::StyleSheet,
|
Renderer::Theme: StyleSheet + container::StyleSheet,
|
||||||
{
|
{
|
||||||
id: Option<Id>,
|
|
||||||
contents: Contents<'a, Content<'a, Message, Renderer>>,
|
contents: Contents<'a, Content<'a, Message, Renderer>>,
|
||||||
width: Length,
|
width: Length,
|
||||||
height: Length,
|
height: Length,
|
||||||
|
|
@ -148,7 +147,6 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
id: None,
|
|
||||||
contents,
|
contents,
|
||||||
width: Length::Fill,
|
width: Length::Fill,
|
||||||
height: Length::Fill,
|
height: Length::Fill,
|
||||||
|
|
@ -160,12 +158,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the [`Id`] of the [`PaneGrid`].
|
|
||||||
pub fn id(mut self, id: Id) -> Self {
|
|
||||||
self.id = Some(id);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the width of the [`PaneGrid`].
|
/// Sets the width of the [`PaneGrid`].
|
||||||
pub fn width(mut self, width: Length) -> Self {
|
pub fn width(mut self, width: Length) -> Self {
|
||||||
self.width = width;
|
self.width = width;
|
||||||
|
|
@ -305,18 +297,15 @@ where
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
operation: &mut dyn widget::Operation<Message>,
|
operation: &mut dyn widget::Operation<Message>,
|
||||||
) {
|
) {
|
||||||
operation.container(
|
operation.container(None, &mut |operation| {
|
||||||
self.id.as_ref().map(|id| &id.0),
|
self.contents
|
||||||
&mut |operation| {
|
.iter()
|
||||||
self.contents
|
.zip(&mut tree.children)
|
||||||
.iter()
|
.zip(layout.children())
|
||||||
.zip(&mut tree.children)
|
.for_each(|(((_pane, content), state), layout)| {
|
||||||
.zip(layout.children())
|
content.operate(state, layout, renderer, operation);
|
||||||
.for_each(|(((_pane, content), state), layout)| {
|
})
|
||||||
content.operate(state, layout, renderer, operation);
|
});
|
||||||
})
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(
|
fn on_event(
|
||||||
|
|
@ -1007,27 +996,3 @@ impl<'a, T> Contents<'a, T> {
|
||||||
matches!(self, Self::Maximized(..))
|
matches!(self, Self::Maximized(..))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The identifier of a [`PaneGrid`].
|
|
||||||
#[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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::layout::{self, Layout};
|
||||||
use crate::mouse;
|
use crate::mouse;
|
||||||
use crate::overlay;
|
use crate::overlay;
|
||||||
use crate::renderer;
|
use crate::renderer;
|
||||||
use crate::widget::{self, Operation, Tree};
|
use crate::widget::{Operation, Tree};
|
||||||
use crate::{
|
use crate::{
|
||||||
Alignment, Clipboard, Element, Length, Padding, Point, Rectangle, Shell,
|
Alignment, Clipboard, Element, Length, Padding, Point, Rectangle, Shell,
|
||||||
Widget,
|
Widget,
|
||||||
|
|
@ -13,7 +13,6 @@ use crate::{
|
||||||
/// A container that distributes its contents horizontally.
|
/// A container that distributes its contents horizontally.
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Row<'a, Message, Renderer> {
|
pub struct Row<'a, Message, Renderer> {
|
||||||
id: Option<Id>,
|
|
||||||
spacing: u16,
|
spacing: u16,
|
||||||
padding: Padding,
|
padding: Padding,
|
||||||
width: Length,
|
width: Length,
|
||||||
|
|
@ -33,7 +32,6 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> {
|
||||||
children: Vec<Element<'a, Message, Renderer>>,
|
children: Vec<Element<'a, Message, Renderer>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Row {
|
Row {
|
||||||
id: None,
|
|
||||||
spacing: 0,
|
spacing: 0,
|
||||||
padding: Padding::ZERO,
|
padding: Padding::ZERO,
|
||||||
width: Length::Shrink,
|
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.
|
/// Sets the horizontal spacing _between_ elements.
|
||||||
///
|
///
|
||||||
/// Custom margins per element do not exist in iced. You should use this
|
/// Custom margins per element do not exist in iced. You should use this
|
||||||
|
|
@ -145,20 +137,17 @@ where
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
operation: &mut dyn Operation<Message>,
|
operation: &mut dyn Operation<Message>,
|
||||||
) {
|
) {
|
||||||
operation.container(
|
operation.container(None, &mut |operation| {
|
||||||
self.id.as_ref().map(|id| &id.0),
|
self.children
|
||||||
&mut |operation| {
|
.iter()
|
||||||
self.children
|
.zip(&mut tree.children)
|
||||||
.iter()
|
.zip(layout.children())
|
||||||
.zip(&mut tree.children)
|
.for_each(|((child, state), layout)| {
|
||||||
.zip(layout.children())
|
child
|
||||||
.for_each(|((child, state), layout)| {
|
.as_widget()
|
||||||
child
|
.operate(state, layout, renderer, operation);
|
||||||
.as_widget()
|
})
|
||||||
.operate(state, layout, renderer, operation);
|
});
|
||||||
})
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(
|
fn on_event(
|
||||||
|
|
@ -262,27 +251,3 @@ where
|
||||||
Self::new(row)
|
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