[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26310] trunk/blender: Drag and drop 2. 5 integration! Finally, slashdot regulars can use
Ton Roosendaal
ton at blender.org
Tue Jan 26 19:18:21 CET 2010
Revision: 26310
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26310
Author: ton
Date: 2010-01-26 19:18:21 +0100 (Tue, 26 Jan 2010)
Log Message:
-----------
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
Modified Paths:
--------------
trunk/blender/intern/ghost/GHOST_Types.h
trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
trunk/blender/intern/ghost/intern/GHOST_WindowCarbon.cpp
trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm
trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp
trunk/blender/intern/ghost/intern/GHOST_WindowX11.cpp
trunk/blender/source/blender/blenkernel/BKE_screen.h
trunk/blender/source/blender/blenlib/BLI_storage_types.h
trunk/blender/source/blender/blenlib/BLI_string.h
trunk/blender/source/blender/blenlib/intern/storage.c
trunk/blender/source/blender/blenlib/intern/string.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/editors/include/ED_view3d.h
trunk/blender/source/blender/editors/include/UI_interface.h
trunk/blender/source/blender/editors/interface/interface.c
trunk/blender/source/blender/editors/interface/interface_draw.c
trunk/blender/source/blender/editors/interface/interface_handlers.c
trunk/blender/source/blender/editors/interface/interface_icons.c
trunk/blender/source/blender/editors/interface/interface_intern.h
trunk/blender/source/blender/editors/interface/interface_layout.c
trunk/blender/source/blender/editors/interface/interface_templates.c
trunk/blender/source/blender/editors/interface/interface_widgets.c
trunk/blender/source/blender/editors/mesh/mesh_data.c
trunk/blender/source/blender/editors/mesh/mesh_intern.h
trunk/blender/source/blender/editors/mesh/mesh_ops.c
trunk/blender/source/blender/editors/object/object_add.c
trunk/blender/source/blender/editors/object/object_intern.h
trunk/blender/source/blender/editors/object/object_ops.c
trunk/blender/source/blender/editors/object/object_relations.c
trunk/blender/source/blender/editors/screen/area.c
trunk/blender/source/blender/editors/screen/screen_edit.c
trunk/blender/source/blender/editors/screen/screen_ops.c
trunk/blender/source/blender/editors/space_action/space_action.c
trunk/blender/source/blender/editors/space_api/spacetypes.c
trunk/blender/source/blender/editors/space_buttons/buttons_context.c
trunk/blender/source/blender/editors/space_buttons/space_buttons.c
trunk/blender/source/blender/editors/space_console/space_console.c
trunk/blender/source/blender/editors/space_file/file_draw.c
trunk/blender/source/blender/editors/space_file/file_ops.c
trunk/blender/source/blender/editors/space_file/filelist.c
trunk/blender/source/blender/editors/space_file/filelist.h
trunk/blender/source/blender/editors/space_file/space_file.c
trunk/blender/source/blender/editors/space_graph/space_graph.c
trunk/blender/source/blender/editors/space_image/space_image.c
trunk/blender/source/blender/editors/space_info/space_info.c
trunk/blender/source/blender/editors/space_logic/space_logic.c
trunk/blender/source/blender/editors/space_nla/space_nla.c
trunk/blender/source/blender/editors/space_node/space_node.c
trunk/blender/source/blender/editors/space_outliner/outliner.c
trunk/blender/source/blender/editors/space_outliner/space_outliner.c
trunk/blender/source/blender/editors/space_script/space_script.c
trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c
trunk/blender/source/blender/editors/space_sequencer/space_sequencer.c
trunk/blender/source/blender/editors/space_sound/space_sound.c
trunk/blender/source/blender/editors/space_text/space_text.c
trunk/blender/source/blender/editors/space_time/space_time.c
trunk/blender/source/blender/editors/space_userpref/space_userpref.c
trunk/blender/source/blender/editors/space_view3d/space_view3d.c
trunk/blender/source/blender/editors/space_view3d/view3d_select.c
trunk/blender/source/blender/makesdna/DNA_screen_types.h
trunk/blender/source/blender/makesdna/DNA_windowmanager_types.h
trunk/blender/source/blender/windowmanager/WM_api.h
trunk/blender/source/blender/windowmanager/WM_types.h
trunk/blender/source/blender/windowmanager/intern/wm.c
trunk/blender/source/blender/windowmanager/intern/wm_cursors.c
trunk/blender/source/blender/windowmanager/intern/wm_draw.c
trunk/blender/source/blender/windowmanager/intern/wm_event_system.c
trunk/blender/source/blender/windowmanager/intern/wm_gesture.c
trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
trunk/blender/source/blender/windowmanager/intern/wm_window.c
trunk/blender/source/blender/windowmanager/wm_cursors.h
trunk/blender/source/blender/windowmanager/wm_event_system.h
trunk/blender/source/blender/windowmanager/wm_event_types.h
trunk/blender/source/nan_compile.mk
trunk/blender/source/nan_definitions.mk
Added Paths:
-----------
trunk/blender/source/blender/windowmanager/intern/wm_dragdrop.c
Modified: trunk/blender/intern/ghost/GHOST_Types.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_Types.h 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/intern/ghost/GHOST_Types.h 2010-01-26 18:18:21 UTC (rev 26310)
@@ -204,6 +204,7 @@
GHOST_kStandardCursorTopRightCorner,
GHOST_kStandardCursorBottomRightCorner,
GHOST_kStandardCursorBottomLeftCorner,
+ GHOST_kStandardCursorCopy,
GHOST_kStandardCursorCustom,
GHOST_kStandardCursorNumCursors,
GHOST_kStandardCursorPencil
Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm 2010-01-26 18:18:21 UTC (rev 26310)
@@ -1002,6 +1002,9 @@
case GHOST_kEventWindowUpdate:
pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
break;
+ case GHOST_kEventWindowMove:
+ pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, window) );
+ break;
case GHOST_kEventWindowSize:
if (!m_ignoreWindowSizedMessages)
{
Modified: trunk/blender/intern/ghost/intern/GHOST_WindowCarbon.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowCarbon.cpp 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowCarbon.cpp 2010-01-26 18:18:21 UTC (rev 26310)
@@ -635,6 +635,7 @@
GCMAP( GHOST_kStandardCursorTopRightCorner, kThemeArrowCursor);
GCMAP( GHOST_kStandardCursorBottomRightCorner, kThemeArrowCursor);
GCMAP( GHOST_kStandardCursorBottomLeftCorner, kThemeArrowCursor);
+ GCMAP( GHOST_kStandardCursorCopy, kThemeCopyArrowCursor);
};
#undef GCMAP
Modified: trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm 2010-01-26 18:18:21 UTC (rev 26310)
@@ -72,6 +72,8 @@
- (void)windowDidResignKey:(NSNotification *)notification;
- (void)windowDidExpose:(NSNotification *)notification;
- (void)windowDidResize:(NSNotification *)notification;
+- (void)windowDidMove:(NSNotification *)notification;
+- (void)windowWillMove:(NSNotification *)notification;
@end
@implementation CocoaWindowDelegate : NSObject
@@ -101,6 +103,16 @@
systemCocoa->handleWindowEvent(GHOST_kEventWindowUpdate, associatedWindow);
}
+- (void)windowDidMove:(NSNotification *)notification
+{
+ systemCocoa->handleWindowEvent(GHOST_kEventWindowMove, associatedWindow);
+}
+
+- (void)windowWillMove:(NSNotification *)notification
+{
+ systemCocoa->handleWindowEvent(GHOST_kEventWindowMove, associatedWindow);
+}
+
- (void)windowDidResize:(NSNotification *)notification
{
#ifdef MAC_OS_X_VERSION_10_6
@@ -1042,6 +1054,7 @@
case GHOST_kStandardCursorTopRightCorner:
case GHOST_kStandardCursorBottomRightCorner:
case GHOST_kStandardCursorBottomLeftCorner:
+ case GHOST_kStandardCursorCopy:
case GHOST_kStandardCursorDefault:
default:
tmpCursor = [NSCursor arrowCursor];
Modified: trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp 2010-01-26 18:18:21 UTC (rev 26310)
@@ -821,6 +821,7 @@
case GHOST_kStandardCursorBottomRightCorner: id = IDC_SIZENWSE; break;
case GHOST_kStandardCursorBottomLeftCorner: id = IDC_SIZENESW; break;
case GHOST_kStandardCursorPencil: id = IDC_ARROW; break;
+ case GHOST_kStandardCursorCopy: id = IDC_ARROW; break;
default:
success = false;
}
Modified: trunk/blender/intern/ghost/intern/GHOST_WindowX11.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowX11.cpp 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowX11.cpp 2010-01-26 18:18:21 UTC (rev 26310)
@@ -1359,6 +1359,7 @@
GtoX(GHOST_kStandardCursorBottomRightCorner, XC_bottom_right_corner); break;
GtoX(GHOST_kStandardCursorBottomLeftCorner, XC_bottom_left_corner); break;
GtoX(GHOST_kStandardCursorPencil, XC_pencil); break;
+ GtoX(GHOST_kStandardCursorCopy, XC_arrow); break;
default:
xcursor_id = 0;
}
Modified: trunk/blender/source/blender/blenkernel/BKE_screen.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_screen.h 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/source/blender/blenkernel/BKE_screen.h 2010-01-26 18:18:21 UTC (rev 26310)
@@ -84,6 +84,8 @@
void (*operatortypes)(void);
/* add default items to WM keymap */
void (*keymap)(struct wmKeyConfig *);
+ /* on startup, define dropboxes for spacetype+regions */
+ void (*dropboxes)(void);
/* return context data */
int (*context)(const struct bContext *, const char*, struct bContextDataResult *);
@@ -93,7 +95,7 @@
/* tool shelf definitions */
ListBase toolshelf;
-
+
/* read and write... */
/* default keymaps to add */
@@ -142,6 +144,8 @@
/* hardcoded constraints, smaller than these values region is not visible */
int minsizex, minsizey;
+ /* when new region opens (region prefsizex/y are zero then */
+ int prefsizex, prefsizey;
/* default keymaps to add */
int keymapflag;
} ARegionType;
Modified: trunk/blender/source/blender/blenlib/BLI_storage_types.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_storage_types.h 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/source/blender/blenlib/BLI_storage_types.h 2010-01-26 18:18:21 UTC (rev 26310)
@@ -55,6 +55,7 @@
char *string;
mode_t type;
char *relname;
+ char *path;
#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500)
struct _stat64 s;
#else
Modified: trunk/blender/source/blender/blenlib/BLI_string.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_string.h 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/source/blender/blenlib/BLI_string.h 2010-01-26 18:18:21 UTC (rev 26310)
@@ -66,6 +66,14 @@
* the size of dst)
* @retval Returns dst
*/
+char *BLI_strdupcat(const char *str1, const char *str2);
+
+ /**
+ * Appends the two strings, and returns new mallocN'ed string
+ * @param str1 first string for copy
+ * @param str2 second string for append
+ * @retval Returns dst
+ */
char *BLI_strncpy(char *dst, const char *src, int maxncpy);
/* Makes a copy of the text within the "" that appear after some text 'blahblah'
Modified: trunk/blender/source/blender/blenlib/intern/storage.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/storage.c 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/source/blender/blenlib/intern/storage.c 2010-01-26 18:18:21 UTC (rev 26310)
@@ -261,6 +261,7 @@
while(dlink){
memset(&files[actnum], 0 , sizeof(struct direntry));
files[actnum].relname = dlink->name;
+ files[actnum].path = BLI_strdupcat(dirname, dlink->name);
// use 64 bit file size, only needed for WIN32 and WIN64.
// Excluding other than current MSVC compiler until able to test.
#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500)
Modified: trunk/blender/source/blender/blenlib/intern/string.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/string.c 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/source/blender/blenlib/intern/string.c 2010-01-26 18:18:21 UTC (rev 26310)
@@ -54,6 +54,19 @@
return BLI_strdupn(str, strlen(str));
}
+char *BLI_strdupcat(const char *str1, const char *str2)
+{
+ int len;
+ char *n;
+
+ len= strlen(str1)+strlen(str2);
+ n= MEM_mallocN(len+1, "strdupcat");
+ strcpy(n, str1);
+ strcat(n, str2);
+
+ return n;
+}
+
char *BLI_strncpy(char *dst, const char *src, int maxncpy) {
int srclen= strlen(src);
int cpylen= (srclen>(maxncpy-1))?(maxncpy-1):srclen;
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2010-01-26 18:18:21 UTC (rev 26310)
@@ -4536,6 +4536,7 @@
wm->defaultconf= NULL;
wm->jobs.first= wm->jobs.last= NULL;
+ wm->drags.first= wm->drags.last= NULL;
wm->windrawable= NULL;
wm->initialized= 0;
Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h 2010-01-26 18:18:21 UTC (rev 26310)
@@ -159,5 +159,7 @@
void view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]);
+Base *ED_view3d_give_base_under_cursor(struct bContext *C, short *mval);
+
#endif /* ED_VIEW3D_H */
Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h 2010-01-26 17:39:45 UTC (rev 26309)
+++ trunk/blender/source/blender/editors/include/UI_interface.h 2010-01-26 18:18:21 UTC (rev 26310)
@@ -61,6 +61,7 @@
struct uiWidgetColors;
struct Tex;
struct MTex;
+struct ImBuf;
typedef struct uiBut uiBut;
typedef struct uiBlock uiBlock;
@@ -343,6 +344,15 @@
int uiButGetRetVal (uiBut *but);
+void uiButSetDragID(uiBut *but, struct ID *id);
+void uiButSetDragRNA(uiBut *but, struct PointerRNA *ptr);
+void uiButSetDragPath(uiBut *but, const char *path);
+void uiButSetDragName(uiBut *but, const char *name);
+void uiButSetDragValue(uiBut *but);
+void uiButSetDragImage(uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale);
+
+int UI_but_active_drop_name(struct bContext *C);
+
void uiButSetFlag (uiBut *but, int flag);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list