Add ctrl-click rename to most lists in Blender UI and templates/examples.
authorBastien Montagne <montagne29@wanadoo.fr>
Sat, 23 Nov 2013 19:37:23 +0000 (20:37 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Sat, 23 Nov 2013 19:54:32 +0000 (20:54 +0100)
Notes:
* Did not touch to addons, that's up to the authors. ;)
* Did not removed any "name" field below lists. We might want to do this in some cases (less UI clutter), but probably not always, so will let maintainers of the related areas decide here.

13 files changed:
doc/python_api/examples/bpy.types.UIList.1.py
doc/python_api/examples/bpy.types.UIList.2.py
release/scripts/startup/bl_ui/properties_data_mesh.py
release/scripts/startup/bl_ui/properties_freestyle.py
release/scripts/startup/bl_ui/properties_mask_common.py
release/scripts/startup/bl_ui/properties_material.py
release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
release/scripts/startup/bl_ui/properties_render_layer.py
release/scripts/startup/bl_ui/properties_scene.py
release/scripts/startup/bl_ui/properties_texture.py
release/scripts/startup/bl_ui/space_clip.py
release/scripts/startup/bl_ui/space_node.py
release/scripts/templates_py/ui_list_simple.py

index 88f6b0999cd0070d440590cee39e3299ba7b4a00..92b115b2af4c42db8e4407b4b5b22405504ff390 100644 (file)
@@ -32,11 +32,14 @@ class MATERIAL_UL_matslots_example(bpy.types.UIList):
         ma = slot.material
         # draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code.
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            # You should always start your row layout by a label (icon + text), this will also make the row easily
-            # selectable in the list!
+            # You should always start your row layout by a label (icon + text), or a non-embossed text field,
+            # this will also make the row easily selectable in the list! The later also enables ctrl-click rename.
             # We use icon_value of label, as our given icon is an integer value, not an enum ID.
             # Note "data" names should never be translated!
-            layout.label(text=ma.name if ma else "", translate=False, icon_value=icon)
+            if ma:
+                layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
+            else:
+                layout.label(text="", translate=False, icon_value=icon)
             # And now we can add other UI stuff...
             # Here, we add nodes info if this material uses (old!) shading nodes.
             if ma and not context.scene.render.use_shading_nodes:
index 4e30e6895d6bbfe6e5b7e47bbd556fec9bf994a9..feed263b2e70436b2dbe37b8d49b6b93f2e1ee9b 100644 (file)
@@ -49,9 +49,9 @@ class MESH_UL_vgroups_slow(bpy.types.UIList):
                 col = layout.column()
                 col.enabled = False
                 col.alignment = 'LEFT'
-                col.label(text=vgroup.name, translate=False, icon_value=icon)
+                col.prop(vgroup, "name", text="", emboss=False, icon_value=icon)
             else:
-                layout.label(text=vgroup.name, translate=False, icon_value=icon)
+                layout.prop(vgroup, "name", text="", emboss=False, icon_value=icon)
             icon = 'LOCKED' if vgroup.lock_weight else 'UNLOCKED'
             layout.prop(vgroup, "lock_weight", text="", icon=icon, emboss=False)
         elif self.layout_type in {'GRID'}:
index 0ec22323092d4f4b31487548772a7cfbcd5ab063..87f745dc4a10daca05fb773b17719fff3d6e7835 100644 (file)
@@ -80,7 +80,7 @@ class MESH_UL_shape_keys(UIList):
         key_block = item
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
             split = layout.split(0.66, False)
-            split.label(text=item.name, translate=False, icon_value=icon)
+            split.prop(key_block, "name", text="", emboss=False, icon_value=icon)
             row = split.row(align=True)
             if key_block.mute or (obj.mode == 'EDIT' and not (obj.use_shape_key_edit_mode and obj.type == 'MESH')):
                 row.active = False
@@ -98,7 +98,7 @@ class MESH_UL_uvmaps_vcols(UIList):
     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
         # assert(isinstance(item, (bpy.types.MeshTexturePolyLayer, bpy.types.MeshLoopColorLayer))
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            layout.label(text=item.name, translate=False, icon_value=icon)
+            layout.prop(item, "name", text="", emboss=False, icon_value=icon)
             icon = 'RESTRICT_RENDER_OFF' if item.active_render else 'RESTRICT_RENDER_ON'
             layout.prop(item, "active_render", text="", icon=icon, emboss=False)
         elif self.layout_type in {'GRID'}:
index a57567ae79ea731443c9eeba81d0015af15e359f..607e4cc521e0feb020c628e93a33ad387b8d59af 100644 (file)
@@ -97,7 +97,7 @@ class RENDERLAYER_UL_linesets(UIList):
     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
         lineset = item
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            layout.label(lineset.name, icon_value=icon)
+            layout.prop(lineset, "name", text="", emboss=False, icon_value=icon)
             layout.prop(lineset, "show_render", text="", index=index)
         elif self.layout_type in {'GRID'}:
             layout.alignment = 'CENTER'
index 203e5078ee4aae58142e5d8b9785deee09c62f49..b6f3cf9353121230e85e165a44bc3fc4066bff82 100644 (file)
@@ -31,7 +31,7 @@ class MASK_UL_layers(UIList):
         # assert(isinstance(item, bpy.types.MaskLayer)
         mask = item
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            layout.label(text=mask.name, translate=False, icon_value=icon)
+            layout.prop(mask, "name", text="", emboss=False, icon_value=icon)
             row = layout.row(align=True)
             row.prop(mask, "hide", text="", emboss=False)
             row.prop(mask, "hide_select", text="", emboss=False)
index 344074c5893c620aa20cd88d06035a63c6fb8456..d48c4957e6e686e213e354f9daacabb6267fe804 100644 (file)
@@ -77,7 +77,10 @@ class MATERIAL_UL_matslots(UIList):
         slot = item
         ma = slot.material
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            layout.label(text=ma.name if ma else "", translate=False, icon_value=icon)
+            if ma:
+                layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
+            else:
+                layout.label(text="", icon_value=icon)
             if ma and not context.scene.render.use_shading_nodes:
                 manode = ma.active_node_material
                 if manode:
index f0c7a532414665adc6111add32f19c340607e40c..898e385ce3db86f2c5d1dd440df6da26fcebec00 100644 (file)
@@ -33,7 +33,7 @@ class PHYSICS_UL_dynapaint_surfaces(UIList):
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
             row = layout.row(align=True)
             row.label(text="", icon_value=icon)
-            row.label(text=surf.name, translate=False, icon_value=sticon)
+            row.prop(surf, "name", text="", emboss=False, icon_value=sticon)
             row = layout.row(align=True)
             if surf.use_color_preview:
                 row.prop(surf, "show_preview", text="", emboss=False,
index dcc4508f0865b261115eaf897ab06aa48de34b99..6a44feeaac61544a80c37e37e80486e533088817 100644 (file)
@@ -38,7 +38,7 @@ class RENDERLAYER_UL_renderlayers(UIList):
         # assert(isinstance(item, bpy.types.SceneRenderLayer)
         layer = item
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            layout.label(layer.name, icon_value=icon, translate=False)
+            layout.prop(layer, "name", text="", icon_value=icon, emboss=False)
             layout.prop(layer, "use", text="", index=index)
         elif self.layout_type in {'GRID'}:
             layout.alignment = 'CENTER'
index 91a5abd0ad0ddc65b52547f06168d8bacb6676d3..34143c77998d85645e4bcbbf49dc5867d6711d47 100644 (file)
@@ -33,6 +33,7 @@ class SCENE_UL_keying_set_paths(UIList):
         kspath = item
         icon = layout.enum_item_icon(kspath, "id_type", kspath.id_type)
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
+            # Do not make this one editable in uiList for now...
             layout.label(text=kspath.data_path, translate=False, icon_value=icon)
         elif self.layout_type in {'GRID'}:
             layout.alignment = 'CENTER'
index 023b3a138485c9e6865c39655dc87d39811b2cdc..c03ea1c5422a4de1dcf0ca9481732bcffdfe40e0 100644 (file)
@@ -63,7 +63,10 @@ class TEXTURE_UL_texslots(UIList):
         slot = item
         tex = slot.texture if slot else None
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            layout.label(text=tex.name if tex else "", translate=False, icon_value=icon)
+            if tex:
+                layout.prop(tex, "name", text="", emboss=False, icon_value=icon)
+            else:
+                layout.label(text="", icon_value=icon)
             if tex and isinstance(item, bpy.types.MaterialTextureSlot):
                 layout.prop(ma, "use_textures", text="", index=index)
         elif self.layout_type in {'GRID'}:
index 3db8697a45795d1f3a5035a6f114860b89c28cd5..19f1563c4fb3cb824b927c684fa62214149e16fb 100644 (file)
@@ -29,9 +29,9 @@ class CLIP_UL_tracking_objects(UIList):
         # assert(isinstance(item, bpy.types.MovieTrackingObject)
         tobj = item
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            layout.label(text=tobj.name, translate=False,
-                         icon='CAMERA_DATA' if tobj.is_camera
-                         else 'OBJECT_DATA')
+            layout.prop(tobj, "name", text="", emboss=False,
+                        icon='CAMERA_DATA' if tobj.is_camera
+                        else 'OBJECT_DATA')
         elif self.layout_type in {'GRID'}:
             layout.alignment = 'CENTER'
             layout.label(text="",
index 46234b638ebc1bd554effc5c3aaa03b9115f1ad7..9750d7bac0d32a3ded7f5133400919a4adb298ab 100644 (file)
@@ -410,7 +410,7 @@ class NODE_UL_interface_sockets(bpy.types.UIList):
             if not socket.is_output:
                 row.template_node_socket(color)
 
-            row.label(text=socket.name, icon_value=icon)
+            row.prop(socket, "name", text="", emboss=False, icon_value=icon)
 
             # outputs get icon on the right
             if socket.is_output:
index 815d62ad73403c76a15bf909878a4e3cf7aad6cc..e911a0dd23679a200025fa787ad687e273396e55 100644 (file)
@@ -20,11 +20,14 @@ class MATERIAL_UL_matslots_example(bpy.types.UIList):
         ma = slot.material
         # draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code.
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            # You should always start your row layout by a label (icon + text), this will also make the row easily
-            # selectable in the list!
+            # You should always start your row layout by a label (icon + text), or a non-embossed text field,
+            # this will also make the row easily selectable in the list! The later also enables ctrl-click rename.
             # We use icon_value of label, as our given icon is an integer value, not an enum ID.
             # Note "data" names should never be translated!
-            layout.label(text=ma.name if ma else "", translate=False, icon_value=icon)
+            if ma:
+                layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
+            else:
+                layout.label(text="", translate=False, icon_value=icon)
             # And now we can add other UI stuff...
             # Here, we add nodes info if this material uses (old!) shading nodes.
             if ma and not context.scene.render.use_shading_nodes: