aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llinventorybridge.h
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/llinventorybridge.h
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 'linden/indra/newview/llinventorybridge.h')
-rwxr-xr-xlinden/indra/newview/llinventorybridge.h598
1 files changed, 598 insertions, 0 deletions
diff --git a/linden/indra/newview/llinventorybridge.h b/linden/indra/newview/llinventorybridge.h
new file mode 100755
index 0000000..2d2288f
--- /dev/null
+++ b/linden/indra/newview/llinventorybridge.h
@@ -0,0 +1,598 @@
1/**
2 * @file llinventorybridge.h
3 * @brief Implementation of the Inventory-Folder-View-Bridge classes.
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 "llfloaterproperties.h"
29#include "llwearable.h"
30#include "llviewercontrol.h"
31#include "llcallingcard.h"
32
33enum EInventoryIcon
34{
35 TEXTURE_ICON_NAME,
36 SOUND_ICON_NAME,
37 CALLINGCARD_ONLINE_ICON_NAME,
38 CALLINGCARD_OFFLINE_ICON_NAME,
39 LANDMARK_ICON_NAME,
40 LANDMARK_VISITED_ICON_NAME,
41 SCRIPT_ICON_NAME,
42 CLOTHING_ICON_NAME,
43 OBJECT_ICON_NAME,
44 NOTECARD_ICON_NAME,
45 BODYPART_ICON_NAME,
46 SNAPSHOT_ICON_NAME,
47
48 BODYPART_SHAPE_ICON_NAME,
49 BODYPART_SKIN_ICON_NAME,
50 BODYPART_HAIR_ICON_NAME,
51 BODYPART_EYES_ICON_NAME,
52 CLOTHING_SHIRT_ICON_NAME,
53 CLOTHING_PANTS_ICON_NAME,
54 CLOTHING_SHOES_ICON_NAME,
55 CLOTHING_SOCKS_ICON_NAME,
56 CLOTHING_JACKET_ICON_NAME,
57 CLOTHING_GLOVES_ICON_NAME,
58 CLOTHING_UNDERSHIRT_ICON_NAME,
59 CLOTHING_UNDERPANTS_ICON_NAME,
60 CLOTHING_SKIRT_ICON_NAME,
61
62 ANIMATION_ICON_NAME,
63 GESTURE_ICON_NAME,
64
65 ICON_NAME_COUNT
66};
67
68extern const char* ICON_NAME[ICON_NAME_COUNT];
69
70typedef std::pair<LLUUID, LLUUID> two_uuids_t;
71typedef std::list<two_uuids_t> two_uuids_list_t;
72typedef std::pair<LLUUID, two_uuids_list_t> uuid_move_list_t;
73
74struct LLMoveInv
75{
76 LLUUID mObjectID;
77 LLUUID mCategoryID;
78 two_uuids_list_t mMoveList;
79 void (*mCallback)(S32, void*);
80 void* mUserData;
81};
82
83struct LLAttachmentRezAction
84{
85 LLUUID mItemID;
86 S32 mAttachPt;
87};
88
89
90//helper functions
91class LLShowProps
92{
93public:
94
95 static void showProperties(const LLUUID& uuid)
96 {
97 if(!LLFloaterProperties::show(uuid, LLUUID::null))
98 {
99 S32 left, top;
100 gFloaterView->getNewFloaterPosition(&left, &top);
101 LLRect rect = gSavedSettings.getRect("PropertiesRect");
102 rect.translate( left - rect.mLeft, top - rect.mTop );
103 LLFloaterProperties* floater;
104 floater = new LLFloaterProperties("item properties",
105 rect,
106 "Inventory Item Properties",
107 uuid,
108 LLUUID::null);
109 // keep onscreen
110 gFloaterView->adjustToFitScreen(floater, FALSE);
111 }
112 }
113};
114
115//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116// Class LLInventoryPanelObserver
117//
118// Bridge to support knowing when the inventory has changed.
119//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120class LLInventoryPanelObserver : public LLInventoryObserver
121{
122public:
123 LLInventoryPanelObserver(LLInventoryPanel* ip) : mIP(ip) {}
124 virtual ~LLInventoryPanelObserver() {}
125 virtual void changed(U32 mask) { mIP->modelChanged(mask); }
126protected:
127 LLInventoryPanel* mIP;
128};
129
130//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131// Class LLInvFVBridge (& it's derived classes)
132//
133// Short for Inventory-Folder-View-Bridge. This is an
134// implementation class to be able to view inventory items.
135//
136// You'll want to call LLInvItemFVELister::createBridge() to actually create
137// an instance of this class. This helps encapsulate the
138// funcationality a bit. (except for folders, you can create those
139// manually...)
140//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141class LLInvFVBridge : public LLFolderViewEventListener
142{
143public:
144 // This method is a convenience function which creates the correct
145 // type of bridge based on some basic information
146 static LLInvFVBridge* createBridge(LLAssetType::EType asset_type,
147 LLInventoryType::EType inv_type,
148 LLInventoryPanel* inventory,
149 const LLUUID& uuid,
150 U32 flags = 0x00);
151 virtual ~LLInvFVBridge() {}
152
153 virtual const LLUUID& getUUID() const { return mUUID; }
154
155 virtual const LLString& getPrefix() { return LLString::null; }
156 virtual void restoreItem() {}
157
158 // LLFolderViewEventListener functions
159 virtual const LLString& getName() const;
160 virtual const LLString& getDisplayName() const;
161 virtual PermissionMask getPermissionMask() const;
162 virtual U32 getCreationDate() const;
163 virtual LLFontGL::StyleFlags getLabelStyle() const
164 {
165 return LLFontGL::NORMAL;
166 }
167 virtual LLString getLabelSuffix() const { return LLString::null; }
168 virtual void openItem() {}
169 virtual void previewItem() {openItem();}
170 virtual void showProperties();
171 virtual BOOL isItemRenameable() const { return TRUE; }
172 //virtual BOOL renameItem(const LLString& new_name) {}
173 virtual BOOL isItemRemovable();
174 virtual BOOL isItemMovable();
175 //virtual BOOL removeItem() = 0;
176 virtual void removeBatch(LLDynamicArray<LLFolderViewEventListener*>& batch);
177 virtual void move(LLFolderViewEventListener* new_parent_bridge) {}
178 virtual BOOL isItemCopyable() const { return FALSE; }
179 virtual BOOL copyToClipboard() const { return FALSE; }
180 virtual void cutToClipboard() {}
181 virtual BOOL isClipboardPasteable() const;
182 virtual void pasteFromClipboard() {}
183 void getClipboardEntries(bool show_asset_id, std::vector<LLString> &items,
184 std::vector<LLString> &disabled_items, U32 flags);
185 virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
186 virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id);
187 virtual BOOL dragOrDrop(MASK mask, BOOL drop,
188 EDragAndDropType cargo_type,
189 void* cargo_data) { return FALSE; }
190 virtual LLInventoryType::EType getInventoryType() const { return mInvType; }
191
192 // LLInvFVBridge functionality
193 virtual void clearDisplayName() {}
194
195protected:
196 LLInvFVBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
197 mInventoryPanel(inventory), mUUID(uuid) {}
198
199 LLInventoryObject* getInventoryObject() const;
200 BOOL isInTrash() const;
201 // return true if the item is in agent inventory. if false, it
202 // must be lost or in the inventory library.
203 BOOL isAgentInventory() const;
204 virtual BOOL isItemPermissive() const;
205 static void changeItemParent(LLInventoryModel* model,
206 LLViewerInventoryItem* item,
207 const LLUUID& new_parent,
208 BOOL restamp);
209 static void changeCategoryParent(LLInventoryModel* model,
210 LLViewerInventoryCategory* item,
211 const LLUUID& new_parent,
212 BOOL restamp);
213 void removeBatchNoCheck(LLDynamicArray<LLFolderViewEventListener*>& batch);
214
215protected:
216 LLInventoryPanel* mInventoryPanel;
217 LLUUID mUUID; // item id
218 LLInventoryType::EType mInvType;
219};
220
221
222class LLItemBridge : public LLInvFVBridge
223{
224public:
225 LLItemBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
226 LLInvFVBridge(inventory, uuid) {}
227
228 virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
229
230 virtual void selectItem();
231 virtual void restoreItem();
232
233 virtual LLViewerImage* getIcon() const;
234 virtual const LLString& getDisplayName() const;
235 virtual LLString getLabelSuffix() const;
236 virtual PermissionMask getPermissionMask() const;
237 virtual U32 getCreationDate() const;
238 virtual BOOL isItemRenameable() const;
239 virtual BOOL renameItem(const LLString& new_name);
240 virtual BOOL removeItem();
241 virtual BOOL isItemCopyable() const;
242 virtual BOOL copyToClipboard() const;
243 virtual BOOL hasChildren() const { return FALSE; }
244 virtual BOOL isUpToDate() const { return TRUE; }
245
246 // override for LLInvFVBridge
247 virtual void clearDisplayName() { mDisplayName.clear(); }
248
249 LLViewerInventoryItem* getItem() const;
250
251protected:
252 virtual BOOL isItemPermissive() const;
253 static void buildDisplayName(LLInventoryItem* item, LLString& name);
254 mutable LLString mDisplayName;
255};
256
257
258class LLFolderBridge : public LLInvFVBridge
259{
260 friend class LLInvFVBridge;
261public:
262 BOOL dragItemIntoFolder(LLInventoryItem* inv_item,
263 BOOL drop);
264 BOOL dragCategoryIntoFolder(LLInventoryCategory* inv_category,
265 BOOL drop);
266 virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
267 virtual void openItem();
268 virtual BOOL isItemRenameable() const;
269 virtual void selectItem();
270 virtual void restoreItem();
271
272
273 virtual LLViewerImage* getIcon() const;
274 virtual BOOL renameItem(const LLString& new_name);
275 virtual BOOL removeItem();
276 virtual BOOL isClipboardPasteable() const;
277 virtual void pasteFromClipboard();
278 virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
279 virtual BOOL hasChildren() const;
280 virtual BOOL dragOrDrop(MASK mask, BOOL drop,
281 EDragAndDropType cargo_type,
282 void* cargo_data);
283
284 virtual BOOL isItemRemovable();
285 virtual BOOL isItemMovable();
286 virtual BOOL isUpToDate() const;
287
288 static void createWearable(LLFolderBridge* bridge, EWearableType type);
289 static void createWearable(LLUUID parent_folder_id, EWearableType type);
290
291 LLViewerInventoryCategory* getCategory() const;
292
293protected:
294 LLFolderBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
295 LLInvFVBridge(inventory, uuid) {}
296
297 // menu callbacks
298 static void pasteClipboard(void* user_data);
299 static void createNewCategory(void* user_data);
300
301 static void createNewShirt(void* user_data);
302 static void createNewPants(void* user_data);
303 static void createNewShoes(void* user_data);
304 static void createNewSocks(void* user_data);
305 static void createNewJacket(void* user_data);
306 static void createNewSkirt(void* user_data);
307 static void createNewGloves(void* user_data);
308 static void createNewUndershirt(void* user_data);
309 static void createNewUnderpants(void* user_data);
310 static void createNewShape(void* user_data);
311 static void createNewSkin(void* user_data);
312 static void createNewHair(void* user_data);
313 static void createNewEyes(void* user_data);
314
315 BOOL checkFolderForContentsOfType(LLInventoryModel* model, LLInventoryCollectFunctor& typeToCheck);
316
317 void beginIMSession(BOOL only_online);
318 void modifyOutfit(BOOL append);
319public:
320 static LLFolderBridge* sSelf;
321 static void staticFolderOptionsMenu();
322 void folderOptionsMenu();
323private:
324 BOOL mCallingCards;
325 BOOL mWearables;
326 LLMenuGL* mMenu;
327 std::vector<LLString> mItems;
328 std::vector<LLString> mDisabledItems;
329};
330
331// DEPRECATED
332class LLScriptBridge : public LLItemBridge
333{
334 friend class LLInvFVBridge;
335public:
336 LLViewerImage* getIcon() const;
337
338protected:
339 LLScriptBridge( LLInventoryPanel* inventory, const LLUUID& uuid ) :
340 LLItemBridge(inventory, uuid) {}
341};
342
343
344class LLTextureBridge : public LLItemBridge
345{
346 friend class LLInvFVBridge;
347public:
348 virtual const LLString& getPrefix() { return sPrefix; }
349
350 virtual LLViewerImage* getIcon() const;
351 virtual void openItem();
352
353protected:
354 LLTextureBridge(LLInventoryPanel* inventory, const LLUUID& uuid, LLInventoryType::EType type) :
355 LLItemBridge(inventory, uuid), mInvType(type) {}
356 static LLString sPrefix;
357 LLInventoryType::EType mInvType;
358};
359
360class LLSoundBridge : public LLItemBridge
361{
362 friend class LLInvFVBridge;
363public:
364 virtual const LLString& getPrefix() { return sPrefix; }
365
366 virtual LLViewerImage* getIcon() const;
367 virtual void openItem();
368 virtual void previewItem();
369 virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
370 static void openSoundPreview(void*);
371
372protected:
373 LLSoundBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
374 LLItemBridge(inventory, uuid) {}
375 static LLString sPrefix;
376};
377
378class LLLandmarkBridge : public LLItemBridge
379{
380 friend class LLInvFVBridge;
381public:
382 virtual const LLString& getPrefix() { return sPrefix; }
383 virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
384 virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
385 virtual LLViewerImage* getIcon() const;
386 virtual void openItem();
387
388protected:
389 LLLandmarkBridge(LLInventoryPanel* inventory, const LLUUID& uuid, U32 flags = 0x00) :
390 LLItemBridge(inventory, uuid)
391 {
392 mVisited = FALSE;
393 if (flags & LLInventoryItem::II_FLAGS_LANDMARK_VISITED)
394 {
395 mVisited = TRUE;
396 }
397 }
398
399protected:
400 static LLString sPrefix;
401 BOOL mVisited;
402};
403
404class LLCallingCardBridge;
405
406class LLCallingCardObserver : public LLFriendObserver
407{
408public:
409 LLCallingCardObserver(LLCallingCardBridge* bridge) : mBridgep(bridge) {}
410 virtual ~LLCallingCardObserver() { mBridgep = NULL; }
411 virtual void changed(U32 mask);
412
413protected:
414 LLCallingCardBridge* mBridgep;
415};
416
417class LLCallingCardBridge : public LLItemBridge
418{
419 friend class LLInvFVBridge;
420public:
421 virtual const LLString& getPrefix() { return sPrefix; }
422
423 virtual LLString getLabelSuffix() const;
424 //virtual const LLString& getDisplayName() const;
425 virtual LLViewerImage* getIcon() const;
426 virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
427 virtual void openItem();
428 virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
429 //virtual void renameItem(const LLString& new_name);
430 //virtual BOOL removeItem();
431 virtual BOOL dragOrDrop(MASK mask, BOOL drop,
432 EDragAndDropType cargo_type,
433 void* cargo_data);
434 void refreshFolderViewItem();
435
436protected:
437 LLCallingCardBridge( LLInventoryPanel* inventory, const LLUUID& uuid );
438 ~LLCallingCardBridge();
439
440protected:
441 static LLString sPrefix;
442 LLCallingCardObserver* mObserver;
443};
444
445
446class LLNotecardBridge : public LLItemBridge
447{
448 friend class LLInvFVBridge;
449public:
450 virtual const LLString& getPrefix() { return sPrefix; }
451
452 virtual LLViewerImage* getIcon() const;
453 virtual void openItem();
454
455protected:
456 LLNotecardBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
457 LLItemBridge(inventory, uuid) {}
458
459protected:
460 static LLString sPrefix;
461};
462
463class LLGestureBridge : public LLItemBridge
464{
465 friend class LLInvFVBridge;
466public:
467 virtual const LLString& getPrefix() { return sPrefix; }
468
469 virtual LLViewerImage* getIcon() const;
470
471 // Only suffix for gesture items, not task items, because only
472 // gestures in your inventory can be active.
473 virtual LLFontGL::StyleFlags getLabelStyle() const;
474 virtual LLString getLabelSuffix() const;
475
476 virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
477 virtual void openItem();
478 virtual BOOL removeItem();
479
480 virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
481
482protected:
483 LLGestureBridge(LLInventoryPanel* inventory, const LLUUID& uuid)
484 : LLItemBridge(inventory, uuid) {}
485
486protected:
487 static LLString sPrefix;
488};
489
490
491class LLAnimationBridge : public LLItemBridge
492{
493 friend class LLInvFVBridge;
494public:
495 virtual const LLString& getPrefix() { return sPrefix; }
496 virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
497 virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
498
499 virtual LLViewerImage* getIcon() const;
500 virtual void openItem();
501
502protected:
503 LLAnimationBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
504 LLItemBridge(inventory, uuid) {}
505
506protected:
507 static LLString sPrefix;
508};
509
510
511class LLObjectBridge : public LLItemBridge
512{
513 friend class LLInvFVBridge;
514public:
515 virtual const LLString& getPrefix() { return sPrefix; }
516
517 virtual LLViewerImage* getIcon() const;
518 virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
519 virtual void openItem();
520 virtual LLFontGL::StyleFlags getLabelStyle() const;
521 virtual LLString getLabelSuffix() const;
522 virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
523 virtual BOOL isItemRemovable();
524 virtual BOOL renameItem(const LLString& new_name);
525
526protected:
527 LLObjectBridge(LLInventoryPanel* inventory, const LLUUID& uuid, LLInventoryType::EType type, U32 flags) :
528 LLItemBridge(inventory, uuid), mInvType(type)
529 {
530 mAttachPt = (flags & 0xff); // low bye of inventory flags
531 }
532
533protected:
534 static LLString sPrefix;
535 static LLUUID sContextMenuItemID; // Only valid while the context menu is open.
536 LLInventoryType::EType mInvType;
537 U32 mAttachPt;
538
539};
540
541
542class LLLSLTextBridge : public LLItemBridge
543{
544 friend class LLInvFVBridge;
545public:
546 virtual const LLString& getPrefix() { return sPrefix; }
547
548 virtual LLViewerImage* getIcon() const;
549 virtual void openItem();
550
551protected:
552 LLLSLTextBridge( LLInventoryPanel* inventory, const LLUUID& uuid ) :
553 LLItemBridge(inventory, uuid) {}
554
555protected:
556 static LLString sPrefix;
557};
558
559
560class LLWearableBridge : public LLItemBridge
561{
562 friend class LLInvFVBridge;
563public:
564 virtual LLViewerImage* getIcon() const;
565 virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
566 virtual void openItem();
567 virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
568 virtual LLFontGL::StyleFlags getLabelStyle() const;
569 virtual LLString getLabelSuffix() const;
570 virtual BOOL isItemRemovable();
571 virtual BOOL renameItem(const LLString& new_name);
572
573 static void onWearOnAvatar( void* userdata ); // Access to wearOnAvatar() from menu
574 static BOOL canWearOnAvatar( void* userdata );
575 static void onWearOnAvatarArrived( LLWearable* wearable, void* userdata );
576 void wearOnAvatar();
577
578 static BOOL canEditOnAvatar( void* userdata ); // Access to editOnAvatar() from menu
579 static void onEditOnAvatar( void* userdata );
580 void editOnAvatar();
581
582 static BOOL canRemoveFromAvatar( void* userdata );
583 static void onRemoveFromAvatar( void* userdata );
584 static void onRemoveFromAvatarArrived( LLWearable* wearable, void* userdata );
585
586protected:
587 LLWearableBridge(LLInventoryPanel* inventory, const LLUUID& uuid, LLAssetType::EType asset_type, LLInventoryType::EType inv_type, EWearableType wearable_type) :
588 LLItemBridge(inventory, uuid),
589 mAssetType( asset_type ),
590 mInvType(inv_type),
591 mWearableType(wearable_type)
592 {}
593
594protected:
595 LLAssetType::EType mAssetType;
596 LLInventoryType::EType mInvType;
597 EWearableType mWearableType;
598};