diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-18 18:28:45 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-18 18:28:45 +0400 |
commit | cc314e442c1dfc6646be0d04675c3dc16cfc2eaf (patch) | |
tree | 5e4b7b9931e16cf8bc0aa647f2cdbac3f3bfa28e /source/blender | |
parent | d498dd393970c4bfddaf3236433171c4274776d8 (diff) |
Rename bgpic.add() to bgpic.new() to correspond others collections like
render layers, vertices groups and so.
Also added bgpig.remove() function to remove specified picture.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 28 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 21 |
3 files changed, 37 insertions, 15 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 82a1e6f1f00..6536741af00 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -290,6 +290,7 @@ void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d); /* copy the view to the camera, return TRUE if */ int ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); -struct BGpic *ED_view3D_background_image_add(struct View3D *v3d); +struct BGpic *ED_view3D_background_image_new(struct View3D *v3d); +void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic); #endif /* ED_VIEW3D_H */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 7eaa5d42dd0..771accd462b 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2944,7 +2944,7 @@ static BGpic *background_image_add(bContext *C) { View3D *v3d= CTX_wm_view3d(C); - return ED_view3D_background_image_add(v3d); + return ED_view3D_background_image_new(v3d); } static int background_image_add_exec(bContext *C, wmOperator *UNUSED(op)) @@ -3014,16 +3014,13 @@ void VIEW3D_OT_background_image_add(wmOperatorType *ot) /* ***** remove image operator ******* */ static int background_image_remove_exec(bContext *C, wmOperator *op) { - View3D *vd = CTX_wm_view3d(C); + View3D *v3d = CTX_wm_view3d(C); int index = RNA_int_get(op->ptr, "index"); - BGpic *bgpic_rem= BLI_findlink(&vd->bgpicbase, index); + BGpic *bgpic_rem= BLI_findlink(&v3d->bgpicbase, index); if(bgpic_rem) { - BLI_remlink(&vd->bgpicbase, bgpic_rem); - if(bgpic_rem->ima) id_us_min(&bgpic_rem->ima->id); - if(bgpic_rem->clip) id_us_min(&bgpic_rem->clip->id); - MEM_freeN(bgpic_rem); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, vd); + ED_view3D_background_image_remove(v3d, bgpic_rem); + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } else { @@ -3529,7 +3526,7 @@ void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], co object_apply_mat4(ob, mat, TRUE, TRUE); } -BGpic *ED_view3D_background_image_add(View3D *v3d) +BGpic *ED_view3D_background_image_new(View3D *v3d) { BGpic *bgpic= MEM_callocN(sizeof(BGpic), "Background Image"); @@ -3543,3 +3540,16 @@ BGpic *ED_view3D_background_image_add(View3D *v3d) return bgpic; } + +void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic) +{ + BLI_remlink(&v3d->bgpicbase, bgpic); + + if(bgpic->ima) + id_us_min(&bgpic->ima->id); + + if(bgpic->clip) + id_us_min(&bgpic->clip->id); + + MEM_freeN(bgpic); +} diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 8fb232332d5..393ffa69cbc 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -891,15 +891,22 @@ static void rna_BackgroundImage_opacity_set(PointerRNA *ptr, float value) bgpic->blend = 1.0f - value; } -static BGpic *rna_BackgroundImage_add(View3D *v3d) +static BGpic *rna_BackgroundImage_new(View3D *v3d) { - BGpic *bgpic= ED_view3D_background_image_add(v3d);; + BGpic *bgpic= ED_view3D_background_image_new(v3d); - WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, v3d); return bgpic; } +static void rna_BackgroundImage_remove(View3D *v3d, BGpic *bgpic) +{ + ED_view3D_background_image_remove(v3d, bgpic); + + WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, v3d); +} + /* Space Node Editor */ static int rna_SpaceNodeEditor_node_tree_poll(PointerRNA *ptr, PointerRNA value) @@ -1307,11 +1314,15 @@ static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_sdna(srna, "View3D"); RNA_def_struct_ui_text(srna, "Background Images", "Collection of background images"); - func= RNA_def_function(srna, "add", "rna_BackgroundImage_add"); + func= RNA_def_function(srna, "new", "rna_BackgroundImage_new"); RNA_def_function_ui_description(func, "Add new background image"); - parm= RNA_def_pointer(func, "image", "BackgroundImage", "", "Image displayed as viewport background"); RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_BackgroundImage_remove"); + RNA_def_function_ui_description(func, "Remove background image"); + parm= RNA_def_pointer(func, "image", "BackgroundImage", "", "Image displayed as viewport background"); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } static void rna_def_space_view3d(BlenderRNA *brna) |