API Documentation
Loading...
Searching...
No Matches
IconManager.h
Go to the documentation of this file.
1#pragma once
2#include <NDEVR/Dictionary.h>
3#include <NDEVR/JSONNode.h>
4#include <NDEVR/String.h>
5namespace NDEVR
6{
8 {
10 : icon_id(def)
12 {}
13
14 IconDefinition(const String& id, const String& def)
15 : icon_id(id)
17 {}
18
20 {
21 fromJSON(node);
22 }
23 void toJSON(JSONNode& node) const
24 {
25 node["icon_id"] = icon_id;
26 node["default_draw_operation"] = default_draw_operation;
27 }
28 void fromJSON(const JSONNode& node)
29 {
30 icon_id = node["icon_id"].getAs<String>();
31 default_draw_operation = node["default_draw_operation"].getAs<String>();
32 }
35 };
36
38 {
39 public:
40 void toJSON(JSONNode& node) const
41 {
42 for (auto& def : m_icons)
43 {
44 def.second.toJSON(node[def.first]);
45 }
46 }
47 void fromJSON(const JSONNode& node)
48 {
49 for (const JSONNode* def : node.children())
50 {
52 }
53 }
54 void addIcon(const IconDefinition& definition)
55 {
56 m_icons.add(definition.icon_id, definition);
57 }
58 protected:
60 };
61 #define _i(id, def) (IconDefinition(id, def))
62}
Definition Dictionary.h:48
Definition IconManager.h:38
Dictionary< String, IconDefinition > m_icons
Definition IconManager.h:59
void toJSON(JSONNode &node) const
Definition IconManager.h:40
void addIcon(const IconDefinition &definition)
Definition IconManager.h:54
void fromJSON(const JSONNode &node)
Definition IconManager.h:47
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
Definition JSONParser.h:121
decltype(auto) getAs() const
Definition JSONParser.h:286
const Buffer< JSONNode * > & children() const
Definition JSONParser.h:336
Definition String.h:40
Definition ACIColor.h:37
Definition IconManager.h:8
String icon_id
Definition IconManager.h:33
String default_draw_operation
Definition IconManager.h:34
IconDefinition(const String &id, const String &def)
Definition IconManager.h:14
IconDefinition(const JSONNode &node)
Definition IconManager.h:19
IconDefinition(const String &def)
Definition IconManager.h:9
void toJSON(JSONNode &node) const
Definition IconManager.h:23
void fromJSON(const JSONNode &node)
Definition IconManager.h:28