llinventorybridge.h

Go to the documentation of this file.
00001 
00032 #include "llfloaterproperties.h"
00033 #include "llwearable.h"
00034 #include "llviewercontrol.h"
00035 #include "llcallingcard.h"
00036 
00037 enum EInventoryIcon
00038 {
00039         TEXTURE_ICON_NAME,
00040         SOUND_ICON_NAME,
00041         CALLINGCARD_ONLINE_ICON_NAME,
00042         CALLINGCARD_OFFLINE_ICON_NAME,
00043         LANDMARK_ICON_NAME,
00044         LANDMARK_VISITED_ICON_NAME,
00045         SCRIPT_ICON_NAME,
00046         CLOTHING_ICON_NAME,
00047         OBJECT_ICON_NAME,
00048         OBJECT_MULTI_ICON_NAME,
00049         NOTECARD_ICON_NAME,
00050         BODYPART_ICON_NAME,
00051         SNAPSHOT_ICON_NAME,
00052 
00053         BODYPART_SHAPE_ICON_NAME,
00054         BODYPART_SKIN_ICON_NAME,
00055         BODYPART_HAIR_ICON_NAME,
00056         BODYPART_EYES_ICON_NAME,
00057         CLOTHING_SHIRT_ICON_NAME,
00058         CLOTHING_PANTS_ICON_NAME,
00059         CLOTHING_SHOES_ICON_NAME,
00060         CLOTHING_SOCKS_ICON_NAME,
00061         CLOTHING_JACKET_ICON_NAME,
00062         CLOTHING_GLOVES_ICON_NAME,
00063         CLOTHING_UNDERSHIRT_ICON_NAME,
00064         CLOTHING_UNDERPANTS_ICON_NAME,
00065         CLOTHING_SKIRT_ICON_NAME,
00066         
00067         ANIMATION_ICON_NAME,
00068         GESTURE_ICON_NAME,
00069 
00070         ICON_NAME_COUNT
00071 };
00072 
00073 extern const char* ICON_NAME[ICON_NAME_COUNT];
00074 
00075 typedef std::pair<LLUUID, LLUUID> two_uuids_t;
00076 typedef std::list<two_uuids_t> two_uuids_list_t;
00077 typedef std::pair<LLUUID, two_uuids_list_t> uuid_move_list_t;
00078 
00079 struct LLMoveInv
00080 {
00081         LLUUID mObjectID;
00082         LLUUID mCategoryID;
00083         two_uuids_list_t mMoveList;
00084         void (*mCallback)(S32, void*);
00085         void* mUserData;
00086 };
00087 
00088 struct LLAttachmentRezAction
00089 {
00090         LLUUID  mItemID;
00091         S32             mAttachPt;
00092 };
00093 
00094 
00095 //helper functions
00096 class LLShowProps 
00097 {
00098 public:
00099 
00100         static void showProperties(const LLUUID& uuid)
00101         {
00102                 if(!LLFloaterProperties::show(uuid, LLUUID::null))
00103                 {
00104                         S32 left, top;
00105                         gFloaterView->getNewFloaterPosition(&left, &top);
00106                         LLRect rect = gSavedSettings.getRect("PropertiesRect");
00107                         rect.translate( left - rect.mLeft, top - rect.mTop );
00108                         LLFloaterProperties* floater;
00109                         floater = new LLFloaterProperties("item properties",
00110                                                                                         rect,
00111                                                                                         "Inventory Item Properties",
00112                                                                                         uuid,
00113                                                                                         LLUUID::null);
00114                         // keep onscreen
00115                         gFloaterView->adjustToFitScreen(floater, FALSE);
00116                 }
00117         }
00118 };
00119 
00120 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00121 // Class LLInventoryPanelObserver
00122 //
00123 // Bridge to support knowing when the inventory has changed.
00124 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00125 class LLInventoryPanelObserver : public LLInventoryObserver
00126 {
00127 public:
00128         LLInventoryPanelObserver(LLInventoryPanel* ip) : mIP(ip) {}
00129         virtual ~LLInventoryPanelObserver() {}
00130         virtual void changed(U32 mask) { mIP->modelChanged(mask); }
00131 protected:
00132         LLInventoryPanel* mIP;
00133 };
00134 
00135 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00136 // Class LLInvFVBridge (& it's derived classes)
00137 //
00138 // Short for Inventory-Folder-View-Bridge. This is an
00139 // implementation class to be able to view inventory items.
00140 //
00141 // You'll want to call LLInvItemFVELister::createBridge() to actually create
00142 // an instance of this class. This helps encapsulate the
00143 // funcationality a bit. (except for folders, you can create those
00144 // manually...)
00145 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00146 class LLInvFVBridge : public LLFolderViewEventListener
00147 {
00148 public:
00149         // This method is a convenience function which creates the correct
00150         // type of bridge based on some basic information
00151         static LLInvFVBridge* createBridge(LLAssetType::EType asset_type,
00152                                                                            LLInventoryType::EType inv_type,
00153                                                                            LLInventoryPanel* inventory,
00154                                                                            const LLUUID& uuid,
00155                                                                            U32 flags = 0x00);
00156         virtual ~LLInvFVBridge() {}
00157 
00158         virtual const LLUUID& getUUID() const { return mUUID; }
00159 
00160         virtual const LLString& getPrefix() { return LLString::null; }
00161         virtual void restoreItem() {}
00162 
00163         // LLFolderViewEventListener functions
00164         virtual const LLString& getName() const;
00165         virtual const LLString& getDisplayName() const;
00166         virtual PermissionMask getPermissionMask() const;
00167         virtual U32 getCreationDate() const;
00168         virtual LLFontGL::StyleFlags getLabelStyle() const
00169         {
00170                 return LLFontGL::NORMAL;
00171         }
00172         virtual LLString getLabelSuffix() const { return LLString::null; }
00173         virtual void openItem() {}
00174         virtual void previewItem() {openItem();}
00175         virtual void showProperties();
00176         virtual BOOL isItemRenameable() const { return TRUE; }
00177         //virtual BOOL renameItem(const LLString& new_name) {}
00178         virtual BOOL isItemRemovable();
00179         virtual BOOL isItemMovable();
00180         //virtual BOOL removeItem() = 0;
00181         virtual void removeBatch(LLDynamicArray<LLFolderViewEventListener*>& batch);
00182         virtual void move(LLFolderViewEventListener* new_parent_bridge) {}
00183         virtual BOOL isItemCopyable() const { return FALSE; }
00184         virtual BOOL copyToClipboard() const { return FALSE; }
00185         virtual void cutToClipboard() {}
00186         virtual BOOL isClipboardPasteable() const;
00187         virtual void pasteFromClipboard() {}
00188         void getClipboardEntries(bool show_asset_id, std::vector<LLString> &items, 
00189                 std::vector<LLString> &disabled_items, U32 flags);
00190         virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
00191         virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id);
00192         virtual BOOL dragOrDrop(MASK mask, BOOL drop,
00193                                                         EDragAndDropType cargo_type,
00194                                                         void* cargo_data) { return FALSE; }
00195         virtual LLInventoryType::EType getInventoryType() const { return mInvType; }
00196 
00197         // LLInvFVBridge functionality
00198         virtual void clearDisplayName() {}
00199 
00200 protected:
00201         LLInvFVBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
00202                 mInventoryPanel(inventory), mUUID(uuid) {}
00203 
00204         LLInventoryObject* getInventoryObject() const;
00205         BOOL isInTrash() const;
00206         // return true if the item is in agent inventory. if false, it
00207         // must be lost or in the inventory library.
00208         BOOL isAgentInventory() const;
00209         virtual BOOL isItemPermissive() const;
00210         static void changeItemParent(LLInventoryModel* model,
00211                                                                  LLViewerInventoryItem* item,
00212                                                                  const LLUUID& new_parent,
00213                                                                  BOOL restamp);
00214         static void changeCategoryParent(LLInventoryModel* model,
00215                                                                          LLViewerInventoryCategory* item,
00216                                                                          const LLUUID& new_parent,
00217                                                                          BOOL restamp);
00218         void removeBatchNoCheck(LLDynamicArray<LLFolderViewEventListener*>& batch);
00219 
00220 protected:
00221         LLInventoryPanel* mInventoryPanel;
00222         LLUUID mUUID;   // item id
00223         LLInventoryType::EType mInvType;
00224 };
00225 
00226 
00227 class LLItemBridge : public LLInvFVBridge
00228 {
00229 public:
00230         LLItemBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
00231                 LLInvFVBridge(inventory, uuid) {}
00232 
00233         virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
00234 
00235         virtual void selectItem();
00236         virtual void restoreItem();
00237 
00238         virtual LLViewerImage* getIcon() const;
00239         virtual const LLString& getDisplayName() const;
00240         virtual LLString getLabelSuffix() const;
00241         virtual PermissionMask getPermissionMask() const;
00242         virtual U32 getCreationDate() const;
00243         virtual BOOL isItemRenameable() const;
00244         virtual BOOL renameItem(const LLString& new_name);
00245         virtual BOOL removeItem();
00246         virtual BOOL isItemCopyable() const;
00247         virtual BOOL copyToClipboard() const;
00248         virtual BOOL hasChildren() const { return FALSE; }
00249         virtual BOOL isUpToDate() const { return TRUE; }
00250 
00251         // override for LLInvFVBridge
00252         virtual void clearDisplayName() { mDisplayName.clear(); }
00253 
00254         LLViewerInventoryItem* getItem() const;
00255 
00256 protected:
00257         virtual BOOL isItemPermissive() const;
00258         static void buildDisplayName(LLInventoryItem* item, LLString& name);
00259         mutable LLString mDisplayName;
00260 };
00261 
00262 
00263 class LLFolderBridge : public LLInvFVBridge
00264 {
00265         friend class LLInvFVBridge;
00266 public:
00267         BOOL dragItemIntoFolder(LLInventoryItem* inv_item,
00268                                                         BOOL drop);
00269         BOOL dragCategoryIntoFolder(LLInventoryCategory* inv_category,
00270                                                                 BOOL drop);
00271         virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
00272         virtual void openItem();
00273         virtual BOOL isItemRenameable() const;
00274         virtual void selectItem();
00275         virtual void restoreItem();
00276 
00277 
00278         virtual LLViewerImage* getIcon() const;
00279         virtual BOOL renameItem(const LLString& new_name);
00280         virtual BOOL removeItem();
00281         virtual BOOL isClipboardPasteable() const;
00282         virtual void pasteFromClipboard();
00283         virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
00284         virtual BOOL hasChildren() const;
00285         virtual BOOL dragOrDrop(MASK mask, BOOL drop,
00286                                                         EDragAndDropType cargo_type,
00287                                                         void* cargo_data);
00288 
00289         virtual BOOL isItemRemovable();
00290         virtual BOOL isItemMovable();
00291         virtual BOOL isUpToDate() const;
00292 
00293         static void createWearable(LLFolderBridge* bridge, EWearableType type);
00294         static void createWearable(LLUUID parent_folder_id, EWearableType type);
00295 
00296         LLViewerInventoryCategory* getCategory() const;
00297 
00298 protected:
00299         LLFolderBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
00300                 LLInvFVBridge(inventory, uuid) {}
00301 
00302         // menu callbacks
00303         static void pasteClipboard(void* user_data);
00304         static void createNewCategory(void* user_data);
00305 
00306         static void createNewShirt(void* user_data);
00307         static void createNewPants(void* user_data);
00308         static void createNewShoes(void* user_data);
00309         static void createNewSocks(void* user_data);
00310         static void createNewJacket(void* user_data);
00311         static void createNewSkirt(void* user_data);
00312         static void createNewGloves(void* user_data);
00313         static void createNewUndershirt(void* user_data);
00314         static void createNewUnderpants(void* user_data);
00315         static void createNewShape(void* user_data);
00316         static void createNewSkin(void* user_data);
00317         static void createNewHair(void* user_data);
00318         static void createNewEyes(void* user_data);
00319 
00320         BOOL checkFolderForContentsOfType(LLInventoryModel* model, LLInventoryCollectFunctor& typeToCheck);
00321 
00322         void modifyOutfit(BOOL append);
00323 public:
00324         static LLFolderBridge* sSelf;
00325         static void staticFolderOptionsMenu();
00326         void folderOptionsMenu();
00327 private:
00328         BOOL                    mCallingCards;
00329         BOOL                    mWearables;
00330         LLMenuGL*               mMenu;
00331         std::vector<LLString> mItems;
00332         std::vector<LLString> mDisabledItems;
00333 };
00334 
00335 // DEPRECATED
00336 class LLScriptBridge : public LLItemBridge
00337 {
00338         friend class LLInvFVBridge;
00339 public:
00340         LLViewerImage* getIcon() const;
00341 
00342 protected:
00343         LLScriptBridge( LLInventoryPanel* inventory, const LLUUID& uuid ) :
00344                 LLItemBridge(inventory, uuid) {}
00345 };
00346 
00347 
00348 class LLTextureBridge : public LLItemBridge
00349 {
00350         friend class LLInvFVBridge;
00351 public:
00352         virtual const LLString& getPrefix() { return sPrefix; }
00353 
00354         virtual LLViewerImage* getIcon() const;
00355         virtual void openItem();
00356 
00357 protected:
00358         LLTextureBridge(LLInventoryPanel* inventory, const LLUUID& uuid, LLInventoryType::EType type) :
00359                 LLItemBridge(inventory, uuid), mInvType(type) {}
00360         static LLString sPrefix;
00361         LLInventoryType::EType mInvType;
00362 };
00363 
00364 class LLSoundBridge : public LLItemBridge
00365 {
00366         friend class LLInvFVBridge;
00367 public:
00368         virtual const LLString& getPrefix() { return sPrefix; }
00369 
00370         virtual LLViewerImage* getIcon() const;
00371         virtual void openItem();
00372         virtual void previewItem();
00373         virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
00374         static void openSoundPreview(void*);
00375 
00376 protected:
00377         LLSoundBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
00378                 LLItemBridge(inventory, uuid) {}
00379         static LLString sPrefix;
00380 };
00381 
00382 class LLLandmarkBridge : public LLItemBridge
00383 {
00384         friend class LLInvFVBridge;
00385 public:
00386         virtual const LLString& getPrefix() { return sPrefix; }
00387         virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
00388         virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
00389         virtual LLViewerImage* getIcon() const;
00390         virtual void openItem();
00391 
00392 protected:
00393         LLLandmarkBridge(LLInventoryPanel* inventory, const LLUUID& uuid, U32 flags = 0x00) :
00394                 LLItemBridge(inventory, uuid) 
00395         {
00396                 mVisited = FALSE;
00397                 if (flags & LLInventoryItem::II_FLAGS_LANDMARK_VISITED)
00398                 {
00399                         mVisited = TRUE;
00400                 }
00401         }
00402 
00403 protected:
00404         static LLString sPrefix;
00405         BOOL mVisited;
00406 };
00407 
00408 class LLCallingCardBridge;
00409 
00410 class LLCallingCardObserver : public LLFriendObserver
00411 {
00412 public:
00413         LLCallingCardObserver(LLCallingCardBridge* bridge) : mBridgep(bridge) {}
00414         virtual ~LLCallingCardObserver() { mBridgep = NULL; }
00415         virtual void changed(U32 mask);
00416 
00417 protected:
00418         LLCallingCardBridge* mBridgep;
00419 };
00420 
00421 class LLCallingCardBridge : public LLItemBridge
00422 {
00423         friend class LLInvFVBridge;
00424 public:
00425         virtual const LLString& getPrefix() { return sPrefix; }
00426 
00427         virtual LLString getLabelSuffix() const;
00428         //virtual const LLString& getDisplayName() const;
00429         virtual LLViewerImage* getIcon() const;
00430         virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
00431         virtual void openItem();
00432         virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
00433         //virtual void renameItem(const LLString& new_name);
00434         //virtual BOOL removeItem();
00435         virtual BOOL dragOrDrop(MASK mask, BOOL drop,
00436                                                         EDragAndDropType cargo_type,
00437                                                         void* cargo_data);
00438         void refreshFolderViewItem();
00439 
00440 protected:
00441         LLCallingCardBridge( LLInventoryPanel* inventory, const LLUUID& uuid );
00442         ~LLCallingCardBridge();
00443         
00444 protected:
00445         static LLString sPrefix;
00446         LLCallingCardObserver* mObserver;
00447 };
00448 
00449 
00450 class LLNotecardBridge : public LLItemBridge
00451 {
00452         friend class LLInvFVBridge;
00453 public:
00454         virtual const LLString& getPrefix() { return sPrefix; }
00455 
00456         virtual LLViewerImage* getIcon() const;
00457         virtual void openItem();
00458 
00459 protected:
00460         LLNotecardBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
00461                 LLItemBridge(inventory, uuid) {}
00462 
00463 protected:
00464         static LLString sPrefix;
00465 };
00466 
00467 class LLGestureBridge : public LLItemBridge
00468 {
00469         friend class LLInvFVBridge;
00470 public:
00471         virtual const LLString& getPrefix() { return sPrefix; }
00472 
00473         virtual LLViewerImage* getIcon() const;
00474 
00475         // Only suffix for gesture items, not task items, because only
00476         // gestures in your inventory can be active.
00477         virtual LLFontGL::StyleFlags getLabelStyle() const;
00478         virtual LLString getLabelSuffix() const;
00479 
00480         virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
00481         virtual void openItem();
00482         virtual BOOL removeItem();
00483 
00484         virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
00485 
00486 protected:
00487         LLGestureBridge(LLInventoryPanel* inventory, const LLUUID& uuid)
00488         :       LLItemBridge(inventory, uuid) {}
00489 
00490 protected:
00491         static LLString sPrefix;
00492 };
00493 
00494 
00495 class LLAnimationBridge : public LLItemBridge
00496 {
00497         friend class LLInvFVBridge;
00498 public:
00499         virtual const LLString& getPrefix() { return sPrefix; }
00500         virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
00501         virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
00502 
00503         virtual LLViewerImage* getIcon() const;
00504         virtual void openItem();
00505 
00506 protected:
00507         LLAnimationBridge(LLInventoryPanel* inventory, const LLUUID& uuid) :
00508                 LLItemBridge(inventory, uuid) {}
00509 
00510 protected:
00511         static LLString sPrefix;
00512 };
00513 
00514 
00515 class LLObjectBridge : public LLItemBridge
00516 {
00517         friend class LLInvFVBridge;
00518 public:
00519         virtual const LLString& getPrefix() { return sPrefix; }
00520 
00521         virtual LLViewerImage*  getIcon() const;
00522         virtual void                    performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
00523         virtual void                    openItem();
00524         virtual LLFontGL::StyleFlags getLabelStyle() const;
00525         virtual LLString getLabelSuffix() const;
00526         virtual void                    buildContextMenu(LLMenuGL& menu, U32 flags);
00527         virtual BOOL                    isItemRemovable();
00528         virtual BOOL renameItem(const LLString& new_name);
00529 
00530 protected:
00531         LLObjectBridge(LLInventoryPanel* inventory, const LLUUID& uuid, LLInventoryType::EType type, U32 flags) :
00532                 LLItemBridge(inventory, uuid), mInvType(type)
00533         {
00534                 mAttachPt = (flags & 0xff); // low bye of inventory flags
00535 
00536                 mIsMultiObject = ( flags & LLInventoryItem::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS ) ?  TRUE: FALSE;
00537         }
00538 
00539 protected:
00540         static LLString sPrefix;
00541         static LLUUID   sContextMenuItemID;  // Only valid while the context menu is open.
00542         LLInventoryType::EType mInvType;
00543         U32 mAttachPt;
00544         BOOL mIsMultiObject;
00545 };
00546 
00547 
00548 class LLLSLTextBridge : public LLItemBridge
00549 {
00550         friend class LLInvFVBridge;
00551 public:
00552         virtual const LLString& getPrefix() { return sPrefix; }
00553 
00554         virtual LLViewerImage* getIcon() const;
00555         virtual void openItem();
00556 
00557 protected:
00558         LLLSLTextBridge( LLInventoryPanel* inventory, const LLUUID& uuid ) :
00559                 LLItemBridge(inventory, uuid) {}
00560 
00561 protected:
00562         static LLString sPrefix;
00563 };
00564 
00565 
00566 class LLWearableBridge : public LLItemBridge
00567 {
00568         friend class LLInvFVBridge;
00569 public:
00570         virtual LLViewerImage* getIcon() const;
00571         virtual void    performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
00572         virtual void    openItem();
00573         virtual void    buildContextMenu(LLMenuGL& menu, U32 flags);
00574         virtual LLFontGL::StyleFlags getLabelStyle() const;
00575         virtual LLString getLabelSuffix() const;
00576         virtual BOOL    isItemRemovable();
00577         virtual BOOL renameItem(const LLString& new_name);
00578 
00579         static void             onWearOnAvatar( void* userdata );       // Access to wearOnAvatar() from menu
00580         static BOOL             canWearOnAvatar( void* userdata );
00581         static void             onWearOnAvatarArrived( LLWearable* wearable, void* userdata );
00582         void                    wearOnAvatar();
00583 
00584         static BOOL             canEditOnAvatar( void* userdata );      // Access to editOnAvatar() from menu
00585         static void             onEditOnAvatar( void* userdata );
00586         void                    editOnAvatar();
00587 
00588         static BOOL             canRemoveFromAvatar( void* userdata );
00589         static void             onRemoveFromAvatar( void* userdata );
00590         static void             onRemoveFromAvatarArrived( LLWearable* wearable, void* userdata );
00591 
00592 protected:
00593         LLWearableBridge(LLInventoryPanel* inventory, const LLUUID& uuid, LLAssetType::EType asset_type, LLInventoryType::EType inv_type, EWearableType  wearable_type) :
00594                 LLItemBridge(inventory, uuid),
00595                 mAssetType( asset_type ),
00596                 mInvType(inv_type),
00597                 mWearableType(wearable_type)
00598                 {}
00599 
00600 protected:
00601         LLAssetType::EType mAssetType;
00602         LLInventoryType::EType mInvType;
00603         EWearableType  mWearableType;
00604 };

Generated on Thu Jul 1 06:08:45 2010 for Second Life Viewer by  doxygen 1.4.7