[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24671] trunk/blender/intern/ghost: Drag'n 'drop : moved "setAcceptDragOperation" functions at window level

Damien Plisson damien.plisson at yahoo.fr
Thu Nov 19 09:56:27 CET 2009


Revision: 24671
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24671
Author:   damien78
Date:     2009-11-19 09:56:26 +0100 (Thu, 19 Nov 2009)

Log Message:
-----------
Drag'n'drop : moved "setAcceptDragOperation" functions at window level
GHOST/Cocoa : changed strings encoding to isoLatin1 (was UTF-8)

Modified Paths:
--------------
    trunk/blender/intern/ghost/GHOST_C-api.h
    trunk/blender/intern/ghost/GHOST_ISystem.h
    trunk/blender/intern/ghost/GHOST_IWindow.h
    trunk/blender/intern/ghost/intern/GHOST_C-api.cpp
    trunk/blender/intern/ghost/intern/GHOST_System.cpp
    trunk/blender/intern/ghost/intern/GHOST_System.h
    trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
    trunk/blender/intern/ghost/intern/GHOST_Window.cpp
    trunk/blender/intern/ghost/intern/GHOST_Window.h
    trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm

Modified: trunk/blender/intern/ghost/GHOST_C-api.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_C-api.h	2009-11-19 04:50:00 UTC (rev 24670)
+++ trunk/blender/intern/ghost/GHOST_C-api.h	2009-11-19 08:56:26 UTC (rev 24671)
@@ -414,7 +414,7 @@
 /**
  * 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);
 	
 	
 /**

Modified: trunk/blender/intern/ghost/GHOST_ISystem.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_ISystem.h	2009-11-19 04:50:00 UTC (rev 24670)
+++ trunk/blender/intern/ghost/GHOST_ISystem.h	2009-11-19 08:56:26 UTC (rev 24671)
@@ -369,21 +369,6 @@
 	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.

Modified: trunk/blender/intern/ghost/GHOST_IWindow.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_IWindow.h	2009-11-19 04:50:00 UTC (rev 24670)
+++ trunk/blender/intern/ghost/GHOST_IWindow.h	2009-11-19 08:56:26 UTC (rev 24671)
@@ -149,6 +149,17 @@
 	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.
 	 */

Modified: trunk/blender/intern/ghost/intern/GHOST_C-api.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_C-api.cpp	2009-11-19 04:50:00 UTC (rev 24670)
+++ trunk/blender/intern/ghost/intern/GHOST_C-api.cpp	2009-11-19 08:56:26 UTC (rev 24671)
@@ -404,11 +404,11 @@
 }
 
 
-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);
 }
 
 

Modified: trunk/blender/intern/ghost/intern/GHOST_System.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_System.cpp	2009-11-19 04:50:00 UTC (rev 24670)
+++ trunk/blender/intern/ghost/intern/GHOST_System.cpp	2009-11-19 08:56:26 UTC (rev 24671)
@@ -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 @@
 	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 ();

Modified: trunk/blender/intern/ghost/intern/GHOST_System.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_System.h	2009-11-19 04:50:00 UTC (rev 24670)
+++ trunk/blender/intern/ghost/intern/GHOST_System.h	2009-11-19 08:56:26 UTC (rev 24671)
@@ -233,21 +233,6 @@
 	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 @@
     /** 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;

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2009-11-19 04:50:00 UTC (rev 24670)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2009-11-19 08:56:26 UTC (rev 24671)
@@ -892,7 +892,6 @@
 	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 @@
 					{
 						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 @@
 							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 @@
 					
 				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 @@
 						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 @@
 	}
 	
 	NSArray *supportedTypes =
-		[NSArray arrayWithObjects: @"public.utf8-plain-text", nil];
+		[NSArray arrayWithObjects: NSStringPboardType, nil];
 	
 	NSString *bestType = [[NSPasteboard generalPasteboard]
 						  availableTypeFromArray:supportedTypes];
@@ -1331,14 +1330,14 @@
 		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 @@
 		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 @@
 		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];
 }

Modified: trunk/blender/intern/ghost/intern/GHOST_Window.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_Window.cpp	2009-11-19 04:50:00 UTC (rev 24670)
+++ trunk/blender/intern/ghost/intern/GHOST_Window.cpp	2009-11-19 08:56:26 UTC (rev 24671)
@@ -53,6 +53,7 @@
 	m_stereoVisual(stereoVisual)
 {
 	m_isUnsavedChanges = false;
+	m_canAcceptDragOperation = false;
 	
     m_cursorGrabAccumPos[0] = 0;
     m_cursorGrabAccumPos[1] = 0;
@@ -154,7 +155,16 @@
 	}
 }
 
+void GHOST_Window::setAcceptDragOperation(bool canAccept)
+{
+	m_canAcceptDragOperation = canAccept;
+}
 
+bool GHOST_Window::canAcceptDragOperation() const
+{
+	return m_canAcceptDragOperation;
+}
+
 GHOST_TSuccess GHOST_Window::setModifiedState(bool isUnsavedChanges)
 {
 	m_isUnsavedChanges = isUnsavedChanges;

Modified: trunk/blender/intern/ghost/intern/GHOST_Window.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_Window.h	2009-11-19 04:50:00 UTC (rev 24670)
+++ trunk/blender/intern/ghost/intern/GHOST_Window.h	2009-11-19 08:56:26 UTC (rev 24671)
@@ -184,6 +184,17 @@
 	virtual GHOST_TSuccess getCursorGrabBounds(GHOST_Rect& bounds);
 
 	/**
+	 * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
+	 */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list