Merge branch 'master' into virtual-widgets

This commit is contained in:
Héctor Ramón Jiménez 2022-03-07 15:29:43 +07:00
commit c35496d80f
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
58 changed files with 446 additions and 909 deletions

View file

@ -10,8 +10,8 @@ use crate::renderer;
use crate::text::{self, Text};
use crate::touch;
use crate::{
Clipboard, Element, Hasher, Layout, Length, Padding, Point, Rectangle,
Shell, Size, Widget,
Clipboard, Element, Layout, Length, Padding, Point, Rectangle, Shell, Size,
Widget,
};
use std::borrow::Cow;
@ -194,40 +194,6 @@ where
layout::Node::new(size)
}
/// Hashes the layout attributes of a [`PickList`].
pub fn hash_layout<T>(
state: &mut Hasher,
width: Length,
padding: Padding,
text_size: Option<u16>,
placeholder: Option<&str>,
options: &[T],
) where
T: ToString,
{
use std::hash::Hash as _;
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);
padding.hash(state);
text_size.hash(state);
match width {
Length::Shrink => {
placeholder.hash(state);
options
.iter()
.map(ToString::to_string)
.for_each(|label| label.hash(state));
}
_ => {
width.hash(state);
}
}
}
/// Processes an [`Event`] and updates the [`State`] of a [`PickList`]
/// accordingly.
pub fn update<'a, T, Message>(
@ -487,17 +453,6 @@ where
)
}
fn hash_layout(&self, state: &mut Hasher) {
hash_layout(
state,
self.width,
self.padding,
self.text_size,
self.placeholder.as_ref().map(String::as_str),
&self.options,
)
}
fn on_event(
&mut self,
event: Event,