00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034
00035 #include "lltoolselectrect.h"
00036
00037
00038 #include "llgl.h"
00039 #include "lldarray.h"
00040
00041
00042 #include "llviewercontrol.h"
00043 #include "llui.h"
00044 #include "llselectmgr.h"
00045 #include "lltoolview.h"
00046 #include "lltoolmgr.h"
00047 #include "llviewerobject.h"
00048 #include "llviewerobjectlist.h"
00049 #include "llviewerwindow.h"
00050 #include "llviewercamera.h"
00051 #include "viewer.h"
00052
00053 #include "llglheaders.h"
00054
00055
00056 const S32 SLOP_RADIUS = 5;
00057
00058
00059
00060
00061
00062
00063 LLToolSelectRect::LLToolSelectRect( LLToolComposite* composite )
00064 :
00065 LLToolSelect( composite ),
00066 mDragStartX(0),
00067 mDragStartY(0),
00068 mDragEndX(0),
00069 mDragEndY(0),
00070 mDragLastWidth(0),
00071 mDragLastHeight(0),
00072 mMouseOutsideSlop(FALSE)
00073
00074 { }
00075
00076
00077 void dialog_refresh_all(void);
00078
00079 BOOL LLToolSelectRect::handleMouseDown(S32 x, S32 y, MASK mask)
00080 {
00081
00082 setMouseCapture( TRUE );
00083
00084 mDragStartX = x;
00085 mDragStartY = y;
00086 mDragEndX = x;
00087 mDragEndY = y;
00088
00089 mMouseOutsideSlop = FALSE;
00090
00091 LLToolSelect::handleMouseDown(x, y, mask);
00092 return TRUE;
00093 }
00094
00095
00096 BOOL LLToolSelectRect::handleMouseUp(S32 x, S32 y, MASK mask)
00097 {
00098 setMouseCapture( FALSE );
00099
00100 if( mMouseOutsideSlop )
00101 {
00102 mDragLastWidth = 0;
00103 mDragLastHeight = 0;
00104
00105 mMouseOutsideSlop = FALSE;
00106
00107 if (mask == MASK_CONTROL)
00108 {
00109 gSelectMgr->deselectHighlightedObjects();
00110 }
00111 else
00112 {
00113 gSelectMgr->selectHighlightedObjects();
00114 }
00115 return TRUE;
00116 }
00117 else
00118 {
00119 return LLToolSelect::handleMouseUp(x, y, mask);
00120 }
00121 }
00122
00123
00124 BOOL LLToolSelectRect::handleHover(S32 x, S32 y, MASK mask)
00125 {
00126 if( hasMouseCapture() )
00127 {
00128 if (mMouseOutsideSlop || outsideSlop(x, y, mDragStartX, mDragStartY))
00129 {
00130 if (!mMouseOutsideSlop && !(mask & MASK_SHIFT) && !(mask & MASK_CONTROL))
00131 {
00132
00133 gSelectMgr->deselectAll();
00134 }
00135 mMouseOutsideSlop = TRUE;
00136 mDragEndX = x;
00137 mDragEndY = y;
00138
00139 handleRectangleSelection(x, y, mask);
00140 }
00141 else
00142 {
00143 return LLToolSelect::handleHover(x, y, mask);
00144 }
00145
00146 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectRect (active)" << llendl;
00147 }
00148 else
00149 {
00150 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectRect (inactive)" << llendl;
00151 }
00152
00153 gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
00154 return TRUE;
00155 }
00156
00157
00158 void LLToolSelectRect::draw()
00159 {
00160 if( hasMouseCapture() && mMouseOutsideSlop)
00161 {
00162 if (gKeyboard->currentMask(TRUE) == MASK_CONTROL)
00163 {
00164 glColor4f(1.f, 0.f, 0.f, 1.f);
00165 }
00166 else
00167 {
00168 glColor4f(1.f, 1.f, 0.f, 1.f);
00169 }
00170 LLGLSNoTexture gls_no_texture;
00171 gl_rect_2d(
00172 llmin(mDragStartX, mDragEndX),
00173 llmax(mDragStartY, mDragEndY),
00174 llmax(mDragStartX, mDragEndX),
00175 llmin(mDragStartY, mDragEndY),
00176 FALSE);
00177 if (gKeyboard->currentMask(TRUE) == MASK_CONTROL)
00178 {
00179 glColor4f(1.f, 0.f, 0.f, 0.1f);
00180 }
00181 else
00182 {
00183 glColor4f(1.f, 1.f, 0.f, 0.1f);
00184 }
00185 gl_rect_2d(
00186 llmin(mDragStartX, mDragEndX),
00187 llmax(mDragStartY, mDragEndY),
00188 llmax(mDragStartX, mDragEndX),
00189 llmin(mDragStartY, mDragEndY));
00190 }
00191 }
00192
00193
00194 BOOL LLToolSelectRect::outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y)
00195 {
00196 S32 dx = x - start_x;
00197 S32 dy = y - start_y;
00198
00199 return (dx <= -SLOP_RADIUS || SLOP_RADIUS <= dx || dy <= -SLOP_RADIUS || SLOP_RADIUS <= dy);
00200 }
00201
00202
00203
00204
00205