summaryrefslogtreecommitdiff
path: root/indra/llui/lluicolortable.h
blob: dcbb1ee5cb6e45bd23912452ca71b929c6fff60e (plain)
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
/** 
 * @file lluicolortable.h
 * @brief brief LLUIColorTable class header file
 *
 * $LicenseInfo:firstyear=2009&license=viewergpl$
 * Copyright (c) 2009, Linden Research, Inc.
 * $/LicenseInfo$
 */

#ifndef LL_LLUICOLORTABLE_H_
#define LL_LLUICOLORTABLE_H_

#include <map>

#include "llinitparam.h"
#include "llsingleton.h"

#include "v4color.h"

class LLUIColorTable : public LLSingleton<LLUIColorTable>
{
public:
	struct ColorParams : LLInitParam::Choice<ColorParams>
	{
		Alternative<LLColor4>    value;
		Alternative<std::string> reference;

		ColorParams();
	};

	struct ColorEntryParams : LLInitParam::Block<ColorEntryParams>
	{
		Mandatory<std::string> name;
		Mandatory<ColorParams> color;

		ColorEntryParams();
	};

	struct Params : LLInitParam::Block<Params>
	{
		Multiple<ColorEntryParams> color_entries;

		Params();
	};

	// define colors by passing in a param block that can be generated via XUI file or manually
	void init(const Params& p);

	// color lookup
	const LLColor4& getColor(const std::string& name) const;

private:
	// consider using sorted vector
	typedef std::map<std::string, LLColor4>  string_color_map_t;
	string_color_map_t mColors;
};

#endif // LL_LLUICOLORTABLE_H