/
icolourscheme.h
86 lines (62 loc) · 2.49 KB
/
icolourscheme.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
#include "imodule.h"
#include <functional>
#include "math/Vector3.h"
namespace colours
{
class IColourItem
{
public:
virtual ~IColourItem() {}
// Const and non-const colour accessors
virtual const Vector3& getColour() const = 0;
virtual Vector3& getColour() = 0;
};
class IColourScheme
{
public:
virtual ~IColourScheme() {}
// Iterate over all colours in this scheme
virtual void foreachColour(const std::function<void(const std::string& name, IColourItem& colour)>& functor) = 0;
virtual void foreachColour(const std::function<void(const std::string& name, const IColourItem& colour)>& functor) const = 0;
// Returns the requested colour object
virtual IColourItem& getColour(const std::string& colourName) = 0;
// returns the name of this colour scheme
virtual const std::string& getName() const = 0;
// returns true if the scheme is read-only
virtual bool isReadOnly() const = 0;
// set the read-only status of this scheme
virtual void setReadOnly(bool isReadOnly) = 0;
// Tries to add any missing items from the given scheme into this one
virtual void mergeMissingItemsFromScheme(const IColourScheme& other) = 0;
};
class IColourSchemeManager :
public RegisterableModule
{
public:
virtual ~IColourSchemeManager() {}
// Visit each known colour scheme with the given functor
virtual void foreachScheme(const std::function<void(const std::string&, IColourScheme&)>& functor) = 0;
// Get the named scheme
virtual IColourScheme& getColourScheme(const std::string& schemeName) = 0;
// Checks if the specified scheme already exists
virtual bool schemeExists(const std::string& name) = 0;
virtual void setActive(const std::string& name) = 0;
virtual IColourScheme& getActiveScheme() = 0;
// greebo: Returns the named colour, returns <0,0,0> if not found
virtual Vector3 getColour(const std::string& colourName) = 0;
virtual void deleteScheme(const std::string& name) = 0;
virtual void copyScheme(const std::string& fromName, const std::string& toName) = 0;
// Loads/Saves all the schemes from/to the registry
virtual void loadColourSchemes() = 0;
virtual void saveColourSchemes() = 0;
// Reverts all changes to the current objects and re-load them from the registry
virtual void restoreColourSchemes() = 0;
};
}
const char* const MODULE_COLOURSCHEME_MANAGER("ColourSchemeManager");
inline colours::IColourSchemeManager& GlobalColourSchemeManager()
{
static module::InstanceReference<colours::IColourSchemeManager> _reference(MODULE_COLOURSCHEME_MANAGER);
return _reference;
}