PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/llui/llmultislider.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 128 lines | 82 code | 21 blank | 25 comment | 0 complexity | 4efd92902ed34a51b98ba6675095d6de MD5 | raw file
  1/** 
  2 * @file llmultislider.h
  3 * @brief A simple multislider
  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_SLIDER_H
 28#define LL_MULTI_SLIDER_H
 29
 30#include "llf32uictrl.h"
 31#include "v4color.h"
 32
 33class LLUICtrlFactory;
 34
 35class LLMultiSlider : public LLF32UICtrl
 36{
 37public:
 38	struct SliderParams : public LLInitParam::Block<SliderParams>
 39	{
 40		Optional<std::string>	name;
 41		Mandatory<F32>			value;
 42		SliderParams();
 43	};
 44
 45	struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
 46	{
 47		Optional<S32>	max_sliders;
 48
 49		Optional<bool>	allow_overlap,
 50						draw_track,
 51						use_triangle;
 52
 53		Optional<LLUIColor>	track_color,
 54							thumb_disabled_color,
 55							thumb_outline_color,
 56							thumb_center_color,
 57							thumb_center_selected_color,
 58							triangle_color;
 59
 60		Optional<CommitCallbackParam>	mouse_down_callback,
 61										mouse_up_callback;
 62		Optional<S32>		thumb_width;
 63
 64		Multiple<SliderParams>	sliders;
 65		Params();
 66	};
 67
 68protected:
 69	LLMultiSlider(const Params&);
 70	friend class LLUICtrlFactory;
 71public:
 72	virtual ~LLMultiSlider();
 73	void				setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE);
 74	F32					getSliderValue(const std::string& name) const;
 75
 76	const std::string&	getCurSlider() const					{ return mCurSlider; }
 77	F32					getCurSliderValue() const				{ return getSliderValue(mCurSlider); }
 78	void				setCurSlider(const std::string& name);
 79	void				setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mCurSlider, val, from_event); }
 80
 81	/*virtual*/ void	setValue(const LLSD& value);
 82	/*virtual*/ LLSD	getValue() const		{ return mValue; }
 83
 84	boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb );
 85	boost::signals2::connection setMouseUpCallback(	const commit_signal_t::slot_type& cb );
 86
 87	bool				findUnusedValue(F32& initVal);
 88	const std::string&	addSlider();
 89	const std::string&	addSlider(F32 val);
 90	void				addSlider(F32 val, const std::string& name);
 91	void				deleteSlider(const std::string& name);
 92	void				deleteCurSlider()			{ deleteSlider(mCurSlider); }
 93	void				clear();
 94
 95	/*virtual*/ BOOL	handleHover(S32 x, S32 y, MASK mask);
 96	/*virtual*/ BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
 97	/*virtual*/ BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
 98	/*virtual*/ BOOL	handleKeyHere(KEY key, MASK mask);
 99	/*virtual*/ void	draw();
100
101protected:
102	LLSD			mValue;
103	std::string		mCurSlider;
104	static S32		mNameCounter;
105
106	S32				mMaxNumSliders;
107	BOOL			mAllowOverlap;
108	BOOL			mDrawTrack;
109	BOOL			mUseTriangle;			/// hacked in toggle to use a triangle
110
111	S32				mMouseOffset;
112	LLRect			mDragStartThumbRect;
113	S32				mThumbWidth;
114
115	std::map<std::string, LLRect>	
116					mThumbRects;
117	LLUIColor		mTrackColor;
118	LLUIColor		mThumbOutlineColor;
119	LLUIColor		mThumbCenterColor;
120	LLUIColor		mThumbCenterSelectedColor;
121	LLUIColor		mDisabledThumbColor;
122	LLUIColor		mTriangleColor;
123	
124	commit_signal_t*	mMouseDownSignal;
125	commit_signal_t*	mMouseUpSignal;
126};
127
128#endif  // LL_MULTI_SLIDER_H