bWidgets
Core widget toolkit designed for Blender
bwStyleProperties.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <optional>
5#include <string>
6#include <vector>
7
8namespace bWidgets {
9
10class bwColor;
11
36 template<typename> friend class bwStylePropertyInternal;
37
38 public:
39 enum class Type {
40 BOOL,
41 INTEGER,
42 FLOAT,
43 COLOR,
44 };
45
46 void setValue(bool);
47 void setValue(int);
48 void setValue(float);
49 void setValue(const bwColor&);
50 void setValue(const bwStyleProperty&);
51 void setValueToDefault();
52
53 void setDefaultValue(bool);
54 void setDefaultValue(int);
55 void setDefaultValue(float);
56 void setDefaultValue(const bwColor&);
57
58 auto getIdentifier() const -> std::string_view;
59 auto getType() const -> Type;
60
61 private:
62 bwStyleProperty(std::string_view identifier, enum Type type);
63
64 const std::string identifier;
65 enum Type type;
66};
67
78 public:
79 // Store properties as pointer, they are actually created as bwStylePropertyInternal instances.
80 using PropertyList = std::vector<std::unique_ptr<bwStyleProperty>>;
81 using iterator = PropertyList::iterator;
82 using const_iterator = PropertyList::const_iterator;
83
84 auto addBool(const std::string_view& name, bool& reference) -> bwStyleProperty&;
85 auto addBool(const std::string_view& name) -> bwStyleProperty&;
86 auto addInteger(const std::string_view& name, int& reference) -> bwStyleProperty&;
87 auto addInteger(const std::string_view& name) -> bwStyleProperty&;
88 auto addFloat(const std::string_view& name, float& reference) -> bwStyleProperty&;
89 auto addFloat(const std::string_view& name) -> bwStyleProperty&;
90 auto addColor(const std::string_view& name, class bwColor& reference) -> bwStyleProperty&;
91 auto addColor(const std::string_view& name) -> bwStyleProperty&;
92 auto addProperty(const std::string_view& name, const bwStyleProperty::Type prop_type)
94
95 auto lookup(const std::string_view& name) const -> const bwStyleProperty*;
96
97 auto begin() -> iterator;
98 auto end() -> iterator;
99 auto begin() const -> const_iterator;
100 auto end() const -> const_iterator;
101
102 private:
103 PropertyList properties{};
104};
105
106} // namespace bWidgets
Definition: bwColor.h:5
Manage a list of properties (bwStyleProperty instances).
Definition: bwStyleProperties.h:77
std::vector< std::unique_ptr< bwStyleProperty > > PropertyList
Definition: bwStyleProperties.h:80
PropertyList::const_iterator const_iterator
Definition: bwStyleProperties.h:82
PropertyList::iterator iterator
Definition: bwStyleProperties.h:81
Definition: bwStyleProperties.cc:10
Simple class for managing properties that can be manipulated through stylesheets (CSS).
Definition: bwStyleProperties.h:35
void setValue(bool)
Definition: bwStyleProperties.cc:63
auto getType() const -> Type
Definition: bwStyleProperties.cc:324
void setValueToDefault()
Definition: bwStyleProperties.cc:121
Type
Definition: bwStyleProperties.h:39
auto getIdentifier() const -> std::string_view
Definition: bwStyleProperties.cc:320
void setDefaultValue(bool)
Definition: bwStyleProperties.cc:150
auto end(Node &) -> PreOrderIterator
Definition: Iterators.cc:116
auto begin(Node &node) -> PreOrderIterator
Definition: Iterators.cc:112
Definition: bwContext.h:3