Revision: 33884
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33884
Author:   ton
Date:     2010-12-24 11:15:57 +0100 (Fri, 24 Dec 2010)

Log Message:
-----------
Bugfix #25365

Property buttons: the "ID template" allowed to unlink data from object,
like Mesh or Curve etc, which is not supported. Button now is hidden.
Thanks Dan Eicher for patch.

Also: improved tooltip for 'data browse'. It was generic, now it gives
specific per-type information.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_data_armature.py
    trunk/blender/release/scripts/ui/properties_data_curve.py
    trunk/blender/release/scripts/ui/properties_data_mesh.py
    trunk/blender/release/scripts/ui/properties_data_metaball.py
    trunk/blender/release/scripts/ui/properties_object.py
    trunk/blender/source/blender/editors/interface/interface_templates.c

Modified: trunk/blender/release/scripts/ui/properties_data_armature.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_data_armature.py        
2010-12-24 07:46:40 UTC (rev 33883)
+++ trunk/blender/release/scripts/ui/properties_data_armature.py        
2010-12-24 10:15:57 UTC (rev 33884)
@@ -42,13 +42,10 @@
         arm = context.armature
         space = context.space_data
 
-        split = layout.split(percentage=0.65)
         if ob:
-            split.template_ID(ob, "data")
-            split.separator()
+            layout.template_ID(ob, "data", unlink="None")
         elif arm:
-            split.template_ID(space, "pin_id")
-            split.separator()
+            layout.template_ID(space, "pin_id", unlink="None")
 
 
 class DATA_PT_skeleton(ArmatureButtonsPanel, bpy.types.Panel):

Modified: trunk/blender/release/scripts/ui/properties_data_curve.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_data_curve.py   2010-12-24 
07:46:40 UTC (rev 33883)
+++ trunk/blender/release/scripts/ui/properties_data_curve.py   2010-12-24 
10:15:57 UTC (rev 33884)
@@ -59,14 +59,10 @@
         curve = context.curve
         space = context.space_data
 
-        split = layout.split(percentage=0.65)
-
         if ob:
-            split.template_ID(ob, "data")
-            split.separator()
+            layout.template_ID(ob, "data", unlink="None")
         elif curve:
-            split.template_ID(space, "pin_id")
-            split.separator()
+            layout.template_ID(space, "pin_id", unlink="None") # XXX: broken
 
 
 class DATA_PT_shape_curve(CurveButtonsPanel, bpy.types.Panel):

Modified: trunk/blender/release/scripts/ui/properties_data_mesh.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_data_mesh.py    2010-12-24 
07:46:40 UTC (rev 33883)
+++ trunk/blender/release/scripts/ui/properties_data_mesh.py    2010-12-24 
10:15:57 UTC (rev 33884)
@@ -70,13 +70,10 @@
         mesh = context.mesh
         space = context.space_data
 
-        split = layout.split(percentage=0.65)
         if ob:
-            split.template_ID(ob, "data")
-            split.separator()
+            layout.template_ID(ob, "data", unlink="None")
         elif mesh:
-            split.template_ID(space, "pin_id")
-            split.separator()
+            layout.template_ID(space, "pin_id", unlink="None")
 
 
 class DATA_PT_normals(MeshButtonsPanel, bpy.types.Panel):

Modified: trunk/blender/release/scripts/ui/properties_data_metaball.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_data_metaball.py        
2010-12-24 07:46:40 UTC (rev 33883)
+++ trunk/blender/release/scripts/ui/properties_data_metaball.py        
2010-12-24 10:15:57 UTC (rev 33884)
@@ -42,13 +42,10 @@
         mball = context.meta_ball
         space = context.space_data
 
-        split = layout.split(percentage=0.65)
         if ob:
-            split.template_ID(ob, "data")
-            split.separator()
+            layout.template_ID(ob, "data", unlink="None")
         elif mball:
-            split.template_ID(space, "pin_id")
-            split.separator()
+            layout.template_ID(space, "pin_id", unlink="None")
 
 
 class DATA_PT_metaball(DataButtonsPanel, bpy.types.Panel):

Modified: trunk/blender/release/scripts/ui/properties_object.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_object.py       2010-12-24 
07:46:40 UTC (rev 33883)
+++ trunk/blender/release/scripts/ui/properties_object.py       2010-12-24 
10:15:57 UTC (rev 33884)
@@ -36,11 +36,11 @@
         space = context.space_data
         ob = context.object
 
