1use crate::style::{StyleProperty, StylePropertyContainer};
25use crate::{
26 absm::{EventAction, EventKind},
27 bit::BitField,
28 border::Border,
29 brush::{Brush, GradientPoint},
30 button::Button,
31 canvas::Canvas,
32 core::{
33 algebra::{Matrix2, Matrix3, Matrix4, SMatrix, UnitQuaternion, Vector2, Vector3, Vector4},
34 color::Color,
35 color_gradient::ColorGradient,
36 math::{curve::Curve, Rect, SmoothAngle},
37 parking_lot::{Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard},
38 pool::Handle,
39 reflect::prelude::*,
40 sstorage::ImmutableString,
41 uuid::Uuid,
42 visitor::prelude::*,
43 SafeLock,
44 },
45 decorator::Decorator,
46 dropdown_list::DropdownList,
47 expander::Expander,
48 font::FontResource,
49 formatted_text::{FormattedText, Run, RunSet, WrapMode},
50 grid::{Grid, GridDimension, SizeMode},
51 image::Image,
52 inspector::{
53 editors::{
54 array::ArrayPropertyEditorDefinition,
55 bool::BoolPropertyEditorDefinition,
56 cell::CellPropertyEditorDefinition,
57 char::CharPropertyEditorDefinition,
58 collection::{CollectionItem, VecCollectionPropertyEditorDefinition},
59 color::{ColorGradientPropertyEditorDefinition, ColorPropertyEditorDefinition},
60 curve::CurvePropertyEditorDefinition,
61 enumeration::{EnumPropertyEditorDefinition, InspectableEnum},
62 immutable_string::ImmutableStringPropertyEditorDefinition,
63 inherit::InheritablePropertyEditorDefinition,
64 inspectable::InspectablePropertyEditorDefinition,
65 key::KeyBindingPropertyEditorDefinition,
66 matrix2::MatrixPropertyEditorDefinition,
67 numeric::NumericPropertyEditorDefinition,
68 path::PathPropertyEditorDefinition,
69 quat::QuatPropertyEditorDefinition,
70 range::RangePropertyEditorDefinition,
71 rect::RectPropertyEditorDefinition,
72 refcell::RefCellPropertyEditorDefinition,
73 string::StringPropertyEditorDefinition,
74 style::StyledPropertyEditorDefinition,
75 texture_slice::TextureSlicePropertyEditorDefinition,
76 utf32::Utf32StringPropertyEditorDefinition,
77 uuid::UuidPropertyEditorDefinition,
78 vec::{
79 Vec2PropertyEditorDefinition, Vec3PropertyEditorDefinition,
80 Vec4PropertyEditorDefinition,
81 },
82 },
83 InspectorEnvironment, InspectorError, PropertyChanged, PropertyFilter,
84 },
85 key::{HotKeyEditor, KeyBinding, KeyBindingEditor},
86 list_view::{ListView, ListViewItem},
87 menu::{Menu, MenuItem},
88 message::{CursorIcon, UiMessage},
89 messagebox::MessageBox,
90 nine_patch::{NinePatch, StretchMode},
91 numeric::NumericUpDown,
92 path::PathEditor,
93 popup::Popup,
94 progress_bar::ProgressBar,
95 range::RangeEditor,
96 rect::RectEditor,
97 scroll_bar::ScrollBar,
98 scroll_panel::ScrollPanel,
99 stack_panel::StackPanel,
100 style::StyledProperty,
101 tab_control::TabControl,
102 text::Text,
103 text_box::{Position, SelectionRange, TextBox, TextCommitMode},
104 tree::{Tree, TreeRoot},
105 uuid::UuidEditor,
106 vec::VecEditor,
107 vector_image::{Primitive, VectorImage},
108 widget::Widget,
109 window::Window,
110 wrap_panel::WrapPanel,
111 BuildContext, HorizontalAlignment, Orientation, RcUiNodeHandle, RcUiNodeHandleInner, Thickness,
112 UiNode, UserInterface, VerticalAlignment,
113};
114use fxhash::FxHashMap;
115use fyrox_animation::machine::Parameter;
116use fyrox_core::pool::ObjectOrVariant;
117use fyrox_texture::TextureResource;
118use std::{
119 any::{Any, TypeId},
120 cell::RefCell,
121 fmt::Debug,
122 fmt::Formatter,
123 ops::Range,
124 path::PathBuf,
125 str::FromStr,
126 sync::Arc,
127};
128use strum::VariantNames;
129
130pub mod array;
131pub mod bit;
132pub mod bool;
133pub mod cell;
134pub mod char;
135pub mod collection;
136pub mod color;
137pub mod curve;
138pub mod enumeration;
139pub mod immutable_string;
140pub mod inherit;
141pub mod inspectable;
142pub mod key;
143pub mod matrix2;
144pub mod numeric;
145pub mod path;
146pub mod quat;
147pub mod range;
148pub mod rect;
149pub mod refcell;
150pub mod string;
151pub mod style;
152pub mod texture_slice;
153pub mod utf32;
154pub mod uuid;
155pub mod vec;
156
157pub struct PropertyEditorBuildContext<'a, 'b, 'c, 'd> {
160 pub build_context: &'a mut BuildContext<'c>,
162 pub property_info: &'b FieldRef<'b, 'd>,
164 pub environment: Option<Arc<dyn InspectorEnvironment>>,
170 pub definition_container: Arc<PropertyEditorDefinitionContainer>,
173 pub layer_index: usize,
178 pub generate_property_string_values: bool,
182 pub filter: PropertyFilter,
184 pub name_column_width: f32,
186 pub base_path: String,
187 pub has_parent_object: bool,
192}
193
194pub struct PropertyEditorMessageContext<'a, 'b, 'c> {
197 pub instance: Handle<UiNode>,
200 pub ui: &'b mut UserInterface,
204 pub property_info: &'a FieldRef<'a, 'c>,
206 pub definition_container: Arc<PropertyEditorDefinitionContainer>,
209 pub layer_index: usize,
213 pub environment: Option<Arc<dyn InspectorEnvironment>>,
218 pub generate_property_string_values: bool,
222 pub filter: PropertyFilter,
224 pub name_column_width: f32,
226 pub base_path: String,
227 pub has_parent_object: bool,
232}
233
234pub struct PropertyEditorTranslationContext<'b, 'c> {
238 pub environment: Option<Arc<dyn InspectorEnvironment>>,
253 pub name: &'b str,
256 pub message: &'c UiMessage,
258 pub definition_container: Arc<PropertyEditorDefinitionContainer>,
261}
262
263#[derive(Clone, Debug, PartialEq, Visit, Reflect)]
266pub enum PropertyEditorInstance {
267 Simple {
270 editor: Handle<UiNode>,
273 },
274 Custom {
276 container: Handle<UiNode>,
279
280 editor: Handle<UiNode>,
283 },
284}
285
286impl Default for PropertyEditorInstance {
287 fn default() -> Self {
288 Self::Simple {
289 editor: Default::default(),
290 }
291 }
292}
293
294impl PropertyEditorInstance {
295 pub fn simple(editor: Handle<impl ObjectOrVariant<UiNode>>) -> Self {
296 Self::Simple {
297 editor: editor.to_base(),
298 }
299 }
300
301 pub fn editor(&self) -> Handle<UiNode> {
302 match self {
303 PropertyEditorInstance::Simple { editor }
304 | PropertyEditorInstance::Custom { editor, .. } => *editor,
305 }
306 }
307}
308
309pub trait PropertyEditorDefinition: Debug + Send + Sync {
313 fn value_type_id(&self) -> TypeId;
315
316 fn create_instance(
321 &self,
322 ctx: PropertyEditorBuildContext,
323 ) -> Result<PropertyEditorInstance, InspectorError>;
324
325 fn create_message(
333 &self,
334 ctx: PropertyEditorMessageContext,
335 ) -> Result<Option<UiMessage>, InspectorError>;
336
337 fn translate_message(&self, ctx: PropertyEditorTranslationContext) -> Option<PropertyChanged>;
342}
343
344pub struct PropertyEditorDefinitionContainerEntry {
346 pub source_type_id: TypeId,
352 pub property_editor: Box<dyn PropertyEditorDefinition>,
355}
356
357pub struct PropertyEditorDefinitionContainer {
363 pub context_type_id: Mutex<TypeId>,
369 definitions: RwLock<FxHashMap<TypeId, PropertyEditorDefinitionContainerEntry>>,
370}
371
372impl Debug for PropertyEditorDefinitionContainer {
373 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
374 write!(f, "PropertyEditorDefinitionContainer")
375 }
376}
377
378impl Default for PropertyEditorDefinitionContainer {
379 fn default() -> Self {
380 Self {
381 context_type_id: Mutex::new(().type_id()),
382 definitions: Default::default(),
383 }
384 }
385}
386
387macro_rules! reg_array_property_editor {
388 ($container:ident, $ty:ty, $($count:literal),*) => {
389 $(
390 $container.insert(ArrayPropertyEditorDefinition::<$ty, $count>::new());
391 )*
392 }
393}
394
395macro_rules! reg_property_editor {
396 ($container:ident, $base:ident:$init:ident, $($ty:ty),*) => {
397 $(
398 $container.insert($base::<$ty>::$init());
399 )*
400 }
401}
402
403macro_rules! reg_inspectables {
404 ($container:ident, $($ty:ty),*) => {
405 $(
406 $container.insert(InspectablePropertyEditorDefinition::<$ty>::new());
407 )*
408 }
409}
410
411macro_rules! reg_matrix_property_editor {
412 ($container:ident, $base:ident[$rows:expr, $columns:expr]:$init:ident, $($ty:ty),*) => {
413 $(
414 $container.insert($base::<$rows, $columns, $ty>::$init());
415 )*
416 }
417}
418
419impl PropertyEditorDefinitionContainer {
420 pub fn empty() -> Self {
421 Self::default()
422 }
423
424 pub fn with_default_editors() -> Self {
426 let container = Self::default();
427
428 container.insert(InheritablePropertyEditorDefinition::<bool>::new());
430 container.insert(BoolPropertyEditorDefinition);
431 container.insert(CellPropertyEditorDefinition::<bool>::new());
432
433 container.insert(StringPropertyEditorDefinition);
435 container.insert(InheritablePropertyEditorDefinition::<String>::new());
436 container.insert(VecCollectionPropertyEditorDefinition::<String>::new());
437
438 container.insert(ImmutableStringPropertyEditorDefinition);
440 container.insert(InheritablePropertyEditorDefinition::<ImmutableString>::new());
441 container.insert(VecCollectionPropertyEditorDefinition::<ImmutableString>::new());
442
443 reg_property_editor! { container, NumericPropertyEditorDefinition: default, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
445 reg_property_editor! { container, InheritablePropertyEditorDefinition: new, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
446 reg_property_editor! { container, CellPropertyEditorDefinition: new, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
447
448 reg_property_editor! { container, Vec4PropertyEditorDefinition: default, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
450 reg_property_editor! { container, InheritablePropertyEditorDefinition: new,
451 Vector4<f64>, Vector4<f32>, Vector4<i64>, Vector4<u64>, Vector4<i32>, Vector4<u32>,
452 Vector4<i16>, Vector4<u16>, Vector4<i8>, Vector4<u8>, Vector4<usize>, Vector4<isize>
453 }
454
455 reg_property_editor! { container, Vec3PropertyEditorDefinition: default, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
457 reg_property_editor! { container, InheritablePropertyEditorDefinition: new,
458 Vector3<f64>, Vector3<f32>, Vector3<i64>, Vector3<u64>, Vector3<i32>, Vector3<u32>,
459 Vector3<i16>, Vector3<u16>, Vector3<i8>, Vector3<u8>, Vector3<usize>, Vector3<isize>
460 }
461
462 reg_property_editor! { container, Vec2PropertyEditorDefinition: default, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
464 reg_property_editor! { container, InheritablePropertyEditorDefinition: new,
465 Vector2<f64>, Vector2<f32>, Vector2<i64>, Vector2<u64>, Vector2<i32>, Vector2<u32>,
466 Vector2<i16>, Vector2<u16>, Vector2<i8>, Vector2<u8>, Vector2<usize>, Vector2<isize>
467 }
468
469 reg_matrix_property_editor! { container, MatrixPropertyEditorDefinition[2, 2]: default, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
470 reg_matrix_property_editor! { container, MatrixPropertyEditorDefinition[3, 3]: default, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
471 reg_matrix_property_editor! { container, MatrixPropertyEditorDefinition[4, 4]: default, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
472
473 container.insert(VecCollectionPropertyEditorDefinition::<SMatrix<f32, 2, 2>>::new());
474 container.insert(VecCollectionPropertyEditorDefinition::<SMatrix<f32, 3, 3>>::new());
475 container.insert(VecCollectionPropertyEditorDefinition::<SMatrix<f32, 4, 4>>::new());
476
477 container.insert(VecCollectionPropertyEditorDefinition::<SMatrix<f64, 2, 2>>::new());
478 container.insert(VecCollectionPropertyEditorDefinition::<SMatrix<f64, 3, 3>>::new());
479 container.insert(VecCollectionPropertyEditorDefinition::<SMatrix<f64, 4, 4>>::new());
480
481 container.insert(CellPropertyEditorDefinition::<Matrix2<f32>>::new());
482 container.insert(CellPropertyEditorDefinition::<Matrix3<f32>>::new());
483 container.insert(CellPropertyEditorDefinition::<Matrix4<f32>>::new());
484
485 reg_property_editor! { container, RangePropertyEditorDefinition: new, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
487 reg_property_editor! { container, InheritablePropertyEditorDefinition: new,
488 Range<f64>, Range<f32>, Range<i64>, Range<u64>, Range<i32>, Range<u32>,
489 Range<i16>, Range<u16>, Range<i8>, Range<u8>, Range<usize>, Range<isize>
490 }
491
492 container.insert(QuatPropertyEditorDefinition::<f64>::default());
494 container.insert(InheritablePropertyEditorDefinition::<UnitQuaternion<f64>>::new());
495 container.insert(QuatPropertyEditorDefinition::<f32>::default());
496 container.insert(InheritablePropertyEditorDefinition::<UnitQuaternion<f32>>::new());
497
498 reg_property_editor! { container, RectPropertyEditorDefinition: new, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
500 reg_property_editor! { container, InheritablePropertyEditorDefinition: new,
501 Rect<f64>, Rect<f32>, Rect<i64>, Rect<u64>, Rect<i32>, Rect<u32>,
502 Rect<i16>, Rect<u16>, Rect<i8>, Rect<u8>, Rect<usize>, Rect<isize>
503 }
504 reg_property_editor! { container, InheritablePropertyEditorDefinition: new,
505 Option<Rect<f64>>, Option<Rect<f32>>, Option<Rect<i64>>, Option<Rect<u64>>, Option<Rect<i32>>, Option<Rect<u32>>,
506 Option<Rect<i16>>, Option<Rect<u16>>, Option<Rect<i8>>, Option<Rect<u8>>, Option<Rect<usize>>, Option<Rect<isize>>
507 }
508 reg_property_editor! { container, EnumPropertyEditorDefinition: new_optional,
509 Rect<f64>, Rect<f32>, Rect<i64>, Rect<u64>, Rect<i32>, Rect<u32>,
510 Rect<i16>, Rect<u16>, Rect<i8>, Rect<u8>, Rect<usize>, Rect<isize>
511 }
512
513 reg_property_editor! { container, EnumPropertyEditorDefinition: new_optional, f64, f32, i64, u64, i32, u32, i16, u16, i8, u8, usize, isize }
515 reg_property_editor! { container, InheritablePropertyEditorDefinition: new,
516 Option<f64>, Option<f32>, Option<i64>, Option<u64>, Option<i32>, Option<u32>,
517 Option<i16>, Option<u16>, Option<i8>, Option<u8>, Option<usize>, Option<isize>
518 }
519
520 container.insert(PathPropertyEditorDefinition);
522 container.insert(VecCollectionPropertyEditorDefinition::<PathBuf>::new());
523
524 container.insert(ColorPropertyEditorDefinition);
526 container.insert(InheritablePropertyEditorDefinition::<Color>::new());
527
528 reg_array_property_editor! { container, f64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
530 reg_array_property_editor! { container, f32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
531 reg_array_property_editor! { container, u64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
532 reg_array_property_editor! { container, i64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
533 reg_array_property_editor! { container, u32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
534 reg_array_property_editor! { container, i32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
535 reg_array_property_editor! { container, u16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
536 reg_array_property_editor! { container, i16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
537 reg_array_property_editor! { container, u8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
538 reg_array_property_editor! { container, i8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
539 reg_array_property_editor! { container, u8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
540 reg_array_property_editor! { container, usize, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
541 reg_array_property_editor! { container, isize, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
542
543 container.register_inheritable_inspectable::<SmoothAngle>();
545
546 container.insert(UuidPropertyEditorDefinition);
548 container.insert(InheritablePropertyEditorDefinition::<Uuid>::new());
549
550 container.insert(ColorGradientPropertyEditorDefinition);
552 container.insert(InheritablePropertyEditorDefinition::<ColorGradient>::new());
553
554 container.insert(KeyBindingPropertyEditorDefinition);
556 container.insert(InheritablePropertyEditorDefinition::<KeyBinding>::new());
557
558 container.insert(CurvePropertyEditorDefinition);
560 container.insert(InheritablePropertyEditorDefinition::<Curve>::new());
561
562 container.register_inheritable_styleable_enum::<Brush, _>();
564 container.register_inheritable_enum::<Orientation, _>();
565 container.register_inheritable_enum::<VerticalAlignment, _>();
566 container.register_inheritable_enum::<HorizontalAlignment, _>();
567 container.register_inheritable_enum::<WrapMode, _>();
568 container.register_inheritable_enum::<Primitive, _>();
569 container.register_inheritable_enum::<SizeMode, _>();
570 container.insert(EnumPropertyEditorDefinition::<CursorIcon>::new());
571 container.insert(EnumPropertyEditorDefinition::<CursorIcon>::new_optional());
572 container.insert(EnumPropertyEditorDefinition::<bool>::new_optional());
573 container.insert(InheritablePropertyEditorDefinition::<Option<bool>>::new());
574 container.insert(InheritablePropertyEditorDefinition::<Option<CursorIcon>>::new());
575
576 container.register_inheritable_vec_collection::<GradientPoint>();
577 container.register_inheritable_vec_collection::<Primitive>();
578
579 container.insert(RefCellPropertyEditorDefinition::<FormattedText>::new());
580
581 container.insert(VecCollectionPropertyEditorDefinition::<GridDimension>::new());
582 container.insert(RefCellPropertyEditorDefinition::<Vec<GridDimension>>::new());
583 container.insert(InheritablePropertyEditorDefinition::<
584 RefCell<Vec<GridDimension>>,
585 >::new());
586
587 container.insert(Utf32StringPropertyEditorDefinition);
588 container.insert(InheritablePropertyEditorDefinition::<Vec<char>>::new());
589
590 container.insert(InheritablePropertyEditorDefinition::<Thickness>::new());
591
592 container.register_inheritable_enum::<EventKind, _>();
593
594 container.register_inheritable_enum::<StretchMode, _>();
595
596 container.insert(InspectablePropertyEditorDefinition::<EventAction>::new());
597 container.register_inheritable_vec_collection::<EventAction>();
598
599 container.insert(EnumPropertyEditorDefinition::<Parameter>::new());
600
601 container.insert(EnumPropertyEditorDefinition::<TextCommitMode>::new());
602 container.insert(InheritablePropertyEditorDefinition::<TextCommitMode>::new());
603
604 container.insert(EnumPropertyEditorDefinition::<SelectionRange>::new_optional());
605 container.insert(InheritablePropertyEditorDefinition::<Option<SelectionRange>>::new());
606
607 container.register_inheritable_inspectable::<Position>();
608
609 container.insert(EnumPropertyEditorDefinition::<RcUiNodeHandle>::new_optional());
610 container.insert(InspectablePropertyEditorDefinition::<RcUiNodeHandle>::new());
611 container.insert(InspectablePropertyEditorDefinition::<RcUiNodeHandleInner>::new());
612 container.insert(InspectablePropertyEditorDefinition::<
613 Arc<Mutex<RcUiNodeHandleInner>>,
614 >::new());
615
616 container.insert(TextureSlicePropertyEditorDefinition);
617
618 container.insert(InspectablePropertyEditorDefinition::<RunSet>::new());
619 container.insert(InspectablePropertyEditorDefinition::<Run>::new());
620 container.insert(VecCollectionPropertyEditorDefinition::<Run>::new());
621 container.insert(EnumPropertyEditorDefinition::<FontResource>::new_optional());
622 container.insert(EnumPropertyEditorDefinition::<Brush>::new_optional());
623 container.insert(EnumPropertyEditorDefinition::<Vector2<f32>>::new_optional());
624
625 container.insert(InheritablePropertyEditorDefinition::<Option<char>>::new());
626 container.insert(EnumPropertyEditorDefinition::<char>::new_optional());
627 container.insert(CharPropertyEditorDefinition);
628
629 container.insert(InheritablePropertyEditorDefinition::<StyledProperty<f32>>::new());
631 container.insert(StyledPropertyEditorDefinition::<f32>::new());
632
633 container.insert(InheritablePropertyEditorDefinition::<StyledProperty<Color>>::new());
634 container.insert(StyledPropertyEditorDefinition::<Color>::new());
635
636 container.insert(InheritablePropertyEditorDefinition::<
637 StyledProperty<Thickness>,
638 >::new());
639 container.insert(StyledPropertyEditorDefinition::<Thickness>::new());
640
641 container.insert(InheritablePropertyEditorDefinition::<
642 StyledProperty<TextureResource>,
643 >::new());
644 container.insert(StyledPropertyEditorDefinition::<TextureResource>::new());
645 container.insert(VecCollectionPropertyEditorDefinition::<
646 StylePropertyContainer,
647 >::new());
648 container.insert(InspectablePropertyEditorDefinition::<StylePropertyContainer>::new());
649 container.insert(EnumPropertyEditorDefinition::<StyleProperty>::new());
650
651 reg_inspectables!(
652 container,
653 Widget,
655 Border,
656 BitField<u8>,
657 BitField<i8>,
658 BitField<u16>,
659 BitField<i16>,
660 BitField<u32>,
661 BitField<i32>,
662 BitField<u64>,
663 BitField<i64>,
664 Button,
665 Canvas,
666 Decorator,
667 DropdownList,
668 Expander,
669 Grid,
670 Image,
671 HotKeyEditor,
672 KeyBindingEditor,
673 ListViewItem,
674 ListView,
675 Menu,
676 MenuItem,
677 MessageBox,
678 NinePatch,
679 NumericUpDown<u8>,
680 NumericUpDown<i8>,
681 NumericUpDown<u16>,
682 NumericUpDown<i16>,
683 NumericUpDown<u32>,
684 NumericUpDown<i32>,
685 NumericUpDown<u64>,
686 NumericUpDown<i64>,
687 NumericUpDown<f32>,
688 NumericUpDown<f64>,
689 PathEditor,
690 Popup,
691 ProgressBar,
692 RangeEditor<u8>,
693 RangeEditor<i8>,
694 RangeEditor<u16>,
695 RangeEditor<i16>,
696 RangeEditor<u32>,
697 RangeEditor<i32>,
698 RangeEditor<u64>,
699 RangeEditor<i64>,
700 RangeEditor<f32>,
701 RangeEditor<f64>,
702 RectEditor<u8>,
703 RectEditor<i8>,
704 RectEditor<u16>,
705 RectEditor<i16>,
706 RectEditor<u32>,
707 RectEditor<i32>,
708 RectEditor<u64>,
709 RectEditor<i64>,
710 RectEditor<f32>,
711 RectEditor<f64>,
712 ScrollBar,
713 ScrollPanel,
714 StackPanel,
715 TabControl,
716 Text,
717 TextBox,
718 Tree,
719 TreeRoot,
720 UuidEditor,
721 VecEditor<u8, 2>,
722 VecEditor<i8, 2>,
723 VecEditor<u16,2>,
724 VecEditor<i16,2>,
725 VecEditor<u32,2>,
726 VecEditor<i32,2>,
727 VecEditor<u64,2>,
728 VecEditor<i64,2>,
729 VecEditor<f32,2>,
730 VecEditor<f64,2>,
731 VecEditor<u8, 3>,
732 VecEditor<i8, 3>,
733 VecEditor<u16,3>,
734 VecEditor<i16,3>,
735 VecEditor<u32,3>,
736 VecEditor<i32,3>,
737 VecEditor<u64,3>,
738 VecEditor<i64,3>,
739 VecEditor<f32,3>,
740 VecEditor<f64,3>,
741 VecEditor<u8, 4>,
742 VecEditor<i8, 4>,
743 VecEditor<u16,4>,
744 VecEditor<i16,4>,
745 VecEditor<u32,4>,
746 VecEditor<i32,4>,
747 VecEditor<u64,4>,
748 VecEditor<i64,4>,
749 VecEditor<f32,4>,
750 VecEditor<f64,4>,
751 VectorImage,
752 Window,
753 WrapPanel,
754 GradientPoint,
756 Thickness,
757 FormattedText,
758 GridDimension
759 );
760
761 container
762 }
763
764 pub fn insert_raw(
768 &self,
769 definition: Box<dyn PropertyEditorDefinition>,
770 ) -> Option<PropertyEditorDefinitionContainerEntry> {
771 self.definitions.write().insert(
772 definition.value_type_id(),
773 PropertyEditorDefinitionContainerEntry {
774 source_type_id: *self.context_type_id.safe_lock(),
775 property_editor: definition,
776 },
777 )
778 }
779
780 pub fn merge(&self, other: Self) {
784 for (_, definition) in other.definitions.into_inner() {
785 self.insert_raw(definition.property_editor);
786 }
787 }
788
789 pub fn insert<T>(&self, definition: T) -> Option<PropertyEditorDefinitionContainerEntry>
793 where
794 T: PropertyEditorDefinition + 'static,
795 {
796 self.definitions.write().insert(
797 definition.value_type_id(),
798 PropertyEditorDefinitionContainerEntry {
799 source_type_id: *self.context_type_id.safe_lock(),
800 property_editor: Box::new(definition),
801 },
802 )
803 }
804
805 pub fn register_inheritable_vec_collection<T>(&self)
808 where
809 T: CollectionItem + FieldValue,
810 {
811 assert!(self
812 .insert(VecCollectionPropertyEditorDefinition::<T>::new())
813 .is_none());
814 assert!(self
815 .insert(InheritablePropertyEditorDefinition::<Vec<T>>::new())
816 .is_none());
817 }
818
819 pub fn register_inheritable_inspectable<T>(&self)
828 where
829 T: Reflect + FieldValue,
830 {
831 assert!(self
832 .insert(InspectablePropertyEditorDefinition::<T>::new())
833 .is_none());
834 assert!(self
835 .insert(InheritablePropertyEditorDefinition::<T>::new())
836 .is_none());
837 }
838
839 pub fn register_inheritable_styleable_inspectable<T>(&self)
840 where
841 T: Reflect + FieldValue + Clone + PartialEq,
842 {
843 assert!(self
844 .insert(InspectablePropertyEditorDefinition::<T>::new())
845 .is_none());
846 assert!(self
847 .insert(InheritablePropertyEditorDefinition::<T>::new())
848 .is_none());
849 assert!(self
850 .insert(InheritablePropertyEditorDefinition::<StyledProperty<T>>::new())
851 .is_none());
852 assert!(self
853 .insert(StyledPropertyEditorDefinition::<T>::new())
854 .is_none());
855 }
856
857 pub fn register_inheritable_enum<T, E: Debug>(&self)
862 where
863 T: InspectableEnum + FieldValue + VariantNames + AsRef<str> + FromStr<Err = E> + Debug,
864 {
865 assert!(self
866 .insert(EnumPropertyEditorDefinition::<T>::new())
867 .is_none());
868 assert!(self
869 .insert(InheritablePropertyEditorDefinition::<T>::new())
870 .is_none());
871 }
872
873 pub fn register_inheritable_styleable_enum<T, E: Debug>(&self)
874 where
875 T: InspectableEnum
876 + FieldValue
877 + VariantNames
878 + AsRef<str>
879 + FromStr<Err = E>
880 + Debug
881 + PartialEq,
882 {
883 assert!(self
884 .insert(EnumPropertyEditorDefinition::<T>::new())
885 .is_none());
886 assert!(self
887 .insert(InheritablePropertyEditorDefinition::<T>::new())
888 .is_none());
889 assert!(self
890 .insert(InheritablePropertyEditorDefinition::<StyledProperty<T>>::new())
891 .is_none());
892 assert!(self
893 .insert(StyledPropertyEditorDefinition::<T>::new())
894 .is_none());
895 }
896
897 pub fn register_inheritable_option<T>(&self)
902 where
903 T: InspectableEnum + FieldValue + Default,
904 {
905 assert!(self
906 .insert(EnumPropertyEditorDefinition::<T>::new_optional())
907 .is_none());
908 assert!(self
909 .insert(InheritablePropertyEditorDefinition::<Option<T>>::new())
910 .is_none());
911 }
912
913 pub fn definitions(
915 &self,
916 ) -> RwLockReadGuard<FxHashMap<TypeId, PropertyEditorDefinitionContainerEntry>> {
917 self.definitions.read()
918 }
919
920 pub fn definitions_mut(
922 &self,
923 ) -> RwLockWriteGuard<FxHashMap<TypeId, PropertyEditorDefinitionContainerEntry>> {
924 self.definitions.write()
925 }
926}