Vuo  2.4.0
VuoUiThemeGroup.cc
Go to the documentation of this file.
1
10#include "VuoUiThemeBase.hh"
11
12#include "type.h"
13
14extern "C" {
15#include "VuoList_VuoUiTheme.h"
16}
17
19#ifdef VUO_COMPILER
21 "title" : "UI Theme Group",
22 });
23#endif
25
30{
31private:
32 VuoList_VuoUiTheme elements;
33
34public:
35 static std::string type;
36
41 {
42 return new VuoUiThemeGroup(VuoJson_getObjectValue(VuoList_VuoUiTheme, js, "elements", NULL));
43 }
44
49 {
50 elements = _elements;
51 VuoRetain(elements);
52 }
54 {
55 VuoRelease(elements);
56 }
57
62 {
64 json_object_object_add(json, "elements", VuoList_VuoUiTheme_getJson(elements));
65 return json;
66 }
67
71 char *getSummary()
72 {
73 return strdup("Widget Theme Group");
74 }
75
79 bool operator==(const VuoSerializable &that)
80 {
82 return VuoList_VuoUiTheme_areEqual(elements, thatSpecialized->elements);
83 }
84
88 bool operator<(const VuoSerializable &that)
89 {
91 VuoType_returnInequality(VuoList_VuoUiTheme, elements, thatSpecialized->elements);
92 return false;
93 }
94
98 VuoUiThemeBase *findElement(std::string typeToFind)
99 {
100 size_t typeToFindLength = typeToFind.length();
101 unsigned long elementCount = VuoListGetCount_VuoUiTheme(elements);
102 for (unsigned long i = 1; i <= elementCount; ++i)
103 {
104 VuoUiTheme item = VuoListGetValue_VuoUiTheme(elements, i);
105 VuoUiThemeBase *base = (VuoUiThemeBase *)item;
106 if (base && base->getType().compare(0, typeToFindLength, typeToFind) == 0)
107 return base;
108 }
109
110 return NULL;
111 }
112};
113
115
120{
121 return reinterpret_cast<VuoUiTheme>(new VuoUiThemeGroup(elements));
122}
123
134{
135 if (theme)
136 {
137 VuoUiThemeBase *base = (VuoUiThemeBase *)theme;
138
139 if (base->getType().compare(0, type.length(), type) == 0)
140 return base;
141
142 VuoUiThemeGroup *group = dynamic_cast<VuoUiThemeGroup *>(base);
143 if (group)
144 {
145 VuoUiThemeBase *found = group->findElement(type);
146 if (found)
147 return found;
148 }
149 }
150
151 // `theme` is neither the specified type nor a group that contains the specified type, make a new instance with default settings.
152 json_object *js = json_object_new_object();
153 std::string roundedType = type + "Rounded";
154 json_object_object_add(js, "type", json_object_new_string(roundedType.c_str()));
156 json_object_put(js);
157 return rounded;
158}