2.5: fix for use background image toggle in 3d view, it didn't
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 25 Jul 2009 22:22:47 +0000 (22:22 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 25 Jul 2009 22:22:47 +0000 (22:22 +0000)
allocate the right data.

release/ui/space_view3d.py
source/blender/makesrna/intern/rna_space.c

index c96960eb8576f6da0ec46e623e6bfb448cdc4e81..0d1a8fd7bc548901ee3a34f9925d41b626d5353e 100644 (file)
@@ -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)
index f04f3b7be68f69ce846b9ca8f87192c82bdc8152..8960714862d88c15dfd110a08b794d0f8a0d3ec6 100644 (file)
@@ -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");