Some drawing code simplification

This commit is contained in:
Sybren A. Stüvel 2018-10-30 11:29:32 +01:00
parent 0562d57513
commit 641b51496a

View File

@ -189,28 +189,41 @@ class ATTRACT_PT_tools(AttractPollMixin, Panel):
layout = self.layout
strip_types = {'MOVIE', 'IMAGE', 'META', 'COLOR'}
selshots = list(selected_shots(context))
if strip and strip.type in strip_types and strip.atc_object_id:
self._draw_attractstrip_buttons(context, strip)
elif context.selected_sequences:
if len(context.selected_sequences) > 1:
noun = 'Selected Strips'
else:
noun = 'This Strip'
layout.operator(ATTRACT_OT_submit_selected.bl_idname,
text='Submit %s as New Shot' % noun)
layout.operator('attract.shot_relink')
else:
layout.operator(ATTRACT_OT_submit_all.bl_idname)
def _draw_attractstrip_buttons(self, context, strip):
"""Draw buttons when selected strips are Attract shots."""
layout = self.layout
selshots = list(selected_shots(context))
if len(selshots) > 1:
noun = '%i Shots' % len(selshots)
else:
noun = 'This Shot'
if strip.atc_object_id_conflict:
warnbox = layout.box()
warnbox.alert = True
warnbox.label(text='Warning: This shot is linked to multiple sequencer strips.',
icon='ERROR')
layout.prop(strip, 'atc_name', text='Name')
layout.prop(strip, 'atc_status', text='Status')
# Create a special sub-layout for read-only properties.
ro_sub = layout.column(align=True)
ro_sub.enabled = False
ro_sub.prop(strip, 'atc_description', text='Description')
ro_sub.prop(strip, 'atc_notes', text='Notes')
if strip.atc_is_synced:
sub = layout.column(align=True)
row = sub.row(align=True)
@ -239,17 +252,6 @@ class ATTRACT_PT_tools(AttractPollMixin, Panel):
text='Delete %s' % noun,
icon='CANCEL')
elif context.selected_sequences:
if len(context.selected_sequences) > 1:
noun = 'Selected Strips'
else:
noun = 'This Strip'
layout.operator(ATTRACT_OT_submit_selected.bl_idname,
text='Submit %s as New Shot' % noun)
layout.operator('attract.shot_relink')
else:
layout.operator(ATTRACT_OT_submit_all.bl_idname)
class AttractOperatorMixin(AttractPollMixin):
"""Mix-in class for all Attract operators."""
@ -957,6 +959,7 @@ def deactivate():
_rna_classes = [cls for cls in locals().values()
if isinstance(cls, type) and cls.__name__.startswith('ATTRACT')]
log.info('RNA classes:\n%s', '\n'.join([repr(cls) for cls in _rna_classes]))
def register():