From de2f8a58a3205030ef4a7a3d0da389aa2c7eaab5 Mon Sep 17 00:00:00 2001 From: timpieces <6488596+timpieces@users.noreply.github.com> Date: Thu, 11 Dec 2025 22:56:26 +0800 Subject: [PATCH] Add proper tooltips for Material properties #24434 (#25509) --- src/Gui/Dialogs/DlgMaterialProperties.ui | 24 +++++++ src/Gui/propertyeditor/PropertyItem.cpp | 66 +++++++++++++++++++ src/Gui/propertyeditor/PropertyItem.h | 2 + src/Mod/Material/Gui/DlgInspectAppearance.cpp | 22 +++++++ .../Models/Rendering/BasicRendering.yml | 31 +++++++-- 5 files changed, 139 insertions(+), 6 deletions(-) diff --git a/src/Gui/Dialogs/DlgMaterialProperties.ui b/src/Gui/Dialogs/DlgMaterialProperties.ui index 1de2e032f8..f99d71d512 100644 --- a/src/Gui/Dialogs/DlgMaterialProperties.ui +++ b/src/Gui/Dialogs/DlgMaterialProperties.ui @@ -46,6 +46,9 @@ Diffuse color + + Defines the base color of a surface when illuminated by light. It represents how the object scatters light evenly in all directions, independent of the viewer’s angle. This property will influence the material color the most. + @@ -53,6 +56,9 @@ Shininess + + Defines the size and sharpness of specular highlights on a surface. Higher values produce small, sharp highlights, while lower values create broad, soft highlights. Note that the highlight intensity is defined by specular color. + @@ -70,6 +76,9 @@ Reset + + Reverts changes done in the dialogue. + @@ -77,6 +86,9 @@ Ambient color + + Defines the color of a surface under indirect, uniform lighting, representing how it appears when illuminated only by ambient light in a scene, without directional light, shading, or highlights + @@ -113,6 +125,9 @@ Specular color + + Defines the color and intensity of the bright, mirror-like highlights that appear on shiny or reflective surfaces when light hits them directly. Set to bright colors for shiny objects. + @@ -130,6 +145,9 @@ Default + + Changes all values to default values + @@ -147,6 +165,9 @@ Emissive color + + Defines the color of a surface that appears to emit as if it were a light source, independent of external lighting, making the object look self-illuminated. Set to black to have no emissive color. + @@ -154,6 +175,9 @@ Transparency + + Defines how much light passes through an object, making it partially or fully see-through + diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 904fd58130..eb99f19c85 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -650,6 +650,11 @@ void PropertyItem::setPropertyValue(const std::string& value) } } +void PropertyItem::setNameToolTipOverride(const QString& name) +{ + nameToolTipOverride = name; +} + void PropertyItem::setPropertyValue(const QString& value) { setPropertyValue(value.toStdString()); @@ -676,6 +681,9 @@ QVariant PropertyItem::dataPropertyName(int role) const } // no properties set if (propertyItems.empty()) { + if (role == Qt::ToolTipRole && nameToolTipOverride.size()) { + return nameToolTipOverride; + } return {}; } if (role == Qt::ToolTipRole) { @@ -3557,21 +3565,41 @@ PropertyMaterialItem::PropertyMaterialItem() diffuse = static_cast(PropertyColorItem::create()); diffuse->setParent(this); diffuse->setPropertyName(QLatin1String("DiffuseColor")); + diffuse->setNameToolTipOverride( + tr("Defines the base color of a surface when illuminated by light. It represents how the " + "object scatters light evenly in all directions, independent of the viewer’s angle. " + "This property will influence the material color the most.") + ); this->appendChild(diffuse); ambient = static_cast(PropertyColorItem::create()); ambient->setParent(this); ambient->setPropertyName(QLatin1String("AmbientColor")); + ambient->setNameToolTipOverride( + tr("Defines the color of a surface under indirect, uniform lighting, representing how it " + "appears when illuminated only by ambient light in a scene, without directional light, " + "shading, or highlights") + ); this->appendChild(ambient); specular = static_cast(PropertyColorItem::create()); specular->setParent(this); specular->setPropertyName(QLatin1String("SpecularColor")); + specular->setNameToolTipOverride( + tr("Defines the color and intensity of the bright, mirror-like highlights that appear on " + "shiny or reflective surfaces when light hits them directly. Set to bright colors for " + "shiny objects.") + ); this->appendChild(specular); emissive = static_cast(PropertyColorItem::create()); emissive->setParent(this); emissive->setPropertyName(QLatin1String("EmissiveColor")); + emissive->setNameToolTipOverride( + tr("Defines the color of a surface that appears to emit as if it were a light source, " + "independent of external lighting, making the object look self-illuminated. Set to " + "black to have no emissive color.") + ); this->appendChild(emissive); shininess = static_cast(PropertyIntegerConstraintItem::create()); @@ -3579,6 +3607,11 @@ PropertyMaterialItem::PropertyMaterialItem() shininess->setStepSize(steps); shininess->setParent(this); shininess->setPropertyName(QLatin1String("Shininess")); + shininess->setNameToolTipOverride( + tr("Defines the size and sharpness of specular highlights on a surface. Higher values " + "produce small, sharp highlights, while lower values create broad, soft highlights. " + "Note that the highlight intensity is defined by specular color.") + ); this->appendChild(shininess); transparency = static_cast(PropertyIntegerConstraintItem::create()); @@ -3586,6 +3619,10 @@ PropertyMaterialItem::PropertyMaterialItem() transparency->setStepSize(steps); transparency->setParent(this); transparency->setPropertyName(QLatin1String("Transparency")); + transparency->setNameToolTipOverride( + tr("Defines how much light passes through an object, making it " + "partially or fully see-through") + ); this->appendChild(transparency); } @@ -3894,21 +3931,41 @@ PropertyMaterialListItem::PropertyMaterialListItem() diffuse = static_cast(PropertyColorItem::create()); diffuse->setParent(this); diffuse->setPropertyName(QLatin1String("DiffuseColor")); + diffuse->setNameToolTipOverride( + tr("Defines the base color of a surface when illuminated by light. It represents how the " + "object scatters light evenly in all directions, independent of the viewer’s angle. " + "This property will influence the material color the most.") + ); this->appendChild(diffuse); ambient = static_cast(PropertyColorItem::create()); ambient->setParent(this); ambient->setPropertyName(QLatin1String("AmbientColor")); + ambient->setNameToolTipOverride( + tr("Defines the color of a surface under indirect, uniform lighting, representing how it " + "appears when illuminated only by ambient light in a scene, without directional light, " + "shading, or highlights") + ); this->appendChild(ambient); specular = static_cast(PropertyColorItem::create()); specular->setParent(this); specular->setPropertyName(QLatin1String("SpecularColor")); + specular->setNameToolTipOverride( + tr("Defines the color and intensity of the bright, mirror-like highlights that appear on " + "shiny or reflective surfaces when light hits them directly. Set to bright colors for " + "shiny objects.") + ); this->appendChild(specular); emissive = static_cast(PropertyColorItem::create()); emissive->setParent(this); emissive->setPropertyName(QLatin1String("EmissiveColor")); + emissive->setNameToolTipOverride( + tr("Defines the color of a surface that appears to emit as if it were a light source, " + "independent of external lighting, making the object look self-illuminated. Set to " + "black to have no emissive color.") + ); this->appendChild(emissive); shininess = static_cast(PropertyIntegerConstraintItem::create()); @@ -3916,6 +3973,11 @@ PropertyMaterialListItem::PropertyMaterialListItem() shininess->setStepSize(steps); shininess->setParent(this); shininess->setPropertyName(QLatin1String("Shininess")); + shininess->setNameToolTipOverride( + tr("Defines the size and sharpness of specular highlights on a surface. Higher values " + "produce small, sharp highlights, while lower values create broad, soft highlights. " + "Note that the highlight intensity is defined by specular color.") + ); this->appendChild(shininess); transparency = static_cast(PropertyIntegerConstraintItem::create()); @@ -3923,6 +3985,10 @@ PropertyMaterialListItem::PropertyMaterialListItem() transparency->setStepSize(steps); transparency->setParent(this); transparency->setPropertyName(QLatin1String("Transparency")); + transparency->setNameToolTipOverride( + tr("Defines how much light passes through an object, making it " + "partially or fully see-through") + ); this->appendChild(transparency); } diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index be5834df07..e7b9683d9b 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -210,6 +210,7 @@ public: QString propertyName() const; void setPropertyName(const QString& name, const QString& realName = QString()); void setPropertyValue(const QString&); + void setNameToolTipOverride(const QString& tooltip); virtual QVariant data(int column, int role) const; bool setData(const QVariant& value); Qt::ItemFlags flags(int column) const; @@ -252,6 +253,7 @@ protected: int precision; bool linked; bool expanded; + QString nameToolTipOverride; friend class PropertyItemAttorney; }; diff --git a/src/Mod/Material/Gui/DlgInspectAppearance.cpp b/src/Mod/Material/Gui/DlgInspectAppearance.cpp index 131d6ee288..c3a6b04374 100644 --- a/src/Mod/Material/Gui/DlgInspectAppearance.cpp +++ b/src/Mod/Material/Gui/DlgInspectAppearance.cpp @@ -200,6 +200,10 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material) int row = 0; auto* labelDiffuse = new QLabel(); labelDiffuse->setText(tr("Diffuse color")); + labelDiffuse->setToolTip( + tr("Defines the base color of a surface when illuminated by light. It represents how the " + "object scatters light evenly in all directions, independent of the viewer’s angle. " + "This property will influence the material color the most.")); auto* colorDiffuse = new ColorWidget(material.diffuseColor); colorDiffuse->setMaximumHeight(23); @@ -209,6 +213,10 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material) auto* labelAmbient = new QLabel(); labelAmbient->setText(tr("Ambient color")); + labelAmbient->setToolTip( + tr("Defines the color of a surface under indirect, uniform lighting, representing how it " + "appears when illuminated only by ambient light in a scene, without directional light, " + "shading, or highlights")); auto* colorAmbient = new ColorWidget(material.ambientColor); colorAmbient->setMaximumHeight(23); @@ -218,6 +226,10 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material) auto* labelEmissive = new QLabel(); labelEmissive->setText(tr("Emissive color")); + labelEmissive->setToolTip( + tr("Defines the color of a surface that appears to emit as if it were a light source, " + "independent of external lighting, making the object look self-illuminated. Set to " + "black to have no emissive color.")); auto* colorEmissive = new ColorWidget(material.emissiveColor); colorEmissive->setMaximumHeight(23); @@ -227,6 +239,10 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material) auto* labelSpecular = new QLabel(); labelSpecular->setText(tr("Specular color")); + labelSpecular->setToolTip( + tr("Defines the color and intensity of the bright, mirror-like highlights that appear on " + "shiny or reflective surfaces when light hits them directly. Set to bright colors for " + "shiny objects.")); auto* colorSpecular = new ColorWidget(material.specularColor); colorSpecular->setMaximumHeight(23); @@ -236,6 +252,10 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material) auto* labelShininess = new QLabel(); labelShininess->setText(tr("Shininess")); + labelShininess->setToolTip( + tr("Defines the size and sharpness of specular highlights on a surface. Higher values " + "produce small, sharp highlights, while lower values create broad, soft highlights. " + "Note that the highlight intensity is defined by specular color.")); auto* editShininess = new QLineEdit(); editShininess->setText(QString::number(material.shininess)); editShininess->setEnabled(false); @@ -246,6 +266,8 @@ QWidget* DlgInspectAppearance::makeAppearanceTab(const App::Material& material) auto* labelTransparency = new QLabel(); labelTransparency->setText(tr("Transparency")); + labelTransparency->setToolTip(tr("Defines how much light passes through an object, making it " + "partially or fully see-through")); auto* editTransparency = new QLineEdit(); editTransparency->setText(QString::number(material.transparency)); editTransparency->setEnabled(false); diff --git a/src/Mod/Material/Resources/Models/Rendering/BasicRendering.yml b/src/Mod/Material/Resources/Models/Rendering/BasicRendering.yml index 0b1e309e43..23f8848f58 100644 --- a/src/Mod/Material/Resources/Models/Rendering/BasicRendering.yml +++ b/src/Mod/Material/Resources/Models/Rendering/BasicRendering.yml @@ -34,32 +34,51 @@ AppearanceModel: Type: 'Color' Units: '' URL: '' - Description: " " + Description: > + Defines the color of a surface under indirect, uniform lighting, + representing how it appears when illuminated only by ambient light in a + scene, without directional light, shading, or highlights DiffuseColor: DisplayName: "Diffuse Color" Type: 'Color' Units: '' URL: '' - Description: " " + Description: > + Defines the base color of a surface when illuminated by light. It + represents how the object scatters light evenly in all directions, + independent of the viewer’s angle. This property will influence the + material color the most. EmissiveColor: DisplayName: "Emissive Color" Type: 'Color' Units: '' URL: '' - Description: " " + Description: > + Defines the color of a surface that appears to emit as if it were a light + source, independent of external lighting, making the object look + self-illuminated. Set to black to have no emissive color. Shininess: Type: 'Float' Units: '' URL: '' - Description: " " + Description: > + Defines the size and sharpness of specular highlights on a surface. + Higher values produce small, sharp highlights, while lower values create + broad, soft highlights. Note that the highlight intensity is defined by + specular color." SpecularColor: DisplayName: "Specular Color" Type: 'Color' Units: '' URL: '' - Description: " " + Description: > + Defines the color and intensity of the bright, mirror-like highlights + that appear on shiny or reflective surfaces when light hits them + directly. Set to bright colors for shiny objects. Transparency: Type: 'Float' Units: '' URL: '' - Description: " " + Description: > + Defines how much light passes through an object, making it partially or + fully see-through