MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / SetStyleFromJSON

Method SetStyleFromJSON

Source/CodeEntry.cpp:1336–1397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1334}
1335
1336void CodeEntry::SetStyleFromJSON(const ofxJSONElement& vdict)
1337{
1338 auto fs = vdict.get("font-size", 14);
1339 auto fsi = fs.asInt();
1340 if (fsi > 4 && fsi < 200)
1341 mFontSize = fsi - 2;
1342
1343 auto fromRGB = [vdict](const std::string& key, ofColor& onto)
1344 {
1345 auto def = Json::Value(Json::arrayValue);
1346 def[0u] = 255;
1347 def[1u] = 0;
1348 def[2u] = 0;
1349 auto arr = vdict.get(key, def);
1350 if (def.size() < 3)
1351 {
1352 onto.r = 255;
1353 onto.g = 0;
1354 onto.b = 0;
1355 }
1356 else
1357 {
1358 try
1359 {
1360 onto.r = arr[0u].asInt();
1361 onto.g = arr[1u].asInt();
1362 onto.b = arr[2u].asInt();
1363
1364 if (def.size() > 3)
1365 onto.a = arr[3u].asInt();
1366 }
1367 catch (Json::LogicError& e)
1368 {
1369 TheSynth->LogEvent(__PRETTY_FUNCTION__ + std::string(" json error: ") + e.what(), kLogEventType_Error);
1370 }
1371 }
1372 };
1373 fromRGB("currentBg", currentBg);
1374 fromRGB("publishedBg", publishedBg);
1375 fromRGB("unpublishedBg", unpublishedBg);
1376 fromRGB("string", stringColor);
1377 fromRGB("number", numberColor);
1378 fromRGB("name1", name1Color);
1379 fromRGB("name2", name2Color);
1380 fromRGB("name3", name3Color);
1381 fromRGB("defined", definedColor);
1382 fromRGB("equals", equalsColor);
1383 fromRGB("paren", parenColor);
1384 fromRGB("brace", braceColor);
1385 fromRGB("bracket", bracketColor);
1386 fromRGB("op", opColor);
1387 fromRGB("comma", commaColor);
1388 fromRGB("comment", commentColor);
1389 fromRGB("selectedOverlay", selectedOverlay);
1390
1391 fromRGB("jediBg", jediBg);
1392 fromRGB("jediIndexBg", jediIndexBg);
1393 fromRGB("jediAutoComplete", jediAutoComplete);

Callers 2

CreateUIControlsMethod · 0.80
SetUpFromSaveDataMethod · 0.80

Calls 3

ValueClass · 0.85
sizeMethod · 0.80
LogEventMethod · 0.80

Tested by

no test coverage detected