PageRenderTime 53ms CodeModel.GetById 19ms app.highlight 28ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/llui/lldraghandle.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 139 lines | 87 code | 23 blank | 29 comment | 0 complexity | 1419b696af7e28141c30c18c3bd3effd MD5 | raw file
  1/** 
  2 * @file lldraghandle.h
  3 * @brief LLDragHandle base class
  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// A widget for dragging a view around the screen using the mouse.
 28
 29#ifndef LL_DRAGHANDLE_H
 30#define LL_DRAGHANDLE_H
 31
 32#include "llview.h"
 33#include "v4color.h"
 34#include "llrect.h"
 35#include "llcoord.h"
 36
 37class LLTextBox;
 38
 39class LLDragHandle : public LLView
 40{
 41public:
 42	struct Params 
 43	:	public LLInitParam::Block<Params, LLView::Params>
 44	{
 45		Optional<std::string> label;
 46		Optional<LLUIColor> drag_highlight_color;
 47		Optional<LLUIColor> drag_shadow_color;
 48		
 49		Params() 
 50		:	label("label"),	
 51			drag_highlight_color("drag_highlight_color", LLUIColorTable::instance().getColor("DefaultHighlightLight")),
 52			drag_shadow_color("drag_shadow_color", LLUIColorTable::instance().getColor("DefaultShadowDark"))
 53		{
 54			changeDefault(mouse_opaque, true);
 55			changeDefault(follows.flags, FOLLOWS_ALL);
 56		}
 57	};
 58	void initFromParams(const Params&);
 59	
 60	virtual ~LLDragHandle();
 61
 62	virtual void setValue(const LLSD& value);
 63
 64	void			setForeground(BOOL b)		{ mForeground = b; }
 65	BOOL			getForeground() const		{ return mForeground; }
 66	void			setMaxTitleWidth(S32 max_width) {mMaxTitleWidth = llmin(max_width, mMaxTitleWidth); }
 67	S32				getMaxTitleWidth() const { return mMaxTitleWidth; }
 68	void			setButtonsRect(const LLRect& rect){ mButtonsRect = rect; }
 69	LLRect			getButtonsRect() { return mButtonsRect; }
 70	void			setTitleVisible(BOOL visible);
 71
 72	virtual void	setTitle( const std::string& title ) = 0;
 73	virtual std::string	getTitle() const = 0;
 74
 75	virtual BOOL	handleHover(S32 x, S32 y, MASK mask);
 76	virtual BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
 77	virtual BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
 78
 79protected:
 80	LLDragHandle(const Params&);
 81	friend class LLUICtrlFactory;
 82	
 83protected:
 84	LLTextBox*		mTitleBox;
 85	
 86private:
 87	LLRect			mButtonsRect;
 88	S32				mDragLastScreenX;
 89	S32				mDragLastScreenY;
 90	S32				mLastMouseScreenX;
 91	S32				mLastMouseScreenY;
 92	LLCoordGL		mLastMouseDir;
 93	LLUIColor		mDragHighlightColor;
 94	LLUIColor		mDragShadowColor;
 95	S32				mMaxTitleWidth;
 96	BOOL			mForeground;
 97
 98	// Pixels near the edge to snap floaters.
 99	static S32		sSnapMargin;
100};
101
102
103// Use this one for traditional top-of-window draggers
104class LLDragHandleTop
105: public LLDragHandle
106{
107protected:
108	LLDragHandleTop(const Params& p) : LLDragHandle(p) {}
109	friend class LLUICtrlFactory;
110public:
111	virtual void	setTitle( const std::string& title );
112	virtual std::string getTitle() const;
113	virtual void	draw();
114	virtual void	reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
115
116private:
117	void	reshapeTitleBox();
118};
119
120
121// Use this for left-side, vertical text draggers
122class LLDragHandleLeft
123: public LLDragHandle
124{
125protected:
126	LLDragHandleLeft(const Params& p) : LLDragHandle(p) {}
127	friend class LLUICtrlFactory;
128public:
129	virtual void	setTitle( const std::string& title );
130	virtual std::string getTitle() const;
131	virtual void	draw();
132	virtual void	reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
133
134};
135
136const S32 DRAG_HANDLE_HEIGHT = 16;
137const S32 DRAG_HANDLE_WIDTH = 16;
138
139#endif  // LL_DRAGHANDLE_H