Clip editor: cleanup up header

One side of change is related on making code easier to follow, due it started
being quite messy because of all in-lined mode/view checks. Now there's a bit
of code duplication, but it's much easier to see what's going on there.

Another side of patch is related on re-arranging elements in header in a way
that follows rule "depending elements are placed after elements they depends on".
This might be a bit against mostly-used-based elements placement, but now it's
much easier to figure out where to add new option. Also it fits better other
blender's areas such as image editor header, i.e.
This commit is contained in:
Sergey Sharybin 2012-06-08 07:55:15 +00:00
parent fc07b1fce3
commit 54297c8d13

@ -25,7 +25,7 @@ from bpy.types import Panel, Header, Menu
class CLIP_HT_header(Header): class CLIP_HT_header(Header):
bl_space_type = 'CLIP_EDITOR' bl_space_type = 'CLIP_EDITOR'
def draw(self, context): def _draw_tracking(self, context):
layout = self.layout layout = self.layout
sc = context.space_data sc = context.space_data
@ -41,39 +41,37 @@ class CLIP_HT_header(Header):
if sc.view == 'CLIP': if sc.view == 'CLIP':
if clip: if clip:
sub.menu("CLIP_MT_select") sub.menu("CLIP_MT_select")
sub.menu("CLIP_MT_clip")
sub.menu("CLIP_MT_track")
sub.menu("CLIP_MT_reconstruction")
else:
sub.menu("CLIP_MT_clip")
sub.menu("CLIP_MT_clip") row = layout.row()
row.template_ID(sc, "clip", open='clip.open')
if clip:
if sc.mode == 'MASKEDIT':
sub.menu("CLIP_MT_mask")
else:
sub.menu("CLIP_MT_track")
sub.menu("CLIP_MT_reconstruction")
if sc.mode != 'MASKEDIT':
layout.prop(sc, "view", text="", expand=True)
if clip: if clip:
tracking = clip.tracking
active_object = tracking.objects.active
if sc.view == 'CLIP': if sc.view == 'CLIP':
layout.prop(sc, "mode", text="") layout.prop(sc, "mode", text="")
layout.prop(sc, "view", text="", expand=True)
layout.prop(sc, "pivot_point", text="", icon_only=True) layout.prop(sc, "pivot_point", text="", icon_only=True)
if sc.mode == 'MASKEDIT': r = active_object.reconstruction
toolsettings = context.tool_settings
row = layout.row(align=True) if r.is_valid and sc.view == 'CLIP':
row.prop(toolsettings, "use_proportional_edit_mask", layout.label(text="Average solve error: %.4f" %
text="", icon_only=True) (r.average_error))
if toolsettings.use_proportional_edit_objects:
row.prop(toolsettings, "proportional_edit_falloff",
text="", icon_only=True)
elif sc.view == 'GRAPH': elif sc.view == 'GRAPH':
layout.prop(sc, "view", text="", expand=True)
row = layout.row(align=True) row = layout.row(align=True)
if sc.show_filters: if sc.show_filters:
row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN', row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN',
text="Filters") text="Filters")
sub = row.column() sub = row.column()
sub.active = clip.tracking.reconstruction.is_valid sub.active = clip.tracking.reconstruction.is_valid
@ -82,32 +80,63 @@ class CLIP_HT_header(Header):
row.prop(sc, "show_graph_tracks", icon='ANIM', text="") row.prop(sc, "show_graph_tracks", icon='ANIM', text="")
else: else:
row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT', row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT',
text="Filters") text="Filters")
elif sc.view == 'DOPESHEET':
layout.prop(sc, "view", text="", expand=True)
layout.label(text="Sort by:")
layout.prop(sc, "dopesheet_sort_method", text="")
layout.prop(sc, "invert_dopesheet_sort", text="Invert")
else:
layout.prop(sc, "view", text="", expand=True)
def _draw_masking(self, context):
layout = self.layout
toolsettings = context.tool_settings
sc = context.space_data
clip = sc.clip
row = layout.row(align=True)
row.template_header()
if context.area.show_menus:
sub = row.row(align=True)
sub.menu("CLIP_MT_view")
if clip:
sub.menu("CLIP_MT_select")
sub.menu("CLIP_MT_clip")
sub.menu("CLIP_MT_mask")
else:
sub.menu("CLIP_MT_clip")
row = layout.row() row = layout.row()
row.template_ID(sc, "clip", open='clip.open') row.template_ID(sc, "clip", open='clip.open')
if sc.mode == 'MASKEDIT': layout.prop(sc, "mode", text="")
row = layout.row()
row.template_ID(sc, "mask", new="mask.new")
if clip: row = layout.row()
tracking = clip.tracking row.template_ID(sc, "mask", new="mask.new")
active = tracking.objects.active
if active and not active.is_camera: layout.prop(sc, "pivot_point", text="", icon_only=True)
r = active.reconstruction
else:
r = tracking.reconstruction
if r.is_valid and sc.view == 'CLIP': row = layout.row(align=True)
layout.label(text="Average solve error: %.4f" % row.prop(toolsettings, "use_proportional_edit_mask",
(r.average_error)) text="", icon_only=True)
if toolsettings.use_proportional_edit_mask:
row.prop(toolsettings, "proportional_edit_falloff",
text="", icon_only=True)
if sc.view == 'DOPESHEET': def draw(self, context):
layout.label(text="Sort by:") layout = self.layout
layout.prop(sc, "dopesheet_sort_method", text="")
layout.prop(sc, "invert_dopesheet_sort", text="Invert") sc = context.space_data
if sc.mode in {'TRACKING', 'RECONSTRUCTION', 'DISTORTION'}:
self._draw_tracking(context)
else:
self._draw_masking(context)
layout.template_running_jobs() layout.template_running_jobs()