diff options
author | Dan Eicher <dan@eu.phorio.us> | 2012-05-29 12:20:11 +0400 |
---|---|---|
committer | Dan Eicher <dan@eu.phorio.us> | 2012-05-29 12:20:11 +0400 |
commit | e0c2ddb8863c90b46725afaca0dce99b463c13d6 (patch) | |
tree | ed571686772dfad7936a8e4d30530cdd40a7ff31 /source/blender/editors/space_outliner/space_outliner.c | |
parent | a5373554262eab69e23bb173e3e7f3026d0bf474 (diff) |
OUTLINER_OT_scene_drop -- "Drag object to scene in Outliner" operator
Refactored the two (well, three now) other places where an object is linked to a scene into ED_object_scene_link()
Diffstat (limited to 'source/blender/editors/space_outliner/space_outliner.c')
-rw-r--r-- | source/blender/editors/space_outliner/space_outliner.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 3110ff3e29e..f3f6e3cf49f 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -144,6 +144,35 @@ static void outliner_parent_clear_copy(wmDrag *drag, wmDropBox *drop) RNA_enum_set(drop->ptr, "type", 0); } +static int outliner_scene_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeElement *te = NULL; + float fmval[2]; + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); + + if (drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if (GS(id->name) == ID_OB) { + /* Ensure item under cursor is valid drop target */ + /* Find object hovered over */ + for (te = soops->tree.first; te; te = te->next) { + if (outliner_dropzone_scene(C, event, te, fmval)) + return 1; + } + } + } + return 0; +} + +static void outliner_scene_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + ID *id = (ID *)drag->poin; + + RNA_string_set(drop->ptr, "object", id->name + 2); +} + /* region dropbox definition */ static void outliner_dropboxes(void) { @@ -151,6 +180,7 @@ static void outliner_dropboxes(void) WM_dropbox_add(lb, "OUTLINER_OT_parent_drop", outliner_parent_drop_poll, outliner_parent_drop_copy); WM_dropbox_add(lb, "OUTLINER_OT_parent_clear", outliner_parent_clear_poll, outliner_parent_clear_copy); + WM_dropbox_add(lb, "OUTLINER_OT_scene_drop", outliner_scene_drop_poll, outliner_scene_drop_copy); } static void outliner_main_area_draw(const bContext *C, ARegion *ar) |