PageRenderTime 26ms CodeModel.GetById 15ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llresizebar.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 91 lines | 52 code | 13 blank | 26 comment | 1 complexity | c7548be047552904fef8545d1b068666 MD5 | raw file
 1/** 
 2 * @file llresizebar.h
 3 * @brief LLResizeBar 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#ifndef LL_RESIZEBAR_H
28#define LL_RESIZEBAR_H
29
30#include "llview.h"
31#include "llcoord.h"
32
33class LLResizeBar : public LLView
34{
35public:
36	enum Side { LEFT, TOP, RIGHT, BOTTOM };
37
38	struct Params : public LLInitParam::Block<Params, LLView::Params>
39	{
40		Mandatory<LLView*> resizing_view;
41		Mandatory<Side>	side;
42
43		Optional<S32>	min_size;
44		Optional<S32>	max_size;
45		Optional<bool>	snapping_enabled;
46		Optional<bool>	allow_double_click_snapping;
47
48		Params()
49		:	max_size("max_size", S32_MAX),
50			snapping_enabled("snapping_enabled", true),
51			resizing_view("resizing_view"),
52			side("side"),
53			allow_double_click_snapping("allow_double_click_snapping", true)
54		{
55			name = "resize_bar";
56		}
57	};
58
59protected:
60	LLResizeBar(const LLResizeBar::Params& p);
61	friend class LLUICtrlFactory;
62public:
63
64//	virtual void	draw();  No appearance
65	virtual BOOL	handleHover(S32 x, S32 y, MASK mask);
66	virtual BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
67	virtual BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
68	virtual BOOL	handleDoubleClick(S32 x, S32 y, MASK mask);
69
70	void			setResizeLimits( S32 min_size, S32 max_size ) { mMinSize = min_size; mMaxSize = max_size; }
71	void			setEnableSnapping(BOOL enable) { mSnappingEnabled = enable; }
72	void			setAllowDoubleClickSnapping(BOOL allow) { mAllowDoubleClickSnapping = allow; }
73	bool			canResize() { return getEnabled() && mMaxSize > mMinSize; }
74
75private:
76	S32				mDragLastScreenX;
77	S32				mDragLastScreenY;
78	S32				mLastMouseScreenX;
79	S32				mLastMouseScreenY;
80	LLCoordGL		mLastMouseDir;
81	S32				mMinSize;
82	S32				mMaxSize;
83	const Side		mSide;
84	BOOL			mSnappingEnabled;
85	BOOL			mAllowDoubleClickSnapping;
86	LLView*			mResizingView;
87};
88
89#endif  // LL_RESIZEBAR_H
90
91