3using json = nlohmann::json;
5#define STYLE_READ_COLOR(values, variable) { \
6 auto valueRef = values[#variable]; \
7 if(!valueRef.is_boolean()) { \
8 if (valueRef.is_array()) { \
9 std::vector<int> rgb; rgb.reserve(3); \
10 for (auto it = valueRef.begin(); it != valueRef.end(); ++it) { \
11 rgb.push_back(it->get<int>()); \
13 variable.setRgb(rgb[0], rgb[1], rgb[2]); \
15 std::string str = valueRef;\
16 if(str.compare("white") == 0) {variable = Wt::WColor(Wt::StandardColor::White) ;}\
17 if(str.compare("black") == 0) {variable = Wt::WColor(Wt::StandardColor::Black) ;}\
18 if(str.compare("red") == 0) {variable = Wt::WColor(Wt::StandardColor::Red) ;}\
19 if(str.compare("darkred") == 0) {variable = Wt::WColor(Wt::StandardColor::DarkRed) ;}\
20 if(str.compare("green") == 0) {variable = Wt::WColor(Wt::StandardColor::Green) ;}\
21 if(str.compare("darkgreen") == 0) {variable = Wt::WColor(Wt::StandardColor::DarkGreen) ;}\
22 if(str.compare("blue") == 0) {variable = Wt::WColor(Wt::StandardColor::Blue) ;}\
23 if(str.compare("darlblue") == 0) {variable = Wt::WColor(Wt::StandardColor::DarkBlue) ;}\
24 if(str.compare("cyan") == 0) {variable = Wt::WColor(Wt::StandardColor::Cyan) ;}\
25 if(str.compare("darkcyan") == 0) {variable = Wt::WColor(Wt::StandardColor::DarkCyan) ;}\
26 if(str.compare("megenta") == 0) {variable = Wt::WColor(Wt::StandardColor::Magenta) ;}\
27 if(str.compare("darkmegenta") == 0) {variable = Wt::WColor(Wt::StandardColor::DarkMagenta) ;}\
28 if(str.compare("yellow") == 0) {variable = Wt::WColor(Wt::StandardColor::Yellow) ;}\
29 if(str.compare("darkyellow") == 0) {variable = Wt::WColor(Wt::StandardColor::DarkYellow) ;}\
30 if(str.compare("gray") == 0) {variable = Wt::WColor(Wt::StandardColor::Gray) ;}\
31 if(str.compare("darkgray") == 0) {variable = Wt::WColor(Wt::StandardColor::DarkGray) ;}\
32 if(str.compare("lightgray") == 0) {variable = Wt::WColor(Wt::StandardColor::LightGray) ;}\
33 if(str.compare("transparent") == 0) {variable = Wt::WColor(Wt::StandardColor::Transparent) ;}\
34 if(str.compare("lightcyan") == 0) {variable = Wt::WColor(224, 255, 255) ;}\
39#define STYLE_READ_FLOAT(values, variable) { \
40 auto valueRef = values[#variable]; \
41 if(!valueRef.is_boolean()) { \
42 if(valueRef.is_number_float()) { \
43 variable = valueRef; \
46 Wt::log("error") << "Error with Json"; \
51#define STYLE_READ_BOOL(values, variable) { \
52 auto valueRef = values[#variable]; \
53 if(valueRef.is_boolean()){ \
54 variable = valueRef; \
57 Wt::log("error") << "Error with Json"; \
63 std::string filePath = getAssetPath() +
"../src/Rendering/GUI/WtGUI/resources/WtDefaultStyle.json";
80 std::ifstream file(styleFile, std::ios::in);
84 Wt::log(
"error") <<
"Couldn't open style file" << styleFile;
87 std::stringstream buffer;
88 buffer << file.rdbuf();
100 json j = json::parse(jsonData);
101 json obj = j.
at(
"NodeStyle");
131 std::string filePath = getAssetPath() +
"../external/nodeeditor/resources/DefaultStyle.json";
148 std::ifstream file(styleFile, std::ios::in);
152 Wt::log(
"error") <<
"Couldn't open style file" << styleFile;
155 std::stringstream buffer;
156 buffer << file.rdbuf();
168 json j = json::parse(jsonData);
169 json obj = j.
at(
"ConnectionStyle");
203 if (typeID ==
"port")
205 return Wt::WColor(198, 241, 79);
207 else if (typeID ==
"FInstance")
209 return Wt::WColor(207, 174, 113);
213 return Wt::WColor(Wt::StandardColor::Black);
224 r = g = b =
static_cast<int>(l * 255);
228 float q = l < 0.5f ? l * (1 + s) : l + s - l * s;
230 float hk = h / 360.0f;
233 float tr = hk + 1.0f / 3.0f;
235 float tb = hk - 1.0f / 3.0f;
238 tr = tr -
static_cast<int>(tr);
239 tg = tg -
static_cast<int>(tg);
240 tb = tb -
static_cast<int>(tb);
251 if (tr < 1.0f / 6.0f) rf = p + (q - p) * 6.0f * tr;
252 else if (tr < 0.5f) rf = q;
253 else if (tr < 2.0f / 3.0f) rf = p + (q - p) * (2.0f / 3.0f - tr) * 6.0f;
257 if (tg < 1.0f / 6.0f) gf = p + (q - p) * 6.0f * tg;
258 else if (tg < 0.5f) gf = q;
259 else if (tg < 2.0f / 3.0f) gf = p + (q - p) * (2.0f / 3.0f - tg) * 6.0f;
263 if (tb < 1.0f / 6.0f) bf = p + (q - p) * 6.0f * tb;
264 else if (tb < 0.5f) bf = q;
265 else if (tb < 2.0f / 3.0f) bf = p + (q - p) * (2.0f / 3.0f - tb) * 6.0f;
269 r =
static_cast<int>(rf * 255);
270 g =
static_cast<int>(gf * 255);
271 b =
static_cast<int>(bf * 255);
274 return Wt::WColor(r, g, b);
314 std::string filePath = getAssetPath() +
"../external/nodeeditor/resources/DefaultStyle.json";
331 std::ifstream file(styleFile, std::ios::in);
335 Wt::log(
"error") <<
"Couldn't open style file" << styleFile;
338 std::stringstream buffer;
339 buffer << file.rdbuf();
351 json j = json::parse(jsonData);
352 json obj = j.
at(
"FlowViewStyle");
#define STYLE_READ_COLOR(values, variable)
#define STYLE_READ_FLOAT(values, variable)
#define STYLE_READ_BOOL(values, variable)
float ConstructionLineWidth
float constructionLineWidth() const
Wt::WColor normalColor() const
bool UseDataDefinedColors
bool useDataDefinedColors() const
void loadJsonFromByteArray(std::string const &jsonData) override
void loadJsonFile(std::string fileName) override
Wt::WColor hoveredColor() const
static void setConnectionStyle(std::string jsonText)
float pointDiameter() const
Wt::WColor ConstructionColor
void loadJsonText(std::string jsonText) override
Wt::WColor constructionColor() const
Wt::WColor selectedHaloColor() const
Wt::WColor fromHSL(int h, int s, int l) const
Wt::WColor SelectedHaloColor
Wt::WColor selectedColor() const
void loadJsonFile(std::string fileName) override
Wt::WColor CoarseGridColor
void loadJsonFromByteArray(std::string const &jsonData) override
Wt::WColor BackgroundColor
void loadJsonText(std::string jsonText) override
static void setStyle(std::string jsonText)
void loadJsonFromByteArray(std::string const &jsonData) override
Wt::WColor GradientColor2
Wt::WColor GradientColor0
Wt::WColor SelectedBoundaryColor
void loadJsonText(std::string jsonText) override
float ConnectionPointDiameter
Wt::WColor ConnectionPointColor
static void setNodeStyle(std::string jsonText)
Wt::WColor FilledConnectionPointColor
Wt::WColor GradientColor1
Wt::WColor NormalBoundaryColor
Wt::WColor SelectedDragColor
Wt::WColor FontColorFaded
void loadJsonFile(std::string fileName) override
Wt::WColor GradientColor3
WtConnectionStyle _connectionStyle
static WtFlowViewStyle const & flowViewStyle()
static WtStyleCollection & instance()
WtFlowViewStyle _flowViewStyle
static void setConnectionStyle(WtConnectionStyle)
static WtNodeStyle const & nodeStyle()
static void setNodeStyle(WtNodeStyle)
static WtConnectionStyle const & connectionStyle()
static void setFlowViewStyle(WtFlowViewStyle)
WtStyleCollection()=default
reference at(size_type idx)
access specified array element with bounds checking
basic_json<> json
default specialization