rename SIPO_AUTOVIEW -> SIPO_AUTO_VIEW_SELECTED
[blender-staging.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         GRAPH_MT_editor_menus.draw_collapsible(context, layout)
39
40         layout.prop(st, "mode", text="")
41
42         dopesheet_filter(layout, context)
43
44         layout.prop(st, "use_auto_view_selected", text="Auto View")
45
46         layout.prop(st, "use_normalization", text="Normalize")
47         row = layout.row()
48         row.active = st.use_normalization
49         row.prop(st, "use_auto_normalization", text="Auto")
50
51         layout.prop(st, "auto_snap", text="")
52         layout.prop(st, "pivot_point", icon_only=True)
53
54         row = layout.row(align=True)
55         row.operator("graph.copy", text="", icon='COPYDOWN')
56         row.operator("graph.paste", text="", icon='PASTEDOWN')
57         row.operator("graph.paste", text="", icon='PASTEFLIPDOWN').flipped = True
58
59         row = layout.row(align=True)
60         if st.has_ghost_curves:
61             row.operator("graph.ghost_curves_clear", text="", icon='GHOST_DISABLED')
62         else:
63             row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED')
64
65
66 class GRAPH_MT_editor_menus(Menu):
67     bl_idname = "GRAPH_MT_editor_menus"
68     bl_label = ""
69
70     def draw(self, context):
71         self.draw_menus(self.layout, context)
72
73     @staticmethod
74     def draw_menus(layout, context):
75         layout.menu("GRAPH_MT_view")
76         layout.menu("GRAPH_MT_select")
77         layout.menu("GRAPH_MT_marker")
78         layout.menu("GRAPH_MT_channel")
79         layout.menu("GRAPH_MT_key")
80
81
82 class GRAPH_MT_view(Menu):
83     bl_label = "View"
84
85     def draw(self, context):
86         layout = self.layout
87
88         st = context.space_data
89
90         layout.operator("graph.properties", icon='MENU_PANEL')
91         layout.separator()
92
93         layout.prop(st, "use_realtime_update")
94         layout.prop(st, "show_frame_indicator")
95         layout.prop(st, "show_cursor")
96         layout.prop(st, "show_sliders")
97         layout.prop(st, "show_group_colors")
98         layout.prop(st, "use_auto_merge_keyframes")
99
100         layout.separator()
101         layout.prop(st, "use_beauty_drawing")
102
103         layout.separator()
104
105         layout.prop(st, "show_handles")
106
107         layout.prop(st, "use_only_selected_curves_handles")
108         layout.prop(st, "use_only_selected_keyframe_handles")
109
110         layout.prop(st, "show_seconds")
111         layout.prop(st, "show_locked_time")
112
113         layout.separator()
114         layout.operator("anim.previewrange_set")
115         layout.operator("anim.previewrange_clear")
116         layout.operator("graph.previewrange_set")
117
118         layout.separator()
119         layout.operator("graph.view_all")
120         layout.operator("graph.view_selected")
121
122         layout.separator()
123         layout.operator("screen.area_dupli")
124         layout.operator("screen.screen_full_area", text="Toggle Maximize Area")
125         layout.operator("screen.screen_full_area").use_hide_panels = True
126
127
128 class GRAPH_MT_select(Menu):
129     bl_label = "Select"
130
131     def draw(self, context):
132         layout = self.layout
133
134         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
135         layout.operator("graph.select_all_toggle").invert = False
136         layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True
137
138         layout.separator()
139         props = layout.operator("graph.select_border")
140         props.axis_range = False
141         props.include_handles = False
142         props = layout.operator("graph.select_border", text="Border Axis Range")
143         props.axis_range = True
144         props.include_handles = False
145         props = layout.operator("graph.select_border", text="Border (Include Handles)")
146         props.axis_range = False
147         props.include_handles = True
148
149         layout.separator()
150         layout.operator("graph.select_column", text="Columns on Selected Keys").mode = 'KEYS'
151         layout.operator("graph.select_column", text="Column on Current Frame").mode = 'CFRA'
152
153         layout.operator("graph.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
154         layout.operator("graph.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
155
156         layout.separator()
157         props = layout.operator("graph.select_leftright", text="Before Current Frame")
158         props.extend = False
159         props.mode = 'LEFT'
160         props = layout.operator("graph.select_leftright", text="After Current Frame")
161         props.extend = False
162         props.mode = 'RIGHT'
163
164         layout.separator()
165         layout.operator("graph.select_more")
166         layout.operator("graph.select_less")
167
168         layout.separator()
169         layout.operator("graph.select_linked")
170
171
172 class GRAPH_MT_marker(Menu):
173     bl_label = "Marker"
174
175     def draw(self, context):
176         layout = self.layout
177
178         from bl_ui.space_time import marker_menu_generic
179         marker_menu_generic(layout)
180
181         # TODO: pose markers for action edit mode only?
182
183
184 class GRAPH_MT_channel(Menu):
185     bl_label = "Channel"
186
187     def draw(self, context):
188         layout = self.layout
189
190         layout.operator_context = 'INVOKE_REGION_CHANNELS'
191
192         layout.operator("anim.channels_delete")
193
194         layout.separator()
195         layout.operator("anim.channels_group")
196         layout.operator("anim.channels_ungroup")
197
198         layout.separator()
199         layout.operator_menu_enum("anim.channels_setting_toggle", "type")
200         layout.operator_menu_enum("anim.channels_setting_enable", "type")
201         layout.operator_menu_enum("anim.channels_setting_disable", "type")
202
203         layout.separator()
204         layout.operator("anim.channels_editable_toggle")
205         layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
206
207         layout.separator()
208         layout.operator("graph.hide", text="Hide Selected Curves").unselected = False
209         layout.operator("graph.hide", text="Hide Unselected Curves").unselected = True
210         layout.operator("graph.reveal")
211
212         layout.separator()
213         layout.operator("anim.channels_expand")
214         layout.operator("anim.channels_collapse")
215
216         layout.separator()
217         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
218
219         layout.separator()
220         layout.operator("anim.channels_fcurves_enable")
221
222
223 class GRAPH_MT_key(Menu):
224     bl_label = "Key"
225
226     def draw(self, context):
227         layout = self.layout
228
229         layout.menu("GRAPH_MT_key_transform", text="Transform")
230
231         layout.operator_menu_enum("graph.snap", "type", text="Snap")
232         layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
233
234         layout.separator()
235         layout.operator_menu_enum("graph.keyframe_insert", "type")
236         layout.operator_menu_enum("graph.fmodifier_add", "type")
237         layout.operator("graph.sound_bake")
238
239         layout.separator()
240         layout.operator("graph.frame_jump")
241
242         layout.separator()
243         layout.operator("graph.duplicate_move")
244         layout.operator("graph.delete")
245
246         layout.separator()
247         layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
248         layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
249         layout.operator_menu_enum("graph.easing_type", "type", text="Easing Type")
250
251         layout.separator()
252         layout.operator("graph.clean")
253         layout.operator("graph.smooth")
254         layout.operator("graph.sample")
255         layout.operator("graph.bake")
256
257         layout.separator()
258         layout.operator("graph.copy")
259         layout.operator("graph.paste")
260
261         layout.separator()
262         layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
263
264
265 class GRAPH_MT_key_transform(Menu):
266     bl_label = "Transform"
267
268     def draw(self, context):
269         layout = self.layout
270
271         layout.operator("transform.translate", text="Grab/Move")
272         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
273         layout.operator("transform.rotate", text="Rotate")
274         layout.operator("transform.resize", text="Scale")
275
276 if __name__ == "__main__":  # only for live edit.
277     bpy.utils.register_module(__name__)