diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-20 15:21:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-20 15:39:50 +0300 |
commit | 8b9b3422eb1528339173142976e04544979f15e5 (patch) | |
tree | cdb1ce3f140b69a4e160951a65a1ceebee24a137 /release/scripts | |
parent | 1b1b60459686de36cb8e307d8fce711bc6cf87af (diff) |
UI: popup panel for renaming the active item
In 2.79 there was an "Item" panel with only to give access to rename
from the 3D view.
Add this functionality for context sensitive renaming.
Currently this works for objects/bones/sequence strips & nodes.
This uses F2 for a window level shortcut, replacing the file-io menu.
See: T61480
Diffstat (limited to 'release/scripts')
-rw-r--r-- | release/scripts/presets/keyconfig/keymap_data/blender_default.py | 2 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_topbar.py | 74 |
2 files changed, 75 insertions, 1 deletions
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index c9b271c57ca..6fffad012df 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -347,7 +347,7 @@ def km_window(params): # New shortcuts items.extend([ ("wm.doc_view_manual_ui_context", {"type": 'F1', "value": 'PRESS'}, None), - op_menu("TOPBAR_MT_file_context_menu", {"type": 'F2', "value": 'PRESS'}), + op_panel("TOPBAR_PT_name", {"type": 'F2', "value": 'PRESS'}, [("keep_open", False)]), ("wm.search_menu", {"type": 'F3', "value": 'PRESS'}, None), op_menu("TOPBAR_MT_window_context_menu", {"type": 'F4', "value": 'PRESS'}), ]) diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index a3e4d6c2565..28658141427 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -815,6 +815,11 @@ class TOPBAR_MT_edit(Menu): layout.separator() + # Mainly to expose shortcut since this depends on the context. + props = layout.operator("wm.call_panel", text="Rename Active Item...", icon='OUTLINER_DATA_FONT') + props.name = "TOPBAR_PT_name" + props.keep_open = False + layout.operator("wm.search_menu", text="Operator Search...", icon='VIEWZOOM') layout.separator() @@ -1067,6 +1072,74 @@ class TOPBAR_PT_gpencil_fill(Panel): row.prop(gp_settings, "fill_threshold", text="Threshold") +# Only a popover +class TOPBAR_PT_name(Panel): + bl_space_type = 'TOPBAR' # dummy + bl_region_type = 'WINDOW' + bl_label = "Rename Active Item" + bl_ui_units_x = 14 + + @classmethod + def poll(cls, context): + return True + + def draw(self, context): + layout = self.layout + + # Edit first editable button in popup + def row_with_icon(layout, icon): + row = layout.row() + row.activate_init = True + row.label(icon=icon) + return row + + mode = context.mode + scene = context.scene + space = context.space_data + space_type = None if (space is None) else space.type + found = False + if space_type == 'SEQUENCE_EDITOR': + layout.label(text="Sequence Strip Name") + item = getattr(scene.sequence_editor, "active_strip") + if item: + row = row_with_icon(layout, 'SEQUENCE') + row.prop(item, "name", text="") + found = True + elif space_type == 'NODE_EDITOR': + layout.label(text="Node Name") + item = context.active_node + if item: + row = row_with_icon(layout, 'NODE') + row.prop(item, "name", text="") + found = True + else: + if mode == 'POSE' or (mode == 'WEIGHT_PAINT' and context.pose_object): + layout.label(text="Bone Name") + item = getattr(context.active_pose_bone, "bone", None) + if item: + row = row_with_icon(layout, 'BONE_DATA') + row.prop(item, "name", text="", icon='OBJECT_DATA') + found = True + elif mode == 'EDIT_ARMATURE': + layout.label(text="Bone Name") + item = context.active_bone + if item: + row = row_with_icon(layout, 'BONE_DATA') + row.prop(item, "name", text="") + found = True + else: + layout.label(text="Object Name") + item = context.object + if item: + row = row_with_icon(layout, 'OBJECT_DATA') + row.prop(item, "name", text="") + found = True + + if not found: + row = row_with_icon(layout, 'ERROR') + row.label(text="No active item") + + classes = ( TOPBAR_HT_upper_bar, TOPBAR_HT_lower_bar, @@ -1089,6 +1162,7 @@ classes = ( TOPBAR_PT_gpencil_layers, TOPBAR_PT_gpencil_primitive, TOPBAR_PT_gpencil_fill, + TOPBAR_PT_name, ) if __name__ == "__main__": # only for live edit. |