Remove generics from the user-facing name for the Vector data type
This commit is contained in:
parent
fa45efa9e2
commit
2fa958aa79
|
|
@ -233,15 +233,7 @@ pub(crate) fn property_from_type(
|
|||
widgets.extend_from_slice(&[
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
TextLabel::new("-")
|
||||
.tooltip_label(format!(
|
||||
"Data Type: {}",
|
||||
concrete_type
|
||||
.alias
|
||||
.as_deref()
|
||||
// TODO: Avoid needing to remove spaces here by fixing how `alias` is generated
|
||||
.map(|s| s.to_string().replace(" ", ""))
|
||||
.unwrap_or_else(|| graphene_std::format_type(concrete_type.name.as_ref())),
|
||||
))
|
||||
.tooltip_label(format!("Data Type: {concrete_type}"))
|
||||
.tooltip_description("This data can only be supplied through the node graph because no widget exists for its type.")
|
||||
.widget_instance(),
|
||||
]);
|
||||
|
|
@ -251,7 +243,7 @@ pub(crate) fn property_from_type(
|
|||
}
|
||||
}
|
||||
}
|
||||
Type::Generic(_) => vec![TextLabel::new("Generic type (not supported)").widget_instance()].into(),
|
||||
Type::Generic(_) => vec![TextLabel::new("Generic Type (Not Supported)").widget_instance()].into(),
|
||||
Type::Fn(_, out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context),
|
||||
Type::Future(out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -216,6 +216,13 @@ impl std::hash::Hash for TypeDescriptor {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for TypeDescriptor {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let text = make_type_user_readable(&format_type(&self.name));
|
||||
write!(f, "{text}")
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for TypeDescriptor {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self.id, other.id) {
|
||||
|
|
@ -361,9 +368,13 @@ pub fn format_type(ty: &str) -> String {
|
|||
.join("<")
|
||||
}
|
||||
|
||||
pub fn make_type_user_readable(ty: &str) -> String {
|
||||
ty.replace("Option<Arc<OwnedContextImpl>>", "Context").replace("Vector<Option<Table<Graphic>>>", "Vector")
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Type {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let result = match self {
|
||||
let text = match self {
|
||||
Self::Generic(name) => name.to_string(),
|
||||
#[cfg(feature = "type_id_logging")]
|
||||
Self::Concrete(ty) => format!("Concrete<{}, {:?}>", ty.name, ty.id),
|
||||
|
|
@ -372,20 +383,20 @@ impl std::fmt::Debug for Type {
|
|||
Self::Fn(call_arg, return_value) => format!("{return_value:?} called with {call_arg:?}"),
|
||||
Self::Future(ty) => format!("{ty:?}"),
|
||||
};
|
||||
let result = result.replace("Option<Arc<OwnedContextImpl>>", "Context");
|
||||
write!(f, "{result}")
|
||||
let text = make_type_user_readable(&text);
|
||||
write!(f, "{text}")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Type {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let result = match self {
|
||||
let text = match self {
|
||||
Type::Generic(name) => name.to_string(),
|
||||
Type::Concrete(ty) => format_type(&ty.name),
|
||||
Type::Fn(call_arg, return_value) => format!("{return_value} called with {call_arg}"),
|
||||
Type::Future(ty) => ty.to_string(),
|
||||
};
|
||||
let result = result.replace("Option<Arc<OwnedContextImpl>>", "Context");
|
||||
write!(f, "{result}")
|
||||
let text = make_type_user_readable(&text);
|
||||
write!(f, "{text}")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue