Added the LLWindowCallbacks::DragNDropAction enum, and made the mac implementation and the cross-platform window callbacks use it (instead of 'bool drop').

This will break the windows impl until someone fixes it to match.
master
Monroe Linden 2009-12-03 17:40:58 -08:00
parent bfe66526c8
commit fe0b027d4d
6 changed files with 93 additions and 62 deletions

View File

@ -163,7 +163,7 @@ void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *da
{
}
LLWindowCallbacks::DragNDropResult LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data )
LLWindowCallbacks::DragNDropResult LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, DragNDropAction action, std::string data )
{
return LLWindowCallbacks::DND_NONE;
}

View File

@ -70,6 +70,13 @@ public:
virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data);
virtual BOOL handleTimerEvent(LLWindow *window);
virtual BOOL handleDeviceChange(LLWindow *window);
enum DragNDropAction {
DNDA_START_TRACKING = 0,// Start tracking an incoming drag
DNDA_TRACK, // User is dragging an incoming drag around the window
DNDA_STOP_TRACKING, // User is no longer dragging an incoming drag around the window (may have either cancelled or dropped on the window)
DNDA_DROPPED // User dropped an incoming drag on the window (this is the "commit" event)
};
enum DragNDropResult {
DND_NONE = 0, // No drop allowed
@ -77,7 +84,7 @@ public:
DND_COPY, // Drop accepted would result in a "copy" operation
DND_LINK // Drop accepted would result in a "link" operation
};
virtual DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data);
virtual DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, DragNDropAction action, std::string data);
virtual void handlePingWatchdog(LLWindow *window, const char * msg);
virtual void handlePauseWatchdog(LLWindow *window);

View File

@ -3396,12 +3396,15 @@ OSErr LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef
switch(message)
{
case kDragTrackingInWindow:
result = self->handleDragNDrop(drag, false);
result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_TRACK);
break;
case kDragTrackingEnterHandler:
result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_START_TRACKING);
break;
case kDragTrackingLeaveHandler:
// TODO: We probably want to do something clever for these (at least for the LeaveHandler).
result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_STOP_TRACKING);
break;
default:
@ -3415,11 +3418,11 @@ OSErr LLWindowMacOSX::dragReceiveHandler(WindowRef theWindow, void * handlerRefC
DragRef drag)
{
LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon;
return self->handleDragNDrop(drag, true);
return self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_DROPPED);
}
OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, bool drop)
OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDropAction action)
{
OSErr result = dragNotAcceptedErr; // overall function result
OSErr err = noErr; // for local error handling
@ -3488,7 +3491,7 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, bool drop)
if(!url.empty())
{
LLWindowCallbacks::DragNDropResult res =
mCallbacks->handleDragNDrop(this, gl_pos, mask, drop, url);
mCallbacks->handleDragNDrop(this, gl_pos, mask, action, url);
if (LLWindowCallbacks::DND_NONE != res)
{

View File

@ -34,6 +34,7 @@
#define LL_LLWINDOWMACOSX_H
#include "llwindow.h"
#include "llwindowcallbacks.h"
#include "lltimer.h"
@ -164,7 +165,7 @@ protected:
static OSErr dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow,
void * handlerRefCon, DragRef theDrag);
static OSErr dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, DragRef theDrag);
OSErr handleDragNDrop(DragRef theDrag, bool drop);
OSErr handleDragNDrop(DragRef theDrag, LLWindowCallbacks::DragNDropAction action);
//
// Platform specific variables

View File

