diff --git a/include/openspace/gui/guipropertycomponent.h b/include/openspace/gui/guipropertycomponent.h index 22b41de2cb..c6f356299c 100644 --- a/include/openspace/gui/guipropertycomponent.h +++ b/include/openspace/gui/guipropertycomponent.h @@ -86,9 +86,9 @@ protected: std::set _vec3Properties; std::set _vec4Properties; std::set _stringProperties; - std::set _optionProperty; - std::set _selectionProperty; - std::set _triggerProperty; + std::set _optionProperties; + std::set _selectionProperties; + std::set _triggerProperties; std::map> _propertiesByOwner; //std::vector _properties; diff --git a/src/gui/guipropertycomponent.cpp b/src/gui/guipropertycomponent.cpp index 969c716aeb..8593089110 100644 --- a/src/gui/guipropertycomponent.cpp +++ b/src/gui/guipropertycomponent.cpp @@ -30,8 +30,10 @@ #include #include #include +#include #include +#include #include #include #include "imgui.h" @@ -103,6 +105,20 @@ namespace { } } + void renderStringProperty(Property* prop, const std::string& ownerName) { + StringProperty* p = static_cast(prop); + std::string name = p->guiName(); + + static const int bufferSize = 256; + static char buffer[bufferSize]; + strcpy(buffer, p->value().c_str()); + ImGui::InputText((ownerName + "." + name).c_str(), buffer, bufferSize); + std::string newValue(buffer); + + if (newValue != p->value() && FileSys.fileExists(newValue)) + executeScript(p->fullyQualifiedIdentifier(), "'" + newValue + "'"); + } + void renderIntProperty(Property* prop, const std::string& ownerName) { IntProperty* p = static_cast(prop); std::string name = p->guiName(); @@ -336,11 +352,11 @@ void GuiPropertyComponent::registerProperty(properties::Property* prop) { else if (className == "Vec4Property") _vec4Properties.insert(prop); else if (className == "OptionProperty") - _optionProperty.insert(prop); + _optionProperties.insert(prop); else if (className == "TriggerProperty") - _triggerProperty.insert(prop); + _triggerProperties.insert(prop); else if (className == "SelectionProperty") - _selectionProperty.insert(prop); + _selectionProperties.insert(prop); else { LWARNING("Class name '" << className << "' not handled in GUI generation"); return; @@ -447,20 +463,25 @@ void GuiPropertyComponent::render() { continue; } - if (_optionProperty.find(prop) != _optionProperty.end()) { + if (_optionProperties.find(prop) != _optionProperties.end()) { renderOptionProperty(prop, p.first); continue; } - if (_triggerProperty.find(prop) != _triggerProperty.end()) { + if (_triggerProperties.find(prop) != _triggerProperties.end()) { renderTriggerProperty(prop, p.first); continue; } - if (_selectionProperty.find(prop) != _selectionProperty.end()) { + if (_selectionProperties.find(prop) != _selectionProperties.end()) { renderSelectionProperty(prop, p.first); continue; } + + if (_stringProperties.find(prop) != _stringProperties.end()) { + renderStringProperty(prop, p.first); + continue; + } } } }