Add ctrl-click rename to most lists in Blender UI and templates/examples.

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.
This commit is contained in:
Bastien Montagne 2013-11-23 20:37:23 +01:00
parent 5009346907
commit 4c52e737df
Notes: blender-bot 2023-02-14 11:28:45 +01:00
Referenced by issue #37830, UILists text now right align
13 changed files with 33 additions and 20 deletions

View 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:

View 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'}:

View 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'}:

View 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'

View 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)

View 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:

View 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,

View 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'

View 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'

View 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'}:

View 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="",

View 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:

View 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: