Fix #21470: changing brush settings redraws the 3d view unecessarily,
[blender-staging.git] / source / blender / editors / space_view3d / space_view3d.c
index bda7dfcabf18b3ba07b51046c7487fb7682a7488..92e3b35f6145a17e8d9bc9b723e5c05480662132 100644 (file)
@@ -57,6 +57,8 @@
 
 #include "RNA_access.h"
 
+#include "UI_resources.h"
+
 #include "view3d_intern.h"     // own include
 
 /* ******************** manage regions ********************* */
@@ -411,10 +413,16 @@ static int view3d_mat_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
 
 static int view3d_ima_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
 {
-       if(drag->type==WM_DRAG_ID) {
-               ID *id= (ID *)drag->poin;
-               if( GS(id->name)==ID_IM )
-                       return 1;
+       if( ED_view3d_give_base_under_cursor(C, event->mval) ) {
+               if(drag->type==WM_DRAG_ID) {
+                       ID *id= (ID *)drag->poin;
+                       if( GS(id->name)==ID_IM )
+                               return 1;
+               }
+               else if(drag->type==WM_DRAG_PATH){
+                       if(ELEM(drag->icon, 0, ICON_FILE_IMAGE))        /* rule might not work? */
+                               return 1;
+               }
        }
        return 0;
 }
@@ -435,10 +443,20 @@ static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop)
 static void view3d_id_drop_copy(wmDrag *drag, wmDropBox *drop)
 {
        ID *id= (ID *)drag->poin;
-
+       
        RNA_string_set(drop->ptr, "name", id->name+2);
 }
 
+static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+       ID *id= (ID *)drag->poin;
+       
+       if(id)
+               RNA_string_set(drop->ptr, "name", id->name+2);
+       if(drag->path[0]) 
+               RNA_string_set(drop->ptr, "filepath", drag->path);
+}
+
 
 /* region dropbox definition */
 static void view3d_dropboxes(void)
@@ -447,7 +465,7 @@ static void view3d_dropboxes(void)
        
        WM_dropbox_add(lb, "OBJECT_OT_add_named_cursor", view3d_ob_drop_poll, view3d_ob_drop_copy);
        WM_dropbox_add(lb, "OBJECT_OT_drop_named_material", view3d_mat_drop_poll, view3d_id_drop_copy);
-       WM_dropbox_add(lb, "MESH_OT_drop_named_image", view3d_ima_drop_poll, view3d_id_drop_copy);
+       WM_dropbox_add(lb, "MESH_OT_drop_named_image", view3d_ima_drop_poll, view3d_id_path_drop_copy);
 }
 
 
@@ -505,13 +523,19 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
        switch(wmn->category) {
                case NC_ANIMATION:
                        switch(wmn->data) {
-                               case ND_KEYFRAME_EDIT:
                                case ND_KEYFRAME_PROP:
-                               case ND_NLA_EDIT:
                                case ND_NLA_ACTCHANGE:
-                               case ND_ANIMCHAN_SELECT:
                                        ED_region_tag_redraw(ar);
                                        break;
+                               case ND_NLA:
+                               case ND_KEYFRAME:
+                                       if (wmn->action == NA_EDITED)
+                                               ED_region_tag_redraw(ar);
+                                       break;
+                               case ND_ANIMCHAN:
+                                       if (wmn->action == NA_SELECTED)
+                                               ED_region_tag_redraw(ar);
+                                       break;
                        }
                        break;
                case NC_SCENE:
@@ -539,8 +563,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                                case ND_MODIFIER:
                                case ND_CONSTRAINT:
                                case ND_KEYS:
-                               case ND_PARTICLE_SELECT:
-                               case ND_PARTICLE_DATA:
+                               case ND_PARTICLE:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
@@ -564,7 +587,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                        break;
                case NC_BRUSH:
                        if(wmn->action == NA_EDITED)
-                               ED_region_tag_redraw(ar);
+                               ED_region_tag_redraw_overlay(ar);
                        break;                  
                case NC_MATERIAL:
                        switch(wmn->data) {
@@ -592,6 +615,10 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                         * more context than just the region */
                        ED_region_tag_redraw(ar);
                        break;
+               case NC_TEXTURE:        
+                       /* same as above */
+                       ED_region_tag_redraw(ar);
+                       break;
                case NC_SPACE:
                        if(wmn->data == ND_SPACE_VIEW3D) {
                                if (wmn->subtype == NS_VIEW3D_GPU) {
@@ -687,12 +714,15 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
        switch(wmn->category) {
                case NC_ANIMATION:
                        switch(wmn->data) {
-                               case ND_KEYFRAME_EDIT:
                                case ND_KEYFRAME_PROP:
-                               case ND_NLA_EDIT:
                                case ND_NLA_ACTCHANGE:
                                        ED_region_tag_redraw(ar);
                                        break;
+                               case ND_NLA:
+                               case ND_KEYFRAME:
+                                       if (wmn->action == NA_EDITED)
+                                               ED_region_tag_redraw(ar);
+                                       break;  
                        }
                        break;
                case NC_SCENE:
@@ -817,7 +847,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                                }
                        }
                }
-
+               CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
                return 1;
        }
        else if(CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) {
@@ -835,7 +865,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                                }
                        }
                }
-               
+               CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
                return 1;
        }
        else if(CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) {
@@ -851,7 +881,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                                }
                        }
                }
-               
+               CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
                return 1;
        }
        else if(CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) {
@@ -867,7 +897,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
                                }
                        }
                }
-               
+               CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
                return 1;
        }
        else if(CTX_data_equals(member, "active_base")) {