diff options
author | Leslie Linden <leslie@lindenlab.com> | 2011-12-14 14:37:38 -0800 |
---|---|---|
committer | Leslie Linden <leslie@lindenlab.com> | 2011-12-14 14:37:38 -0800 |
commit | 399f8dd1913530488744046794a74d6c7e61ffa3 (patch) | |
tree | ae0ad0fc284a0a63c8351b3b057ee0696c2f740f /indra/newview | |
parent | bff737ebefdfeeb17a81e1c3c4741d3e9aab2862 (diff) |
EXP-1723 -- Improved drag and drop behavior for outbox floater.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloateroutbox.cpp | 36 | ||||
-rw-r--r-- | indra/newview/llfolderviewitem.cpp | 52 | ||||
-rw-r--r-- | indra/newview/llfolderviewitem.h | 5 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 10 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.h | 2 |
5 files changed, 61 insertions, 44 deletions
diff --git a/indra/newview/llfloateroutbox.cpp b/indra/newview/llfloateroutbox.cpp index 984f47abb0..725e521e58 100644 --- a/indra/newview/llfloateroutbox.cpp +++ b/indra/newview/llfloateroutbox.cpp @@ -30,6 +30,7 @@ #include "llfloaterreg.h" #include "llfolderview.h" +#include "llinventorybridge.h" #include "llinventorymodelbackgroundfetch.h" #include "llinventoryobserver.h" #include "llinventorypanel.h" @@ -348,23 +349,34 @@ BOOL LLFloaterOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, return FALSE; } - BOOL handled = (childrenHandleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg) != NULL); + LLView * handled_view = childrenHandleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); + BOOL handled = (handled_view != NULL); - // Pass drag and drop to this floater to the outbox inventory control if no other children handle it + // Pass all drag and drop for this floater to the outbox inventory control if (!handled || (*accept == ACCEPT_NO)) { - S32 local_x; - S32 local_y; + // Always assume we are going to move the drag and drop operation to the outbox root folder + bool move_to_root = true; - LLFolderView * outbox_root_folder = mOutboxInventoryPanel->getRootFolder(); - localPointToOtherView(x, y, &local_x, &local_y, outbox_root_folder); - - const LLRect& outbox_rect = outbox_root_folder->getRect(); - - local_x = llclamp(local_x, outbox_rect.mLeft + 1, outbox_rect.mRight - 1); - local_y = llclamp(local_y, outbox_rect.mBottom + 1, outbox_rect.mTop - 1); + // If the inventory panel is visible, then only override it to the outbox root if we're outside the inventory panel + // (otherwise the inventory panel itself will handle the drag and drop operation, without any override) + if (mOutboxInventoryPanel->getVisible()) + { + S32 inv_x, inv_y; + localPointToOtherView(x, y, &inv_x, &inv_y, mOutboxInventoryPanel); + + const LLRect& inv_rect = mOutboxInventoryPanel->getRect(); - handled = outbox_root_folder->LLFolderViewFolder::handleDragAndDrop(local_x, local_y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); + move_to_root = !inv_rect.pointInRect(inv_x, inv_y); + } + + // Handle the drag and drop directly to the root of the outbox + if (move_to_root) + { + LLFolderView * root_folder = mOutboxInventoryPanel->getRootFolder(); + + handled = root_folder->handleDragAndDropToRoot(mask, drop, cargo_type, cargo_data, accept, tooltip_msg); + } } return handled; diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index f27fd035db..526800d4be 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -2276,33 +2276,16 @@ BOOL LLFolderViewFolder::handleDragAndDrop(S32 x, S32 y, MASK mask, EAcceptance* accept, std::string& tooltip_msg) { - LLFolderView* root_view = getRoot(); - BOOL handled = FALSE; - if(mIsOpen) + + if (mIsOpen) { - handled = childrenHandleDragAndDrop(x, y, mask, drop, cargo_type, - cargo_data, accept, tooltip_msg) != NULL; + handled = (childrenHandleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg) != NULL); } if (!handled) { - BOOL accepted = mListener && mListener->dragOrDrop(mask, drop,cargo_type,cargo_data, tooltip_msg); - - if (accepted) - { - mDragAndDropTarget = TRUE; - *accept = ACCEPT_YES_MULTI; - } - else - { - *accept = ACCEPT_NO; - } - - if (!drop && accepted) - { - root_view->autoOpenTest(this); - } + handleDragAndDropToRoot(mask, drop, cargo_type, cargo_data, accept, tooltip_msg); lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLFolderViewFolder" << llendl; } @@ -2310,6 +2293,33 @@ BOOL LLFolderViewFolder::handleDragAndDrop(S32 x, S32 y, MASK mask, return TRUE; } +BOOL LLFolderViewFolder::handleDragAndDropToRoot(MASK mask, + BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) +{ + BOOL accepted = mListener && mListener->dragOrDrop(mask, drop, cargo_type, cargo_data, tooltip_msg); + + if (accepted) + { + mDragAndDropTarget = TRUE; + *accept = ACCEPT_YES_MULTI; + } + else + { + *accept = ACCEPT_NO; + } + + if (!drop && accepted) + { + getRoot()->autoOpenTest(this); + } + + return TRUE; +} + BOOL LLFolderViewFolder::handleRightMouseDown( S32 x, S32 y, MASK mask ) { diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h index 3433e3f7f3..02461fb144 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/newview/llfolderviewitem.h @@ -547,6 +547,11 @@ public: void* cargo_data, EAcceptance* accept, std::string& tooltip_msg); + BOOL handleDragAndDropToRoot(MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg); virtual void draw(); time_t getCreationDate() const; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 4bc846faeb..d6b520d75e 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1820,14 +1820,6 @@ static BOOL can_move_to_outbox(LLInventoryItem* inv_item, std::string& tooltip_m } - -void LLFolderBridge::dropFolderToOutbox(LLInventoryCategory* inv_cat) -{ - copy_folder_to_outbox(inv_cat, getInventoryModel()->findCategoryUUIDForType(LLFolderType::FT_OUTBOX, false), inv_cat->getUUID()); -} - - - int get_folder_levels(LLInventoryCategory* inv_cat) { LLInventoryModel::cat_array_t* cats; @@ -2046,7 +2038,7 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, } else if (move_is_into_outbox && !move_is_from_outbox) { - dropFolderToOutbox(inv_cat); + copy_folder_to_outbox(inv_cat, mUUID, inv_cat->getUUID()); } else { diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 2d625befb4..126a28f74c 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -306,8 +306,6 @@ protected: void dropToFavorites(LLInventoryItem* inv_item); void dropToOutfit(LLInventoryItem* inv_item, BOOL move_is_into_current_outfit); - void dropToOutbox(LLInventoryItem* inv_item); - void dropFolderToOutbox(LLInventoryCategory* inv_cat); //-------------------------------------------------------------------- // Messy hacks for handling folder options |