Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRedMser <RedMser>2022-04-14 11:56:08 +0300
committerSybren A. Stüvel <sybren@blender.org>2022-04-14 11:58:14 +0300
commitd6e72412373e2f90969b2f2a6ecfcb420011784b (patch)
tree192a0e71c9760e6d9fe1ed66aa16afda34adce13 /release/scripts/startup/bl_ui/space_topbar.py
parent4fa3eadce99a87de90b8119e49cfd8ccba56c305 (diff)
Animation: Add F2 for renaming markers
F2 allows renaming lots of different types of active items, and now it also works for markers. Before, Ctrl+M was used, and it's context-sensitive: you often get "Mirror Keys" instead, when your cursor isn't on the markers region, and that operator has nothing to do with either renaming or markers. **What this commit does:** - Replace Ctrl+M shortcut with F2. - Adds the `TOPBAR_PT_name_marker` panel which is implemented similar to the global rename panel. This having to press enter twice to confirm or escape twice to cancel, which would happen if the `marker.rename` operator was called directly. - Replace usages of `marker.rename` in the UI with `wm.call_panel`. - To make the Industry Compatible keymap consistent with Blender Default, the rename shortcut only works when hovering the markers area. Reviewed By: ChrisLend, sybren Differential Revision: https://developer.blender.org/D12298
Diffstat (limited to 'release/scripts/startup/bl_ui/space_topbar.py')
-rw-r--r--release/scripts/startup/bl_ui/space_topbar.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 55dcb4a20eb..2cf50bdbf95 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -851,6 +851,64 @@ class TOPBAR_PT_name(Panel):
row.label(text="No active item")
+class TOPBAR_PT_name_marker(Panel):
+ bl_space_type = 'TOPBAR' # dummy
+ bl_region_type = 'HEADER'
+ bl_label = "Rename Marker"
+ bl_ui_units_x = 14
+
+ @staticmethod
+ def is_using_pose_markers(context):
+ sd = context.space_data
+ return (sd.type == 'DOPESHEET_EDITOR' and sd.mode in {'ACTION', 'SHAPEKEY'} and
+ sd.show_pose_markers and sd.action)
+
+ @staticmethod
+ def get_selected_marker(context):
+ if TOPBAR_PT_name_marker.is_using_pose_markers(context):
+ markers = context.space_data.action.pose_markers
+ else:
+ markers = context.scene.timeline_markers
+
+ for marker in markers:
+ if marker.select:
+ return marker
+ return None
+
+ @staticmethod
+ def row_with_icon(layout, icon):
+ row = layout.row()
+ row.activate_init = True
+ row.label(icon=icon)
+ return row
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.label(text="Marker Name")
+
+ scene = context.scene
+ if scene.tool_settings.lock_markers:
+ row = self.row_with_icon(layout, 'ERROR')
+ label = "Markers are locked"
+ row.label(text=label)
+ return
+
+ marker = self.get_selected_marker(context)
+ if marker is None:
+ row = self.row_with_icon(layout, 'ERROR')
+ row.label(text="No active marker")
+ return
+
+ icon = 'TIME'
+ if marker.camera is not None:
+ icon = 'CAMERA_DATA'
+ elif self.is_using_pose_markers(context):
+ icon = 'ARMATURE_DATA'
+ row = self.row_with_icon(layout, icon)
+ row.prop(marker, "name", text="")
+
+
classes = (
TOPBAR_HT_upper_bar,
TOPBAR_MT_file_context_menu,
@@ -877,6 +935,7 @@ classes = (
TOPBAR_PT_gpencil_layers,
TOPBAR_PT_gpencil_primitive,
TOPBAR_PT_name,
+ TOPBAR_PT_name_marker,
)
if __name__ == "__main__": # only for live edit.