PageRenderTime 25ms CodeModel.GetById 13ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llslider.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 112 lines | 67 code | 19 blank | 26 comment | 0 complexity | 0d391358001a7eedc7ca00ef6b84c5e7 MD5 | raw file
  1/** 
  2 * @file llslider.h
  3 * @brief A simple slider with no label.
  4 *
  5 * $LicenseInfo:firstyear=2002&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_LLSLIDER_H
 28#define LL_LLSLIDER_H
 29
 30#include "llf32uictrl.h"
 31#include "v4color.h"
 32#include "lluiimage.h"
 33
 34class LLSlider : public LLF32UICtrl
 35{
 36public:
 37	enum ORIENTATION { HORIZONTAL, VERTICAL };
 38
 39	struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
 40	{
 41		Optional<std::string> orientation;
 42
 43		Optional<LLUIColor>	track_color,
 44							thumb_outline_color,
 45							thumb_center_color;
 46
 47		Optional<LLUIImage*>	thumb_image,
 48								thumb_image_pressed,
 49								thumb_image_disabled,
 50								track_image_horizontal,
 51								track_image_vertical,
 52								track_highlight_horizontal_image,
 53								track_highlight_vertical_image;
 54
 55		Optional<CommitCallbackParam>	mouse_down_callback,
 56										mouse_up_callback;
 57
 58
 59		Params();
 60	};
 61protected:
 62	LLSlider(const Params&);
 63	friend class LLUICtrlFactory;
 64public:
 65	virtual ~LLSlider();
 66	void			setValue( F32 value, BOOL from_event = FALSE );
 67    // overrides for LLF32UICtrl methods
 68	virtual void	setValue(const LLSD& value )	{ setValue((F32)value.asReal(), TRUE); }
 69	
 70	virtual void 	setMinValue(const LLSD& min_value) { setMinValue((F32)min_value.asReal()); }
 71	virtual void 	setMaxValue(const LLSD& max_value) { setMaxValue((F32)max_value.asReal()); }
 72	virtual void	setMinValue(F32 min_value) { LLF32UICtrl::setMinValue(min_value); updateThumbRect(); }
 73	virtual void	setMaxValue(F32 max_value) { LLF32UICtrl::setMaxValue(max_value); updateThumbRect(); }
 74
 75	boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb );
 76	boost::signals2::connection setMouseUpCallback(	const commit_signal_t::slot_type& cb );
 77
 78	virtual BOOL	handleHover(S32 x, S32 y, MASK mask);
 79	virtual BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
 80	virtual BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
 81	virtual BOOL	handleKeyHere(KEY key, MASK mask);
 82	virtual BOOL	handleScrollWheel(S32 x, S32 y, S32 clicks);
 83	virtual void	draw();
 84
 85private:
 86	void			setValueAndCommit(F32 value);
 87	void			updateThumbRect();
 88
 89	BOOL			mVolumeSlider;
 90	S32				mMouseOffset;
 91	LLRect			mDragStartThumbRect;
 92
 93	LLPointer<LLUIImage>	mThumbImage;
 94	LLPointer<LLUIImage>	mThumbImagePressed;
 95	LLPointer<LLUIImage>	mThumbImageDisabled;
 96	LLPointer<LLUIImage>	mTrackImageHorizontal;
 97	LLPointer<LLUIImage>	mTrackImageVertical;
 98	LLPointer<LLUIImage>	mTrackHighlightHorizontalImage;
 99	LLPointer<LLUIImage>	mTrackHighlightVerticalImage;
100
101	const ORIENTATION	mOrientation;
102
103	LLRect		mThumbRect;
104	LLUIColor	mTrackColor;
105	LLUIColor	mThumbOutlineColor;
106	LLUIColor	mThumbCenterColor;
107	
108	commit_signal_t*	mMouseDownSignal;
109	commit_signal_t*	mMouseUpSignal;
110};
111
112#endif  // LL_LLSLIDER_H