@ -823,71 +823,91 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS
return TRUE;
}
LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data)
LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, LLWindowCallbacks::DragNDropAction action, std::string data)
{
LLWindowCallbacks::DragNDropResult result = LLWindowCallbacks::DND_NONE;
if (gSavedSettings.getBOOL("PrimMediaDragNDrop"))
{
// special case SLURLs
if ( drop && std::string::npos != data.find("slurl.com") )
{
LLURLDispatcher::dispatch( data, NULL, true );
LLURLSimString::setString( LLSLURL::stripProtocol( data ) );
LLPanelLogin::refreshLocation( true );
LLPanelLogin::updateLocationUI();
return LLWindowCallbacks::DND_MOVE;
};
LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ );
LLUUID object_id = pick_info.getObjectID();
S32 object_face = pick_info.mObjectFace;
std::string url = data;
llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl;
LLVOVolume *obj = dynamic_cast<LLVOVolume*>(static_cast<LLViewerObject*>(pick_info.getObject()));
if (obj && obj->permModify())
switch(action)
{
LLTextureEntry *te = obj->getTE(object_face);
if (te)
// Much of the handling for these two cases is the same.
case LLWindowCallbacks::DNDA_TRACK:
case LLWindowCallbacks::DNDA_DROPPED:
{
if (drop)
bool drop = (LLWindowCallbacks::DNDA_DROPPED == action);
// special case SLURLs
if ( drop && std::string::npos != data.find("slurl.com") )
{
if (! te->hasMedia())
LLURLDispatcher::dispatch( data, NULL, true );
LLURLSimString::setString( LLSLURL::stripProtocol( data ) );
LLPanelLogin::refreshLocation( true );
LLPanelLogin::updateLocationUI();
return LLWindowCallbacks::DND_MOVE;
};
LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ );
LLUUID object_id = pick_info.getObjectID();
S32 object_face = pick_info.mObjectFace;
std::string url = data;
llinfos << "### Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl;
LLVOVolume *obj = dynamic_cast<LLVOVolume*>(static_cast<LLViewerObject*>(pick_info.getObject()));
if (obj && obj->permModify())
{
LLTextureEntry *te = obj->getTE(object_face);
if (te)
{
// Create new media entry
LLSD media_data;
// XXX Should we really do Home URL too?
media_data[LLMediaEntry::HOME_URL_KEY] = url;
media_data[LLMediaEntry::CURRENT_URL_KEY] = url;
media_data[LLMediaEntry::AUTO_PLAY_KEY] = true;
obj->syncMediaData(object_face, media_data, true, true);
// XXX This shouldn't be necessary, should it ?!?
obj->getMediaImpl(object_face)->navigateReload();
obj->sendMediaDataUpdate();
result = LLWindowCallbacks::DND_COPY;
if (drop)
{
if (! te->hasMedia())
{
// Create new media entry
LLSD media_data;
// XXX Should we really do Home URL too?
media_data[LLMediaEntry::HOME_URL_KEY] = url;
media_data[LLMediaEntry::CURRENT_URL_KEY] = url;
media_data[LLMediaEntry::AUTO_PLAY_KEY] = true;
obj->syncMediaData(object_face, media_data, true, true);
// XXX This shouldn't be necessary, should it ?!?
obj->getMediaImpl(object_face)->navigateReload();
obj->sendMediaDataUpdate();
result = LLWindowCallbacks::DND_COPY;
}
else {
// just navigate to the URL
obj->getMediaImpl(object_face)->navigateTo(url);
result = LLWindowCallbacks::DND_LINK;
}
LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject);
mDragHoveredObject = NULL;
}
else {
mDragHoveredObject = obj;
// Highlight the dragged object
LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject);
result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK;
}
}
else {
// just navigate to the URL
obj->getMediaImpl(object_face)->navigateTo(url);
result = LLWindowCallbacks::DND_LINK;
}
LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject);
mDragHoveredObject = NULL;
}
else {
mDragHoveredObject = obj;
// Highlight the dragged object
LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject);
result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK;
}
}
break;
case LLWindowCallbacks::DNDA_START_TRACKING:
// No special handling here yet -- we'll actually start tracking on the first DNDA_TRACK event.
break;
case LLWindowCallbacks::DNDA_STOP_TRACKING:
// The cleanup case below will make sure things are unhilighted if necessary.
break;
}
if (result == LLWindowCallbacks::DND_NONE && !mDragHoveredObject.isNull())

View File

@ -170,7 +170,7 @@ public:
/*virtual*/ BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
/*virtual*/ BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
/*virtual*/ BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
/*virtual*/ LLWindowCallbacks::DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data);
/*virtual*/ LLWindowCallbacks::DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, LLWindowCallbacks::DragNDropAction action, std::string data);
void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask);
/*virtual*/ void handleMouseLeave(LLWindow *window);
/*virtual*/ void handleResize(LLWindow *window, S32 x, S32 y);