diff --git a/fyrox-ui/src/inspector/editors/hashmap/editor.rs b/fyrox-ui/src/inspector/editors/hashmap/editor.rs index f5c10ce2b..71015a06d 100644 --- a/fyrox-ui/src/inspector/editors/hashmap/editor.rs +++ b/fyrox-ui/src/inspector/editors/hashmap/editor.rs @@ -18,12 +18,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -use crate::grid::{Grid, GridMessage}; -use crate::widget::WidgetMessage; use crate::{ button::{Button, ButtonBuilder, ButtonMessage}, core::{pool::Handle, reflect::prelude::*, visitor::prelude::*}, - grid::{Column, GridBuilder, Row}, + grid::{Column, Grid, GridBuilder, GridMessage, Row}, inspector::{ editors::{ hashmap::{ @@ -38,7 +36,7 @@ use crate::{ InspectorEnvironmentContainer, }, message::{MessageData, UiMessage}, - widget::{Widget, WidgetBuilder}, + widget::{Widget, WidgetBuilder, WidgetMessage}, window::{WindowAlignment, WindowBuilder, WindowMessage, WindowTitle}, BuildContext, Control, UiNode, UserInterface, }; @@ -49,7 +47,7 @@ use std::{ sync::Arc, }; -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, Clone)] pub enum HashMapPropertyEditorMessage where K: HashMapKey, @@ -62,6 +60,43 @@ where Remove { key: K }, InsertDefault { key: K }, } + +impl PartialEq for HashMapPropertyEditorMessage +where + K: HashMapKey, + V: HashMapValue, + S: HashMapState, +{ + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Entries { hash_map: a }, Self::Entries { hash_map: b }) => a.eq(b), + ( + Self::ValueChanged { + key: k_a, + message: m_a, + }, + Self::ValueChanged { + key: k_b, + message: m_b, + }, + ) => k_a.eq(k_b) && m_a.eq(m_b), + ( + Self::KeyChanged { + key: k_a, + message: m_a, + }, + Self::KeyChanged { + key: k_b, + message: m_b, + }, + ) => k_a.eq(k_b) && m_a.eq(m_b), + (Self::Remove { key: a }, Self::Remove { key: b }) => a.eq(b), + (Self::InsertDefault { key: a }, Self::InsertDefault { key: b }) => a.eq(b), + _ => false, + } + } +} + impl MessageData for HashMapPropertyEditorMessage where K: HashMapKey, diff --git a/fyrox-ui/src/inspector/editors/hashmap/mod.rs b/fyrox-ui/src/inspector/editors/hashmap/mod.rs index 77fda83b7..c72921b5c 100644 --- a/fyrox-ui/src/inspector/editors/hashmap/mod.rs +++ b/fyrox-ui/src/inspector/editors/hashmap/mod.rs @@ -57,8 +57,8 @@ impl HashMapKey for pub trait HashMapValue: Reflect + Clone + PartialEq + Default + Send {} impl HashMapValue for T {} -pub trait HashMapState: BuildHasher + Clone + Debug + PartialEq + Default + Send + 'static {} -impl HashMapState for T {} +pub trait HashMapState: BuildHasher + Clone + Debug + Default + Send + 'static {} +impl HashMapState for T {} pub struct HashMapPropertyEditorDefinition where