aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltoolpipette.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/lltoolpipette.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 '')
-rwxr-xr-xlinden/indra/newview/lltoolpipette.cpp139
1 files changed, 139 insertions, 0 deletions
diff --git a/linden/indra/newview/lltoolpipette.cpp b/linden/indra/newview/lltoolpipette.cpp
new file mode 100755
index 0000000..8886150
--- /dev/null
+++ b/linden/indra/newview/lltoolpipette.cpp
@@ -0,0 +1,139 @@
1/**
2 * @file lltoolpipette.cpp
3 * @brief LLToolPipette class implementation
4 *
5 * Copyright (c) 2006-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/**
29 * A tool to pick texture entry infro from objects in world (color/texture)
30 */
31
32#include "llviewerprecompiledheaders.h"
33
34// File includes
35#include "lltoolpipette.h"
36
37// Library includes
38
39// Viewer includes
40#include "llviewerobjectlist.h"
41#include "llviewerwindow.h"
42#include "llselectmgr.h"
43#include "lltoolmgr.h"
44
45// Globals
46LLToolPipette *gToolPipette = NULL;
47
48//
49// Member functions
50//
51
52LLToolPipette::LLToolPipette()
53: LLTool("Pipette"),
54mSuccess(TRUE)
55{
56 mSelectCallback = NULL;
57 mUserData = NULL;
58}
59
60
61LLToolPipette::~LLToolPipette()
62{ }
63
64
65BOOL LLToolPipette::handleMouseDown(S32 x, S32 y, MASK mask)
66{
67 mSuccess = TRUE;
68 mTooltipMsg.clear();
69 gPickFaces = TRUE;
70 setMouseCapture(TRUE);
71 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback);
72 return TRUE;
73}
74
75BOOL LLToolPipette::handleMouseUp(S32 x, S32 y, MASK mask)
76{
77 mSuccess = TRUE;
78 gSelectMgr->unhighlightAll();
79 // *NOTE: This assumes the pipette tool is a transient tool.
80 gToolMgr->clearTransientTool();
81 setMouseCapture(FALSE);
82 return TRUE;
83}
84
85BOOL LLToolPipette::handleHover(S32 x, S32 y, MASK mask)
86{
87 gViewerWindow->setCursor(mSuccess ? UI_CURSOR_PIPETTE : UI_CURSOR_NO);
88 if (hasMouseCapture()) // mouse button is down
89 {
90 gPickFaces = TRUE;
91 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback);
92 return TRUE;
93 }
94 return FALSE;
95}
96
97BOOL LLToolPipette::handleToolTip(S32 x, S32 y, LLString& msg, LLRect *sticky_rect_screen)
98{
99 if (mTooltipMsg.empty())
100 {
101 return FALSE;
102 }
103 // keep tooltip message up when mouse in this part of screen
104 sticky_rect_screen->setCenterAndSize(x, y, 20, 20);
105 msg = mTooltipMsg;
106 return TRUE;
107}
108
109void LLToolPipette::pickCallback(S32 x, S32 y, MASK mask)
110{
111 LLViewerObject* hit_obj = gViewerWindow->lastObjectHit();
112 gSelectMgr->unhighlightAll();
113
114 // if we clicked on a face of a valid prim, save off texture entry data
115 if (hit_obj &&
116 hit_obj->getPCode() == LL_PCODE_VOLUME &&
117 gLastHitObjectFace != -1)
118 {
119 //TODO: this should highlight the selected face only
120 gSelectMgr->highlightObjectOnly(hit_obj);
121 gToolPipette->mTextureEntry = *hit_obj->getTE(gLastHitObjectFace);
122 if (gToolPipette->mSelectCallback)
123 {
124 gToolPipette->mSelectCallback(gToolPipette->mTextureEntry, gToolPipette->mUserData);
125 }
126 }
127}
128
129void LLToolPipette::setSelectCallback(select_callback callback, void* user_data)
130{
131 mSelectCallback = callback;
132 mUserData = user_data;
133}
134
135void LLToolPipette::setResult(BOOL success, const LLString& msg)
136{
137 mTooltipMsg = msg;
138 mSuccess = success;
139}