aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltooldraganddrop.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltooldraganddrop.h258
1 files changed, 258 insertions, 0 deletions
diff --git a/linden/indra/newview/lltooldraganddrop.h b/linden/indra/newview/lltooldraganddrop.h
new file mode 100644
index 0000000..4f94ed8
--- /dev/null
+++ b/linden/indra/newview/lltooldraganddrop.h
@@ -0,0 +1,258 @@
1/**
2 * @file lltooldraganddrop.h
3 * @brief LLToolDragAndDrop class header file
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#ifndef LL_TOOLDRAGANDDROP_H
29#define LL_TOOLDRAGANDDROP_H
30
31#include "lltool.h"
32#include "llview.h"
33#include "lluuid.h"
34#include "stdenums.h"
35#include "llassetstorage.h"
36#include "lldarray.h"
37#include "llpermissions.h"
38#include "llwindow.h"
39#include "llviewerinventory.h"
40
41class LLToolDragAndDrop;
42class LLViewerRegion;
43class LLVOAvatar;
44
45class LLToolDragAndDrop : public LLTool
46{
47public:
48 LLToolDragAndDrop();
49
50 // overridden from LLTool
51 virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
52 virtual BOOL handleHover(S32 x, S32 y, MASK mask);
53 virtual BOOL handleKey(KEY key, MASK mask);
54 virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect *sticky_rect_screen);
55 virtual void onMouseCaptureLost();
56 virtual void handleDeselect();
57
58 void setDragStart( S32 x, S32 y ); // In screen space
59 BOOL isOverThreshold( S32 x, S32 y ); // In screen space
60
61 enum ESource
62 {
63 SOURCE_AGENT,
64 SOURCE_WORLD,
65 SOURCE_NOTECARD,
66 SOURCE_LIBRARY
67 };
68
69 void beginDrag(EDragAndDropType type,
70 const LLUUID& cargo_id,
71 ESource source,
72 const LLUUID& source_id = LLUUID::null,
73 const LLUUID& object_id = LLUUID::null);
74 void beginMultiDrag(const std::vector<EDragAndDropType> types,
75 const std::vector<LLUUID>& cargo_ids,
76 ESource source,
77 const LLUUID& source_id = LLUUID::null);
78 void endDrag();
79 ESource getSource() const { return mSource; }
80 const LLUUID& getSourceID() const { return mSourceID; }
81 const LLUUID& getObjectID() const { return mObjectID; }
82 EAcceptance getLastAccept() { return mLastAccept; }
83
84protected:
85 enum EDropTarget
86 {
87 DT_NONE = 0,
88 DT_SELF = 1,
89 DT_AVATAR = 2,
90 DT_OBJECT = 3,
91 DT_LAND = 4,
92 DT_COUNT = 5
93 };
94
95 // dragOrDrop3dImpl points to a member of LLToolDragAndDrop that
96 // takes parameters (LLViewerObject* obj, S32 face, MASK, BOOL
97 // drop) and returns a BOOL if drop is ok
98 typedef EAcceptance (LLToolDragAndDrop::*dragOrDrop3dImpl)
99 (LLViewerObject*, S32, MASK, BOOL);
100
101 void dragOrDrop(S32 x, S32 y, MASK mask, BOOL drop,
102 EAcceptance* acceptance);
103 void dragOrDrop3D(S32 x, S32 y, MASK mask, BOOL drop,
104 EAcceptance* acceptance);
105 static void pickCallback(S32 x, S32 y, MASK mask);
106
107protected:
108
109 S32 mDragStartX;
110 S32 mDragStartY;
111
112 std::vector<EDragAndDropType> mCargoTypes;
113 //void* mCargoData;
114 std::vector<LLUUID> mCargoIDs;
115 ESource mSource;
116 LLUUID mSourceID;
117 LLUUID mObjectID;
118
119 LLVector3d mLastCameraPos;
120 LLVector3d mLastHitPos;
121
122 ECursorType mCursor;
123 EAcceptance mLastAccept;
124 BOOL mDrop;
125 S32 mCurItemIndex;
126 LLString mToolTipMsg;
127
128 // array of pointers to functions that implement the logic to
129 // dragging and dropping into the simulator.
130 static dragOrDrop3dImpl sDragAndDrop3d[DAD_COUNT][DT_COUNT];
131
132protected:
133 // 3d drop functions. these call down into the static functions
134 // named drop<ThingToDrop> if drop is TRUE and permissions allow
135 // that behavior.
136 EAcceptance dad3dNULL(LLViewerObject*, S32, MASK, BOOL);
137 EAcceptance dad3dRezObjectOnLand(LLViewerObject* obj, S32 face,
138 MASK mask, BOOL drop);
139 EAcceptance dad3dRezObjectOnObject(LLViewerObject* obj, S32 face,
140 MASK mask, BOOL drop);
141 EAcceptance dad3dRezScript(LLViewerObject* obj, S32 face,
142 MASK mask, BOOL drop);
143 EAcceptance dad3dTextureObject(LLViewerObject* obj, S32 face,
144 MASK mask, BOOL drop);
145// EAcceptance dad3dTextureSelf(LLViewerObject* obj, S32 face,
146// MASK mask, BOOL drop);
147 EAcceptance dad3dWearItem(LLViewerObject* obj, S32 face,
148 MASK mask, BOOL drop);
149 EAcceptance dad3dWearCategory(LLViewerObject* obj, S32 face,
150 MASK mask, BOOL drop);
151 EAcceptance dad3dUpdateInventory(LLViewerObject* obj, S32 face,
152 MASK mask, BOOL drop);
153 EAcceptance dad3dUpdateInventoryCategory(LLViewerObject* obj,
154 S32 face,
155 MASK mask,
156 BOOL drop);
157 EAcceptance dad3dGiveInventoryObject(LLViewerObject* obj, S32 face,
158 MASK mask, BOOL drop);
159 EAcceptance dad3dGiveInventory(LLViewerObject* obj, S32 face,
160 MASK mask, BOOL drop);
161 EAcceptance dad3dGiveInventoryCategory(LLViewerObject* obj, S32 face,
162 MASK mask, BOOL drop);
163 EAcceptance dad3dRezFromObjectOnLand(LLViewerObject* obj, S32 face,
164 MASK mask, BOOL drop);
165 EAcceptance dad3dRezFromObjectOnObject(LLViewerObject* obj, S32 face,
166 MASK mask, BOOL drop);
167 EAcceptance dad3dRezAttachmentFromInv(LLViewerObject* obj, S32 face,
168 MASK mask, BOOL drop);
169 EAcceptance dad3dCategoryOnLand(LLViewerObject *obj, S32 face,
170 MASK mask, BOOL drop);
171 EAcceptance dad3dAssetOnLand(LLViewerObject *obj, S32 face,
172 MASK mask, BOOL drop);
173 EAcceptance dad3dActivateGesture(LLViewerObject *obj, S32 face,
174 MASK mask, BOOL drop);
175
176 // This method converts mCargoID to an inventory item or
177 // folder. If no item or category is found, both pointers will be
178 // returned NULL.
179 LLInventoryObject* locateInventory(LLViewerInventoryItem*& item,
180 LLViewerInventoryCategory*& cat);
181
182 //LLInventoryObject* locateMultipleInventory(
183 // LLViewerInventoryCategory::cat_array_t& cats,
184 // LLViewerInventoryItem::item_array_t& items);
185
186 void createContainer(LLViewerInventoryItem::item_array_t &items, const char* preferred_name);
187 void dropObject(LLViewerObject* raycast_target,
188 BOOL bypass_sim_raycast,
189 BOOL from_task_inventory,
190 BOOL remove_from_inventory);
191
192 // accessor that looks at permissions, copyability, and names of
193 // inventory items to determine if a drop would be ok.
194 static EAcceptance willObjectAcceptInventory(LLViewerObject* obj, LLInventoryItem* item);
195
196 // deal with permissions of object, etc. returns TRUE if drop can
197 // proceed, otherwise FALSE.
198 static BOOL handleDropTextureProtections(LLViewerObject* hit_obj,
199 LLInventoryItem* item,
200 LLToolDragAndDrop::ESource source,
201 const LLUUID& src_id);
202
203
204 // give inventory item functionality
205 static void handleCopyProtectedItem(S32 option, void* data);
206 static void commitGiveInventoryItem(const LLUUID& to_agent,
207 LLInventoryItem* item);
208
209 // give inventory category functionality
210 static void handleCopyProtectedCategory(S32 option, void* data);
211 static void commitGiveInventoryCategory(const LLUUID& to_agent,
212 LLInventoryCategory* cat);
213public:
214 // helper functions
215 static BOOL isInventoryDropAcceptable(LLViewerObject* obj, LLInventoryItem* item) { return (ACCEPT_YES_COPY_SINGLE <= willObjectAcceptInventory(obj, item)); }
216
217 // This simple helper function assumes you are attempting to
218 // transfer item. returns true if you can give, otherwise false.
219 static BOOL isInventoryGiveAcceptable(LLInventoryItem* item);
220 static BOOL isInventoryGroupGiveAcceptable(LLInventoryItem* item);
221
222 BOOL dadUpdateInventory(LLViewerObject* obj, BOOL drop);
223 BOOL dadUpdateInventoryCategory(LLViewerObject* obj, BOOL drop);
224
225 // methods that act on the simulator state.
226 static void dropScript(LLViewerObject* hit_obj,
227 LLInventoryItem* item,
228 BOOL active,
229 ESource source,
230 const LLUUID& src_id);
231 static void dropTextureOneFace(LLViewerObject* hit_obj, S32 hit_face,
232 LLInventoryItem* item,
233 ESource source,
234 const LLUUID& src_id);
235 static void dropTextureAllFaces(LLViewerObject* hit_obj,
236 LLInventoryItem* item,
237 ESource source,
238 const LLUUID& src_id);
239 //static void dropTextureOneFaceAvatar(LLVOAvatar* avatar,S32 hit_face,
240 // LLInventoryItem* item)
241
242 static void dropInventory(LLViewerObject* hit_obj,
243 LLInventoryItem* item,
244 ESource source,
245 const LLUUID& src_id);
246
247 static void giveInventory(const LLUUID& to_agent, LLInventoryItem* item);
248 static void giveInventoryCategory(const LLUUID& to_agent,
249 LLInventoryCategory* item);
250};
251
252// Singleton
253extern LLToolDragAndDrop *gToolDragAndDrop;
254
255// utility functions
256void pack_permissions_slam(LLMessageSystem* msg, U32 flags, const LLPermissions& perms);
257
258#endif // LL_TOOLDRAGANDDROP_H