Struct InspectorContext

Source
pub struct InspectorContext {
    pub stack_panel: Handle<UiNode>,
    pub menu: Menu,
    pub entries: Vec<ContextEntry>,
    pub property_definitions: Arc<PropertyEditorDefinitionContainer>,
    pub environment: Option<Arc<dyn InspectorEnvironment>>,
    pub sync_flag: u64,
    pub object_type_id: TypeId,
    pub name_column_width: f32,
}
Expand description

The widget handle and associated information that represents what an Inspector is currently displaying.

Fields§

§stack_panel: Handle<UiNode>

The handle of a UI node containing property editor widgets. This would usually be a vertical Stack widget, but any widget will sever the same purpose so long as it produces messages that are recognized by the PropertyEditorDefinitions contained in InspectorContext::property_definitions.

To ensure this, the widget should be composed of widgets produced by PropertyEditorDefinition::create_instance.

§menu: Menu

The context menu that opens when right-clicking on the inspector.

§entries: Vec<ContextEntry>

List of the editors in this inspector, in order, with each entry giving the editor widget handle, the name of the field being edited, and so on.

§property_definitions: Arc<PropertyEditorDefinitionContainer>

List if property definitions that are by sync to update the widgets of stack_panel, with the current values of properties that may have changed.

§environment: Option<Arc<dyn InspectorEnvironment>>

Untyped information from the application that is using the inspector. This can be used by editors that may be supplied by that application, if those editors know the actual type of this value to be able to successfully cast it.

§sync_flag: u64

The value given to UiMessage::flags when sync is generating update messages for editor widgets. This identifies sync messages and prevents the Inspector from trying to translate them, and thereby it prevents sync messages from potentially creating an infinite message loop.

§object_type_id: TypeId

Type id of the object for which the context was created.

§name_column_width: f32

A width of the property name column.

Implementations§

Source§

impl InspectorContext

Source

pub fn from_object( object: &(dyn Reflect + 'static), ctx: &mut BuildContext<'_>, definition_container: Arc<PropertyEditorDefinitionContainer>, environment: Option<Arc<dyn InspectorEnvironment>>, sync_flag: u64, layer_index: usize, generate_property_string_values: bool, filter: PropertyFilter, name_column_width: f32, ) -> InspectorContext

Build the widgets for an Inspector to represent the given object by accessing the object’s fields through reflection.

  • object: The object to inspect.
  • ctx: The general context for widget creation.
  • definition_container: The list of property editor definitions that will create the editors based on the type of each field.
  • environment: Untyped optional generic information about the application using the inspector, which may be useful to some editors. Often this will be Fyroxed’s EditorEnvironment.
  • sync_flag: Flag bits to identify messages that are sent by the sync method to update an editor with the current value of the property that it is editing. This becomes the value of UiMessage::flags.
  • layer_index: Inspectors can be nested within the editors of other inspectors. The layer_index is the count of how deeply nested this inspector will be.
  • generate_property_string_values: Should we use format!("{:?}", field) to construct string representations for each property?
  • filter: A filter function that controls whether each field will be included in the inspector.
Source

pub fn sync( &self, object: &(dyn Reflect + 'static), ui: &mut UserInterface, layer_index: usize, generate_property_string_values: bool, filter: PropertyFilter, ) -> Result<(), Vec<InspectorError>>

Update the widgest to reflect the value of the given object. We will iterate through the fields and find the appropriate PropertyEditorDefinition for each field. We call create_message to get each property editor definition to generate the appropriate message to get the editor widget to update itself, and we set the flags of each message to InspectorContext::sync_flag before sending the message.

  • object: The object to take the property values from.
  • ui: The UserInterface to include in the PropertyEditorMessageContext.
  • layer_index: The depth of the nesting of this inspector.
  • generator_property_string_values: if any editors within this inspector contain inner inspectors, should those inspectors generate strings for their properties?
  • filter: filter function for the fields of object and for any inspectors within the editors of this inspector.
Source

pub fn property_editors(&self) -> impl Iterator<Item = &ContextEntry>

Iterates through every property.

Source

pub fn find_property_editor(&self, name: &str) -> Option<&ContextEntry>

Return the entry for the property with the given name.

Source

pub fn find_property_editor_by_tag(&self, tag: &str) -> Option<&ContextEntry>

Return the entry for the property with the given tag.

Source

pub fn find_property_editor_widget(&self, name: &str) -> Handle<UiNode>

Shortcut for getting the editor widget from the property with the given name. Returns Handle::NONE if there is no property with that name.

Trait Implementations§

Source§

impl Clone for InspectorContext

Source§

fn clone(&self) -> InspectorContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InspectorContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for InspectorContext

Source§

fn default() -> InspectorContext

Returns the “default value” for a type. Read more
Source§

impl PartialEq for InspectorContext

Source§

fn eq(&self, other: &InspectorContext) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsyncTaskResult for T
where T: Any + Send + 'static,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> FieldValue for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self to a &dyn Any
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MessageData for T
where T: 'static + Debug + PartialEq + Any + Send + Clone,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self as Any reference.
Source§

fn compare(&self, other: &(dyn MessageData + 'static)) -> bool

Compares this message data with some other.
Source§

fn clone_box(&self) -> Box<dyn MessageData>

Clones self as boxed value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ScriptMessagePayload for T
where T: 'static + Send + Debug,

Source§

fn as_any_ref(&self) -> &(dyn Any + 'static)

Returns self as &dyn Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns self as &dyn Any
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ResourceLoadError for T
where T: 'static + Debug + Send + Sync,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,