Debian Codegraph @

include/ieclasscolours.h

raw
1 #pragma once
2
3 #include <functional>
4 #include <sigc++/signal.h>
5 #include "imodule.h"
6 #include "ieclass.h"
7 #include "math/Vector3.h"
8
9 namespace eclass
10 {
11
12 /**
13 * Manages the entity class colour overrides that are applied
14 * to certain eclasses as defined in the currently active
15 * colour scheme.
16 */
17 class IColourManager :
18 public RegisterableModule
19 {
20 public:
21 virtual ~IColourManager() {}
22
23 // Register an override for the given entity class, such that the wire/fill shader
24 // colours of the named entity class are using the given colour instead of the one
25 // defined in the entityDef block.
26 // Adding an override for an entity class will replace any existing overrides.
27 // The colour is given in RGB values with each component in the interval [0..1].
28 virtual void addOverrideColour(const std::string& eclass, const Vector4& colour) = 0;
29
30 /**
31 * \brief Applies a possible colour override to the given entity class.
32 *
33 * If an override was found, the entity class's colour will be changed with
34 * setColour().
35 *
36 * \return true if an override was found, false otherwise.
37 */
38 virtual bool applyColours(IEntityClass& eclass) = 0;
39
40 // Visit each override definition with the given functor
41 virtual void foreachOverrideColour(const std::function<void(const std::string&, const Vector4&)>& functor) = 0;
42
43 // Removes the override colour for the given entity class
44 virtual void removeOverrideColour(const std::string& eclass) = 0;
45
46 // Removes all registered overrides
47 virtual void clearOverrideColours() = 0;
48
49 // Signal invoked when an override of a specific eclass is added, changed or removed
50 // function signature: void(const std::string& eclass, bool hasBeenRemoved)
51 virtual sigc::signal<void, const std::string&, bool>& sig_overrideColourChanged() = 0;
52 };
53
54 }
55
56 const char* const MODULE_ECLASS_COLOUR_MANAGER("EclassColourManager");
57
58 /**
59 * Return the global IEClassColourManager to the application.
60 * \ingroup eclass
61 */
62 inline eclass::IColourManager& GlobalEclassColourManager()
63 {
64 static module::InstanceReference<eclass::IColourManager> _reference(MODULE_ECLASS_COLOUR_MANAGER);
65 return _reference;
66 }