diff options
| author | 2022-02-23 22:41:22 +0700 | |
|---|---|---|
| committer | 2022-02-23 22:41:22 +0700 | |
| commit | af7cbf0003496d757696ea6e15ea32f0649cf8f9 (patch) | |
| tree | a586436e4a1076543a3205ebc895a8463d9f7ffe /native/src/overlay | |
| parent | 9fe50801537e8fbfd2914f5139b5a609929e25db (diff) | |
| parent | 1313c94e3bb206f064462bc521f78dbffc2a6cd6 (diff) | |
| download | iced-af7cbf0003496d757696ea6e15ea32f0649cf8f9.tar.gz iced-af7cbf0003496d757696ea6e15ea32f0649cf8f9.tar.bz2 iced-af7cbf0003496d757696ea6e15ea32f0649cf8f9.zip  | |
Merge pull request #1263 from iced-rs/remove-hash-layout
Remove `hash_layout` method from `Widget` trait
Diffstat (limited to '')
| -rw-r--r-- | native/src/overlay.rs | 15 | ||||
| -rw-r--r-- | native/src/overlay/element.rs | 11 | ||||
| -rw-r--r-- | native/src/overlay/menu.rs | 26 | 
3 files changed, 4 insertions, 48 deletions
diff --git a/native/src/overlay.rs b/native/src/overlay.rs index d4b641af..124bcac2 100644 --- a/native/src/overlay.rs +++ b/native/src/overlay.rs @@ -10,7 +10,7 @@ use crate::event::{self, Event};  use crate::layout;  use crate::mouse;  use crate::renderer; -use crate::{Clipboard, Hasher, Layout, Point, Rectangle, Shell, Size}; +use crate::{Clipboard, Layout, Point, Rectangle, Shell, Size};  /// An interactive component that can be displayed on top of other widgets.  pub trait Overlay<Message, Renderer> @@ -39,19 +39,6 @@ where          cursor_position: Point,      ); -    /// Computes the _layout_ hash of the [`Overlay`]. -    /// -    /// The produced hash is used by the runtime to decide if the [`Layout`] -    /// needs to be recomputed between frames. Therefore, to ensure maximum -    /// efficiency, the hash should only be affected by the properties of the -    /// [`Overlay`] that can affect layouting. -    /// -    /// For example, the [`Text`] widget does not hash its color property, as -    /// its value cannot affect the overall [`Layout`] of the user interface. -    /// -    /// [`Text`]: crate::widget::Text -    fn hash_layout(&self, state: &mut Hasher, position: Point); -      /// Processes a runtime [`Event`].      ///      /// It receives: diff --git a/native/src/overlay/element.rs b/native/src/overlay/element.rs index e7621600..b60881e3 100644 --- a/native/src/overlay/element.rs +++ b/native/src/overlay/element.rs @@ -4,7 +4,7 @@ use crate::event::{self, Event};  use crate::layout;  use crate::mouse;  use crate::renderer; -use crate::{Clipboard, Hasher, Layout, Point, Rectangle, Shell, Size, Vector}; +use crate::{Clipboard, Layout, Point, Rectangle, Shell, Size, Vector};  /// A generic [`Overlay`].  #[allow(missing_debug_implementations)] @@ -100,11 +100,6 @@ where      ) {          self.overlay.draw(renderer, style, layout, cursor_position)      } - -    /// Computes the _layout_ hash of the [`Element`]. -    pub fn hash_layout(&self, state: &mut Hasher) { -        self.overlay.hash_layout(state, self.position); -    }  }  struct Map<'a, A, B, Renderer> { @@ -184,8 +179,4 @@ where      ) {          self.content.draw(renderer, style, layout, cursor_position)      } - -    fn hash_layout(&self, state: &mut Hasher, position: Point) { -        self.content.hash_layout(state, position); -    }  } diff --git a/native/src/overlay/menu.rs b/native/src/overlay/menu.rs index 2deef551..13fa7beb 100644 --- a/native/src/overlay/menu.rs +++ b/native/src/overlay/menu.rs @@ -10,8 +10,8 @@ use crate::touch;  use crate::widget::scrollable::{self, Scrollable};  use crate::widget::Container;  use crate::{ -    Clipboard, Color, Element, Hasher, Layout, Length, Padding, Point, -    Rectangle, Shell, Size, Vector, Widget, +    Clipboard, Color, Element, Layout, Length, Padding, Point, Rectangle, +    Shell, Size, Vector, Widget,  };  pub use iced_style::menu::Style; @@ -204,17 +204,6 @@ where          node      } -    fn hash_layout(&self, state: &mut Hasher, position: Point) { -        use std::hash::Hash; - -        struct Marker; -        std::any::TypeId::of::<Marker>().hash(state); - -        (position.x as u32).hash(state); -        (position.y as u32).hash(state); -        self.container.hash_layout(state); -    } -      fn on_event(          &mut self,          event: Event, @@ -320,17 +309,6 @@ where          layout::Node::new(size)      } -    fn hash_layout(&self, state: &mut Hasher) { -        use std::hash::Hash as _; - -        struct Marker; -        std::any::TypeId::of::<Marker>().hash(state); - -        self.options.len().hash(state); -        self.text_size.hash(state); -        self.padding.hash(state); -    } -      fn on_event(          &mut self,          event: Event,  | 
