123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- /**
- * @file lltooldraganddrop.h
- * @brief LLToolDragAndDrop class header file
- *
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2009, Linden Research, Inc.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- #ifndef LL_TOOLDRAGANDDROP_H
- #define LL_TOOLDRAGANDDROP_H
- #include "llassetstorage.h"
- #include "lldictionary.h"
- #include "llpermissions.h"
- #include "lltool.h"
- #include "lluuid.h"
- #include "llview.h"
- #include "llviewerinventory.h"
- #include "llwindow.h"
- class LLToolDragAndDrop;
- class LLViewerRegion;
- class LLVOAvatar;
- class LLPickInfo;
- class LLToolDragAndDrop final : public LLTool
- {
- protected:
- LOG_CLASS(LLToolDragAndDrop);
- public:
- LLToolDragAndDrop();
- // Overridden from LLTool
- bool handleMouseUp(S32 x, S32 y, MASK mask) override;
- bool handleHover(S32 x, S32 y, MASK mask) override;
- bool handleKey(KEY key, MASK mask) override;
- bool handleToolTip(S32 x, S32 y, std::string& msg, LLRect* rect) override;
- void onMouseCaptureLost() override;
- void handleDeselect() override;
- LL_INLINE void setDragStart(S32 x, S32 y) // In screen space
- {
- mDragStartX = x;
- mDragStartY = y;
- }
- bool isOverThreshold(S32 x, S32 y); // In screen space
- enum ESource
- {
- SOURCE_AGENT,
- SOURCE_WORLD,
- SOURCE_NOTECARD,
- SOURCE_LIBRARY
- };
- void beginDrag(EDragAndDropType type, const LLUUID& cargo_id,
- ESource src, const LLUUID& src_id = LLUUID::null,
- const LLUUID& object_id = LLUUID::null);
- void beginMultiDrag(const std::vector<EDragAndDropType> types,
- const std::vector<LLUUID>& cargo_ids,
- ESource src, const LLUUID& src_id = LLUUID::null);
- void endDrag();
- LL_INLINE ESource getSource() const { return mSource; }
- LL_INLINE const LLUUID& getSourceID() const { return mSourceID; }
- LL_INLINE const LLUUID& getObjectID() const { return mObjectID; }
- LL_INLINE EAcceptance getLastAccept() { return mLastAccept; }
- LL_INLINE U32 getCargoCount() const { return mCargoIDs.size(); }
- LL_INLINE S32 getCargoIndex() const { return mCurItemIndex; }
- protected:
- enum EDropTarget
- {
- DT_NONE = 0,
- DT_SELF = 1,
- DT_AVATAR = 2,
- DT_OBJECT = 3,
- DT_LAND = 4,
- DT_COUNT = 5
- };
- // dragOrDrop3dImpl points to a member of LLToolDragAndDrop that
- // takes parameters (LLViewerObject* objp, S32 face, MASK, bool
- // drop) and returns a bool if drop is ok
- typedef EAcceptance (LLToolDragAndDrop::*dragOrDrop3dImpl)(LLViewerObject*,
- S32, MASK,
- bool);
- void dragOrDrop(S32 x, S32 y, MASK mask, bool drop,
- EAcceptance* acceptance);
- void dragOrDrop3D(S32 x, S32 y, MASK mask, bool drop,
- EAcceptance* acceptance);
- static void pickCallback(const LLPickInfo& pick_info);
- protected:
- // 3d drop functions. these call down into the static functions named
- // drop<ThingToDrop> if drop is true and permissions allow that behavior.
- EAcceptance dad3dNULL(LLViewerObject*, S32, MASK, bool);
- EAcceptance dad3dRezObjectOnLand(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dRezObjectOnObject(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dRezCategoryOnObject(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dRezScript(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dTextureObject(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dMaterialObject(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- #if LL_MESH_ASSET_SUPPORT
- EAcceptance dad3dMeshObject(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- #endif
- EAcceptance dad3dWearItem(LLViewerObject* obj, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dWearCategory(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dUpdateInventory(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dUpdateInventoryCategory(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dGiveInventoryObject(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dGiveInventory(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dGiveInventoryCategory(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dRezFromObjectOnLand(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dRezFromObjectOnObject(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dRezAttachmentFromInv(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dCategoryOnLand(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dAssetOnLand(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- EAcceptance dad3dActivateGesture(LLViewerObject* objp, S32 face,
- MASK mask, bool drop);
- // Helper called by methods above to handle "application" of an item to an
- // object (texture applied to face, mesh applied to shape, etc.)
- EAcceptance dad3dApplyToObject(LLViewerObject* objp, S32 face, MASK mask,
- bool drop, EDragAndDropType cargo_type);
- // Sets the LLToolDragAndDrop's cursor based on the given acceptance
- ECursorType acceptanceToCursor(EAcceptance acceptance);
- // This method converts mCargoID to an inventory item or folder. If no item
- // or category is found, both pointers will be returned NULL.
- LLInventoryObject* locateInventory(LLViewerInventoryItem*& itemp,
- LLViewerInventoryCategory*& catp);
- void dropObject(LLViewerObject* raycast_target, bool bypass_sim_raycast,
- bool from_task_inventory, bool remove_from_inventory);
- // Accessor that looks at permissions, copyability, and names of inventory
- // items to determine if a drop would be ok.
- static EAcceptance willObjectAcceptInventory(LLViewerObject* objp,
- LLInventoryItem* itemp,
- EDragAndDropType type =
- DAD_NONE);
- // Gives inventory item functionality
- static bool handleCopyProtectedItem(const LLSD& notification,
- const LLSD& response);
- static void commitGiveInventoryItem(const LLUUID& to_agent,
- LLInventoryItem* itemp,
- const LLUUID& im_session_id =
- LLUUID::null);
- // Gives inventory category functionality
- static bool handleCopyProtectedCategory(const LLSD& notification,
- const LLSD& response);
- static void commitGiveInventoryCategory(const LLUUID& to_agent,
- LLInventoryCategory* catp,
- const LLUUID& im_session_id =
- LLUUID::null);
- public:
- // Deals with permissions of object, etc. returns true if drop can
- // proceed, otherwise false.
- static bool handleDropAssetProtections(LLViewerObject* objp,
- LLInventoryItem* itemp,
- ESource source,
- const LLUUID& src_id =
- LLUUID::null);
- // Helper method
- LL_INLINE static bool isInventoryDropAcceptable(LLViewerObject* objp,
- LLInventoryItem* itemp)
- {
- return willObjectAcceptInventory(objp, itemp) >=
- ACCEPT_YES_COPY_SINGLE;
- }
- // This simple helper function assumes you are attempting to
- // transfer item. returns true if you can give, otherwise false.
- static bool isInventoryGiveAcceptable(LLInventoryItem* itemp);
- static bool isInventoryGroupGiveAcceptable(LLInventoryItem* itemp);
- bool dadUpdateInventory(LLViewerObject* objp, bool drop);
- bool dadUpdateInventoryCategory(LLViewerObject* objp, bool drop);
- // Methods that act on the simulator state.
- static void dropTextureOneFace(LLViewerObject* hit_objp, S32 hit_face,
- LLInventoryItem* itemp, ESource source,
- const LLUUID& src_id = LLUUID::null);
- static void dropTextureAllFaces(LLViewerObject* hit_objp,
- LLInventoryItem* itemp, ESource source,
- const LLUUID& src_id = LLUUID::null);
- static void dropMaterialOneFace(LLViewerObject* hit_objp, S32 hit_face,
- LLInventoryItem* itemp, ESource source,
- const LLUUID& src_id = LLUUID::null);
- static void dropMaterialAllFaces(LLViewerObject* hit_objp,
- LLInventoryItem* itemp, ESource source,
- const LLUUID& src_id = LLUUID::null);
- static void dropScript(LLViewerObject* hit_objp, LLInventoryItem* itemp,
- bool active, ESource source, const LLUUID& src_id);
- #if LL_MESH_ASSET_SUPPORT
- static void dropMesh(LLViewerObject* hit_objp, LLInventoryItem* itemp,
- ESource source, const LLUUID& src_id);
- #endif
- static void dropInventory(LLViewerObject* hit_objp, LLInventoryItem* itemp,
- ESource source,
- const LLUUID& src_id = LLUUID::null);
- static void giveInventory(const LLUUID& to_agent, LLInventoryItem* itemp,
- const LLUUID& session_id = LLUUID::null);
- static void giveInventoryCategory(const LLUUID& to_agent,
- LLInventoryCategory* catp,
- const LLUUID& session_id = LLUUID::null);
- static bool handleGiveDragAndDrop(const LLUUID& agent, const LLUUID& session,
- bool drop, EDragAndDropType cargo_type,
- void* cargo_data, EAcceptance* acceptp);
- // Classes used for determining 3d drag and drop types.
- private:
- struct DragAndDropEntry : public LLDictionaryEntry
- {
- DragAndDropEntry(dragOrDrop3dImpl f_none,
- dragOrDrop3dImpl f_self,
- dragOrDrop3dImpl f_avatar,
- dragOrDrop3dImpl f_object,
- dragOrDrop3dImpl f_land);
- dragOrDrop3dImpl mFunctions[DT_COUNT];
- };
- class LLDragAndDropDictionary : public LLSingleton<LLDragAndDropDictionary>,
- public LLDictionary<EDragAndDropType, DragAndDropEntry>
- {
- public:
- LLDragAndDropDictionary();
- dragOrDrop3dImpl get(EDragAndDropType dad_type,
- EDropTarget drop_target);
- };
- protected:
- LLUUID mSourceID;
- LLUUID mObjectID;
- std::vector<LLUUID> mCargoIDs;
- std::vector<EDragAndDropType> mCargoTypes;
- LLVector3d mLastCameraPos;
- LLVector3d mLastHitPos;
- std::string mToolTipMsg;
- S32 mCurItemIndex;
- S32 mDragStartX;
- S32 mDragStartY;
- ESource mSource;
- ECursorType mCursor;
- EAcceptance mLastAccept;
- bool mDrop;
- };
- // Utility function
- void pack_permissions_slam(LLMessageSystem* msg, U32 flags,
- const LLPermissions& perms);
- extern LLToolDragAndDrop gToolDragAndDrop;
- #endif // LL_TOOLDRAGANDDROP_H
|