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 #include "GDCore/Project/QuickCustomization.h"
13 
14 namespace gd {
15 class SerializerElement;
16 }
17 
18 namespace gd {
19 
25 class GD_CORE_API PropertyDescriptor {
26  public:
34  : currentValue(propertyValue), type("string"), label(""), hidden(false),
35  deprecated(false), advanced(false),
36  hasImpactOnOtherProperties(false),
37  measurementUnit(gd::MeasurementUnit::GetUndefined()),
38  quickCustomizationVisibility(QuickCustomization::Visibility::Default) {}
39 
44  : hidden(false), deprecated(false), advanced(false),
45  hasImpactOnOtherProperties(false),
46  measurementUnit(gd::MeasurementUnit::GetUndefined()),
47  quickCustomizationVisibility(QuickCustomization::Visibility::Default){};
48 
52  virtual ~PropertyDescriptor();
53 
58  currentValue = value;
59  return *this;
60  }
61 
70  type = type_;
71  return *this;
72  }
73 
78  label = label_;
79  return *this;
80  }
81 
86  description = description_;
87  return *this;
88  }
89 
94  group = group_;
95  return *this;
96  }
97 
101  PropertyDescriptor& SetExtraInfo(const std::vector<gd::String>& info) {
102  extraInformation = info;
103  return *this;
104  }
105 
114  extraInformation.push_back(info);
115  return *this;
116  }
117 
122  measurementUnit = measurementUnit_;
123  return *this;
124  }
125 
126  const gd::String& GetValue() const { return currentValue; }
127  const gd::String& GetType() const { return type; }
128  const gd::String& GetLabel() const { return label; }
129  const gd::String& GetDescription() const { return description; }
130  const gd::String& GetGroup() const { return group; }
131  const gd::MeasurementUnit& GetMeasurementUnit() const { return measurementUnit; }
132 
133  const std::vector<gd::String>& GetExtraInfo() const {
134  return extraInformation;
135  }
136 
137  std::vector<gd::String>& GetExtraInfo() {
138  return extraInformation;
139  }
140 
144  PropertyDescriptor& SetHidden(bool enable = true) {
145  hidden = enable;
146  return *this;
147  }
148 
152  bool IsHidden() const { return hidden; }
153 
157  PropertyDescriptor& SetDeprecated(bool enable = true) {
158  deprecated = enable;
159  return *this;
160  }
161 
165  bool IsDeprecated() const { return deprecated; }
166 
170  PropertyDescriptor& SetAdvanced(bool enable = true) {
171  advanced = enable;
172  return *this;
173  }
174 
178  bool IsAdvanced() const { return advanced; }
179 
184  bool HasImpactOnOtherProperties() const { return hasImpactOnOtherProperties; }
185 
191  hasImpactOnOtherProperties = enable;
192  return *this;
193  }
194 
195  QuickCustomization::Visibility GetQuickCustomizationVisibility() const { return quickCustomizationVisibility; }
196 
197  PropertyDescriptor& SetQuickCustomizationVisibility(QuickCustomization::Visibility visibility) {
198  quickCustomizationVisibility = visibility;
199  return *this;
200  }
201 
205 
208  virtual void SerializeTo(SerializerElement& element) const;
209 
213  virtual void UnserializeFrom(const SerializerElement& element);
214 
218  virtual void SerializeValuesTo(SerializerElement& element) const;
219 
223  virtual void UnserializeValuesFrom(const SerializerElement& element);
225 
226  private:
227  gd::String currentValue;
228  gd::String
229  type;
231  gd::String label; //< The user-friendly property name
232  gd::String description; //< The user-friendly property description
233  gd::String group; //< The user-friendly property group
234  std::vector<gd::String>
235  extraInformation;
238  bool hidden;
239  bool deprecated;
240  bool advanced;
241  bool hasImpactOnOtherProperties;
242  gd::MeasurementUnit measurementUnit; //< The unit of measurement of the property vale.
243  QuickCustomization::Visibility quickCustomizationVisibility;
244 };
245 
246 } // namespace gd
247 
248 #endif
A unit of measurement.
Definition: MeasurementUnit.h:24
Used to describe a property shown in a property grid.
Definition: PropertyDescriptor.h:25
PropertyDescriptor & SetValue(gd::String value)
Change the value displayed in the property grid.
Definition: PropertyDescriptor.h:57
bool IsHidden() const
Check if the property should be shown or hidden in the editor.
Definition: PropertyDescriptor.h:152
PropertyDescriptor & SetHasImpactOnOtherProperties(bool enable)
Set if the property has impact on other properties - which means a change must re-render other proper...
Definition: PropertyDescriptor.h:190
bool IsDeprecated() const
Check if the property is deprecated.
Definition: PropertyDescriptor.h:165
PropertyDescriptor & SetHidden(bool enable=true)
Set if the property should be shown or hidden in the editor.
Definition: PropertyDescriptor.h:144
PropertyDescriptor & SetExtraInfo(const std::vector< gd::String > &info)
Set and replace the additional information for the property.
Definition: PropertyDescriptor.h:101
PropertyDescriptor & SetGroup(gd::String group_)
Change the group where this property is displayed to the user, if any.
Definition: PropertyDescriptor.h:93
PropertyDescriptor & SetDeprecated(bool enable=true)
Set if the property is deprecated.
Definition: PropertyDescriptor.h:157
bool HasImpactOnOtherProperties() const
Check if the property has impact on other properties - which means a change must re-render other prop...
Definition: PropertyDescriptor.h:184
bool IsAdvanced() const
Check if the property is marked as advanced.
Definition: PropertyDescriptor.h:178
PropertyDescriptor()
Empty constructor creating an empty property to be displayed.
Definition: PropertyDescriptor.h:43
PropertyDescriptor & SetMeasurementUnit(const gd::MeasurementUnit &measurementUnit_)
Change the unit of measurement of the property value.
Definition: PropertyDescriptor.h:121
PropertyDescriptor & SetAdvanced(bool enable=true)
Set if the property is marked as advanced.
Definition: PropertyDescriptor.h:170
PropertyDescriptor(gd::String propertyValue)
Create a property being a simple gd::String with the specified value.
Definition: PropertyDescriptor.h:33
PropertyDescriptor & SetType(gd::String type_)
Change the type of the value displayed in the property grid.
Definition: PropertyDescriptor.h:69
PropertyDescriptor & AddExtraInfo(const gd::String &info)
Add an information about the property.
Definition: PropertyDescriptor.h:113
PropertyDescriptor & SetDescription(gd::String description_)
Change the description displayed to the user, if any.
Definition: PropertyDescriptor.h:85
PropertyDescriptor & SetLabel(gd::String label_)
Change the label displayed in the property grid.
Definition: PropertyDescriptor.h:77
Definition: QuickCustomization.h:6
Visibility
Definition: QuickCustomization.h:8
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24