pub struct InspectorEguiImpl { /* private fields */ }
Expand description

Function pointers for displaying a concrete type, to be registered in the TypeRegistry.

This can used for leaf types like u8 or String, as well as people who want to completely customize the way to display a certain type.

Implementations§

Create a new InspectorEguiImpl from functions displaying a type

Examples found in repository?
src/inspector_egui_impls/mod.rs (lines 100-104)
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
fn add_no_many<T: 'static>(
    type_registry: &mut TypeRegistry,
    fn_mut: InspectorEguiImplFn,
    fn_readonly: InspectorEguiImplFnReadonly,
) {
    type_registry
        .get_mut(TypeId::of::<T>())
        .unwrap_or_else(|| panic!("{} not registered", std::any::type_name::<T>()))
        .insert(InspectorEguiImpl::new(
            fn_mut,
            fn_readonly,
            many_unimplemented::<T>,
        ));
}
fn add<T: 'static>(
    type_registry: &mut TypeRegistry,
    fn_mut: InspectorEguiImplFn,
    fn_readonly: InspectorEguiImplFnReadonly,
    fn_many: InspectorEguiImplFnMany,
) {
    type_registry
        .get_mut(TypeId::of::<T>())
        .unwrap_or_else(|| panic!("{} not registered", std::any::type_name::<T>()))
        .insert(InspectorEguiImpl::new(fn_mut, fn_readonly, fn_many));
}
Examples found in repository?
src/egui_reflect_inspector/mod.rs (line 214)
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
    pub fn ui_for_reflect_with_options(
        &mut self,
        value: &mut dyn Reflect,
        ui: &mut egui::Ui,
        id: egui::Id,
        options: &dyn Any,
    ) -> bool {
        let mut options = options;
        if options.is::<()>() {
            if let Some(data) = self
                .type_registry
                .get_type_data::<ReflectInspectorOptions>(Any::type_id(value))
            {
                options = &data.0;
            }
        }

        if let Some(s) = self
            .type_registry
            .get_type_data::<InspectorEguiImpl>(Any::type_id(value))
        {
            return s.execute(value.as_any_mut(), ui, options, self.reborrow());
        }

        if let Some(changed) = (self.short_circuit)(self, value, ui, id, options) {
            return changed;
        }

        match value.reflect_mut() {
            bevy_reflect::ReflectMut::Struct(value) => self.ui_for_struct(value, ui, id, options),
            bevy_reflect::ReflectMut::TupleStruct(value) => {
                self.ui_for_tuple_struct(value, ui, id, options)
            }
            bevy_reflect::ReflectMut::Tuple(value) => self.ui_for_tuple(value, ui, id, options),
            bevy_reflect::ReflectMut::List(value) => self.ui_for_list(value, ui, id, options),
            bevy_reflect::ReflectMut::Array(value) => self.ui_for_array(value, ui, id, options),
            bevy_reflect::ReflectMut::Map(value) => self.ui_for_reflect_map(value, ui, id, options),
            bevy_reflect::ReflectMut::Enum(value) => self.ui_for_enum(value, ui, id, options),
            bevy_reflect::ReflectMut::Value(value) => self.ui_for_value(value, ui, id, options),
        }
    }
Examples found in repository?
src/egui_reflect_inspector/mod.rs (line 261)
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
    pub fn ui_for_reflect_readonly_with_options(
        &mut self,
        value: &dyn Reflect,
        ui: &mut egui::Ui,
        id: egui::Id,
        options: &dyn Any,
    ) {
        let mut options = options;
        if options.is::<()>() {
            if let Some(data) = self
                .type_registry
                .get_type_data::<ReflectInspectorOptions>(Any::type_id(value))
            {
                options = &data.0;
            }
        }

        if let Some(s) = self
            .type_registry
            .get_type_data::<InspectorEguiImpl>(Any::type_id(value))
        {
            s.execute_readonly(value.as_any(), ui, options, self.reborrow());
            return;
        }

        if let Some(()) = (self.short_circuit_readonly)(self, value, ui, id, options) {
            return;
        }

        match value.reflect_ref() {
            bevy_reflect::ReflectRef::Struct(value) => {
                self.ui_for_struct_readonly(value, ui, id, options)
            }
            bevy_reflect::ReflectRef::TupleStruct(value) => {
                self.ui_for_tuple_struct_readonly(value, ui, id, options)
            }
            bevy_reflect::ReflectRef::Tuple(value) => {
                self.ui_for_tuple_readonly(value, ui, id, options)
            }
            bevy_reflect::ReflectRef::List(value) => {
                self.ui_for_list_readonly(value, ui, id, options)
            }
            bevy_reflect::ReflectRef::Array(value) => {
                self.ui_for_array_readonly(value, ui, id, options)
            }
            bevy_reflect::ReflectRef::Map(value) => {
                self.ui_for_reflect_map_readonly(value, ui, id, options)
            }
            bevy_reflect::ReflectRef::Enum(value) => {
                self.ui_for_enum_readonly(value, ui, id, options)
            }
            bevy_reflect::ReflectRef::Value(value) => {
                self.ui_for_value_readonly(value, ui, id, options)
            }
        }
    }
Examples found in repository?
src/egui_reflect_inspector/mod.rs (line 327)
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
    pub fn ui_for_reflect_many_with_options(
        &mut self,
        type_id: TypeId,
        name: &str,
        ui: &mut egui::Ui,
        id: egui::Id,
        options: &dyn Any,
        values: &mut [&mut dyn Reflect],
        projector: &dyn Fn(&mut dyn Reflect) -> &mut dyn Reflect,
    ) -> bool {
        let Some(registration) = self.type_registry.get(type_id) else {
            error_message_not_in_type_registry(ui, name);
            return false;
        };
        let info = registration.type_info();

        let mut options = options;
        if options.is::<()>() {
            if let Some(data) = self
                .type_registry
                .get_type_data::<ReflectInspectorOptions>(type_id)
            {
                options = &data.0;
            }
        }

        if let Some(s) = self
            .type_registry
            .get_type_data::<InspectorEguiImpl>(type_id)
        {
            return s.execute_many(ui, options, self.reborrow(), values, projector);
        }

        if let Some(changed) =
            (self.short_circuit_many)(self, type_id, name, ui, id, options, values, projector)
        {
            return changed;
        }

        match info {
            TypeInfo::Struct(info) => {
                self.ui_for_struct_many(info, ui, id, options, values, projector)
            }
            TypeInfo::TupleStruct(info) => {
                self.ui_for_tuple_struct_many(info, ui, id, options, values, projector)
            }
            TypeInfo::Tuple(info) => {
                self.ui_for_tuple_many(info, ui, id, options, values, projector)
            }
            TypeInfo::List(info) => self.ui_for_list_many(info, ui, id, options, values, projector),
            TypeInfo::Array(info) => {
                error_message_no_multiedit(
                    ui,
                    &pretty_type_name::pretty_type_name_str(info.type_name()),
                );
                false
            }
            TypeInfo::Map(info) => {
                error_message_no_multiedit(
                    ui,
                    &pretty_type_name::pretty_type_name_str(info.type_name()),
                );
                false
            }
            TypeInfo::Enum(info) => self.ui_for_enum_many(info, ui, id, options, values, projector),
            TypeInfo::Value(info) => self.ui_for_value_many(info, ui, id, options),
            TypeInfo::Dynamic(_) => {
                error_message_no_multiedit(
                    ui,
                    &pretty_type_name::pretty_type_name_str(info.type_name()),
                );
                false
            }
        }
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Return the T [ShaderType] for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
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.
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.

Returns the argument unchanged.

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

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more