PageRenderTime 19ms CodeModel.GetById 2ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llmultisliderctrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 152 lines | 91 code | 32 blank | 29 comment | 1 complexity | 28bac77ce100efe577c4742298fb0da7 MD5 | raw file
  1/** 
  2 * @file llmultisliderctrl.h
  3 * @brief LLMultiSliderCtrl base class
  4 *
  5 * $LicenseInfo:firstyear=2007&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_MULTI_SLIDERCTRL_H
 28#define LL_MULTI_SLIDERCTRL_H
 29
 30#include "llf32uictrl.h"
 31#include "v4color.h"
 32#include "llmultislider.h"
 33#include "lltextbox.h"
 34#include "llrect.h"
 35
 36
 37//
 38// Classes
 39//
 40class LLFontGL;
 41class LLLineEditor;
 42class LLSlider;
 43
 44
 45class LLMultiSliderCtrl : public LLF32UICtrl
 46{
 47public:
 48	struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
 49	{
 50		Optional<S32>			label_width,
 51								text_width;
 52		Optional<bool>			show_text,
 53								can_edit_text;
 54		Optional<S32>			decimal_digits;
 55		Optional<S32>			max_sliders;	
 56		Optional<bool>			allow_overlap,
 57								draw_track,
 58								use_triangle;
 59
 60		Optional<LLUIColor>		text_color,
 61								text_disabled_color;
 62
 63		Optional<CommitCallbackParam>	mouse_down_callback,
 64										mouse_up_callback;
 65
 66		Multiple<LLMultiSlider::SliderParams>	sliders;
 67
 68		Params();
 69	};
 70
 71protected:
 72	LLMultiSliderCtrl(const Params&);
 73	friend class LLUICtrlFactory;
 74public:
 75	virtual ~LLMultiSliderCtrl();
 76
 77	F32				getSliderValue(const std::string& name) const;
 78	void			setSliderValue(const std::string& name, F32 v, BOOL from_event = FALSE);
 79
 80	virtual void	setValue(const LLSD& value );
 81	virtual LLSD	getValue() const		{ return mMultiSlider->getValue(); }
 82	virtual BOOL	setLabelArg( const std::string& key, const LLStringExplicit& text );
 83
 84	const std::string& getCurSlider() const					{ return mMultiSlider->getCurSlider(); }
 85	F32				getCurSliderValue() const				{ return mCurValue; }
 86	void			setCurSlider(const std::string& name);		
 87	void			setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mMultiSlider->getCurSlider(), val, from_event); }
 88
 89	virtual void	setMinValue(const LLSD& min_value)	{ setMinValue((F32)min_value.asReal()); }
 90	virtual void	setMaxValue(const LLSD& max_value)	{ setMaxValue((F32)max_value.asReal());  }
 91
 92	BOOL			isMouseHeldDown();
 93
 94	virtual void    setEnabled( BOOL b );
 95	virtual void	clear();
 96	virtual void	setPrecision(S32 precision);
 97	void			setMinValue(F32 min_value) {mMultiSlider->setMinValue(min_value);}
 98	void			setMaxValue(F32 max_value) {mMultiSlider->setMaxValue(max_value);}
 99	void			setIncrement(F32 increment) {mMultiSlider->setIncrement(increment);}
100
101	/// for adding and deleting sliders
102	const std::string&	addSlider();
103	const std::string&	addSlider(F32 val);
104	void			deleteSlider(const std::string& name);
105	void			deleteCurSlider()			{ deleteSlider(mMultiSlider->getCurSlider()); }
106
107	F32				getMinValue() const { return mMultiSlider->getMinValue(); }
108	F32				getMaxValue() const { return mMultiSlider->getMaxValue(); }
109
110	void			setLabel(const std::string& label)				{ if (mLabelBox) mLabelBox->setText(label); }
111	void			setLabelColor(const LLColor4& c)			{ mTextEnabledColor = c; }
112	void			setDisabledLabelColor(const LLColor4& c)	{ mTextDisabledColor = c; }
113
114	boost::signals2::connection setSliderMouseDownCallback( const commit_signal_t::slot_type& cb );
115	boost::signals2::connection setSliderMouseUpCallback( const commit_signal_t::slot_type& cb );
116
117	virtual void	onTabInto();
118
119	virtual void	setTentative(BOOL b);			// marks value as tentative
120	virtual void	onCommit();						// mark not tentative, then commit
121
122	virtual void		setControlName(const std::string& control_name, LLView* context);
123	
124	static void		onSliderCommit(LLUICtrl* caller, const LLSD& userdata);
125	
126	static void		onEditorCommit(LLUICtrl* ctrl, const LLSD& userdata);
127	static void		onEditorGainFocus(LLFocusableElement* caller, void *userdata);
128	static void		onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
129
130private:
131	void			updateText();
132	void			reportInvalidData();
133
134private:
135	const LLFontGL*	mFont;
136	BOOL			mShowText;
137	BOOL			mCanEditText;
138
139	S32				mPrecision;
140	LLTextBox*		mLabelBox;
141	S32				mLabelWidth;
142
143	F32				mCurValue;
144	LLMultiSlider*	mMultiSlider;
145	LLLineEditor*	mEditor;
146	LLTextBox*		mTextBox;
147
148	LLUIColor	mTextEnabledColor;
149	LLUIColor	mTextDisabledColor;
150};
151
152#endif  // LL_MULTI_SLIDERCTRL_H