Merge branch 'master' into blender2.8
[blender.git] / release / scripts / startup / bl_ui / space_graph.py
index 7a920435b183b99936be6b3f4c9b3d30ff79dfbd..ee3f5de0f09032928bf75af9004a00f31d455ec1 100644 (file)
 # <pep8 compliant>
 
 import bpy
-from bpy.types import Header, Menu
+from bpy.types import Header, Menu, Panel
+from .space_dopesheet import (
+    DopesheetFilterPopoverBase,
+    dopesheet_filter,
+)
 
 
 class GRAPH_HT_header(Header):
     bl_space_type = 'GRAPH_EDITOR'
 
     def draw(self, context):
-        from .space_dopesheet import dopesheet_filter
-
         layout = self.layout
         tool_settings = context.tool_settings
 
@@ -36,11 +38,10 @@ class GRAPH_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        GRAPH_MT_editor_menus.draw_collapsible(context, layout)
-
-        layout.prop(st, "mode", text="")
+        # Now a exposed as a sub-space type
+        # layout.prop(st, "mode", text="")
 
-        dopesheet_filter(layout, context)
+        GRAPH_MT_editor_menus.draw_collapsible(context, layout)
 
         row = layout.row(align=True)
         row.prop(st, "use_normalization", icon='NORMALIZE_FCURVES', text="Normalize", toggle=True)
@@ -48,21 +49,9 @@ class GRAPH_HT_header(Header):
         sub.active = st.use_normalization
         sub.prop(st, "use_auto_normalization", icon='FILE_REFRESH', text="", toggle=True)
 
-        row = layout.row(align=True)
-
-        row.prop(tool_settings, "use_proportional_fcurve",
-                 text="", icon_only=True)
-        if tool_settings.use_proportional_fcurve:
-            row.prop(tool_settings, "proportional_edit_falloff",
-                     text="", icon_only=True)
-
-        layout.prop(st, "auto_snap", text="")
-        layout.prop(st, "pivot_point", icon_only=True)
+        layout.separator_spacer()
 
-        row = layout.row(align=True)
-        row.operator("graph.copy", text="", icon='COPYDOWN')
-        row.operator("graph.paste", text="", icon='PASTEDOWN')
-        row.operator("graph.paste", text="", icon='PASTEFLIPDOWN').flipped = True
+        dopesheet_filter(layout, context)
 
         row = layout.row(align=True)
         if st.has_ghost_curves:
@@ -70,6 +59,37 @@ class GRAPH_HT_header(Header):
         else:
             row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED')
 
+        layout.popover(
+            panel="GRAPH_PT_filters",
+            text="",
+            icon='FILTER',
+        )
+
+        layout.prop(st, "auto_snap", text="")
+
+        row = layout.row(align=True)
+        row.prop(tool_settings, "use_proportional_fcurve", text="", icon_only=True)
+        sub = row.row(align=True)
+        sub.active = tool_settings.use_proportional_fcurve
+        sub.prop(tool_settings, "proportional_edit_falloff", text="", icon_only=True)
+
+        layout.prop(st, "pivot_point", icon_only=True)
+
+
+class GRAPH_PT_filters(DopesheetFilterPopoverBase, Panel):
+    bl_space_type = 'GRAPH_EDITOR'
+    bl_region_type = 'HEADER'
+    bl_label = "Filters"
+
+    def draw(self, context):
+        layout = self.layout
+
+        DopesheetFilterPopoverBase.draw_generic_filters(context, layout)
+        layout.separator()
+        DopesheetFilterPopoverBase.draw_search_filters(context, layout)
+        layout.separator()
+        DopesheetFilterPopoverBase.draw_standard_filters(context, layout)
+
 
 class GRAPH_MT_editor_menus(Menu):
     bl_idname = "GRAPH_MT_editor_menus"
@@ -128,10 +148,14 @@ class GRAPH_MT_view(Menu):
         layout.operator("graph.view_selected")
         layout.operator("graph.view_frame")
 
+        # Add this to show key-binding (reverse action in dope-sheet).
         layout.separator()
-        layout.operator("screen.area_dupli")
-        layout.operator("screen.screen_full_area")
-        layout.operator("screen.screen_full_area", text="Toggle Fullscreen Area").use_hide_panels = True
+        props = layout.operator("wm.context_set_enum", text="Toggle Dope Sheet")
+        props.data_path = "area.type"
+        props.value = 'DOPESHEET_EDITOR'
+
+        layout.separator()
+        layout.menu("INFO_MT_area")
 
 
 class GRAPH_MT_select(Menu):
@@ -140,18 +164,19 @@ class GRAPH_MT_select(Menu):
     def draw(self, context):
         layout = self.layout
 
-        # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
-        layout.operator("graph.select_all_toggle").invert = False
-        layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True
+        layout.operator("graph.select_all", text="All").action = 'SELECT'
+        layout.operator("graph.select_all", text="None").action = 'DESELECT'
+        layout.operator("graph.select_all", text="Invert").action = 'INVERT'
 
         layout.separator()
-        props = layout.operator("graph.select_border")
+
+        props = layout.operator("graph.select_box")
         props.axis_range = False
         props.include_handles = False
-        props = layout.operator("graph.select_border", text="Border Axis Range")
+        props = layout.operator("graph.select_box", text="Border Axis Range")
         props.axis_range = True
         props.include_handles = False
