diff --git a/src/geoflow/gui/parameter_widgets.cpp b/src/geoflow/gui/parameter_widgets.cpp index 1f6ffff..c18e068 100644 --- a/src/geoflow/gui/parameter_widgets.cpp +++ b/src/geoflow/gui/parameter_widgets.cpp @@ -18,6 +18,18 @@ namespace geoflow { ImGui::Checkbox(valptr->get_label().c_str(), &valptr->get()); } }; + static void HelpMarker(const char* desc) + { + ImGui::TextDisabled("(?)"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); + ImGui::TextUnformatted(desc); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } + } bool draw_parameter(Parameter* param) { bool changed=false; @@ -95,6 +107,8 @@ namespace geoflow { } else { ImGui::Text("%s", param->get_label().c_str()); } + ImGui::SameLine(); + HelpMarker(param->get_help().c_str()); return changed; }; diff --git a/src/geoflow/parameters.cpp b/src/geoflow/parameters.cpp index a22f38b..2a4f7b1 100644 --- a/src/geoflow/parameters.cpp +++ b/src/geoflow/parameters.cpp @@ -29,6 +29,9 @@ namespace geoflow { std::string Parameter::get_label() { return label_; } + const std::string& Parameter::get_help() const { + return help_; + } bool Parameter::is_type(std::type_index type) { return type_ == type; } diff --git a/src/geoflow/parameters.hpp b/src/geoflow/parameters.hpp index 3ac41ca..bca31b5 100644 --- a/src/geoflow/parameters.hpp +++ b/src/geoflow/parameters.hpp @@ -48,6 +48,7 @@ namespace geoflow { public: Parameter(std::string label, std::string help, std::type_index ttype=typeid(void)); std::string get_label(); + const std::string& get_help() const; virtual json as_json() const = 0; virtual void from_json(const json& json_object) = 0; // virtual void to_string(std::string& str) const = 0;