From f305261f14254656c888438205887769ad45b8bd Mon Sep 17 00:00:00 2001 From: Dan Eicher Date: Sun, 10 Jun 2012 22:22:26 +0000 Subject: OUTLINER_OT_material_drop -- Drag & Drop materials onto objects in the outliner Adds the material at materials + 1 unlike the DnD view3d one which replaces the first one --- .../editors/space_outliner/space_outliner.c | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source/blender/editors/space_outliner/space_outliner.c') diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index c78be8bd223..489a4efe891 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -194,6 +194,35 @@ static void outliner_scene_drop_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "object", id->name + 2); } +static int outliner_material_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_MA) { + /* Ensure item under cursor is valid drop target */ + /* Find object hovered over */ + for (te = soops->tree.first; te; te = te->next) { + if (outliner_dropzone_parent(C, event, te, fmval)) + return 1; + } + } + } + return 0; +} + +static void outliner_material_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + ID *id = (ID *)drag->poin; + + RNA_string_set(drop->ptr, "material", id->name + 2); +} + /* region dropbox definition */ static void outliner_dropboxes(void) { @@ -202,6 +231,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); + WM_dropbox_add(lb, "OUTLINER_OT_material_drop", outliner_material_drop_poll, outliner_material_drop_copy); } static void outliner_main_area_draw(const bContext *C, ARegion *ar) -- cgit v1.2.3