[Bf-blender-cvs] [6a49161c8c6] master: VSE: Tool system integration

Richard Antalik noreply at git.blender.org
Wed Jan 22 15:07:09 CET 2020


Commit: 6a49161c8c60cb63d9e3ed8dbe700163ff858436
Author: Richard Antalik
Date:   Wed Jan 22 14:54:44 2020 +0100
Branches: master
https://developer.blender.org/rB6a49161c8c60cb63d9e3ed8dbe700163ff858436

VSE: Tool system integration

Add toolbar to sequencer regions.

A bit of refactoring has to be done in RNA space.
Currently there is only cut tool implemented to serve as template for
anybody who would like to add more.

===================================================================

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_sequencer.py
M	release/scripts/startup/bl_ui/space_toolsystem_common.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/blenkernel/BKE_sequencer.h
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/space_sequencer/sequencer_edit.c
M	source/blender/editors/space_sequencer/space_sequencer.c
M	source/blender/makesrna/RNA_enum_types.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_workspace.c
M	source/blender/windowmanager/WM_toolsystem.h
M	source/blender/windowmanager/intern/wm_toolsystem.c

===================================================================

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index bc4b5f49bdc..81d59f9f751 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -2335,6 +2335,7 @@ def km_sequencercommon(_params):
 
     items.extend([
         *_template_space_region_type_toggle(
+            toolbar_key={"type": 'T', "value": 'PRESS'},
             sidebar_key={"type": 'N', "value": 'PRESS'},
         ),
         ("wm.context_toggle", {"type": 'O', "value": 'PRESS', "shift": True},
@@ -2342,6 +2343,13 @@ def km_sequencercommon(_params):
         ("sequencer.view_toggle", {"type": 'TAB', "value": 'PRESS', "ctrl": True}, None),
     ])
 
+    if _params.select_mouse == 'LEFTMOUSE' and not _params.legacy:
+        # Quick switch to select tool, since left select can't easily
+        # select with any tool active.
+        items.extend([
+            op_tool_cycle("builtin.select_box", {"type": 'W', "value": 'PRESS'}),
+        ])
+
     return keymap
 
 
@@ -6051,6 +6059,39 @@ def km_3d_view_tool_sculpt_gpencil_select_lasso(params):
     )
 
 
