From 42fe9293f8186edcf6bc688c2b779fbff2850189 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 8 Feb 2009 01:05:34 +0000 Subject: [PATCH] Tracker now alters the cursor to indicate the resulting FS op when drag and dropping files. If the op is determined to be a copy, the copy cursor from Wonderbrush (thanks Stephan!) is displayed. Otherwise, the default hand cursor is used to indicate move. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29155 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/PoseView.cpp | 64 +++++++++++++++++++++++++++++------ src/kits/tracker/PoseView.h | 2 +- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 20dd6a263b..f6c0447362 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -131,6 +131,18 @@ const BPoint kTransparentDragThreshold(256, 192); // maximum size of the transparent drag bitmap, use a drag rect // if larger in any direction +const unsigned char kCopyCursor[] = { 16, 1, 1, 1, + 0x00, 0x00, 0x70, 0x00, 0x48, 0x00, 0x48, 0x00, + 0x27, 0xc0, 0x24, 0xb8, 0x12, 0x54, 0x10, 0x02, + 0x79, 0xe2, 0x99, 0x22, 0x85, 0x7a, 0x61, 0x4a, + 0x19, 0xca, 0x04, 0x4a, 0x02, 0x78, 0x00, 0x00, + + 0x00, 0x00, 0x70, 0x00, 0x78, 0x00, 0x78, 0x00, + 0x3f, 0xc0, 0x3f, 0xf8, 0x1f, 0xfc, 0x1f, 0xfe, + 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0x7f, 0xfe, + 0x1f, 0xfe, 0x07, 0xfe, 0x03, 0xf8, 0x00, 0x00 +}; + const char *kNoCopyToTrashStr = "Sorry, you can't copy items to the Trash."; const char *kNoLinkToTrashStr = "Sorry, you can't create links in the Trash."; const char *kNoCopyToRootStr = "You must drop items on one of the disk icons " @@ -217,6 +229,7 @@ BPoseView::BPoseView(Model *model, BRect bounds, uint32 viewMode, uint32 resizeM fIsDesktopWindow(false), fIsWatchingDateFormatChange(false), fHasPosesInClipboard(false), + fCursorCheck(false), fLastKeyTime(0), fLastDeskbarFrameCheckTime(LONGLONG_MIN), fDeskbarFrame(0, 0, -1, -1) @@ -3854,6 +3867,10 @@ bool BPoseView::HandleMessageDropped(BMessage *message) { ASSERT(message->WasDropped()); + + // reset system cursor in case it was altered by drag and drop + SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); + fCursorCheck = false; if (!fDropEnabled) return false; @@ -4345,6 +4362,18 @@ CopySelectionListToBListAsEntryRefs(const PoseList *original, BObjectListEntryRef()); + struct stat deststat; + destDir.GetStat(&deststat); + + return srcRef->device == deststat.st_dev; + +} + + void BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, bool forceCopy, bool forceMove, bool createLink, bool relativeLink) @@ -4487,12 +4516,7 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, moveMode = kCreateLink; else { moveMode = kMoveSelectionTo; - entry_ref *srcRef = srcList->ItemAt(0); - BDirectory destDir (destEntry); - struct stat deststat; - destDir.GetStat(&deststat); - - if (srcRef->device != deststat.st_dev) + if (!CheckDevicesEqual(srcList->ItemAt(0), destFolder)) moveMode = kCopySelectionTo; } @@ -7556,7 +7580,7 @@ BPoseView::SendSelectionAsRefs(uint32 what, bool onlyQueries) if (onlyQueries) // this is used to make query templates come up in a special edit window - message.AddBool("editQueryOnPose", &onlyQueries); + message.AddBool("editQueryOnPose", onlyQueries); BMessenger(kTrackerSignature).SendMessage(&message); } @@ -8604,6 +8628,9 @@ BPoseView::MouseMoved(BPoint mouseLoc, uint32 moveCode, const BMessage *message) } case B_EXITED_VIEW: + // reset cursor in case we set it to the copy cursor in UpdateDropTarget + SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); + fCursorCheck = false; // TODO: autoscroll here if (!window->ContextMenu()) { HiliteDropTarget(false); @@ -8623,11 +8650,12 @@ BPoseView::UpdateDropTarget(BPoint mouseLoc, const BMessage *dragMessage, int32 index; BPose *targetPose = FindPose(mouseLoc, &index); - if (targetPose == fDropTarget + if (fCursorCheck && targetPose == fDropTarget || (trackingContextMenu && !targetPose)) // no change return false; - + + fCursorCheck = true; if (fDropTarget && !DragSelectionContains(fDropTarget, dragMessage)) HiliteDropTarget(false); @@ -8645,10 +8673,24 @@ BPoseView::UpdateDropTarget(BPoint mouseLoc, const BMessage *dragMessage, bool ignoreTypes = (modifiers() & B_CONTROL_KEY) != 0; if (targetPose && CanHandleDragSelection(targetModel, dragMessage, ignoreTypes)) { // new target is valid, select it - HiliteDropTarget(true); - } else + HiliteDropTarget(true); + } else { fDropTarget = NULL; + if (targetPose == NULL) + targetModel = TargetModel(); + } + entry_ref srcRef; + if (targetModel->IsDirectory() && dragMessage->HasRef("refs") + && dragMessage->FindRef("refs", &srcRef) == B_OK) { + if (!CheckDevicesEqual(&srcRef, targetModel)) { + BCursor copyCursor(kCopyCursor); + SetViewCursor(©Cursor); + return true; + } + } + + SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); return true; } diff --git a/src/kits/tracker/PoseView.h b/src/kits/tracker/PoseView.h index 1c1b749a9d..efb45dc291 100644 --- a/src/kits/tracker/PoseView.h +++ b/src/kits/tracker/PoseView.h @@ -648,7 +648,7 @@ class BPoseView : public BView { bool fIsDesktopWindow : 1; bool fIsWatchingDateFormatChange : 1; bool fHasPosesInClipboard : 1; - + bool fCursorCheck : 1; BRect fStartFrame; BRect fSelectionRect;