-        props = layout.operator("graph.select_border", text="Border (Include Handles)")
+        props = layout.operator("graph.select_box", text="Border (Include Handles)")
         props.axis_range = False
         props.include_handles = True
 
@@ -253,6 +278,9 @@ class GRAPH_MT_key(Menu):
         layout.operator("graph.frame_jump")
 
         layout.separator()
+        layout.operator("graph.copy")
+        layout.operator("graph.paste")
+        layout.operator("graph.paste", text="Paste Flipped").flipped = True
         layout.operator("graph.duplicate_move")
         layout.operator("graph.delete")
 
@@ -268,10 +296,6 @@ class GRAPH_MT_key(Menu):
         layout.operator("graph.sample")
         layout.operator("graph.bake")
 
-        layout.separator()
-        layout.operator("graph.copy")
-        layout.operator("graph.paste")
-
         layout.separator()
         layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
 
@@ -282,7 +306,7 @@ class GRAPH_MT_key_transform(Menu):
     def draw(self, context):
         layout = self.layout
 
-        layout.operator("transform.translate", text="Grab/Move")
+        layout.operator("transform.translate", text="Move")
         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
         layout.operator("transform.rotate", text="Rotate")
         layout.operator("transform.resize", text="Scale")
@@ -302,6 +326,102 @@ class GRAPH_MT_delete(Menu):
         layout.operator("graph.clean", text="Clean Channels").channels = True
 
 
+class GRAPH_MT_specials(Menu):
+    bl_label = "F-Curve Context Menu"
+
+    def draw(self, context):
+        layout = self.layout
+
+        layout.operator("graph.copy", text="Copy")
+        layout.operator("graph.paste", text="Paste")
+        layout.operator("graph.paste", text="Paste Flipped").flipped = True
+
+        layout.separator()
+
+        layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
+        layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
+        layout.operator_menu_enum("graph.easing_type", "type", text="Easing Type")
+
+        layout.separator()
+
+        layout.operator("graph.keyframe_insert").type = 'SEL'
+        layout.operator("graph.duplicate_move")
+        layout.operator("graph.delete")
+
+        layout.separator()
+
+        layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
+        layout.operator_menu_enum("graph.snap", "type", text="Snap")
+
+
+class GRAPH_MT_pivot_pie(Menu):
+    bl_label = "Pivot Point"
+
+    def draw(self, context):
+        layout = self.layout
+        pie = layout.menu_pie()
+
+        pie.prop_enum(context.space_data, "pivot_point", value='BOUNDING_BOX_CENTER')
+        pie.prop_enum(context.space_data, "pivot_point", value='CURSOR')
+        pie.prop_enum(context.space_data, "pivot_point", value='INDIVIDUAL_ORIGINS')
+
+
+class GRAPH_MT_snap_pie(Menu):
+    bl_label = "Snap"
+
+    def draw(self, context):
+        layout = self.layout
+        pie = layout.menu_pie()
+
+        pie.operator("graph.snap", text="Current Frame").type = 'CFRA'
+        pie.operator("graph.snap", text="Cursor Value").type = 'VALUE'
+        pie.operator("graph.snap", text="Nearest Frame").type = 'NEAREST_FRAME'
+        pie.operator("graph.snap", text="Nearest Second").type = 'NEAREST_SECOND'
+        pie.operator("graph.snap", text="Nearest Marker").type = 'NEAREST_MARKER'
+        pie.operator("graph.snap", text="Flatten Handles").type = 'HORIZONTAL'
+
+
+class GRAPH_MT_channel_specials(Menu):
+    bl_label = "F-Curve Channel Context Menu"
+
+    def draw(self, context):
+        layout = self.layout
+        st = context.space_data
+
+        layout.separator()
+        layout.operator("anim.channels_setting_enable", text="Mute Channels").type = 'MUTE'
+        layout.operator("anim.channels_setting_disable", text="Unmute Channels").type = 'MUTE'
+        layout.separator()
+        layout.operator("anim.channels_setting_enable", text="Protect Channels").type = 'PROTECT'
+        layout.operator("anim.channels_setting_disable", text="Unprotect Channels").type = 'PROTECT'
+
+        layout.separator()
+        layout.operator("anim.channels_group")
+        layout.operator("anim.channels_ungroup")
+
+        layout.separator()
+        layout.operator("anim.channels_editable_toggle")
+        layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
+
+        layout.separator()
+        layout.operator("graph.hide", text="Hide Selected Curves").unselected = False
+        layout.operator("graph.hide", text="Hide Unselected Curves").unselected = True
+        layout.operator("graph.reveal")
+
+        layout.separator()
+        layout.operator("anim.channels_expand")
+        layout.operator("anim.channels_collapse")
+
+        layout.separator()
+        layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
+
+        layout.separator()
+
+        layout.operator("anim.channels_delete")
+        if st.mode == 'DRIVERS':
+            layout.operator("graph.driver_delete_invalid")
+
+
 classes = (
     GRAPH_HT_header,
     GRAPH_MT_editor_menus,
@@ -312,6 +432,11 @@ classes = (
     GRAPH_MT_key,
     GRAPH_MT_key_transform,
     GRAPH_MT_delete,
+    GRAPH_MT_specials,
+    GRAPH_MT_channel_specials,
+    GRAPH_MT_pivot_pie,
+    GRAPH_MT_snap_pie,
+    GRAPH_PT_filters,
 )
 
 if __name__ == "__main__":  # only for live edit.