lltooldraganddrop.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_TOOLDRAGANDDROP_H
00033 #define LL_TOOLDRAGANDDROP_H
00034 
00035 #include "lltool.h"
00036 #include "llview.h"
00037 #include "lluuid.h"
00038 #include "stdenums.h"
00039 #include "llassetstorage.h"
00040 #include "lldarray.h"
00041 #include "llpermissions.h"
00042 #include "llwindow.h"
00043 #include "llviewerinventory.h"
00044 
00045 class LLToolDragAndDrop;
00046 class LLViewerRegion;
00047 class LLVOAvatar;
00048 
00049 class LLToolDragAndDrop : public LLTool
00050 {
00051 public:
00052         LLToolDragAndDrop();
00053 
00054         // overridden from LLTool
00055         virtual BOOL    handleMouseUp(S32 x, S32 y, MASK mask);
00056         virtual BOOL    handleHover(S32 x, S32 y, MASK mask);
00057         virtual BOOL    handleKey(KEY key, MASK mask);
00058         virtual BOOL    handleToolTip(S32 x, S32 y, LLString& msg, LLRect *sticky_rect_screen);
00059         virtual void    onMouseCaptureLost();
00060         virtual void    handleDeselect();
00061 
00062         void                    setDragStart( S32 x, S32 y );                   // In screen space
00063         BOOL                    isOverThreshold( S32 x, S32 y );                // In screen space
00064 
00065         enum ESource
00066         {
00067                 SOURCE_AGENT,
00068                 SOURCE_WORLD,
00069                 SOURCE_NOTECARD,
00070                 SOURCE_LIBRARY
00071         };
00072 
00073         void beginDrag(EDragAndDropType type,
00074                                    const LLUUID& cargo_id,
00075                                    ESource source,
00076                                    const LLUUID& source_id = LLUUID::null,
00077                                    const LLUUID& object_id = LLUUID::null);
00078         void beginMultiDrag(const std::vector<EDragAndDropType> types,
00079                                                 const std::vector<LLUUID>& cargo_ids,
00080                                                 ESource source,
00081                                                 const LLUUID& source_id = LLUUID::null);
00082         void endDrag();
00083         ESource getSource() const { return mSource; }
00084         const LLUUID& getSourceID() const { return mSourceID; }
00085         const LLUUID& getObjectID() const { return mObjectID; }
00086         EAcceptance getLastAccept() { return mLastAccept; }
00087 
00088 protected:
00089         enum EDropTarget
00090         {
00091                 DT_NONE = 0,
00092                 DT_SELF = 1,
00093                 DT_AVATAR = 2,
00094                 DT_OBJECT = 3,
00095                 DT_LAND = 4,
00096                 DT_COUNT = 5
00097         };
00098 
00099         // dragOrDrop3dImpl points to a member of LLToolDragAndDrop that
00100         // takes parameters (LLViewerObject* obj, S32 face, MASK, BOOL
00101         // drop) and returns a BOOL if drop is ok
00102         typedef EAcceptance (LLToolDragAndDrop::*dragOrDrop3dImpl)
00103                 (LLViewerObject*, S32, MASK, BOOL);
00104 
00105         void dragOrDrop(S32 x, S32 y, MASK mask, BOOL drop,
00106                                         EAcceptance* acceptance);
00107         void dragOrDrop3D(S32 x, S32 y, MASK mask, BOOL drop,
00108                                           EAcceptance* acceptance);
00109         static void pickCallback(S32 x, S32 y, MASK mask);
00110 
00111 protected:
00112 
00113         S32                             mDragStartX;
00114         S32                             mDragStartY;
00115         
00116         std::vector<EDragAndDropType> mCargoTypes;
00117         //void*                 mCargoData;
00118         std::vector<LLUUID> mCargoIDs;
00119         ESource mSource;
00120         LLUUID mSourceID;
00121         LLUUID mObjectID;
00122 
00123         LLVector3d              mLastCameraPos;
00124         LLVector3d              mLastHitPos;
00125 
00126         ECursorType             mCursor;
00127         EAcceptance             mLastAccept;
00128         BOOL                    mDrop;
00129         S32                             mCurItemIndex;
00130         LLString                mToolTipMsg;
00131 
00132         // array of pointers to functions that implement the logic to
00133         // dragging and dropping into the simulator.
00134         static dragOrDrop3dImpl sDragAndDrop3d[DAD_COUNT][DT_COUNT];
00135 
00136 protected:
00137         // 3d drop functions. these call down into the static functions
00138         // named drop<ThingToDrop> if drop is TRUE and permissions allow
00139         // that behavior.
00140         EAcceptance dad3dNULL(LLViewerObject*, S32, MASK, BOOL);
00141         EAcceptance dad3dRezObjectOnLand(LLViewerObject* obj, S32 face,
00142                                                                          MASK mask, BOOL drop);
00143         EAcceptance dad3dRezObjectOnObject(LLViewerObject* obj, S32 face,
00144                                                                            MASK mask, BOOL drop);
00145         EAcceptance dad3dRezScript(LLViewerObject* obj, S32 face,
00146                                                            MASK mask, BOOL drop);
00147         EAcceptance dad3dTextureObject(LLViewerObject* obj, S32 face,
00148                                                                    MASK mask, BOOL drop);
00149 //      EAcceptance dad3dTextureSelf(LLViewerObject* obj, S32 face,
00150 //                                                               MASK mask, BOOL drop);
00151         EAcceptance dad3dWearItem(LLViewerObject* obj, S32 face,
00152                                                                  MASK mask, BOOL drop);
00153         EAcceptance dad3dWearCategory(LLViewerObject* obj, S32 face,
00154                                                                  MASK mask, BOOL drop);
00155         EAcceptance dad3dUpdateInventory(LLViewerObject* obj, S32 face,
00156                                                                          MASK mask, BOOL drop);
00157         EAcceptance dad3dUpdateInventoryCategory(LLViewerObject* obj,
00158                                                                                          S32 face,
00159                                                                                          MASK mask,
00160                                                                                          BOOL drop);
00161         EAcceptance dad3dGiveInventoryObject(LLViewerObject* obj, S32 face,
00162                                                                    MASK mask, BOOL drop);
00163         EAcceptance dad3dGiveInventory(LLViewerObject* obj, S32 face,
00164                                                                    MASK mask, BOOL drop);
00165         EAcceptance dad3dGiveInventoryCategory(LLViewerObject* obj, S32 face,
00166                                                                                    MASK mask, BOOL drop);
00167         EAcceptance dad3dRezFromObjectOnLand(LLViewerObject* obj, S32 face,
00168                                                                                  MASK mask, BOOL drop);
00169         EAcceptance dad3dRezFromObjectOnObject(LLViewerObject* obj, S32 face,
00170                                                                                    MASK mask, BOOL drop);
00171         EAcceptance dad3dRezAttachmentFromInv(LLViewerObject* obj, S32 face,
00172                                                                                   MASK mask, BOOL drop);
00173         EAcceptance dad3dCategoryOnLand(LLViewerObject *obj, S32 face,
00174                                                                         MASK mask, BOOL drop);
00175         EAcceptance dad3dAssetOnLand(LLViewerObject *obj, S32 face,
00176                                                                  MASK mask, BOOL drop);
00177         EAcceptance dad3dActivateGesture(LLViewerObject *obj, S32 face,
00178                                                                  MASK mask, BOOL drop);
00179 
00180         // This method converts mCargoID to an inventory item or
00181         // folder. If no item or category is found, both pointers will be
00182         // returned NULL.
00183         LLInventoryObject* locateInventory(LLViewerInventoryItem*& item,
00184                                                                            LLViewerInventoryCategory*& cat);
00185 
00186         //LLInventoryObject* locateMultipleInventory(
00187         //      LLViewerInventoryCategory::cat_array_t& cats,
00188         //      LLViewerInventoryItem::item_array_t& items);
00189 
00190         void createContainer(LLViewerInventoryItem::item_array_t &items, const char* preferred_name);
00191         void dropObject(LLViewerObject* raycast_target,
00192                                         BOOL bypass_sim_raycast,
00193                                         BOOL from_task_inventory,
00194                                         BOOL remove_from_inventory);
00195         
00196         // accessor that looks at permissions, copyability, and names of
00197         // inventory items to determine if a drop would be ok.
00198         static EAcceptance willObjectAcceptInventory(LLViewerObject* obj, LLInventoryItem* item);
00199 
00200         // deal with permissions of object, etc. returns TRUE if drop can
00201         // proceed, otherwise FALSE.
00202         static BOOL handleDropTextureProtections(LLViewerObject* hit_obj,
00203                                                                                          LLInventoryItem* item,
00204                                                                                          LLToolDragAndDrop::ESource source,
00205                                                                                          const LLUUID& src_id);
00206 
00207 
00208         // give inventory item functionality
00209         static void handleCopyProtectedItem(S32 option, void* data);
00210         static void commitGiveInventoryItem(const LLUUID& to_agent,
00211                                                                                 LLInventoryItem* item);
00212 
00213         // give inventory category functionality
00214         static void handleCopyProtectedCategory(S32 option, void* data);
00215         static void commitGiveInventoryCategory(const LLUUID& to_agent,
00216                                                                                         LLInventoryCategory* cat);
00217 public:
00218         // helper functions
00219         static BOOL isInventoryDropAcceptable(LLViewerObject* obj, LLInventoryItem* item) { return (ACCEPT_YES_COPY_SINGLE <= willObjectAcceptInventory(obj, item)); }
00220 
00221         // This simple helper function assumes you are attempting to
00222         // transfer item. returns true if you can give, otherwise false.
00223         static BOOL isInventoryGiveAcceptable(LLInventoryItem* item);
00224         static BOOL isInventoryGroupGiveAcceptable(LLInventoryItem* item);
00225 
00226         BOOL dadUpdateInventory(LLViewerObject* obj, BOOL drop);
00227         BOOL dadUpdateInventoryCategory(LLViewerObject* obj, BOOL drop);
00228 
00229         // methods that act on the simulator state.
00230         static void dropScript(LLViewerObject* hit_obj,
00231                                                    LLInventoryItem* item,
00232                                                    BOOL active,
00233                                                    ESource source,
00234                                                    const LLUUID& src_id);
00235         static void dropTextureOneFace(LLViewerObject* hit_obj, S32 hit_face,
00236                                                                    LLInventoryItem* item,
00237                                                                    ESource source,
00238                                                                    const LLUUID& src_id);
00239         static void dropTextureAllFaces(LLViewerObject* hit_obj,
00240                                                                         LLInventoryItem* item,
00241                                                                         ESource source,
00242                                                                         const LLUUID& src_id);
00243         //static void   dropTextureOneFaceAvatar(LLVOAvatar* avatar,S32 hit_face,
00244         //                                                                       LLInventoryItem* item)
00245 
00246         static void dropInventory(LLViewerObject* hit_obj,
00247                                                           LLInventoryItem* item,
00248                                                           ESource source,
00249                                                           const LLUUID& src_id);
00250 
00251         static void giveInventory(const LLUUID& to_agent, LLInventoryItem* item);
00252         static void giveInventoryCategory(const LLUUID& to_agent,
00253                                                                           LLInventoryCategory* item);
00254 };
00255 
00256 // Singleton
00257 extern LLToolDragAndDrop *gToolDragAndDrop;
00258 
00259 // utility functions
00260 void pack_permissions_slam(LLMessageSystem* msg, U32 flags, const LLPermissions& perms);
00261 
00262 #endif  // LL_TOOLDRAGANDDROP_H

Generated on Thu Jul 1 06:09:21 2010 for Second Life Viewer by  doxygen 1.4.7