PageRenderTime 13ms CodeModel.GetById 7ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/lluicolortable.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 103 lines | 45 code | 25 blank | 33 comment | 0 complexity | 9eb8668b9f12d99c8e4cf7b4c9528589 MD5 | raw file
  1/** 
  2 * @file lluicolortable.h
  3 * @brief brief LLUIColorTable class header file
  4 *
  5 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLUICOLORTABLE_H_
 28#define LL_LLUICOLORTABLE_H_
 29
 30#include <map>
 31
 32#include "llinitparam.h"
 33#include "llsingleton.h"
 34
 35#include "v4color.h"
 36
 37class LLUIColor;
 38
 39class LLUIColorTable : public LLSingleton<LLUIColorTable>
 40{
 41LOG_CLASS(LLUIColorTable);
 42
 43	// consider using sorted vector, can be much faster
 44	typedef std::map<std::string, LLUIColor>  string_color_map_t;
 45
 46public:
 47	struct ColorParams : LLInitParam::ChoiceBlock<ColorParams>
 48	{
 49		Alternative<LLColor4>    value;
 50		Alternative<std::string> reference;
 51
 52		ColorParams();
 53	};
 54
 55	struct ColorEntryParams : LLInitParam::Block<ColorEntryParams>
 56	{
 57		Mandatory<std::string> name;
 58		Mandatory<ColorParams> color;
 59
 60		ColorEntryParams();
 61	};
 62
 63	struct Params : LLInitParam::Block<Params>
 64	{
 65		Multiple<ColorEntryParams> color_entries;
 66
 67		Params();
 68	};
 69
 70	// define colors by passing in a param block that can be generated via XUI file or manually
 71	void insertFromParams(const Params& p);
 72
 73	// reset all colors to default magenta color
 74	void clear();
 75
 76	// color lookup
 77	LLUIColor getColor(const std::string& name, const LLColor4& default_color = LLColor4::magenta) const;
 78
 79	// if the color is in the table, it's value is changed, otherwise it is added
 80	void setColor(const std::string& name, const LLColor4& color);
 81
 82	// returns true if color_name exists in the table
 83	bool colorExists(const std::string& color_name) const;
 84
 85	// loads colors from settings files
 86	bool loadFromSettings();
 87
 88	// saves colors specified by the user to the users skin directory
 89	void saveUserSettings() const;
 90
 91private:
 92	bool loadFromFilename(const std::string& filename, string_color_map_t& table);
 93
 94	void insertFromParams(const Params& p, string_color_map_t& table);
 95	
 96	void clearTable(string_color_map_t& table);
 97	void setColor(const std::string& name, const LLColor4& color, string_color_map_t& table);
 98
 99	string_color_map_t mLoadedColors;
100	string_color_map_t mUserSetColors;
101};
102
103#endif // LL_LLUICOLORTABLE_H