GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
PropertyDescriptor.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-present Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #ifndef GDCORE_PROPERTYDESCRIPTOR
7 #define GDCORE_PROPERTYDESCRIPTOR
8 #include <vector>
9 
10 #include "GDCore/String.h"
11 #include "GDCore/Project/MeasurementUnit.h"
12 
13 namespace gd {
14 class SerializerElement;
15 }
16 
17 namespace gd {
18 
24 class GD_CORE_API PropertyDescriptor {
25  public:
33  : currentValue(propertyValue), type("string"), label(""), hidden(false),
34  deprecated(false), advanced(false),
35  measurementUnit(gd::MeasurementUnit::GetUndefined()) {}
36 
41  : hidden(false), deprecated(false), advanced(false),
42  measurementUnit(gd::MeasurementUnit::GetUndefined()){};
43 
47  virtual ~PropertyDescriptor();
48 
53  currentValue = value;
54  return *this;
55  }
56 
65  type = type_;
66  return *this;
67  }
68 
73  label = label_;
74  return *this;
75  }
76 
81  description = description_;
82  return *this;
83  }
84 
89  group = group_;
90  return *this;
91  }
92 
96  PropertyDescriptor& SetExtraInfo(const std::vector<gd::String>& info) {
97  extraInformation = info;
98  return *this;
99  }
100 
109  extraInformation.push_back(info);
110  return *this;
111  }
112 
117  measurementUnit = measurementUnit_;
118  return *this;
119  }
120 
121  const gd::String& GetValue() const { return currentValue; }
122  const gd::String& GetType() const { return type; }
123  const gd::String& GetLabel() const { return label; }
124  const gd::String& GetDescription() const { return description; }
125  const gd::String& GetGroup() const { return group; }
126  const gd::MeasurementUnit& GetMeasurementUnit() const { return measurementUnit; }
127 
128  const std::vector<gd::String>& GetExtraInfo() const {
129  return extraInformation;
130  }
131 
132  std::vector<gd::String>& GetExtraInfo() {
133  return extraInformation;
134  }
135 
139  PropertyDescriptor& SetHidden(bool enable = true) {
140  hidden = enable;
141  return *this;
142  }
143 
147  bool IsHidden() const { return hidden; }
148 
152  PropertyDescriptor& SetDeprecated(bool enable = true) {
153  deprecated = enable;
154  return *this;
155  }
156 
160  bool IsDeprecated() const { return deprecated; }
161 
165  PropertyDescriptor& SetAdvanced(bool enable = true) {
166  advanced = enable;
167  return *this;
168  }
169 
173  bool IsAdvanced() const { return advanced; }
174 
178 
181  virtual void SerializeTo(SerializerElement& element) const;
182 
186  virtual void UnserializeFrom(const SerializerElement& element);
187 
191  virtual void SerializeValuesTo(SerializerElement& element) const;
192 
196  virtual void UnserializeValuesFrom(const SerializerElement& element);
198 
199  private:
200  gd::String currentValue;
201  gd::String
202  type;
204  gd::String label; //< The user-friendly property name
205  gd::String description; //< The user-friendly property description
206  gd::String group; //< The user-friendly property group
207  std::vector<gd::String>
208  extraInformation;
211  bool hidden;
212  bool deprecated;
213  bool advanced;
214  gd::MeasurementUnit measurementUnit; //< The unit of measurement of the property vale.
215 };
216 
217 } // namespace gd
218 
219 #endif
A unit of measurement.
Definition: MeasurementUnit.h:24
Used to describe a property shown in a property grid.
Definition: PropertyDescriptor.h:24
PropertyDescriptor & SetValue(gd::String value)
Change the value displayed in the property grid.
Definition: PropertyDescriptor.h:52
bool IsHidden() const
Check if the property should be shown or hidden in the editor.
Definition: PropertyDescriptor.h:147
bool IsDeprecated() const
Check if the property is deprecated.
Definition: PropertyDescriptor.h:160
PropertyDescriptor & SetHidden(bool enable=true)
Set if the property should be shown or hidden in the editor.
Definition: PropertyDescriptor.h:139
PropertyDescriptor & SetExtraInfo(const std::vector< gd::String > &info)
Set and replace the additional information for the property.
Definition: PropertyDescriptor.h:96
PropertyDescriptor & SetGroup(gd::String group_)
Change the group where this property is displayed to the user, if any.
Definition: PropertyDescriptor.h:88
PropertyDescriptor & SetDeprecated(bool enable=true)
Set if the property is deprecated.
Definition: PropertyDescriptor.h:152
bool IsAdvanced() const
Check if the property is marked as advanced.
Definition: PropertyDescriptor.h:173
PropertyDescriptor()
Empty constructor creating an empty property to be displayed.
Definition: PropertyDescriptor.h:40
PropertyDescriptor & SetMeasurementUnit(const gd::MeasurementUnit &measurementUnit_)
Change the unit of measurement of the property value.
Definition: PropertyDescriptor.h:116
PropertyDescriptor & SetAdvanced(bool enable=true)
Set if the property is marked as advanced.
Definition: PropertyDescriptor.h:165
PropertyDescriptor(gd::String propertyValue)
Create a property being a simple gd::String with the specified value.
Definition: PropertyDescriptor.h:32
PropertyDescriptor & SetType(gd::String type_)
Change the type of the value displayed in the property grid.
Definition: PropertyDescriptor.h:64
PropertyDescriptor & AddExtraInfo(const gd::String &info)
Add an information about the property.
Definition: PropertyDescriptor.h:108
PropertyDescriptor & SetDescription(gd::String description_)
Change the description displayed to the user, if any.
Definition: PropertyDescriptor.h:80
PropertyDescriptor & SetLabel(gd::String label_)
Change the label displayed in the property grid.
Definition: PropertyDescriptor.h:72
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: CommonTools.h:24