+def km_sequencer_editor_tool_select(params):
+    return (
+        "Sequencer Tool: Select",
+        {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
+        {"items": [
+            ("sequencer.select", {"type": params.select_mouse, "value": 'PRESS'},
+             {"properties": [("extend", False), ("deselect_all", not params.legacy)]}),
+        ]},
+    )
+
+
+def km_sequencer_editor_tool_select_box(params):
+    return (
+        "Sequencer Tool: Select Box",
+        {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
+        {"items": _template_items_tool_select_actions_simple(
+            "sequencer.select_box", type=params.tool_tweak, value='ANY',
+            properties=[("tweak", True)],
+        )},
+    )
+
+
+def km_sequencer_editor_tool_cut(params):
+    return (
+        "Sequencer Tool: Cut",
+        {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
+        {"items":[
+            ("sequencer.cut", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+             {"properties": [("type", 'SOFT'), ("side", 'NO_CHANGE'), ("use_cursor_position", True), ("ignore_selection", True)]}),
+        ]},
+    )
+
+
 # ------------------------------------------------------------------------------
 # Full Configuration
 
@@ -6264,6 +6305,9 @@ def generate_keymaps(params=None):
         km_3d_view_tool_sculpt_gpencil_select_box(params),
         km_3d_view_tool_sculpt_gpencil_select_circle(params),
         km_3d_view_tool_sculpt_gpencil_select_lasso(params),
+        km_sequencer_editor_tool_select(params),
+        km_sequencer_editor_tool_select_box(params),
+        km_sequencer_editor_tool_cut(params),
     ]
 
 # ------------------------------------------------------------------------------
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 5f23c7bca20..0e78ddfb648 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -30,6 +30,9 @@ from bpy.app.translations import (
 from bl_ui.properties_grease_pencil_common import (
     AnnotationDataPanel,
 )
+from bl_ui.space_toolsystem_common import (
+    ToolActivePanelHelper,
+)
 from rna_prop_ui import PropertyPanel
 
 
@@ -89,6 +92,35 @@ def draw_color_balance(layout, color_balance):
     split.template_color_picker(color_balance, "gain", value_slider=True, lock_luminosity=True, cubic=True)
 
 
+class SEQUENCER_PT_active_tool(ToolActivePanelHelper, Panel):
+    bl_space_type = 'SEQUENCE_EDITOR'
+    bl_region_type = 'UI'
+    bl_category = "Tool"
+
+
+class SEQUENCER_HT_tool_header(Header):
+    bl_space_type = 'SEQUENCE_EDITOR'
+    bl_region_type = 'TOOL_HEADER'
+
+    def draw(self, context):
+        layout = self.layout
+
+        layout.template_header()
+
+        self.draw_tool_settings(context)
+
+        # TODO: options popover.
+
+    def draw_tool_settings(self, context):
+        layout = self.layout
+
+        # Active Tool
+        # -----------
+        from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
+        tool = ToolSelectPanelHelper.draw_active_tool_header(context, layout)
+        tool_mode = context.mode if tool is None else tool.mode
+
+
 class SEQUENCER_HT_header(Header):
     bl_space_type = 'SEQUENCE_EDITOR'
 
@@ -97,7 +129,10 @@ class SEQUENCER_HT_header(Header):
 
         st = context.space_data
 
-        layout.template_header()
+        show_region_tool_header = st.show_region_tool_header
+
+        if not show_region_tool_header:
+            layout.template_header()
 
         layout.prop(st, "view_type", text="")
 
@@ -226,6 +261,7 @@ class SEQUENCER_MT_view(Menu):
             # wm_keymap_item_find_props() (see #32595).
             layout.operator_context = 'INVOKE_REGION_PREVIEW'
         layout.prop(st, "show_region_ui")
+        layout.prop(st, "show_region_toolbar")
         layout.operator_context = 'INVOKE_DEFAULT'
 
         if is_sequencer_view:
@@ -2131,6 +2167,7 @@ class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
 
 classes = (
     SEQUENCER_MT_change,
+    SEQUENCER_HT_tool_header,
     SEQUENCER_HT_header,
     SEQUENCER_MT_editor_menus,
     SEQUENCER_MT_range,
@@ -2156,7 +2193,7 @@ classes = (
     SEQUENCER_MT_strip_input,
     SEQUENCER_MT_strip_lock_mute,
     SEQUENCER_MT_context_menu,
-
+    SEQUENCER_PT_active_tool,
     SEQUENCER_PT_strip,
 
     SEQUENCER_PT_effect,
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 05785b85dfc..4dc724299f0 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -390,6 +390,14 @@ class ToolSelectPanelHelper:
             if tool is not None:
                 tool.refresh_from_context()
                 return tool
+        elif space_type == 'SEQUENCE_EDITOR':
+            space_data = context.space_data
+            if mode is None:
+                mode = space_data.view_type
+            tool = context.workspace.tools.from_space_sequencer(mode, create=create)
+            if tool is not None:
+                tool.refresh_from_context()
+                return tool
         return None
 
     @staticmethod
@@ -656,6 +664,8 @@ class ToolSelectPanelHelper:
             return space_type, space_data.mode
         elif space_type == 'NODE_EDITOR':
             return space_type, None
+        elif space_type == 'SEQUENCE_EDITOR':
+            return space_type, context.space_data.view_type
         else:
             return None, None
 
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 170b635f7e1..c03d681f2b2 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1707,6 +1707,51 @@ class _defs_node_edit:
             keymap="Node Tool: Links Cut",
         )
 
+class _defs_sequencer_generic:
+
+    @ToolDef.from_fn
+    def cut():
+        def draw_settings(_context, layout, tool):
+            props = tool.operator_properties("sequencer.cut")
+            row = layout.row()
+            row.use_property_split = False
+            row.prop(props, "type", expand=True)
+        return dict(
+            idname="builtin.cut",
+            label="Cut",
+            icon="ops.mesh.knife_tool",
+            widget=None,
+            keymap="Sequencer Tool: Cut",
+            draw_settings=draw_settings,
+        )
+
+class _defs_sequencer_select:
+    @ToolDef.from_fn
+    def select():
+        return dict(
+            idname="builtin.select",
+            label="Select",
+            icon="ops.generic.select",
+            widget=None,
+            keymap="Sequencer Tool: Select",
+        )
+    @ToolDef.from_fn
+    def box():
+        def draw_settings(_context, layout, tool):
+            props = tool.operator_properties("sequencer.select_box")
+            row = layout.row()
+            row.use_property_split = False
+            row.prop(props, "mode", text="", expand=True, icon_only=True)
+            pass
+        return dict(
+            idname="builtin.select_box",
+            label="Select Box",
+            icon="ops.generic.select_box",
+            widget=None,
+            keymap="Sequencer Tool: Select Box",
+            draw_settings=draw_settings,
+        )
+
 
 class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
     bl_space_type = 'IMAGE_EDITOR'
@@ -2150,12 +2195,71 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
             *_tools_annotate,
         ],
     }
+class SEQUENCER_PT_tools_active(ToolSelectPanelHelper, Panel):
+    bl_space_type = 'SEQUENCE_EDITOR'
+    bl_region_type = 'TOOLS'
+    bl_label = "Tools"  # not visible
+    bl_options = {'HIDE_HEADER'}
+
+    # Satisfy the 'ToolSelectPanelHelper' API.
+    keymap_prefix = "Sequence Editor Tool:"
+
+    # Default group to use as a fallback.
+    tool_fallback_id = "builtin.select"
+
+    @classmethod
+    def tools_from_context(cls, context, mode=None):
+        if mode is None:
+            if context.space_data:
+                mode = context.space_data.view_type
+        for tools in (cls._tools[None], cls._tools.get(mode, ())):
+            for item in tools:
+                if not (type(item) is ToolDef) and callable(item):
+                    yield from item(context)
+                else:
+                    yield item
+
+    @classmethod
+    def tools_all(cls):
+        yield from cls._tools.items()
 
+    _tools_select = (
+        (
+            _defs_sequencer_select.select,
+            _defs_sequencer_select.box,
+        ),
+    )
+    _tools_annotate = (
+        (
+            _defs_annotate.scribble,
+            _defs_annotate.line,
+            _defs_annotate.poly,
+            _defs_annotate.eraser,
+        ),
+    )
+
+    _tools = {
+ 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list