mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-02 01:30:34 -06:00
Enable ImGui to handle StringProperty type
This commit is contained in:
@@ -86,9 +86,9 @@ protected:
|
||||
std::set<properties::Property*> _vec3Properties;
|
||||
std::set<properties::Property*> _vec4Properties;
|
||||
std::set<properties::Property*> _stringProperties;
|
||||
std::set<properties::Property*> _optionProperty;
|
||||
std::set<properties::Property*> _selectionProperty;
|
||||
std::set<properties::Property*> _triggerProperty;
|
||||
std::set<properties::Property*> _optionProperties;
|
||||
std::set<properties::Property*> _selectionProperties;
|
||||
std::set<properties::Property*> _triggerProperties;
|
||||
std::map<std::string, std::vector<properties::Property*>> _propertiesByOwner;
|
||||
|
||||
//std::vector<Property> _properties;
|
||||
|
||||
@@ -30,8 +30,10 @@
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/selectionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/lua/lua_helper.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include "imgui.h"
|
||||
@@ -103,6 +105,20 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void renderStringProperty(Property* prop, const std::string& ownerName) {
|
||||
StringProperty* p = static_cast<StringProperty*>(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<IntProperty*>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user