diff --git a/modules/imgui/include/gui.h b/modules/imgui/include/gui.h index 4981eda208..41daff5d83 100644 --- a/modules/imgui/include/gui.h +++ b/modules/imgui/include/gui.h @@ -85,6 +85,8 @@ public: bool _showInternals; + properties::BoolProperty _showHelpText; + private: void renderAndUpdatePropertyVisibility(); diff --git a/modules/imgui/include/guipropertycomponent.h b/modules/imgui/include/guipropertycomponent.h index ca55b8404d..1a7078d898 100644 --- a/modules/imgui/include/guipropertycomponent.h +++ b/modules/imgui/include/guipropertycomponent.h @@ -59,6 +59,7 @@ public: void setVisibility(properties::Property::Visibility visibility); void setHasRegularProperties(bool hasOnlyRegularProperties); + void setShowHelpTooltip(bool showHelpTooltip); void render() override; @@ -76,6 +77,7 @@ protected: UseTreeLayout _useTreeLayout; bool _currentUseTreeLayout; IsTopLevelWindow _isTopLevel; + bool _showHelpTooltip; }; } // namespace openspace::gui diff --git a/modules/imgui/include/renderproperties.h b/modules/imgui/include/renderproperties.h index ce0408cc64..3ab234ba53 100644 --- a/modules/imgui/include/renderproperties.h +++ b/modules/imgui/include/renderproperties.h @@ -36,60 +36,78 @@ namespace openspace::properties { namespace openspace { using IsRegularProperty = ghoul::Boolean; +using ShowToolTip = ghoul::Boolean; void executeScript(const std::string& id, const std::string& value, IsRegularProperty isRegular = IsRegularProperty::Yes); void renderBoolProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderOptionProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderSelectionProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderStringProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderDoubleProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderIntProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderIVec2Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderIVec3Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderIVec4Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderFloatProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderVec2Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderVec3Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderVec4Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderDVec2Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderDVec3Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderDVec4Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderTriggerProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); } // namespace openspace diff --git a/modules/imgui/src/gui.cpp b/modules/imgui/src/gui.cpp index 6db4244e94..0f8f74576e 100644 --- a/modules/imgui/src/gui.cpp +++ b/modules/imgui/src/gui.cpp @@ -245,6 +245,13 @@ void addScreenSpaceRenderableOnline(std::string texturePath) { ); } +static const openspace::properties::Property::PropertyInfo ShowHelpInfo = { + "ShowHelpText", + "Show tooltip help", + "If this value is enabled these kinds of tooltips are shown for most properties " + "explaining what impact they have on the visuals." +}; + } // namespace namespace openspace::gui { @@ -268,6 +275,7 @@ GUI::GUI() GuiPropertyComponent::UseTreeLayout::No, GuiPropertyComponent::IsTopLevelWindow::Yes) , _showInternals(false) + , _showHelpText(ShowHelpInfo, true) , _currentVisibility(properties::Property::Visibility::Developer) { addPropertySubOwner(_help); @@ -285,6 +293,14 @@ GUI::GUI() #ifdef OPENSPACE_MODULE_ISWA_ENABLED addPropertySubOwner(_iswa); #endif // OPENSPACE_MODULE_ISWA_ENABLED + + addProperty(_showHelpText); + _showHelpText.onChange([this](){ + _globalProperty.setShowHelpTooltip(_showHelpText); + _property.setShowHelpTooltip(_showHelpText); + _screenSpaceProperty.setShowHelpTooltip(_showHelpText); + _virtualProperty.setShowHelpTooltip(_showHelpText); + }); } void GUI::initialize() { diff --git a/modules/imgui/src/guipropertycomponent.cpp b/modules/imgui/src/guipropertycomponent.cpp index acdf57952e..143da4826c 100644 --- a/modules/imgui/src/guipropertycomponent.cpp +++ b/modules/imgui/src/guipropertycomponent.cpp @@ -166,6 +166,10 @@ void GuiPropertyComponent::setHasRegularProperties(bool hasOnlyRegularProperties _hasOnlyRegularProperties = hasOnlyRegularProperties; } +void GuiPropertyComponent::setShowHelpTooltip(bool showHelpTooltip) { + _showHelpTooltip = showHelpTooltip; +} + void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) { if (owner->propertiesRecursive().empty()) { return; @@ -373,7 +377,7 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop, properties::PropertyOwner* owner) { using Func = std::function< - void(properties::Property*, const std::string&, IsRegularProperty) + void(properties::Property*, const std::string&, IsRegularProperty, ShowToolTip) >; static const std::map FunctionMapping = { { "BoolProperty", &renderBoolProperty }, @@ -406,14 +410,16 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop, it->second( prop, owner->name(), - IsRegularProperty(_hasOnlyRegularProperties) + IsRegularProperty(_hasOnlyRegularProperties), + ShowToolTip(_showHelpTooltip) ); } else { it->second( prop, "", - IsRegularProperty(_hasOnlyRegularProperties) + IsRegularProperty(_hasOnlyRegularProperties), + ShowToolTip(_showHelpTooltip) ); } } diff --git a/modules/imgui/src/renderproperties.cpp b/modules/imgui/src/renderproperties.cpp index ecf12e5b92..b166a673c2 100644 --- a/modules/imgui/src/renderproperties.cpp +++ b/modules/imgui/src/renderproperties.cpp @@ -85,7 +85,7 @@ void executeScript(const std::string& id, const std::string& value, } void renderBoolProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); BoolProperty* p = static_cast(prop); @@ -94,7 +94,9 @@ void renderBoolProperty(Property* prop, const std::string& ownerName, BoolProperty::ValueType value = *p; ImGui::Checkbox(name.c_str(), &value); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript(p->fullyQualifiedIdentifier(), value ? "true" : "false", isRegular); @@ -103,7 +105,7 @@ void renderBoolProperty(Property* prop, const std::string& ownerName, } void renderOptionProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); OptionProperty* p = static_cast(prop); @@ -120,7 +122,9 @@ void renderOptionProperty(Property* prop, const std::string& ownerName, ImGui::Separator(); for (const OptionProperty::Option& o : options) { ImGui::RadioButton(o.description.c_str(), &value, o.value); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } } ImGui::Separator(); break; @@ -159,7 +163,7 @@ void renderOptionProperty(Property* prop, const std::string& ownerName, } void renderSelectionProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); SelectionProperty* p = static_cast(prop); @@ -179,7 +183,9 @@ void renderSelectionProperty(Property* prop, const std::string& ownerName, ) != selectedIndices.end(); ImGui::Checkbox(description.c_str(), &selected); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (selected) { newSelectedIndices.push_back(i); @@ -200,7 +206,7 @@ void renderSelectionProperty(Property* prop, const std::string& ownerName, } void renderStringProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); StringProperty* p = static_cast(prop); @@ -222,8 +228,9 @@ void renderStringProperty(Property* prop, const std::string& ownerName, bufferSize, ImGuiInputTextFlags_EnterReturnsTrue ); - renderTooltip(prop); - + if (showTooltip) { + renderTooltip(prop); + } if (hasNewValue) { executeScript( @@ -237,7 +244,7 @@ void renderStringProperty(Property* prop, const std::string& ownerName, } void renderDoubleProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); DoubleProperty* p = static_cast(prop); @@ -249,7 +256,9 @@ void renderDoubleProperty(properties::Property* prop, const std::string& ownerNa float max = static_cast(p->maxValue()); ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f"); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != static_cast(p->value())) { executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular); @@ -259,7 +268,7 @@ void renderDoubleProperty(properties::Property* prop, const std::string& ownerNa } void renderIntProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); IntProperty* p = static_cast(prop); @@ -271,7 +280,9 @@ void renderIntProperty(Property* prop, const std::string& ownerName, int max = p->maxValue(); ImGui::SliderInt(name.c_str(), &value, min, max); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular); @@ -281,7 +292,7 @@ void renderIntProperty(Property* prop, const std::string& ownerName, } void renderIVec2Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); IVec2Property* p = static_cast(prop); @@ -297,7 +308,9 @@ void renderIVec2Property(Property* prop, const std::string& ownerName, min, max ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -311,7 +324,7 @@ void renderIVec2Property(Property* prop, const std::string& ownerName, } void renderIVec3Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); IVec3Property* p = static_cast(prop); @@ -328,7 +341,9 @@ void renderIVec3Property(Property* prop, const std::string& ownerName, min, max ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -342,7 +357,7 @@ void renderIVec3Property(Property* prop, const std::string& ownerName, } void renderIVec4Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); IVec4Property* p = static_cast(prop); @@ -363,7 +378,9 @@ void renderIVec4Property(Property* prop, const std::string& ownerName, min, max ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -379,7 +396,7 @@ void renderIVec4Property(Property* prop, const std::string& ownerName, } void renderFloatProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); FloatProperty* p = static_cast(prop); @@ -390,7 +407,9 @@ void renderFloatProperty(Property* prop, const std::string& ownerName, float min = p->minValue(); float max = p->maxValue(); ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f"); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular); @@ -400,7 +419,7 @@ void renderFloatProperty(Property* prop, const std::string& ownerName, } void renderVec2Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); Vec2Property* p = static_cast(prop); @@ -417,7 +436,9 @@ void renderVec2Property(Property* prop, const std::string& ownerName, max, "%.5f" ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -431,7 +452,7 @@ void renderVec2Property(Property* prop, const std::string& ownerName, } void renderVec3Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); Vec3Property* p = static_cast(prop); @@ -442,8 +463,6 @@ void renderVec3Property(Property* prop, const std::string& ownerName, float min = std::min(std::min(p->minValue().x, p->minValue().y), p->minValue().z); float max = std::max(std::max(p->maxValue().x, p->maxValue().y), p->maxValue().z); - - if (prop->viewOption(Property::ViewOptions::Color)) { ImGui::ColorEdit3( name.c_str(), @@ -459,7 +478,9 @@ void renderVec3Property(Property* prop, const std::string& ownerName, "%.5f" ); } - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -475,7 +496,7 @@ void renderVec3Property(Property* prop, const std::string& ownerName, } void renderVec4Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); Vec4Property* p = static_cast(prop); @@ -503,8 +524,9 @@ void renderVec4Property(Property* prop, const std::string& ownerName, "%.5f" ); } - - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -521,7 +543,7 @@ void renderVec4Property(Property* prop, const std::string& ownerName, } void renderDVec2Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); DVec2Property* p = static_cast(prop); @@ -538,7 +560,9 @@ void renderDVec2Property(Property* prop, const std::string& ownerName, max, "%.5f" ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (glm::dvec2(value) != p->value()) { executeScript( @@ -552,7 +576,7 @@ void renderDVec2Property(Property* prop, const std::string& ownerName, } void renderDVec3Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); DVec3Property* p = static_cast(prop); @@ -574,7 +598,9 @@ void renderDVec3Property(Property* prop, const std::string& ownerName, max, "%.5f" ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (changed) { executeScript( @@ -590,7 +616,7 @@ void renderDVec3Property(Property* prop, const std::string& ownerName, } void renderDVec4Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); DVec4Property* p = static_cast(prop); @@ -616,7 +642,9 @@ void renderDVec4Property(Property* prop, const std::string& ownerName, max, "%.5f" ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (glm::dvec4(value) != p->value()) { executeScript( @@ -633,7 +661,7 @@ void renderDVec4Property(Property* prop, const std::string& ownerName, } void renderTriggerProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); std::string name = prop->guiName(); @@ -643,7 +671,9 @@ void renderTriggerProperty(Property* prop, const std::string& ownerName, if (pressed) { executeScript(prop->fullyQualifiedIdentifier(), "nil", isRegular); } - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } ImGui::PopID(); }