space_nla.py 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18. # <pep8 compliant>
  19. from bpy.types import Header, Menu, Panel
  20. from bpy.app.translations import contexts as i18n_contexts
  21. from bl_ui.space_dopesheet import (
  22. DopesheetFilterPopoverBase,
  23. dopesheet_filter,
  24. )
  25. class NLA_HT_header(Header):
  26. bl_space_type = 'NLA_EDITOR'
  27. def draw(self, context):
  28. layout = self.layout
  29. st = context.space_data
  30. layout.template_header()
  31. NLA_MT_editor_menus.draw_collapsible(context, layout)
  32. layout.separator_spacer()
  33. dopesheet_filter(layout, context)
  34. layout.popover(
  35. panel="NLA_PT_filters",
  36. text="",
  37. icon='FILTER',
  38. )
  39. layout.prop(st, "auto_snap", text="")
  40. class NLA_PT_filters(DopesheetFilterPopoverBase, Panel):
  41. bl_space_type = 'NLA_EDITOR'
  42. bl_region_type = 'HEADER'
  43. bl_label = "Filters"
  44. def draw(self, context):
  45. layout = self.layout
  46. DopesheetFilterPopoverBase.draw_generic_filters(context, layout)
  47. layout.separator()
  48. DopesheetFilterPopoverBase.draw_search_filters(context, layout)
  49. layout.separator()
  50. DopesheetFilterPopoverBase.draw_standard_filters(context, layout)
  51. class NLA_MT_editor_menus(Menu):
  52. bl_idname = "NLA_MT_editor_menus"
  53. bl_label = ""
  54. def draw(self, _context):
  55. layout = self.layout
  56. layout.menu("NLA_MT_view")
  57. layout.menu("NLA_MT_select")
  58. layout.menu("NLA_MT_marker")
  59. layout.menu("NLA_MT_edit")
  60. layout.menu("NLA_MT_add")
  61. class NLA_MT_view(Menu):
  62. bl_label = "View"
  63. def draw(self, context):
  64. layout = self.layout
  65. st = context.space_data
  66. layout.prop(st, "show_region_ui")
  67. layout.separator()
  68. layout.prop(st, "use_realtime_update")
  69. layout.prop(st, "show_frame_indicator")
  70. layout.prop(st, "show_seconds")
  71. layout.prop(st, "show_locked_time")
  72. layout.prop(st, "show_strip_curves")
  73. layout.prop(st, "show_local_markers")
  74. layout.prop(st, "show_marker_lines")
  75. layout.separator()
  76. layout.operator("anim.previewrange_set")
  77. layout.operator("anim.previewrange_clear")
  78. layout.operator("nla.previewrange_set")
  79. layout.separator()
  80. layout.operator("nla.view_all")
  81. layout.operator("nla.view_selected")
  82. layout.operator("nla.view_frame")
  83. layout.separator()
  84. layout.menu("INFO_MT_area")
  85. class NLA_MT_select(Menu):
  86. bl_label = "Select"
  87. def draw(self, _context):
  88. layout = self.layout
  89. layout.operator("nla.select_all", text="All").action = 'SELECT'
  90. layout.operator("nla.select_all", text="None").action = 'DESELECT'
  91. layout.operator("nla.select_all", text="Invert").action = 'INVERT'
  92. layout.separator()
  93. layout.operator("nla.select_box").axis_range = False
  94. layout.operator("nla.select_box", text="Border Axis Range").axis_range = True
  95. layout.separator()
  96. props = layout.operator("nla.select_leftright", text="Before Current Frame")
  97. props.extend = False
  98. props.mode = 'LEFT'
  99. props = layout.operator("nla.select_leftright", text="After Current Frame")
  100. props.extend = False
  101. props.mode = 'RIGHT'
  102. class NLA_MT_marker(Menu):
  103. bl_label = "Marker"
  104. def draw(self, context):
  105. layout = self.layout
  106. from bl_ui.space_time import marker_menu_generic
  107. marker_menu_generic(layout, context)
  108. class NLA_MT_edit(Menu):
  109. bl_label = "Edit"
  110. def draw(self, context):
  111. layout = self.layout
  112. scene = context.scene
  113. layout.menu("NLA_MT_edit_transform", text="Transform")
  114. layout.operator_menu_enum("nla.snap", "type", text="Snap")
  115. layout.separator()
  116. layout.operator("nla.duplicate", text="Duplicate").linked = False
  117. layout.operator("nla.duplicate", text="Linked Duplicate").linked = True
  118. layout.operator("nla.split")
  119. layout.operator("nla.delete")
  120. layout.separator()
  121. layout.operator("nla.mute_toggle")
  122. layout.separator()
  123. layout.operator("nla.apply_scale")
  124. layout.operator("nla.clear_scale")
  125. layout.operator("nla.action_sync_length").active = False
  126. layout.separator()
  127. layout.operator("nla.make_single_user")
  128. layout.separator()
  129. layout.operator("nla.swap")
  130. layout.operator("nla.move_up")
  131. layout.operator("nla.move_down")
  132. # TODO: this really belongs more in a "channel" (or better, "track") menu
  133. layout.separator()
  134. layout.operator_menu_enum("anim.channels_move", "direction", text="Track Ordering...")
  135. layout.operator("anim.channels_clean_empty")
  136. layout.separator()
  137. # TODO: names of these tools for 'tweak-mode' need changing?
  138. if scene.is_nla_tweakmode:
  139. layout.operator("nla.tweakmode_exit", text="Stop Editing Stashed Action").isolate_action = True
  140. layout.operator("nla.tweakmode_exit", text="Stop Tweaking Strip Actions")
  141. else:
  142. layout.operator("nla.tweakmode_enter", text="Start Editing Stashed Action").isolate_action = True
  143. layout.operator("nla.tweakmode_enter", text="Start Tweaking Strip Actions")
  144. class NLA_MT_add(Menu):
  145. bl_label = "Add"
  146. bl_translation_context = i18n_contexts.operator_default
  147. def draw(self, _context):
  148. layout = self.layout
  149. layout.operator("nla.actionclip_add")
  150. layout.operator("nla.transition_add")
  151. layout.operator("nla.soundclip_add")
  152. layout.separator()
  153. layout.operator("nla.meta_add")
  154. layout.operator("nla.meta_remove")
  155. layout.separator()
  156. layout.operator("nla.tracks_add").above_selected = False
  157. layout.operator("nla.tracks_add", text="Add Tracks Above Selected").above_selected = True
  158. layout.separator()
  159. layout.operator("nla.selected_objects_add")
  160. class NLA_MT_edit_transform(Menu):
  161. bl_label = "Transform"
  162. def draw(self, _context):
  163. layout = self.layout
  164. layout.operator("transform.translate", text="Move")
  165. layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
  166. layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE'
  167. class NLA_MT_snap_pie(Menu):
  168. bl_label = "Snap"
  169. def draw(self, _context):
  170. layout = self.layout
  171. pie = layout.menu_pie()
  172. pie.operator("nla.snap", text="Current Frame").type = 'CFRA'
  173. pie.operator("nla.snap", text="Nearest Frame").type = 'NEAREST_FRAME'
  174. pie.operator("nla.snap", text="Nearest Second").type = 'NEAREST_SECOND'
  175. pie.operator("nla.snap", text="Nearest Marker").type = 'NEAREST_MARKER'
  176. class NLA_MT_context_menu(Menu):
  177. bl_label = "NLA Context Menu"
  178. def draw(self, context):
  179. layout = self.layout
  180. scene = context.scene
  181. if scene.is_nla_tweakmode:
  182. layout.operator("nla.tweakmode_exit", text="Stop Editing Stashed Action").isolate_action = True
  183. layout.operator("nla.tweakmode_exit", text="Stop Tweaking Strip Actions")
  184. else:
  185. layout.operator("nla.tweakmode_enter", text="Start Editing Stashed Action").isolate_action = True
  186. layout.operator("nla.tweakmode_enter", text="Start Tweaking Strip Actions")
  187. layout.separator()
  188. layout.operator("nla.duplicate", text="Duplicate").linked = False
  189. layout.operator("nla.duplicate", text="Linked Duplicate").linked = True
  190. layout.separator()
  191. layout.operator("nla.split")
  192. layout.operator("nla.delete")
  193. layout.separator()
  194. layout.operator("nla.swap")
  195. layout.separator()
  196. layout.operator_menu_enum("nla.snap", "type", text="Snap")
  197. class NLA_MT_channel_context_menu(Menu):
  198. bl_label = "NLA Channel Context Menu"
  199. def draw(self, _context):
  200. layout = self.layout
  201. layout.operator_menu_enum("anim.channels_move", "direction", text="Track Ordering...")
  202. layout.operator("anim.channels_clean_empty")
  203. classes = (
  204. NLA_HT_header,
  205. NLA_MT_edit,
  206. NLA_MT_editor_menus,
  207. NLA_MT_view,
  208. NLA_MT_select,
  209. NLA_MT_marker,
  210. NLA_MT_add,
  211. NLA_MT_edit_transform,
  212. NLA_MT_snap_pie,
  213. NLA_MT_context_menu,
  214. NLA_MT_channel_context_menu,
  215. NLA_PT_filters,
  216. )
  217. if __name__ == "__main__": # only for live edit.
  218. from bpy.utils import register_class
  219. for cls in classes:
  220. register_class(cls)