Skip to content

Commit

Permalink
display parameter help messages in gui
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylannl committed May 25, 2020
1 parent 03cbac6 commit 86c0ed0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/geoflow/gui/parameter_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};

Expand Down
3 changes: 3 additions & 0 deletions src/geoflow/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/geoflow/parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 86c0ed0

Please sign in to comment.