patch [#27917] MARKER MENUS: Unification and adding "Duplicate Marker to Scene..."
[blender.git] / release / scripts / startup / bl_ui / space_graph.py
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
19 # <pep8 compliant>
20
21 import bpy
22 from bpy.types import Header, Menu
23
24
25 class GRAPH_HT_header(Header):
26     bl_space_type = 'GRAPH_EDITOR'
27
28     def draw(self, context):
29         from bl_ui.space_dopesheet import dopesheet_filter
30
31         layout = self.layout
32
33         st = context.space_data
34
35         row = layout.row(align=True)
36         row.template_header()
37
38         if context.area.show_menus:
39             row.menu("GRAPH_MT_view")
40             row.menu("GRAPH_MT_select")
41             row.menu("GRAPH_MT_marker")
42             row.menu("GRAPH_MT_channel")
43             row.menu("GRAPH_MT_key")
44
45         layout.prop(st, "mode", text="")
46
47         dopesheet_filter(layout, context)
48
49         layout.prop(st, "auto_snap", text="")
50         layout.prop(st, "pivot_point", text="", icon_only=True)
51
52         row = layout.row(align=True)
53         row.operator("graph.copy", text="", icon='COPYDOWN')
54         row.operator("graph.paste", text="", icon='PASTEDOWN')
55
56         row = layout.row(align=True)
57         if st.has_ghost_curves:
58             row.operator("graph.ghost_curves_clear", text="", icon='GHOST_DISABLED')
59         else:
60             row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED')
61
62
63 class GRAPH_MT_view(Menu):
64     bl_label = "View"
65
66     def draw(self, context):
67         layout = self.layout
68
69         st = context.space_data
70
71         layout.operator("graph.properties", icon='MENU_PANEL')
72         layout.separator()
73
74         layout.prop(st, "use_realtime_update")
75         layout.prop(st, "show_frame_indicator")
76         layout.prop(st, "show_cursor")
77         layout.prop(st, "show_sliders")
78         layout.prop(st, "use_auto_merge_keyframes")
79
80         layout.separator()
81         layout.prop(st, "use_beauty_drawing")
82
83         layout.separator()
84         if st.show_handles:
85             layout.operator("graph.handles_view_toggle", icon='CHECKBOX_HLT', text="Show All Handles")
86         else:
87             layout.operator("graph.handles_view_toggle", icon='CHECKBOX_DEHLT', text="Show All Handles")
88         layout.prop(st, "use_only_selected_curves_handles")
89         layout.prop(st, "use_only_selected_keyframe_handles")
90         layout.operator("anim.time_toggle")
91
92         layout.separator()
93         layout.operator("anim.previewrange_set")
94         layout.operator("anim.previewrange_clear")
95         layout.operator("graph.previewrange_set")
96
97         layout.separator()
98         layout.operator("graph.frame_jump")
99         layout.operator("graph.view_all")
100         layout.operator("graph.view_selected")
101
102         layout.separator()
103         layout.operator("screen.area_dupli")
104         layout.operator("screen.screen_full_area")
105
106
107 class GRAPH_MT_select(Menu):
108     bl_label = "Select"
109
110     def draw(self, context):
111         layout = self.layout
112
113         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
114         layout.operator("graph.select_all_toggle")
115         layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True
116
117         layout.separator()
118         layout.operator("graph.select_border")
119         layout.operator("graph.select_border", text="Border Axis Range").axis_range = True
120         layout.operator("graph.select_border", text="Border (Include Handles)").include_handles = True
121
122         layout.separator()
123         layout.operator("graph.select_column", text="Columns on Selected Keys").mode = 'KEYS'
124         layout.operator("graph.select_column", text="Column on Current Frame").mode = 'CFRA'
125
126         layout.operator("graph.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
127         layout.operator("graph.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
128
129         layout.separator()
130         layout.operator("graph.select_leftright", text="Before Current Frame").mode = 'LEFT'
131         layout.operator("graph.select_leftright", text="After Current Frame").mode = 'RIGHT'
132
133         layout.separator()
134         layout.operator("graph.select_more")
135         layout.operator("graph.select_less")
136
137         layout.separator()
138         layout.operator("graph.select_linked")
139
140
141 class GRAPH_MT_marker(Menu):
142     bl_label = "Marker"
143
144     def draw(self, context):
145         layout = self.layout
146
147         from .space_time import marker_menu_generic
148         marker_menu_generic(layout)
149
150         # TODO: pose markers for action edit mode only?
151
152
153 class GRAPH_MT_channel(Menu):
154     bl_label = "Channel"
155
156     def draw(self, context):
157         layout = self.layout
158
159         layout.operator_context = 'INVOKE_REGION_CHANNELS'
160
161         layout.operator("anim.channels_delete")
162
163         layout.separator()
164         layout.operator("anim.channels_setting_toggle")
165         layout.operator("anim.channels_setting_enable")
166         layout.operator("anim.channels_setting_disable")
167
168         layout.separator()
169         layout.operator("anim.channels_editable_toggle")
170         layout.operator("anim.channels_visibility_set")
171         layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
172
173         layout.separator()
174         layout.operator("anim.channels_expand")
175         layout.operator("anim.channels_collapse")
176
177         layout.separator()
178         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
179
180         layout.separator()
181         layout.operator("anim.channels_fcurves_enable")
182
183
184 class GRAPH_MT_key(Menu):
185     bl_label = "Key"
186
187     def draw(self, context):
188         layout = self.layout
189
190         layout.menu("GRAPH_MT_key_transform", text="Transform")
191
192         layout.operator_menu_enum("graph.snap", "type", text="Snap")
193         layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
194
195         layout.separator()
196         layout.operator("graph.keyframe_insert")
197         layout.operator("graph.fmodifier_add")
198         layout.operator("graph.sound_bake")
199
200         layout.separator()
201         layout.operator("graph.duplicate_move")
202         layout.operator("graph.delete")
203
204         layout.separator()
205         layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
206         layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
207
208         layout.separator()
209         layout.operator("graph.clean")
210         layout.operator("graph.smooth")
211         layout.operator("graph.sample")
212         layout.operator("graph.bake")
213
214         layout.separator()
215         layout.operator("graph.copy")
216         layout.operator("graph.paste")
217
218         layout.separator()
219         layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
220
221
222 class GRAPH_MT_key_transform(Menu):
223     bl_label = "Transform"
224
225     def draw(self, context):
226         layout = self.layout
227
228         layout.operator("transform.translate", text="Grab/Move")
229         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
230         layout.operator("transform.rotate", text="Rotate")
231         layout.operator("transform.resize", text="Scale")
232
233 if __name__ == "__main__":  # only for live edit.
234     bpy.utils.register_module(__name__)