PageRenderTime 43ms CodeModel.GetById 38ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LL_LLUICOLORTABLE_H_
  27. #define LL_LLUICOLORTABLE_H_
  28. #include <map>
  29. #include "llinitparam.h"
  30. #include "llsingleton.h"
  31. #include "v4color.h"
  32. class LLUIColor;
  33. class LLUIColorTable : public LLSingleton<LLUIColorTable>
  34. {
  35. LOG_CLASS(LLUIColorTable);
  36. // consider using sorted vector, can be much faster
  37. typedef std::map<std::string, LLUIColor> string_color_map_t;
  38. public:
  39. struct ColorParams : LLInitParam::ChoiceBlock<ColorParams>
  40. {
  41. Alternative<LLColor4> value;
  42. Alternative<std::string> reference;
  43. ColorParams();
  44. };
  45. struct ColorEntryParams : LLInitParam::Block<ColorEntryParams>
  46. {
  47. Mandatory<std::string> name;
  48. Mandatory<ColorParams> color;
  49. ColorEntryParams();
  50. };
  51. struct Params : LLInitParam::Block<Params>
  52. {
  53. Multiple<ColorEntryParams> color_entries;
  54. Params();
  55. };
  56. // define colors by passing in a param block that can be generated via XUI file or manually
  57. void insertFromParams(const Params& p);
  58. // reset all colors to default magenta color
  59. void clear();
  60. // color lookup
  61. LLUIColor getColor(const std::string& name, const LLColor4& default_color = LLColor4::magenta) const;
  62. // if the color is in the table, it's value is changed, otherwise it is added
  63. void setColor(const std::string& name, const LLColor4& color);
  64. // returns true if color_name exists in the table
  65. bool colorExists(const std::string& color_name) const;
  66. // loads colors from settings files
  67. bool loadFromSettings();
  68. // saves colors specified by the user to the users skin directory
  69. void saveUserSettings() const;
  70. private:
  71. bool loadFromFilename(const std::string& filename, string_color_map_t& table);
  72. void insertFromParams(const Params& p, string_color_map_t& table);
  73. void clearTable(string_color_map_t& table);
  74. void setColor(const std::string& name, const LLColor4& color, string_color_map_t& table);
  75. string_color_map_t mLoadedColors;
  76. string_color_map_t mUserSetColors;
  77. };
  78. #endif // LL_LLUICOLORTABLE_H