From 071fd0e1aabfd19ba55530d13de53635714a10b6 Mon Sep 17 00:00:00 2001 From: Dmitry Stepanov Date: Sun, 26 Jul 2026 16:59:55 +0300 Subject: [PATCH] refactored hash map property editor --- .../src/inspector/editors/hashmap/editor.rs | 330 +++++++++++++----- fyrox-ui/src/inspector/editors/hashmap/mod.rs | 166 ++------- 2 files changed, 269 insertions(+), 227 deletions(-) diff --git a/fyrox-ui/src/inspector/editors/hashmap/editor.rs b/fyrox-ui/src/inspector/editors/hashmap/editor.rs index aeefeb36a..642a9e838 100644 --- a/fyrox-ui/src/inspector/editors/hashmap/editor.rs +++ b/fyrox-ui/src/inspector/editors/hashmap/editor.rs @@ -18,6 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +use crate::inspector::editors::PropertyEditorBuildContext; use crate::{ button::{Button, ButtonBuilder, ButtonMessage}, core::{pool::Handle, reflect::prelude::*, visitor::prelude::*}, @@ -29,62 +30,70 @@ use crate::{ SelectHashMapKeyDialogWindow, SelectHashMapKeyDialogWindowBuilder, SelectHashMapKeyDialogWindowMessage, }, - HashMapKey, + HashMapKey, HashMapState, HashMapValue, }, PropertyEditorDefinitionContainer, PropertyEditorInstance, }, - InspectorEnvironmentContainer, ObjectValue, + InspectorEnvironmentContainer, }, message::{MessageData, UiMessage}, widget::{Widget, WidgetBuilder}, window::{WindowAlignment, WindowBuilder, WindowMessage, WindowTitle}, - BuildContext, Control, UiNode, UserInterface, + Control, UiNode, UserInterface, VerticalAlignment, }; use fxhash::FxHashSet; +use fyrox_core::reflect; use std::{ + collections::HashMap, ops::{Deref, DerefMut}, sync::Arc, }; #[derive(Debug, PartialEq, Clone)] -pub enum HashMapPropertyEditorMessage { - ValueChanged { - key: ObjectValue, - message: UiMessage, - }, - KeyChanged { - key: ObjectValue, - message: UiMessage, - }, - Remove { - key: ObjectValue, - }, - InsertDefault { - key: ObjectValue, - }, +pub enum HashMapPropertyEditorMessage +where + K: HashMapKey, + V: HashMapValue, + S: HashMapState, +{ + Update { hash_map: HashMap }, + ValueChanged { key: K, message: UiMessage }, + KeyChanged { key: K, message: UiMessage }, + Remove { key: K }, + InsertDefault { key: K }, +} +impl MessageData for HashMapPropertyEditorMessage +where + K: HashMapKey, + V: HashMapValue, + S: HashMapState, +{ } -impl MessageData for HashMapPropertyEditorMessage {} #[derive(Debug, Reflect, Visit, Clone, PartialEq)] -#[reflect( - derived_type = "UiNode", - type_uuid = "1440dacb-19ae-425b-a1f4-9d73a1009e6a" -)] -pub struct Entry { - #[visit(skip)] - pub key: K, - pub key_hash: u64, +#[reflect(type_uuid = "1440dacb-19ae-425b-a1f4-9d73a1009e6a")] +pub struct Entry { pub key_editor: PropertyEditorInstance, pub value_editor: PropertyEditorInstance, pub remove: Handle