pub trait PropertyEditorDefinition:
Debug
+ Send
+ Sync {
// Required methods
fn value_type_id(&self) -> TypeId;
fn create_instance(
&self,
ctx: PropertyEditorBuildContext<'_, '_, '_, '_>,
) -> Result<PropertyEditorInstance, InspectorError>;
fn create_message(
&self,
ctx: PropertyEditorMessageContext<'_, '_, '_>,
) -> Result<Option<UiMessage>, InspectorError>;
fn translate_message(
&self,
ctx: PropertyEditorTranslationContext<'_, '_>,
) -> Option<PropertyChanged>;
}
Expand description
The trait for all property editor definitions which are capable of providing and editor widget to an Inspector and helping the inspector handle the necessary messages to and from that widget.
Required Methods§
Sourcefn value_type_id(&self) -> TypeId
fn value_type_id(&self) -> TypeId
The type of property that the editor will edit.
Sourcefn create_instance(
&self,
ctx: PropertyEditorBuildContext<'_, '_, '_, '_>,
) -> Result<PropertyEditorInstance, InspectorError>
fn create_instance( &self, ctx: PropertyEditorBuildContext<'_, '_, '_, '_>, ) -> Result<PropertyEditorInstance, InspectorError>
Build a widget that an Inspector can use to edit this property. The returned value is either a simple property editor instance which contains just a UiNode handle, or else it is a custom editor instance that contains both the handle of the editor and the handle of the container.
Sourcefn create_message(
&self,
ctx: PropertyEditorMessageContext<'_, '_, '_>,
) -> Result<Option<UiMessage>, InspectorError>
fn create_message( &self, ctx: PropertyEditorMessageContext<'_, '_, '_>, ) -> Result<Option<UiMessage>, InspectorError>
Create a message that will tell the editor widget to update itself with the current value of the property. This is called by InspectorContext::sync.
Despite the name, this method is also permitted to send messages directly to the widget instead of returning anything. If messages are sent directly, they should have their UiMessage::flags set to PropertyEditorMessageContext::sync_flag, as this is required to identify the message a sync message and prevent potential infinite message loops.
If a message is returned, the caller is responsible for setting flags
and sending the message.
Sourcefn translate_message(
&self,
ctx: PropertyEditorTranslationContext<'_, '_>,
) -> Option<PropertyChanged>
fn translate_message( &self, ctx: PropertyEditorTranslationContext<'_, '_>, ) -> Option<PropertyChanged>
Translate messages from the editor widget created by PropertyEditorDefinition::create_message into PropertyChanged messages that the Inspector widget can use to apply updates. The given PropertyEditorTranslationContext contains all the relevant details of the message to be translated.