diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-12-29 02:19:38 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-12-29 02:19:38 +0300 |
commit | 7c438e5366b22eeace2f2e9872e26519c5d5eb01 (patch) | |
tree | c1625d8c967a8128a4ae0a8a9acc042f13f8fae7 /release/scripts | |
parent | 363cf1152fcbbe5fcd1a0b07833c1cf0370dba74 (diff) |
Cleanup: avoid counting list multiple times
Also simplify selected sequencer length function.
Diffstat (limited to 'release/scripts')
-rw-r--r-- | release/scripts/startup/bl_ui/space_sequencer.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 171e4c38d01..c328efc11d1 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -36,10 +36,7 @@ def act_strip(context): def sel_sequences(context): - try: - return len(context.selected_sequences) if context.selected_sequences else 0 - except AttributeError: - return 0 + return len(getattr(context, "selected_sequences", ())) def draw_color_balance(layout, color_balance): @@ -318,29 +315,35 @@ class SEQUENCER_MT_add(Menu): layout = self.layout layout.operator_context = 'INVOKE_REGION_WIN' - if len(bpy.data.scenes) > 10: + bpy_data_scenes_len = len(bpy.data.scenes) + if bpy_data_scenes_len > 10: layout.operator_context = 'INVOKE_DEFAULT' layout.operator("sequencer.scene_strip_add", text="Scene...", icon='SCENE_DATA') - elif len(bpy.data.scenes) > 1: + elif bpy_data_scenes_len > 1: layout.operator_menu_enum("sequencer.scene_strip_add", "scene", text="Scene", icon='SCENE_DATA') else: layout.menu("SEQUENCER_MT_add_empty", text="Scene", icon='SCENE_DATA') + del bpy_data_scenes_len - if len(bpy.data.movieclips) > 10: + bpy_data_movieclips_len = len(bpy.data.movieclips) + if bpy_data_movieclips_len > 10: layout.operator_context = 'INVOKE_DEFAULT' layout.operator("sequencer.movieclip_strip_add", text="Clip...", icon='CLIP') - elif len(bpy.data.movieclips) > 0: + elif bpy_data_movieclips_len > 0: layout.operator_menu_enum("sequencer.movieclip_strip_add", "clip", text="Clip", icon='CLIP') else: layout.menu("SEQUENCER_MT_add_empty", text="Clip", icon='CLIP') + del bpy_data_movieclips_len - if len(bpy.data.masks) > 10: + bpy_data_masks_len = len(bpy.data.masks) + if bpy_data_masks_len > 10: layout.operator_context = 'INVOKE_DEFAULT' layout.operator("sequencer.mask_strip_add", text="Mask...", icon='MOD_MASK') - elif len(bpy.data.masks) > 0: + elif bpy_data_masks_len > 0: layout.operator_menu_enum("sequencer.mask_strip_add", "mask", text="Mask", icon='MOD_MASK') else: layout.menu("SEQUENCER_MT_add_empty", text="Mask", icon='MOD_MASK') + del bpy_data_masks_len layout.separator() |