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§
source§impl InspectorEguiImpl
impl InspectorEguiImpl
sourcepub fn new(
fn_mut: fn(_: &mut dyn Any, _: &mut Ui, _: &dyn Any, _: InspectorUi<'_, '_>) -> bool,
fn_readonly: fn(_: &dyn Any, _: &mut Ui, _: &dyn Any, _: InspectorUi<'_, '_>),
fn_many: for<'a> fn(_: &mut Ui, _: &dyn Any, _: InspectorUi<'_, '_>, _: &mut [&mut dyn Reflect], _: &dyn Fn(&mut dyn Reflect) -> &mut dyn Reflect) -> bool
) -> Self
pub fn new(
fn_mut: fn(_: &mut dyn Any, _: &mut Ui, _: &dyn Any, _: InspectorUi<'_, '_>) -> bool,
fn_readonly: fn(_: &dyn Any, _: &mut Ui, _: &dyn Any, _: InspectorUi<'_, '_>),
fn_many: for<'a> fn(_: &mut Ui, _: &dyn Any, _: InspectorUi<'_, '_>, _: &mut [&mut dyn Reflect], _: &dyn Fn(&mut dyn Reflect) -> &mut dyn Reflect) -> bool
) -> Self
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));
}
sourcepub fn execute<'a, 'c: 'a>(
&'a self,
value: &mut dyn Any,
ui: &mut Ui,
options: &dyn Any,
env: InspectorUi<'_, '_>
) -> bool
pub fn execute<'a, 'c: 'a>(
&'a self,
value: &mut dyn Any,
ui: &mut Ui,
options: &dyn Any,
env: InspectorUi<'_, '_>
) -> bool
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),
}
}
sourcepub fn execute_readonly<'a, 'c: 'a>(
&'a self,
value: &dyn Any,
ui: &mut Ui,
options: &dyn Any,
env: InspectorUi<'_, '_>
)
pub fn execute_readonly<'a, 'c: 'a>(
&'a self,
value: &dyn Any,
ui: &mut Ui,
options: &dyn Any,
env: InspectorUi<'_, '_>
)
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)
}
}
}
sourcepub fn execute_many<'a, 'c: 'a, 'e>(
&'a self,
ui: &mut Ui,
options: &dyn Any,
env: InspectorUi<'_, '_>,
values: &mut [&mut dyn Reflect],
projector: &dyn Fn(&mut dyn Reflect) -> &mut dyn Reflect
) -> bool
pub fn execute_many<'a, 'c: 'a, 'e>(
&'a self,
ui: &mut Ui,
options: &dyn Any,
env: InspectorUi<'_, '_>,
values: &mut [&mut dyn Reflect],
projector: &dyn Fn(&mut dyn Reflect) -> &mut dyn Reflect
) -> bool
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§
source§impl Clone for InspectorEguiImpl
impl Clone for InspectorEguiImpl
source§fn clone(&self) -> InspectorEguiImpl
fn clone(&self) -> InspectorEguiImpl
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl RefUnwindSafe for InspectorEguiImpl
impl Send for InspectorEguiImpl
impl Sync for InspectorEguiImpl
impl Unpin for InspectorEguiImpl
impl UnwindSafe for InspectorEguiImpl
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
Return the
T
[ShaderType
] for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
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.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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.