-        row = layout.row()
-        row.label(text="", icon='OBJECT_DATA')
         if space.use_pin_id:
-            row.template_ID(space, "pin_id")
+            layout.template_ID(space, "pin_id", unlink="None")
         else:
+            row = layout.row()
+            row.label(text="", icon='OBJECT_DATA')
             row.prop(ob, "name", text="")
 
 

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c        
2010-12-24 07:46:40 UTC (rev 33883)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c        
2010-12-24 10:15:57 UTC (rev 33884)
@@ -292,6 +292,35 @@
        }
 }
 
+static const char *template_id_browse_tip(StructRNA *type)
+{
+       if(type) {
+               switch(RNA_type_to_ID_code(type)) {
+                       case ID_SCE: return "Browse Scene to be linked";
+                       case ID_OB: return "Browse Object to be linked";
+                       case ID_ME: return "Browse Mesh Data to be linked";
+                       case ID_CU: return "Browse Curve Data to be linked";
+                       case ID_MB: return "Browse MetaBall Data to be linked";
+                       case ID_MA: return "Browse Material to be linked";
+                       case ID_TE: return "Browse Texture to be linked";
+                       case ID_IM: return "Browse Image to be linked";
+                       case ID_LA: return "Browse Lattice Data to be linked";
+                       case ID_CA: return "Browse Camera Data to be linked";
+                       case ID_WO: return "Browse World Settings to be linked";
+                       case ID_SCR: return "Choose Screen lay-out";
+                       case ID_TXT: return "Browse Text to be linked";
+                       case ID_SO: return "Browse Sound to be linked";
+                       case ID_AR: return "Browse Armature data to be linked";
+                       case ID_AC: return "Browse Action to be linked";
+                       case ID_NT: return "Browse Node Tree to be linked";
+                       case ID_BR: return "Browse Brush to be linked";
+                       case ID_PA: return "Browse Particle System to be 
linked";
+                       case ID_GD: return "Browse Grease Pencil Data to be 
linked";
+               }
+       }
+       return "Browse ID data to be linked";
+}
+
 static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, 
StructRNA *type, int flag, const char *newop, const char *openop, const char 
*unlinkop)
 {
        uiBut *but;
@@ -313,7 +342,7 @@
 
        if(flag & UI_ID_PREVIEWS) {
 
-               but= uiDefBlockButN(block, id_search_menu, 
MEM_dupallocN(template), "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, "Browse ID data");
+               but= uiDefBlockButN(block, id_search_menu, 
MEM_dupallocN(template), "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, 
template_id_browse_tip(type));
                if(type) {
                        but->icon= RNA_struct_ui_icon(type);
                        if (id) but->icon = ui_id_icon_get(C, id, 1);
@@ -327,7 +356,7 @@
        } else 
                
        if(flag & UI_ID_BROWSE) {
-               but= uiDefBlockButN(block, id_search_menu, 
MEM_dupallocN(template), "", 0, 0, UI_UNIT_X*1.6, UI_UNIT_Y, "Browse ID data");
+               but= uiDefBlockButN(block, id_search_menu, 
MEM_dupallocN(template), "", 0, 0, UI_UNIT_X*1.6, UI_UNIT_Y, 
template_id_browse_tip(type));
                if(type) {
                        but->icon= RNA_struct_ui_icon(type);
                        /* default dragging of icon for id browse buttons */
@@ -428,7 +457,7 @@
                        uiButSetNFunc(but, NULL, MEM_dupallocN(template), 0);
                }
                else {
-                       but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, 
UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Unlink datablock, Shift + Click to 
force removal on save");
+                       but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, 
UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Unlink datablock. Shift + Click to set 
users to zero, data gets not saved");
                        uiButSetNFunc(but, template_id_cb, 
MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE));
 
                        if(RNA_property_flag(template->prop) & PROP_NEVER_NULL)
@@ -465,7 +494,9 @@
                flag |= UI_ID_ADD_NEW;
        if(openop)
                flag |= UI_ID_OPEN;
-       
+       if(unlinkop && strcmp(unlinkop, "None") == 0)
+               flag &= ~UI_ID_DELETE;
+
        type= RNA_property_pointer_type(ptr, prop);
        template->idlb= which_libbase(CTX_data_main(C), 
RNA_type_to_ID_code(type));
        


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to