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

/indra/newview/lltoolcomp.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 235 lines | 135 code | 53 blank | 47 comment | 0 complexity | 54b53e81c05cfa1c29534de76b41954c MD5 | raw file
  1/** 
  2 * @file lltoolcomp.h
  3 * @brief Composite tools
  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_TOOLCOMP_H
 28#define LL_TOOLCOMP_H
 29
 30#include "lltool.h"
 31
 32class LLManip;
 33class LLToolSelectRect;
 34class LLToolPlacer;
 35class LLPickInfo;
 36
 37class LLView;
 38class LLTextBox;
 39
 40//-----------------------------------------------------------------------
 41// LLToolComposite
 42
 43class LLToolComposite : public LLTool
 44{
 45public:
 46	LLToolComposite(const std::string& name);
 47
 48    virtual BOOL			handleMouseDown(S32 x, S32 y, MASK mask) = 0;	// Sets the current tool
 49    virtual BOOL			handleMouseUp(S32 x, S32 y, MASK mask);			// Returns to the default tool
 50	virtual BOOL			handleDoubleClick(S32 x, S32 y, MASK mask) = 0;
 51
 52	// Map virtual functions to the currently active internal tool
 53    virtual BOOL			handleHover(S32 x, S32 y, MASK mask)			{ return mCur->handleHover( x, y, mask ); }
 54	virtual BOOL			handleScrollWheel(S32 x, S32 y, S32 clicks)		{ return mCur->handleScrollWheel( x, y, clicks ); }
 55	virtual BOOL			handleRightMouseDown(S32 x, S32 y, MASK mask)	{ return mCur->handleRightMouseDown( x, y, mask ); }
 56
 57	virtual LLViewerObject*	getEditingObject()								{ return mCur->getEditingObject(); }
 58	virtual LLVector3d		getEditingPointGlobal()							{ return mCur->getEditingPointGlobal(); }
 59	virtual BOOL			isEditing()										{ return mCur->isEditing(); }
 60	virtual void			stopEditing()									{ mCur->stopEditing(); mCur = mDefault; }
 61
 62	virtual BOOL			clipMouseWhenDown()								{ return mCur->clipMouseWhenDown(); }
 63
 64	virtual void			handleSelect();
 65	virtual void			handleDeselect()								{ mCur->handleDeselect(); mCur = mDefault; mSelected = FALSE; }
 66
 67	virtual void			render()										{ mCur->render(); }
 68	virtual void			draw()											{ mCur->draw(); }
 69
 70	virtual BOOL			handleKey(KEY key, MASK mask)					{ return mCur->handleKey( key, mask ); }
 71
 72	virtual void			onMouseCaptureLost();
 73
 74	virtual void			screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const
 75								{ mCur->screenPointToLocal(screen_x, screen_y, local_x, local_y); }
 76
 77	virtual void			localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const
 78								{ mCur->localPointToScreen(local_x, local_y, screen_x, screen_y); }
 79
 80	BOOL					isSelecting();
 81protected:
 82	void					setCurrentTool( LLTool* new_tool );
 83	LLTool*					getCurrentTool()								{ return mCur; }
 84	// In hover handler, call this to auto-switch tools
 85	void					setToolFromMask( MASK mask, LLTool *normal );
 86
 87protected:
 88	LLTool*					mCur;		// The tool to which we're delegating.
 89	LLTool*					mDefault;
 90	BOOL					mSelected;
 91	BOOL					mMouseDown;
 92	LLManip*				mManip;
 93	LLToolSelectRect*		mSelectRect;
 94
 95public:
 96	static const std::string sNameComp;
 97};
 98
 99
100//-----------------------------------------------------------------------
101// LLToolCompTranslate
102
103class LLToolCompInspect : public LLToolComposite, public LLSingleton<LLToolCompInspect>
104{
105public:
106	LLToolCompInspect();
107	virtual ~LLToolCompInspect();
108
109	// Overridden from LLToolComposite
110    virtual BOOL		handleMouseDown(S32 x, S32 y, MASK mask);
111    virtual BOOL		handleDoubleClick(S32 x, S32 y, MASK mask);
112
113	static void pickCallback(const LLPickInfo& pick_info);
114};
115
116//-----------------------------------------------------------------------
117// LLToolCompTranslate
118
119class LLToolCompTranslate : public LLToolComposite, public LLSingleton<LLToolCompTranslate>
120{
121public:
122	LLToolCompTranslate();
123	virtual ~LLToolCompTranslate();
124
125	// Overridden from LLToolComposite
126	virtual BOOL		handleMouseDown(S32 x, S32 y, MASK mask);
127	virtual BOOL		handleDoubleClick(S32 x, S32 y, MASK mask);
128	virtual BOOL		handleHover(S32 x, S32 y, MASK mask);
129	virtual BOOL		handleMouseUp(S32 x, S32 y, MASK mask);			// Returns to the default tool
130	virtual void		render();
131
132	virtual LLTool*		getOverrideTool(MASK mask);
133
134	static void pickCallback(const LLPickInfo& pick_info);
135};
136
137//-----------------------------------------------------------------------
138// LLToolCompScale
139
140class LLToolCompScale : public LLToolComposite, public LLSingleton<LLToolCompScale>
141{
142public:
143	LLToolCompScale();
144	virtual ~LLToolCompScale();
145
146	// Overridden from LLToolComposite
147    virtual BOOL		handleMouseDown(S32 x, S32 y, MASK mask);
148    virtual BOOL		handleDoubleClick(S32 x, S32 y, MASK mask);
149    virtual BOOL		handleHover(S32 x, S32 y, MASK mask);
150	virtual BOOL		handleMouseUp(S32 x, S32 y, MASK mask);			// Returns to the default tool
151	virtual void		render();
152
153	virtual LLTool*		getOverrideTool(MASK mask);
154	
155	static void pickCallback(const LLPickInfo& pick_info);
156};
157
158
159//-----------------------------------------------------------------------
160// LLToolCompRotate
161
162class LLToolCompRotate : public LLToolComposite, public LLSingleton<LLToolCompRotate>
163{
164public:
165	LLToolCompRotate();
166	virtual ~LLToolCompRotate();
167
168	// Overridden from LLToolComposite
169    virtual BOOL		handleMouseDown(S32 x, S32 y, MASK mask);
170    virtual BOOL		handleDoubleClick(S32 x, S32 y, MASK mask);
171    virtual BOOL		handleHover(S32 x, S32 y, MASK mask);
172	virtual BOOL		handleMouseUp(S32 x, S32 y, MASK mask);
173	virtual void		render();
174
175	virtual LLTool*		getOverrideTool(MASK mask);
176
177	static void pickCallback(const LLPickInfo& pick_info);
178
179protected:
180};
181
182//-----------------------------------------------------------------------
183// LLToolCompCreate
184
185class LLToolCompCreate : public LLToolComposite, public LLSingleton<LLToolCompCreate>
186{
187public:
188	LLToolCompCreate();
189	virtual ~LLToolCompCreate();
190
191	// Overridden from LLToolComposite
192    virtual BOOL		handleMouseDown(S32 x, S32 y, MASK mask);
193    virtual BOOL		handleDoubleClick(S32 x, S32 y, MASK mask);
194	virtual BOOL		handleMouseUp(S32 x, S32 y, MASK mask);
195	
196	static void pickCallback(const LLPickInfo& pick_info);
197protected:
198	LLToolPlacer*		mPlacer;
199	BOOL				mObjectPlacedOnMouseDown;
200};
201
202
203//-----------------------------------------------------------------------
204// LLToolCompGun
205
206class LLToolGun;
207class LLToolGrab;
208class LLToolSelect;
209
210class LLToolCompGun : public LLToolComposite, public LLSingleton<LLToolCompGun>
211{
212public:
213	LLToolCompGun();
214	virtual ~LLToolCompGun();
215
216	// Overridden from LLToolComposite
217    virtual BOOL			handleHover(S32 x, S32 y, MASK mask);
218	virtual BOOL			handleMouseDown(S32 x, S32 y, MASK mask);
219	virtual BOOL			handleDoubleClick(S32 x, S32 y, MASK mask);
220	virtual BOOL			handleRightMouseDown(S32 x, S32 y, MASK mask);
221	virtual BOOL			handleMouseUp(S32 x, S32 y, MASK mask);
222	virtual BOOL			handleScrollWheel(S32 x, S32 y, S32 clicks);
223	virtual void			onMouseCaptureLost();
224	virtual void			handleSelect();
225	virtual void			handleDeselect();
226	virtual LLTool*			getOverrideTool(MASK mask) { return NULL; }
227
228protected:
229	LLToolGun*			mGun;
230	LLToolGrab*			mGrab;
231	LLTool*				mNull;
232};
233
234
235#endif  // LL_TOOLCOMP_H