PageRenderTime 54ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llxuixml/lluicolor.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 87 lines | 47 code | 13 blank | 27 comment | 7 complexity | dec96494d834f71ccbfdf8b9be077cc7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lluicolor.cpp
  3. * @brief brief LLUIColor class implementation 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. #include "linden_common.h"
  27. #include "lluicolor.h"
  28. LLUIColor::LLUIColor()
  29. :mColorPtr(NULL)
  30. {
  31. }
  32. LLUIColor::LLUIColor(const LLColor4& color)
  33. : mColor(color),
  34. mColorPtr(NULL)
  35. {
  36. }
  37. LLUIColor::LLUIColor(const LLUIColor* color)
  38. : mColorPtr(color)
  39. {
  40. }
  41. void LLUIColor::set(const LLColor4& color)
  42. {
  43. mColor = color;
  44. mColorPtr = NULL;
  45. }
  46. void LLUIColor::set(const LLUIColor* color)
  47. {
  48. mColorPtr = color;
  49. }
  50. const LLColor4& LLUIColor::get() const
  51. {
  52. return (mColorPtr == NULL ? mColor : mColorPtr->get());
  53. }
  54. LLUIColor::operator const LLColor4& () const
  55. {
  56. return get();
  57. }
  58. const LLColor4& LLUIColor::operator()() const
  59. {
  60. return get();
  61. }
  62. bool LLUIColor::isReference() const
  63. {
  64. return mColorPtr != NULL;
  65. }
  66. namespace LLInitParam
  67. {
  68. // used to detect equivalence with default values on export
  69. bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
  70. {
  71. // do not detect value equivalence, treat pointers to colors as distinct from color values
  72. return (a.mColorPtr == NULL && b.mColorPtr == NULL ? a.mColor == b.mColor : a.mColorPtr == b.mColorPtr);
  73. }
  74. }