summaryrefslogtreecommitdiff
path: root/assetFactory/style.h
diff options
context:
space:
mode:
Diffstat (limited to 'assetFactory/style.h')
-rw-r--r--assetFactory/style.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/assetFactory/style.h b/assetFactory/style.h
index 0c7ad5a..e8fd012 100644
--- a/assetFactory/style.h
+++ b/assetFactory/style.h
@@ -3,19 +3,31 @@
#include "modelFactoryMesh.h"
#include "persistence.h"
#include "shape.h"
+#include <optional>
#include <string>
+#include <utility>
class Style {
public:
using StyleStack = std::vector<const Style *>;
+ using Colour = glm::vec3;
+ using ColourAlpha = glm::vec4;
- static ModelFactoryMesh::Color parseColour(const std::string_view &);
void applyStyle(ModelFactoryMesh &, const StyleStack & parents, const Shape::CreatedFaces &) const;
void applyStyle(ModelFactoryMesh &, const StyleStack & parents, const ModelFactoryMesh::FaceHandle &) const;
- static std::string_view getProperty(const StyleStack & parents, std::string Style::*member);
+ template<typename T>
+ static std::optional<std::reference_wrapper<const T>>
+ getProperty(const StyleStack & parents, T Style::*member, auto && test)
+ {
+ if (const auto itr = std::find_if(parents.rbegin(), parents.rend(), std::forward<decltype(test)>(test));
+ itr != parents.rend()) {
+ return (*itr)->*member;
+ }
+ return {};
+ }
- std::string colour;
+ ColourAlpha colour {};
protected:
bool persist(Persistence::PersistenceStore & store);