aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltool.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lltool.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltool.cpp170
1 files changed, 170 insertions, 0 deletions
diff --git a/linden/indra/newview/lltool.cpp b/linden/indra/newview/lltool.cpp
new file mode 100644
index 0000000..d004a2d
--- /dev/null
+++ b/linden/indra/newview/lltool.cpp
@@ -0,0 +1,170 @@
1/**
2 * @file lltool.cpp
3 * @brief LLTool class implementation
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "lltool.h"
31
32#include "indra_constants.h"
33#include "llerror.h"
34#include "llview.h"
35
36#include "llviewerwindow.h"
37#include "lltoolcomp.h"
38#include "llfocusmgr.h"
39#include "llagent.h"
40#include "llviewborder.h"
41
42extern BOOL gDebugClicks;
43
44//static
45const LLString LLTool::sNameNull("null");
46
47LLTool::LLTool( const LLString& name, LLToolComposite* composite ) :
48 mComposite( composite ),
49 mName(name)
50{
51}
52
53LLTool::~LLTool()
54{
55 if( gFocusMgr.getMouseCapture() == this )
56 {
57 llwarns << "Tool deleted holding mouse capture. Mouse capture removed." << llendl;
58 gFocusMgr.removeMouseCaptureWithoutCallback( this );
59 }
60}
61
62
63BOOL LLTool::handleMouseDown(S32 x, S32 y, MASK mask)
64{
65 if (gDebugClicks)
66 {
67 llinfos << "LLTool left mouse down" << llendl;
68 }
69 // by default, didn't handle it
70 // llinfos << "LLTool::handleMouseDown" << llendl;
71 gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_DOWN);
72 return TRUE;
73}
74
75BOOL LLTool::handleMouseUp(S32 x, S32 y, MASK mask)
76{
77 if (gDebugClicks)
78 {
79 llinfos << "LLTool left mouse up" << llendl;
80 }
81 // by default, didn't handle it
82 // llinfos << "LLTool::handleMouseUp" << llendl;
83 gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_UP);
84 return TRUE;
85}
86
87BOOL LLTool::handleHover(S32 x, S32 y, MASK mask)
88{
89 gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
90 lldebugst(LLERR_USER_INPUT) << "hover handled by a tool" << llendl;
91 // by default, do nothing, say we handled it
92 return TRUE;
93}
94
95BOOL LLTool::handleScrollWheel(S32 x, S32 y, S32 clicks)
96{
97 // by default, didn't handle it
98 // llinfos << "LLTool::handleScrollWheel" << llendl;
99 return FALSE;
100}
101
102BOOL LLTool::handleDoubleClick(S32 x,S32 y,MASK mask)
103{
104 // llinfos << "LLTool::handleDoubleClick" << llendl;
105 // by default, pretend it's a left click
106 return FALSE;
107}
108
109BOOL LLTool::handleRightMouseDown(S32 x,S32 y,MASK mask)
110{
111 // by default, didn't handle it
112 // llinfos << "LLTool::handleRightMouseDown" << llendl;
113 return FALSE;
114}
115
116BOOL LLTool::handleRightMouseUp(S32 x, S32 y, MASK mask)
117{
118 // by default, didn't handle it
119 // llinfos << "LLTool::handleRightMouseDown" << llendl;
120 return FALSE;
121}
122
123BOOL LLTool::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen)
124{
125 // by default, didn't handle it
126 // llinfos << "LLTool::handleToolTip" << llendl;
127 return FALSE;
128}
129
130void LLTool::setMouseCapture( BOOL b )
131{
132 if( b )
133 {
134 gViewerWindow->setMouseCapture(mComposite ? mComposite : this, &LLTool::onMouseCaptureLost );
135 }
136 else
137 if( hasMouseCapture() )
138 {
139 gViewerWindow->setMouseCapture( NULL, NULL );
140 }
141}
142
143// virtual
144void LLTool::draw()
145{ }
146
147BOOL LLTool::hasMouseCapture()
148{
149 return gViewerWindow->hasMouseCapture(mComposite ? mComposite : this);
150}
151
152BOOL LLTool::handleKey(KEY key, MASK mask)
153{
154 return FALSE;
155}
156
157
158// static
159void LLTool::onMouseCaptureLost( LLMouseHandler* old_captor )
160{
161 LLTool* self = (LLTool*) old_captor;
162 if( self->mComposite )
163 {
164 self->mComposite->onMouseCaptureLost();
165 }
166 else
167 {
168 self->onMouseCaptureLost();
169 }
170}