2.5: fix for use background image toggle in 3d view, it didn't

allocate the right data.
This commit is contained in:
Brecht Van Lommel 2009-07-25 22:22:47 +00:00
parent 580d000f8f
commit 5d240af42b
2 changed files with 37 additions and 12 deletions

@ -182,18 +182,20 @@ class VIEW3D_PT_background_image(bpy.types.Panel):
layout = self.layout
view = context.space_data
bg = context.space_data.background_image
layout.active = view.display_background_image
split = layout.split()
col = split.column()
col.itemR(bg, "image")
# col.itemR(bg, "image_user")
col.itemR(bg, "size")
col.itemR(bg, "transparency", slider=True)
col.itemL(text="Offset:")
col.itemR(bg, "x_offset", text="X")
col.itemR(bg, "y_offset", text="Y")
bg = view.background_image
if bg:
layout.active = view.display_background_image
split = layout.split()
col = split.column()
col.itemR(bg, "image", text="")
#col.itemR(bg, "image_user")
col.itemR(bg, "size")
col.itemR(bg, "transparency", slider=True)
col.itemL(text="Offset:")
col.itemR(bg, "x_offset", text="X")
col.itemR(bg, "y_offset", text="Y")
bpy.types.register(VIEW3D_MT_view_navigation)
bpy.types.register(VIEW3D_MT_view)

@ -287,6 +287,22 @@ static void rna_ConsoleLine_cursor_index_range(PointerRNA *ptr, int *min, int *m
*max= ci->len;
}
static void rna_View3D_display_background_image_set(PointerRNA *ptr, int value)
{
View3D *vd= (View3D*)ptr->data;
if(value) vd->flag |= V3D_DISPBGPIC;
else vd->flag &= ~V3D_DISPBGPIC;
if((vd->flag & V3D_DISPBGPIC) && vd->bgpic == NULL) {
vd->bgpic= MEM_callocN(sizeof(BGpic), "bgpic");
vd->bgpic->size= 5.0;
vd->bgpic->blend= 0.5;
vd->bgpic->iuser.fie_ima= 2;
vd->bgpic->iuser.ok= 1;
}
}
#else
static void rna_def_space(BlenderRNA *brna)
@ -454,6 +470,7 @@ static void rna_def_background_image(BlenderRNA *brna)
prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "ima");
RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space.");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, NULL);
prop= RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL);
@ -612,6 +629,7 @@ static void rna_def_space_3dview(BlenderRNA *brna)
RNA_def_property_update(prop, NC_WINDOW, NULL);
prop= RNA_def_property(srna, "display_background_image", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, NULL, "rna_View3D_display_background_image_set");
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_DISPBGPIC);
RNA_def_property_ui_text(prop, "Display Background Image", "Display a reference image behind objects in the 3D View");
RNA_def_property_update(prop, NC_WINDOW, NULL);
@ -701,6 +719,11 @@ static void rna_def_space_buttons(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Align", "Arrangement of the panels.");
RNA_def_property_update(prop, NC_WINDOW, NULL);
prop= RNA_def_property(srna, "brush_texture", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SB_BRUSH_TEX);
RNA_def_property_ui_text(prop, "Brush Texture", "Show brush textures.");
RNA_def_property_update(prop, NC_WINDOW, NULL);
/* pinned data */
prop= RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "pinid");