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{
7 /**--------------------------------------------------------------------------------------------------
8 \brief Information for displaying a particular icon
9
10 **/
12 {
14 : icon_id(def)
16 {}
17
18 IconDefinition(const String& id, const String& def)
19 : icon_id(id)
21 {}
22
24 {
25 fromJSON(node);
26 }
27 void toJSON(JSONNode& node) const
28 {
29 node["icon_id"] = icon_id;
30 node["default_draw_operation"] = default_draw_operation;
31 }
32 void fromJSON(const JSONNode& node)
33 {
34 icon_id = node["icon_id"].getAs<String>();
35 default_draw_operation = node["default_draw_operation"].getAs<String>();
36 }
39 };
40
41 /**--------------------------------------------------------------------------------------------------
42 \brief Stores information about many different icons
43
44 **/
46 {
47 public:
48 void toJSON(JSONNode& node) const
49 {
50 for (auto& def : m_icons)
51 {
52 def.second.toJSON(node[def.first]);
53 }
54 }
55 void fromJSON(const JSONNode& node)
56 {
57 for (const JSONNode* def : node.children())
58 {
60 }
61 }
62 void addIcon(const IconDefinition& definition)
63 {
64 m_icons.add(definition.icon_id, definition);
65 }
66 protected:
68 };
69 #define _i(id, def) (IconDefinition(id, def))
70}
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Stores information about many different icons.
Definition IconManager.h:46
Dictionary< String, IconDefinition > m_icons
Definition IconManager.h:67
void toJSON(JSONNode &node) const
Definition IconManager.h:48
void addIcon(const IconDefinition &definition)
Definition IconManager.h:62
void fromJSON(const JSONNode &node)
Definition IconManager.h:55
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
Definition JSONParser.h:60
decltype(auto) getAs() const
Definition JSONParser.h:201
const Buffer< JSONNode * > & children() const
Definition JSONParser.h:245
The core String class for the NDEVR API.
Definition String.h:69
Definition ACIColor.h:37
Information for displaying a particular icon.
Definition IconManager.h:12
String icon_id
Definition IconManager.h:37
String default_draw_operation
Definition IconManager.h:38
IconDefinition(const String &id, const String &def)
Definition IconManager.h:18
IconDefinition(const JSONNode &node)
Definition IconManager.h:23
IconDefinition(const String &def)
Definition IconManager.h:13
void toJSON(JSONNode &node) const
Definition IconManager.h:27
void fromJSON(const JSONNode &node)
Definition IconManager.h:32