Drag'n'drop : moved "setAcceptDragOperation" functions at window level
GHOST/Cocoa : changed strings encoding to isoLatin1 (was UTF-8)
This commit is contained in:
@@ -414,7 +414,7 @@ extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
|
||||
/**
|
||||
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
|
||||
*/
|
||||
extern void GHOST_setAcceptDragOperation(GHOST_SystemHandle systemhandle, GHOST_TInt8 canAccept);
|
||||
extern void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept);
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -369,21 +369,6 @@ public:
|
||||
virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Drag'n'drop operations
|
||||
***************************************************************************************/
|
||||
|
||||
/**
|
||||
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
|
||||
*/
|
||||
virtual void setAcceptDragOperation(bool canAccept) = 0;
|
||||
|
||||
/**
|
||||
* Returns acceptance of the dropped object
|
||||
* Usually called by the "object dropped" event handling function
|
||||
*/
|
||||
virtual bool canAcceptDragOperation() const = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Initialize the system.
|
||||
|
@@ -148,6 +148,17 @@ public:
|
||||
*/
|
||||
virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
|
||||
|
||||
/**
|
||||
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
|
||||
*/
|
||||
virtual void setAcceptDragOperation(bool canAccept) = 0;
|
||||
|
||||
/**
|
||||
* Returns acceptance of the dropped object
|
||||
* Usually called by the "object dropped" event handling function
|
||||
*/
|
||||
virtual bool canAcceptDragOperation() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the state of the window (normal, minimized, maximized).
|
||||
* @return The state of the window.
|
||||
|
@@ -404,11 +404,11 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
|
||||
}
|
||||
|
||||
|
||||
void GHOST_setAcceptDragOperation(GHOST_SystemHandle systemhandle, GHOST_TInt8 canAccept)
|
||||
void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept)
|
||||
{
|
||||
GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
|
||||
GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
|
||||
|
||||
system->setAcceptDragOperation(canAccept);
|
||||
window->setAcceptDragOperation(canAccept);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -54,7 +54,6 @@
|
||||
GHOST_System::GHOST_System()
|
||||
: m_displayManager(0), m_timerManager(0), m_windowManager(0), m_eventManager(0), m_ndofManager(0)
|
||||
{
|
||||
m_canAcceptDragOperation = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -276,16 +275,6 @@ GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown
|
||||
return success;
|
||||
}
|
||||
|
||||
void GHOST_System::setAcceptDragOperation(bool canAccept)
|
||||
{
|
||||
m_canAcceptDragOperation = canAccept;
|
||||
}
|
||||
|
||||
bool GHOST_System::canAcceptDragOperation() const
|
||||
{
|
||||
return m_canAcceptDragOperation;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_System::init()
|
||||
{
|
||||
m_timerManager = new GHOST_TimerManager ();
|
||||
|
@@ -232,21 +232,6 @@ public:
|
||||
*/
|
||||
virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const;
|
||||
|
||||
/***************************************************************************************
|
||||
** Drag'n'drop operations
|
||||
***************************************************************************************/
|
||||
|
||||
/**
|
||||
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
|
||||
*/
|
||||
virtual void setAcceptDragOperation(bool canAccept);
|
||||
|
||||
/**
|
||||
* Returns acceptance of the dropped object
|
||||
* Usually called by the "object dropped" event handling function
|
||||
*/
|
||||
virtual bool canAcceptDragOperation() const;
|
||||
|
||||
/***************************************************************************************
|
||||
** Other (internal) functionality.
|
||||
***************************************************************************************/
|
||||
@@ -348,9 +333,6 @@ protected:
|
||||
/** The N-degree of freedom device manager */
|
||||
GHOST_NDOFManager* m_ndofManager;
|
||||
|
||||
/** The acceptance of the "drop candidate" of the current drag'n'drop operation */
|
||||
bool m_canAcceptDragOperation;
|
||||
|
||||
/** Prints all the events. */
|
||||
#ifdef GHOST_DEBUG
|
||||
GHOST_EventPrinter* m_eventPrinter;
|
||||
|
@@ -892,7 +892,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
|
||||
switch(eventType)
|
||||
{
|
||||
case GHOST_kEventDraggingEntered:
|
||||
setAcceptDragOperation(FALSE); //Drag operation needs to be accepted explicitely by the event manager
|
||||
case GHOST_kEventDraggingUpdated:
|
||||
case GHOST_kEventDraggingExited:
|
||||
pushEvent(new GHOST_EventDragnDrop(getMilliSeconds(),eventType,draggedObjectType,window,mouseX,mouseY,NULL));
|
||||
@@ -931,7 +930,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
|
||||
{
|
||||
droppedStr = [droppedArray objectAtIndex:i];
|
||||
|
||||
pastedTextSize = [droppedStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
|
||||
pastedTextSize = [droppedStr lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
|
||||
temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1);
|
||||
|
||||
if (!temp_buff) {
|
||||
@@ -939,7 +938,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
|
||||
break;
|
||||
}
|
||||
|
||||
strncpy((char*)temp_buff, [droppedStr UTF8String], pastedTextSize);
|
||||
strncpy((char*)temp_buff, [droppedStr cStringUsingEncoding:NSISOLatin1StringEncoding], pastedTextSize);
|
||||
temp_buff[pastedTextSize] = '\0';
|
||||
|
||||
strArray->strings[i] = temp_buff;
|
||||
@@ -950,7 +949,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
|
||||
|
||||
case GHOST_kDragnDropTypeString:
|
||||
droppedStr = (NSString*)data;
|
||||
pastedTextSize = [droppedStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
|
||||
pastedTextSize = [droppedStr lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
|
||||
|
||||
temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1);
|
||||
|
||||
@@ -958,7 +957,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
strncpy((char*)temp_buff, [droppedStr UTF8String], pastedTextSize);
|
||||
strncpy((char*)temp_buff, [droppedStr cStringUsingEncoding:NSISOLatin1StringEncoding], pastedTextSize);
|
||||
|
||||
temp_buff[pastedTextSize] = '\0';
|
||||
|
||||
@@ -1321,7 +1320,7 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const
|
||||
}
|
||||
|
||||
NSArray *supportedTypes =
|
||||
[NSArray arrayWithObjects: @"public.utf8-plain-text", nil];
|
||||
[NSArray arrayWithObjects: NSStringPboardType, nil];
|
||||
|
||||
NSString *bestType = [[NSPasteboard generalPasteboard]
|
||||
availableTypeFromArray:supportedTypes];
|
||||
@@ -1331,14 +1330,14 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NSString * textPasted = [pasteBoard stringForType:@"public.utf8-plain-text"];
|
||||
NSString * textPasted = [pasteBoard stringForType:NSStringPboardType];
|
||||
|
||||
if (textPasted == nil) {
|
||||
[pool drain];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pastedTextSize = [textPasted lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
|
||||
pastedTextSize = [textPasted lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
|
||||
|
||||
temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1);
|
||||
|
||||
@@ -1347,7 +1346,7 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strncpy((char*)temp_buff, [textPasted UTF8String], pastedTextSize);
|
||||
strncpy((char*)temp_buff, [textPasted cStringUsingEncoding:NSISOLatin1StringEncoding], pastedTextSize);
|
||||
|
||||
temp_buff[pastedTextSize] = '\0';
|
||||
|
||||
@@ -1375,13 +1374,13 @@ void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray *supportedTypes = [NSArray arrayWithObject:@"public.utf8-plain-text"];
|
||||
NSArray *supportedTypes = [NSArray arrayWithObject:NSStringPboardType];
|
||||
|
||||
[pasteBoard declareTypes:supportedTypes owner:nil];
|
||||
|
||||
textToCopy = [NSString stringWithUTF8String:buffer];
|
||||
textToCopy = [NSString stringWithCString:buffer encoding:NSISOLatin1StringEncoding];
|
||||
|
||||
[pasteBoard setString:textToCopy forType:@"public.utf8-plain-text"];
|
||||
[pasteBoard setString:textToCopy forType:NSStringPboardType];
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
|
@@ -53,6 +53,7 @@ GHOST_Window::GHOST_Window(
|
||||
m_stereoVisual(stereoVisual)
|
||||
{
|
||||
m_isUnsavedChanges = false;
|
||||
m_canAcceptDragOperation = false;
|
||||
|
||||
m_cursorGrabAccumPos[0] = 0;
|
||||
m_cursorGrabAccumPos[1] = 0;
|
||||
@@ -154,6 +155,15 @@ GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUn
|
||||
}
|
||||
}
|
||||
|
||||
void GHOST_Window::setAcceptDragOperation(bool canAccept)
|
||||
{
|
||||
m_canAcceptDragOperation = canAccept;
|
||||
}
|
||||
|
||||
bool GHOST_Window::canAcceptDragOperation() const
|
||||
{
|
||||
return m_canAcceptDragOperation;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_Window::setModifiedState(bool isUnsavedChanges)
|
||||
{
|
||||
|
@@ -183,6 +183,17 @@ public:
|
||||
*/
|
||||
virtual GHOST_TSuccess getCursorGrabBounds(GHOST_Rect& bounds);
|
||||
|
||||
/**
|
||||
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
|
||||
*/
|
||||
virtual void setAcceptDragOperation(bool canAccept);
|
||||
|
||||
/**
|
||||
* Returns acceptance of the dropped object
|
||||
* Usually called by the "object dropped" event handling function
|
||||
*/
|
||||
virtual bool canAcceptDragOperation() const;
|
||||
|
||||
/**
|
||||
* Sets the window "modified" status, indicating unsaved changes
|
||||
* @param isUnsavedChanges Unsaved changes or not
|
||||
@@ -294,6 +305,9 @@ protected:
|
||||
/** The current shape of the cursor */
|
||||
GHOST_TStandardCursor m_cursorShape;
|
||||
|
||||
/** The acceptance of the "drop candidate" of the current drag'n'drop operation */
|
||||
bool m_canAcceptDragOperation;
|
||||
|
||||
/** Modified state : are there unsaved changes */
|
||||
bool m_isUnsavedChanges;
|
||||
|
||||
|
@@ -153,6 +153,7 @@ extern "C" {
|
||||
else if ([[draggingPBoard types] containsObject:NSStringPboardType]) m_draggedObjectType = GHOST_kDragnDropTypeString;
|
||||
else return NSDragOperationNone;
|
||||
|
||||
associatedWindow->setAcceptDragOperation(FALSE); //Drag operation needs to be accepted explicitly by the event manager
|
||||
systemCocoa->handleDraggingEvent(GHOST_kEventDraggingEntered, m_draggedObjectType, associatedWindow, mouseLocation.x, mouseLocation.y, nil);
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
@@ -178,7 +179,7 @@ extern "C" {
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id < NSDraggingInfo >)sender
|
||||
{
|
||||
if (systemCocoa->canAcceptDragOperation())
|
||||
if (associatedWindow->canAcceptDragOperation())
|
||||
return YES;
|
||||
else
|
||||
return NO;
|
||||
@@ -198,7 +199,7 @@ extern "C" {
|
||||
data = [draggingPBoard propertyListForType:NSFilenamesPboardType];
|
||||
break;
|
||||
case GHOST_kDragnDropTypeString:
|
||||
data = [draggingPBoard stringForType:@"public.utf8-plain-text"];
|
||||
data = [draggingPBoard stringForType:NSStringPboardType];
|
||||
break;
|
||||
default:
|
||||
return NO;
|
||||
|
Reference in New Issue
Block a user