PageRenderTime 26ms CodeModel.GetById 15ms app.highlight 8ms 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
 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
27#include "linden_common.h"
28
29#include "lluicolor.h"
30
31LLUIColor::LLUIColor()
32	:mColorPtr(NULL)
33{
34}
35
36
37LLUIColor::LLUIColor(const LLColor4& color)
38:	mColor(color), 
39	mColorPtr(NULL)
40{
41}
42
43LLUIColor::LLUIColor(const LLUIColor* color)
44:	mColorPtr(color)
45{
46}
47
48void LLUIColor::set(const LLColor4& color)
49{
50	mColor = color;
51	mColorPtr = NULL;
52}
53
54void LLUIColor::set(const LLUIColor* color)
55{
56	mColorPtr = color;
57}
58
59const LLColor4& LLUIColor::get() const
60{
61	return (mColorPtr == NULL ? mColor : mColorPtr->get());
62}
63
64LLUIColor::operator const LLColor4& () const
65{
66	return get();
67}
68
69const LLColor4& LLUIColor::operator()() const
70{
71	return get();
72}
73
74bool LLUIColor::isReference() const
75{
76	return mColorPtr != NULL;
77}
78
79namespace LLInitParam
80{
81	// used to detect equivalence with default values on export
82	bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
83	{
84		// do not detect value equivalence, treat pointers to colors as distinct from color values
85		return (a.mColorPtr == NULL && b.mColorPtr == NULL ? a.mColor == b.mColor : a.mColorPtr == b.mColorPtr);
86	}
87}