commit 141f2eb6a0bb6aee5028cd2ed0622624988564a9
parent b09b19b76ca880d50c0e78545b9b17cc25545177
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Wed, 16 Mar 2022 16:59:37 +0100
add ability to read float properties
Diffstat:
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/source/jucePlugin/genericUI/uiObject.cpp b/source/jucePlugin/genericUI/uiObject.cpp
@@ -192,6 +192,14 @@ namespace genericUI
return strtol(res.c_str(), nullptr, 10);
}
+ float UiObject::getPropertyFloat(const std::string& _key, float _default) const
+ {
+ const auto res = getProperty(_key);
+ if (res.empty())
+ return _default;
+ return static_cast<float>(atof(res.c_str()));
+ }
+
std::string UiObject::getProperty(const std::string& _key, const std::string& _default) const
{
for (const auto& properties : m_components)
diff --git a/source/jucePlugin/genericUI/uiObject.h b/source/jucePlugin/genericUI/uiObject.h
@@ -48,6 +48,7 @@ namespace genericUI
juce::Component* createJuceObject(Editor& _editor);
int getPropertyInt(const std::string& _key, int _default = 0) const;
+ float getPropertyFloat(const std::string& _key, float _default = 0.0f) const;
std::string getProperty(const std::string& _key, const std::string& _default = std::string()) const;
private: