Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorDamien Plisson <damien.plisson@yahoo.fr>2009-11-19 11:56:26 +0300
committerDamien Plisson <damien.plisson@yahoo.fr>2009-11-19 11:56:26 +0300
commit169b0cbee98d9fa789855f345249941ab3963f0d (patch)
treea3bb78e5c3121814919be0e140b0dd1ce9637587 /intern
parent525fbb22d22f0c8b8d5e13440fa1328bd56036db (diff)
Drag'n'drop : moved "setAcceptDragOperation" functions at window level
GHOST/Cocoa : changed strings encoding to isoLatin1 (was UTF-8)
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/GHOST_C-api.h2
-rw-r--r--intern/ghost/GHOST_ISystem.h15
-rw-r--r--intern/ghost/GHOST_IWindow.h11
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp6
-rw-r--r--intern/ghost/intern/GHOST_System.cpp11
-rw-r--r--intern/ghost/intern/GHOST_System.h18
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm23
-rw-r--r--intern/ghost/intern/GHOST_Window.cpp10
-rw-r--r--intern/ghost/intern/GHOST_Window.h14
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm5
10 files changed, 53 insertions, 62 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 5e434c0eaa0..d4788ae9e86 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -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);
/**
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index e56a0dae879..305caa70ae4 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -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.
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index 512fad877cb..5d1e0a67e7e 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -149,6 +149,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.
*/
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 76b3d7caf7e..556176809f4 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -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);
}
diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp
index cccee12d696..79d8389ffc6 100644
--- a/intern/ghost/intern/GHOST_System.cpp
+++ b/intern/ghost/intern/GHOST_System.cpp
@@ -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 ();
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 542553e830e..e381b673957 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -233,21 +233,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;
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index b31db472ef1..86203a49da7 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -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];
}
diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp
index 33484284d7c..e89e0274276 100644
--- a/intern/ghost/intern/GHOST_Window.cpp
+++ b/intern/ghost/intern/GHOST_Window.cpp
@@ -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)
{
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 86447a8623c..1b5681dc41c 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -184,6 +184,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
* @return Indication of success.
@@ -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;
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 54a62636895..24abc9c45fc 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -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;