PageRenderTime 51ms CodeModel.GetById 40ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llcolorswatch.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 122 lines | 78 code | 16 blank | 28 comment | 0 complexity | 73260c22f38d2bbfb3e08941acc68430 MD5 | raw file
  1/** 
  2 * @file llcolorswatch.h
  3 * @brief LLColorSwatch class definition
  4 *
  5 * $LicenseInfo:firstyear=2001&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_LLCOLORSWATCH_H
 28#define LL_LLCOLORSWATCH_H
 29
 30#include "lluictrl.h"
 31#include "v4color.h"
 32#include "llfloater.h"
 33#include "llviewertexture.h"
 34#include "lltextbox.h"
 35
 36//
 37// Classes
 38//
 39class LLColor4;
 40class LLTextBox;
 41class LLFloaterColorPicker;
 42class LLViewerTexture;
 43
 44class LLColorSwatchCtrl
 45: public LLUICtrl
 46{
 47public:
 48	typedef enum e_color_pick_op
 49	{
 50		COLOR_CHANGE,
 51		COLOR_SELECT,
 52		COLOR_CANCEL
 53	} EColorPickOp;
 54
 55	struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
 56	{
 57		Optional<LLUIColor>				color;
 58		Optional<bool>					can_apply_immediately;
 59		Optional<LLUIImage*>			alpha_background_image;
 60		Optional<commit_callback_t> 	cancel_callback;
 61		Optional<commit_callback_t> 	select_callback;
 62		Optional<LLUIColor>				border_color;
 63		Optional<S32>					label_width;
 64		Optional<S32>					label_height;
 65		
 66		Optional<LLTextBox::Params>		caption_text;
 67		Optional<LLViewBorder::Params>	border;
 68		Params();
 69	};
 70
 71protected:
 72	LLColorSwatchCtrl(const Params& p);
 73	friend class LLUICtrlFactory;
 74public:
 75	~LLColorSwatchCtrl ();
 76
 77	/*virtual*/ void setValue(const LLSD& value);
 78
 79	/*virtual*/ LLSD getValue() const { return mColor.getValue(); }
 80	const LLColor4&	get()							{ return mColor; }
 81	
 82	void			set(const LLColor4& color, BOOL update_picker = FALSE, BOOL from_event = FALSE);
 83	void			setOriginal(const LLColor4& color);
 84	void			setValid(BOOL valid);
 85	void			setLabel(const std::string& label);
 86	void			setLabelWidth(S32 label_width) {mLabelWidth =label_width;}
 87	void			setCanApplyImmediately(BOOL apply) { mCanApplyImmediately = apply; }
 88	void			setOnCancelCallback(commit_callback_t cb) { mOnCancelCallback = cb; }
 89	void			setOnSelectCallback(commit_callback_t cb) { mOnSelectCallback = cb; }
 90	void			setFallbackImageName(const std::string& name) { mFallbackImageName = name; }
 91
 92	void			showPicker(BOOL take_focus);
 93
 94	/*virtual*/ BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
 95	/*virtual*/ BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
 96	/*virtual*/ BOOL	handleDoubleClick(S32 x,S32 y,MASK mask);
 97	/*virtual*/ BOOL	handleHover(S32 x, S32 y, MASK mask);
 98	/*virtual*/ BOOL	handleUnicodeCharHere(llwchar uni_char);
 99	/*virtual*/ void	draw();
100	/*virtual*/ void	setEnabled( BOOL enabled );
101
102	static void		onColorChanged ( void* data, EColorPickOp pick_op = COLOR_CHANGE );
103	void			closeFloaterColorPicker();
104
105protected:
106	BOOL			mValid;
107	LLColor4		mColor;
108	LLUIColor		mBorderColor;
109	LLTextBox*		mCaption;
110	LLHandle<LLFloater> mPickerHandle;
111	LLViewBorder*	mBorder;
112	BOOL			mCanApplyImmediately;
113	commit_callback_t mOnCancelCallback;
114	commit_callback_t mOnSelectCallback;
115	S32             mLabelWidth;
116	S32             mLabelHeight;
117
118	LLPointer<LLUIImage> mAlphaGradientImage;
119	std::string		mFallbackImageName;
120};
121
122#endif  // LL_LLBUTTON_H