Porting of Graph Editor's UI to python, just header done for now.
[blender.git] / release / scripts / 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 class GRAPH_HT_header(bpy.types.Header):
24     bl_space_type = 'GRAPH_EDITOR'
25
26     def draw(self, context):
27         layout = self.layout
28
29         st = context.space_data
30
31         row = layout.row(align=True)
32         row.template_header()
33
34         if context.area.show_menus:
35             sub = row.row(align=True)
36             
37             sub.menu("GRAPH_MT_view")
38             sub.menu("GRAPH_MT_select")
39             sub.menu("GRAPH_MT_channel")
40             sub.menu("GRAPH_MT_key")
41             
42         layout.prop(st, "mode", text="")
43         
44         layout.template_dopesheet_filter(st.dopesheet)
45         
46         layout.prop(st, "autosnap", text="")
47         layout.prop(st, "pivot_point", text="", icon_only=True)
48         
49         row = layout.row(align=True)
50         row.operator("graph.copy", text="", icon='ICON_COPYDOWN')
51         row.operator("graph.paste", text="", icon='ICON_PASTEDOWN')
52         
53         row = layout.row(align=True)
54         # these likely need new icons
55         row.operator("graph.ghost_curves_create", text="", icon='ICON_GHOST_ENABLED')
56         row.operator("graph.ghost_curves_clear", text="", icon='ICON_GHOST_DISABLED')
57
58
59 class GRAPH_MT_view(bpy.types.Menu):
60     bl_label = "View"
61
62     def draw(self, context):
63         layout = self.layout
64
65         st = context.space_data
66
67         layout.column()
68
69         layout.separator()
70         layout.operator("graph.properties")
71
72         layout.prop(st, "show_cframe_indicator")
73         layout.prop(st, "show_cursor")
74         layout.prop(st, "show_sliders")
75         layout.prop(st, "automerge_keyframes")
76         
77         layout.separator()
78         layout.operator("graph.handles_view_toggle")
79         layout.prop(st, "only_selected_curves_handles")
80         layout.prop(st, "only_selected_keyframe_handles")
81         layout.operator("anim.time_toggle")
82         
83         layout.separator()
84         layout.operator("anim.previewrange_set")
85         layout.operator("anim.previewrange_clear")
86         layout.operator("graph.previewrange_set")
87
88         layout.separator()
89         layout.operator("graph.frame_jump")
90         layout.operator("graph.view_all")
91         
92         layout.separator()
93         layout.operator("screen.area_dupli")
94         layout.operator("screen.screen_full_area")
95
96 class GRAPH_MT_select(bpy.types.Menu):
97     bl_label = "Select"
98
99     def draw(self, context):
100         layout = self.layout
101
102         layout.column()
103         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
104         layout.operator("graph.select_all_toggle")
105         layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True
106         
107         layout.separator()
108         layout.operator("graph.select_border")
109         layout.operator("graph.select_border", text="Border Axis Range").axis_range = True
110         
111         layout.separator()
112         layout.operator("graph.select_column", text="Columns on Selected Keys").mode = 'KEYS'
113         layout.operator("graph.select_column", text="Column on Current Frame").mode = 'CFRA'
114         
115         layout.operator("graph.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
116         layout.operator("graph.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
117
118 class GRAPH_MT_channel(bpy.types.Menu):
119     bl_label = "Channel"
120
121     def draw(self, context):
122         layout = self.layout
123
124         layout.column()
125         layout.operator("anim.channels_setting_toggle")
126         layout.operator("anim.channels_setting_enable")
127         layout.operator("anim.channels_setting_disable")
128         
129         layout.separator()
130         layout.operator("anim.channels_editable_toggle")
131         
132         layout.separator()
133         layout.operator("anim.channels_expand")
134         layout.operator("anim.channels_collapse")
135         
136 class GRAPH_MT_key(bpy.types.Menu):
137     bl_label = "Key"
138
139     def draw(self, context):
140         layout = self.layout
141
142         layout.column()
143         layout.menu("GRAPH_MT_key_transform", text="Transform")
144         
145         layout.operator_menu_enum("graph.snap", property="type", text="Snap")
146         layout.operator_menu_enum("graph.mirror", property="type", text="Mirror")
147         
148         layout.separator()
149         layout.operator("graph.keyframe_insert")
150         layout.operator("graph.fmodifier_add")
151         
152         layout.separator()
153         layout.operator("graph.duplicate")
154         layout.operator("graph.delete")
155         
156         layout.separator()
157         layout.operator_menu_enum("graph.handle_type", property="type", text="Handle Type")
158         layout.operator_menu_enum("graph.interpolation_type", property="type", text="Interpolation Mode")
159         layout.operator_menu_enum("graph.extrapolation_type", property="type", text="Extrapolation Mode")
160         
161         layout.separator()
162         layout.operator("graph.clean")
163         layout.operator("graph.sample")
164         layout.operator("graph.bake")
165         
166         layout.separator()
167         layout.operator("graph.copy")
168         layout.operator("graph.paste")
169         
170 class GRAPH_MT_key_transform(bpy.types.Menu):
171     bl_label = "Transform"
172
173     def draw(self, context):
174         layout = self.layout
175
176         layout.column()
177         layout.operator("tfm.translate", text="Grab/Move")
178         layout.operator("tfm.transform", text="Extend").mode = 'TIME_EXTEND'
179         layout.operator("tfm.rotate", text="Rotate")
180         layout.operator("tfm.resize", text="Scale")
181         
182
183 bpy.types.register(GRAPH_HT_header) # header/menu classes
184 bpy.types.register(GRAPH_MT_view)
185 bpy.types.register(GRAPH_MT_select)
186 bpy.types.register(GRAPH_MT_channel)
187 bpy.types.register(GRAPH_MT_key)
188 bpy.types.register(GRAPH_MT_key_transform)
189