diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lltoolselectrect.cpp | |
parent | README.txt (diff) | |
download | meta-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 'linden/indra/newview/lltoolselectrect.cpp')
-rw-r--r-- | linden/indra/newview/lltoolselectrect.cpp | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/linden/indra/newview/lltoolselectrect.cpp b/linden/indra/newview/lltoolselectrect.cpp new file mode 100644 index 0000000..289ee6d --- /dev/null +++ b/linden/indra/newview/lltoolselectrect.cpp | |||
@@ -0,0 +1,201 @@ | |||
1 | /** | ||
2 | * @file lltoolselectrect.cpp | ||
3 | * @brief A tool to select multiple objects with a screen-space rectangle. | ||
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 | // File includes | ||
31 | #include "lltoolselectrect.h" | ||
32 | |||
33 | // Library includes | ||
34 | #include "llgl.h" | ||
35 | #include "lldarray.h" | ||
36 | |||
37 | // Viewer includes | ||
38 | #include "llviewercontrol.h" | ||
39 | #include "llui.h" | ||
40 | #include "llselectmgr.h" | ||
41 | #include "lltoolview.h" | ||
42 | #include "lltoolmgr.h" | ||
43 | #include "llviewerobject.h" | ||
44 | #include "llviewerobjectlist.h" | ||
45 | #include "llviewerwindow.h" | ||
46 | #include "llviewercamera.h" | ||
47 | #include "viewer.h" | ||
48 | |||
49 | #include "llglheaders.h" | ||
50 | |||
51 | // Globals | ||
52 | const S32 SLOP_RADIUS = 5; | ||
53 | |||
54 | |||
55 | // | ||
56 | // Member functions | ||
57 | // | ||
58 | |||
59 | LLToolSelectRect::LLToolSelectRect( LLToolComposite* composite ) | ||
60 | : | ||
61 | LLToolSelect( composite ), | ||
62 | mDragStartX(0), | ||
63 | mDragStartY(0), | ||
64 | mDragEndX(0), | ||
65 | mDragEndY(0), | ||
66 | mDragLastWidth(0), | ||
67 | mDragLastHeight(0), | ||
68 | mMouseOutsideSlop(FALSE) | ||
69 | |||
70 | { } | ||
71 | |||
72 | |||
73 | void dialog_refresh_all(void); | ||
74 | |||
75 | BOOL LLToolSelectRect::handleMouseDown(S32 x, S32 y, MASK mask) | ||
76 | { | ||
77 | // start dragging rectangle | ||
78 | setMouseCapture( TRUE ); | ||
79 | |||
80 | mDragStartX = x; | ||
81 | mDragStartY = y; | ||
82 | mDragEndX = x; | ||
83 | mDragEndY = y; | ||
84 | |||
85 | mMouseOutsideSlop = FALSE; | ||
86 | |||
87 | LLToolSelect::handleMouseDown(x, y, mask); | ||
88 | return TRUE; | ||
89 | } | ||
90 | |||
91 | |||
92 | BOOL LLToolSelectRect::handleMouseUp(S32 x, S32 y, MASK mask) | ||
93 | { | ||
94 | setMouseCapture( FALSE ); | ||
95 | |||
96 | if( mMouseOutsideSlop ) | ||
97 | { | ||
98 | mDragLastWidth = 0; | ||
99 | mDragLastHeight = 0; | ||
100 | |||
101 | mMouseOutsideSlop = FALSE; | ||
102 | |||
103 | if (mask == MASK_CONTROL) | ||
104 | { | ||
105 | gSelectMgr->deselectHighlightedObjects(); | ||
106 | } | ||
107 | else | ||
108 | { | ||
109 | gSelectMgr->selectHighlightedObjects(); | ||
110 | } | ||
111 | return TRUE; | ||
112 | } | ||
113 | else | ||
114 | { | ||
115 | return LLToolSelect::handleMouseUp(x, y, mask); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | |||
120 | BOOL LLToolSelectRect::handleHover(S32 x, S32 y, MASK mask) | ||
121 | { | ||
122 | if( hasMouseCapture() ) | ||
123 | { | ||
124 | if (mMouseOutsideSlop || outsideSlop(x, y, mDragStartX, mDragStartY)) | ||
125 | { | ||
126 | if (!mMouseOutsideSlop && !(mask & MASK_SHIFT) && !(mask & MASK_CONTROL)) | ||
127 | { | ||
128 | // just started rect select, and not adding to current selection | ||
129 | gSelectMgr->deselectAll(); | ||
130 | } | ||
131 | mMouseOutsideSlop = TRUE; | ||
132 | mDragEndX = x; | ||
133 | mDragEndY = y; | ||
134 | |||
135 | handleRectangleSelection(x, y, mask); | ||
136 | } | ||
137 | else | ||
138 | { | ||
139 | return LLToolSelect::handleHover(x, y, mask); | ||
140 | } | ||
141 | |||
142 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectRect (active)" << llendl; | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectRect (inactive)" << llendl; | ||
147 | } | ||
148 | |||
149 | gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW); | ||
150 | return TRUE; | ||
151 | } | ||
152 | |||
153 | |||
154 | void LLToolSelectRect::draw() | ||
155 | { | ||
156 | if( hasMouseCapture() && mMouseOutsideSlop) | ||
157 | { | ||
158 | if (gKeyboard->currentMask(TRUE) == MASK_CONTROL) | ||
159 | { | ||
160 | glColor4f(1.f, 0.f, 0.f, 1.f); | ||
161 | } | ||
162 | else | ||
163 | { | ||
164 | glColor4f(1.f, 1.f, 0.f, 1.f); | ||
165 | } | ||
166 | LLGLSNoTexture gls_no_texture; | ||
167 | gl_rect_2d( | ||
168 | llmin(mDragStartX, mDragEndX), | ||
169 | llmax(mDragStartY, mDragEndY), | ||
170 | llmax(mDragStartX, mDragEndX), | ||
171 | llmin(mDragStartY, mDragEndY), | ||
172 | FALSE); | ||
173 | if (gKeyboard->currentMask(TRUE) == MASK_CONTROL) | ||
174 | { | ||
175 | glColor4f(1.f, 0.f, 0.f, 0.1f); | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | glColor4f(1.f, 1.f, 0.f, 0.1f); | ||
180 | } | ||
181 | gl_rect_2d( | ||
182 | llmin(mDragStartX, mDragEndX), | ||
183 | llmax(mDragStartY, mDragEndY), | ||
184 | llmax(mDragStartX, mDragEndX), | ||
185 | llmin(mDragStartY, mDragEndY)); | ||
186 | } | ||
187 | } | ||
188 | |||
189 | // true if x,y outside small box around start_x,start_y | ||
190 | BOOL LLToolSelectRect::outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y) | ||
191 | { | ||
192 | S32 dx = x - start_x; | ||
193 | S32 dy = y - start_y; | ||
194 | |||
195 | return (dx <= -SLOP_RADIUS || SLOP_RADIUS <= dx || dy <= -SLOP_RADIUS || SLOP_RADIUS <= dy); | ||
196 | } | ||
197 | |||
198 | |||
199 | // | ||
200 | // Static functions | ||
201 | // | ||