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.
This commit is contained in:
Richard Antalik 2020-01-22 14:54:44 +01:00
parent f559e3977e
commit 6a49161c8c
13 changed files with 432 additions and 49 deletions

View File

@ -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),
]
# ------------------------------------------------------------------------------

View File

@ -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,

View File

@ -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

View File

@ -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 = {
None: [
],
'PREVIEW': [
*_tools_annotate,
],
'SEQUENCER': [
*_tools_select,
_defs_sequencer_generic.cut,
],
'SEQUENCER_PREVIEW': [
*_tools_select,
*_tools_annotate,
_defs_sequencer_generic.cut,
],
}
classes = (
IMAGE_PT_tools_active,
NODE_PT_tools_active,
VIEW3D_PT_tools_active,
SEQUENCER_PT_tools_active,
)
if __name__ == "__main__": # only for live edit.

View File

@ -504,6 +504,7 @@ enum {
SEQ_SIDE_LEFT,
SEQ_SIDE_RIGHT,
SEQ_SIDE_BOTH,
SEQ_SIDE_NO_CHANGE,
};
int BKE_sequencer_find_next_prev_edit(struct Scene *scene,
int cfra,

View File

@ -636,6 +636,29 @@ static ARegion *do_versions_add_region(int regiontype, const char *name)
return ar;
}
static void do_versions_area_ensure_tool_region(Main *bmain,
const short space_type,
const short region_flag)
{
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == space_type) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
if (!ar) {
ARegion *header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
ar = do_versions_add_region(RGN_TYPE_TOOLS, "tools region");
BLI_insertlinkafter(regionbase, header, ar);
ar->alignment = RGN_ALIGN_LEFT;
ar->flag = region_flag;
}
}
}
}
}
}
static void do_version_bones_split_bbone_scale(ListBase *lb)
{
for (Bone *bone = lb->first; bone; bone = bone->next) {
@ -3738,7 +3761,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
/* All spaces that use tools must be eventually added. */
ARegion *ar = NULL;
if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_IMAGE) &&
if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_SEQ) &&
((ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER)) == NULL)) {
/* Add tool header. */
ar = do_versions_add_region(RGN_TYPE_TOOL_HEADER, "tool header");
@ -4338,6 +4361,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
/* Keep this block, even when empty. */
/* Sequencer Tool region */
do_versions_area_ensure_tool_region(bmain, SPACE_SEQ, RGN_FLAG_HIDDEN);
/* Cloth internal springs */
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {

View File

@ -103,6 +103,7 @@ EnumPropertyItem prop_side_types[] = {
{SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
{SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
{SEQ_SIDE_BOTH, "BOTH", 0, "Both", ""},
{SEQ_SIDE_NO_CHANGE, "NO_CHANGE", 0, "No change", ""},
{0, NULL, 0, NULL, NULL},
};
@ -958,6 +959,8 @@ static bool cut_seq_list(Main *bmain,
Scene *scene,
ListBase *slist,
int cutframe,
int channel,
bool use_cursor_position,
Sequence *(*cut_seq)(Main *bmain, Scene *, Sequence *, ListBase *, int))
{
Sequence *seq, *seq_next_iter;
@ -968,8 +971,8 @@ static bool cut_seq_list(Main *bmain,
while (seq && seq != seq_first_new) {
seq_next_iter = seq->next; /* we need this because we may remove seq */
seq->tmp = NULL;
if (seq->flag & SELECT) {
if (cutframe > seq->startdisp && cutframe < seq->enddisp) {
if (use_cursor_position) {
if (seq->machine == channel && seq->startdisp < cutframe && seq->enddisp > cutframe) {
Sequence *seqn = cut_seq(bmain, scene, seq, slist, cutframe);
if (seqn) {
if (seq_first_new == NULL) {
@ -977,16 +980,28 @@ static bool cut_seq_list(Main *bmain,
}
}
}
else if (seq->enddisp <= cutframe) {
/* do nothing */
}
else if (seq->startdisp >= cutframe) {
/* move to tail */
BLI_remlink(slist, seq);
BLI_addtail(slist, seq);
}
else {
if (seq->flag & SELECT) {
if (cutframe > seq->startdisp && cutframe < seq->enddisp) {
Sequence *seqn = cut_seq(bmain, scene, seq, slist, cutframe);
if (seqn) {
if (seq_first_new == NULL) {
seq_first_new = seqn;
}
}
}
else if (seq->enddisp <= cutframe) {
/* do nothing */
}
else if (seq->startdisp >= cutframe) {
/* move to tail */
BLI_remlink(slist, seq);
BLI_addtail(slist, seq);
if (seq_first_new == NULL) {
seq_first_new = seq;
if (seq_first_new == NULL) {
seq_first_new = seq;
}
}
}
}
@ -2154,40 +2169,64 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
int cut_side, cut_hard, cut_frame;
bool changed;
int cut_side, cut_hard, cut_frame, cut_channel;
bool changed, use_cursor_position, ignore_selection;
bool seq_selected = false;
cut_frame = RNA_int_get(op->ptr, "frame");
cut_channel = RNA_int_get(op->ptr, "channel");
use_cursor_position = RNA_boolean_get(op->ptr, "use_cursor_position");
cut_hard = RNA_enum_get(op->ptr, "type");
cut_side = RNA_enum_get(op->ptr, "side");
ignore_selection = RNA_boolean_get(op->ptr, "ignore_selection");
if (cut_hard == SEQ_CUT_HARD) {
changed = cut_seq_list(bmain, scene, ed->seqbasep, cut_frame, cut_seq_hard);
changed = cut_seq_list(
bmain, scene, ed->seqbasep, cut_frame, cut_channel, use_cursor_position, cut_seq_hard);
}
else {
changed = cut_seq_list(bmain, scene, ed->seqbasep, cut_frame, cut_seq_soft);
changed = cut_seq_list(
bmain, scene, ed->seqbasep, cut_frame, cut_channel, use_cursor_position, cut_seq_soft);
}
if (changed) { /* got new strips ? */
Sequence *seq;
if (cut_side != SEQ_SIDE_BOTH) {
SEQP_BEGIN (ed, seq) {
if (cut_side == SEQ_SIDE_LEFT) {
if (seq->startdisp >= cut_frame) {
seq->flag &= ~SEQ_ALLSEL;
if (ignore_selection) {
if (use_cursor_position) {
SEQP_BEGIN (ed, seq) {
if (seq->enddisp == cut_frame && seq->machine == cut_channel) {
seq_selected = seq->flag & SEQ_ALLSEL;
}
}
else {
if (seq->enddisp <= cut_frame) {
seq->flag &= ~SEQ_ALLSEL;
SEQ_END;
if (!seq_selected) {
SEQP_BEGIN (ed, seq) {
if (seq->startdisp == cut_frame && seq->machine == cut_channel) {
seq->flag &= ~SEQ_ALLSEL;
}
}
SEQ_END;
}
}
SEQ_END;
}
else {
if (cut_side != SEQ_SIDE_BOTH) {
SEQP_BEGIN (ed, seq) {
if (cut_side == SEQ_SIDE_LEFT) {
if (seq->startdisp >= cut_frame) {
seq->flag &= ~SEQ_ALLSEL;
}
}
else {
if (seq->enddisp <= cut_frame) {
seq->flag &= ~SEQ_ALLSEL;
}
}
}
SEQ_END;
}
}
SEQP_BEGIN (ed, seq) {
if (seq->seq1 || seq->seq2 || seq->seq3) {
BKE_sequence_calc(scene, seq);
@ -2204,7 +2243,8 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
else {
return OPERATOR_CANCELLED;
/* Passthrough to selection if used as tool. */
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
}
@ -2224,7 +2264,17 @@ static int sequencer_cut_invoke(bContext *C, wmOperator *op, const wmEvent *even
cut_side = SEQ_SIDE_BOTH;
}
}
RNA_int_set(op->ptr, "frame", cut_frame);
float mouseloc[2];
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &mouseloc[0], &mouseloc[1]);
if (RNA_boolean_get(op->ptr, "use_cursor_position")) {
RNA_int_set(op->ptr, "frame", mouseloc[0]);
}
else {
RNA_int_set(op->ptr, "frame", cut_frame);
}
RNA_int_set(op->ptr, "channel", mouseloc[1]);
RNA_enum_set(op->ptr, "side", cut_side);
/*RNA_enum_set(op->ptr, "type", cut_hard); */ /*This type is set from the key shortcut */
return sequencer_cut_exec(C, op);
@ -2255,19 +2305,43 @@ void SEQUENCER_OT_cut(struct wmOperatorType *ot)
"Frame where selected strips will be cut",
INT_MIN,
INT_MAX);
RNA_def_int(ot->srna,
"channel",
0,
INT_MIN,
INT_MAX,
"Channel",
"Channel in which strip will be cut",
INT_MIN,
INT_MAX);
RNA_def_enum(ot->srna,
"type",
prop_cut_types,
SEQ_CUT_SOFT,
"Type",
"The type of cut operation to perform on strips");
RNA_def_boolean(ot->srna,
"use_cursor_position",
0,
"Use Cursor Position",
"Cut at position of the cursor instead of playhead");
prop = RNA_def_enum(ot->srna,
"side",
prop_side_types,
SEQ_SIDE_MOUSE,
"Side",
"The side that remains selected after cutting");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(
ot->srna,
"ignore_selection",
false,
"Ignore Selection",
"Make cut event if strip is not selected preserving selection state after cut");
RNA_def_property_flag(prop, PROP_HIDDEN);
}
#undef SEQ_SIDE_MOUSE

View File

@ -110,6 +110,14 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
ar->alignment = RGN_ALIGN_RIGHT;
ar->flag = RGN_FLAG_HIDDEN;
/* toolbar */
ar = MEM_callocN(sizeof(ARegion), "tools for sequencer");
BLI_addtail(&sseq->regionbase, ar);
ar->regiontype = RGN_TYPE_TOOLS;
ar->alignment = RGN_ALIGN_LEFT;
ar->flag = RGN_FLAG_HIDDEN;
/* preview region */
/* NOTE: if you change values here, also change them in sequencer_init_preview_region */
ar = MEM_callocN(sizeof(ARegion), "preview region for sequencer");
@ -618,6 +626,23 @@ static void sequencer_header_region_draw(const bContext *C, ARegion *ar)
ED_region_header(C, ar);
}
/* *********************** toolbar region ************************ */
/* add handlers, stuff you only do once or on area/region changes */
static void sequencer_tools_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
ED_region_panels_init(wm, ar);
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void sequencer_tools_region_draw(const bContext *C, ARegion *ar)
{
ED_region_panels(C, ar);
}
/* *********************** preview region ************************ */
static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *ar)
{
@ -832,7 +857,7 @@ void ED_spacetype_sequencer(void)
art->draw = sequencer_main_region_draw;
art->listener = sequencer_main_region_listener;
art->message_subscribe = sequencer_main_region_message_subscribe;
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_ANIMATION;
art->keymapflag = ED_KEYMAP_TOOL | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_ANIMATION;
BLI_addhead(&st->regiontypes, art);
@ -842,7 +867,8 @@ void ED_spacetype_sequencer(void)
art->init = sequencer_preview_region_init;
art->draw = sequencer_preview_region_draw;
art->listener = sequencer_preview_region_listener;
art->keymapflag = ED_KEYMAP_GIZMO | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL;
art->keymapflag = ED_KEYMAP_TOOL | ED_KEYMAP_GIZMO | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES |
ED_KEYMAP_GPENCIL;
BLI_addhead(&st->regiontypes, art);
/* regions: listview/buttons */
@ -850,12 +876,35 @@ void ED_spacetype_sequencer(void)
art->regionid = RGN_TYPE_UI;
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH * 1.3f;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_ui;
art->listener = sequencer_buttons_region_listener;
art->init = sequencer_buttons_region_init;
art->draw = sequencer_buttons_region_draw;
BLI_addhead(&st->regiontypes, art);
sequencer_buttons_register(art);
/* regions: tool(bar) */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer tools region");
art->regionid = RGN_TYPE_TOOLS;
art->prefsizex = 58; /* XXX */
art->prefsizey = 50; /* XXX */
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->message_subscribe = ED_region_generic_tools_region_message_subscribe;
art->snap_size = ED_region_generic_tools_region_snap_size;
art->init = sequencer_tools_region_init;
art->draw = sequencer_tools_region_draw;
BLI_addhead(&st->regiontypes, art);
/* regions: tool header */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer tool header region");
art->regionid = RGN_TYPE_TOOL_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
art->listener = sequencer_main_region_listener;
art->init = sequencer_header_region_init;
art->draw = sequencer_header_region_draw;
art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header;
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");

View File

@ -52,6 +52,7 @@ extern const EnumPropertyItem rna_enum_mesh_select_mode_items[];
extern const EnumPropertyItem rna_enum_mesh_select_mode_uv_items[];
extern const EnumPropertyItem rna_enum_mesh_delimit_mode_items[];
extern const EnumPropertyItem rna_enum_space_graph_mode_items[];
extern const EnumPropertyItem rna_enum_space_sequencer_view_type_items[];
extern const EnumPropertyItem rna_enum_space_type_items[];
extern const EnumPropertyItem rna_enum_space_image_mode_items[];
extern const EnumPropertyItem rna_enum_space_image_mode_all_items[];

View File

@ -161,6 +161,13 @@ const EnumPropertyItem rna_enum_space_graph_mode_items[] = {
{0, NULL, 0, NULL, NULL},
};
const EnumPropertyItem rna_enum_space_sequencer_view_type_items[] = {
{SEQ_VIEW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""},
{SEQ_VIEW_PREVIEW, "PREVIEW", ICON_SEQ_PREVIEW, "Preview", ""},
{SEQ_VIEW_SEQUENCE_PREVIEW, "SEQUENCER_PREVIEW", ICON_SEQ_SPLITVIEW, "Sequencer/Preview", ""},
{0, NULL, 0, NULL, NULL},
};
#define SACT_ITEM_DOPESHEET \
{ \
SACTCONT_DOPESHEET, "DOPESHEET", ICON_ACTION, "Dope Sheet", "Edit all keyframes in scene" \
@ -4458,17 +4465,6 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
static const EnumPropertyItem view_type_items[] = {
{SEQ_VIEW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""},
{SEQ_VIEW_PREVIEW, "PREVIEW", ICON_SEQ_PREVIEW, "Preview", ""},
{SEQ_VIEW_SEQUENCE_PREVIEW,
"SEQUENCER_PREVIEW",
ICON_SEQ_SPLITVIEW,
"Sequencer/Preview",
""},
{0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem display_mode_items[] = {
{SEQ_DRAW_IMG_IMBUF, "IMAGE", ICON_SEQ_PREVIEW, "Image Preview", ""},
{SEQ_DRAW_IMG_WAVEFORM, "WAVEFORM", ICON_SEQ_LUMA_WAVEFORM, "Luma Waveform", ""},
@ -4528,12 +4524,13 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SpaceSeq");
RNA_def_struct_ui_text(srna, "Space Sequence Editor", "Sequence editor space data");
rna_def_space_generic_show_region_toggles(srna, ((1 << RGN_TYPE_UI) | (1 << RGN_TYPE_HUD)));
rna_def_space_generic_show_region_toggles(
srna, (1 << RGN_TYPE_TOOL_HEADER) | (1 << RGN_TYPE_UI) | (1 << RGN_TYPE_TOOLS));
/* view type, fairly important */
prop = RNA_def_property(srna, "view_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "view");
RNA_def_property_enum_items(prop, view_type_items);
RNA_def_property_enum_items(prop, rna_enum_space_sequencer_view_type_items);
RNA_def_property_ui_text(
prop, "View Type", "Type of the Sequencer view (sequencer, preview or both)");
RNA_def_property_update(prop, 0, "rna_Sequencer_view_type_update");

View File

@ -152,7 +152,17 @@ static bToolRef *rna_WorkSpace_tools_from_space_node(WorkSpace *workspace, bool
},
create);
}
static bToolRef *rna_WorkSpace_tools_from_space_sequencer(WorkSpace *workspace,
int mode,
bool create)
{
return rna_WorkSpace_tools_from_tkey(workspace,
&(bToolKey){
.space_type = SPACE_SEQ,
.mode = mode,
},
create);
}
const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf(bContext *UNUSED(C),
PointerRNA *ptr,
PropertyRNA *UNUSED(prop),
@ -164,6 +174,8 @@ const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf(bContext *UNUSED(C),
return rna_enum_context_mode_items;
case SPACE_IMAGE:
return rna_enum_space_image_mode_all_items;
case SPACE_SEQ:
return rna_enum_space_sequencer_view_type_items;
}
return DummyRNA_DEFAULT_items;
}
@ -335,6 +347,16 @@ static void rna_def_workspace_tools(BlenderRNA *brna, PropertyRNA *cprop)
/* return type */
parm = RNA_def_pointer(func, "result", "WorkSpaceTool", "", "");
RNA_def_function_return(func, parm);
func = RNA_def_function(
srna, "from_space_sequencer", "rna_WorkSpace_tools_from_space_sequencer");
RNA_def_function_ui_description(func, "");
parm = RNA_def_enum(func, "mode", rna_enum_space_sequencer_view_type_items, 0, "", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_boolean(func, "create", false, "Create", "");
/* return type */
parm = RNA_def_pointer(func, "result", "WorkSpaceTool", "", "");
RNA_def_function_return(func, parm);
}
static void rna_def_workspace(BlenderRNA *brna)

View File

@ -41,8 +41,8 @@ struct wmOperatorType;
/* wm_toolsystem.c */
#define WM_TOOLSYSTEM_SPACE_MASK ((1 << SPACE_IMAGE) | (1 << SPACE_NODE) | (1 << SPACE_VIEW3D))
#define WM_TOOLSYSTEM_SPACE_MASK \
((1 << SPACE_IMAGE) | (1 << SPACE_NODE) | (1 << SPACE_VIEW3D) | (1 << SPACE_SEQ))
/* Values that define a categoey of active tool. */
typedef struct bToolKey {
int space_type;

View File

@ -487,6 +487,8 @@ static bool toolsystem_key_ensure_check(const bToolKey *tkey)
break;
case SPACE_NODE:
return true;
case SPACE_SEQ:
return true;
}
return false;
}
@ -516,6 +518,11 @@ int WM_toolsystem_mode_from_spacetype(ViewLayer *view_layer, ScrArea *sa, int sp
mode = 0;
break;
}
case SPACE_SEQ: {
SpaceSeq *sseq = sa->spacedata.first;
mode = sseq->view;
break;
}
}
return mode;
}
@ -736,6 +743,17 @@ static const char *toolsystem_default_tool(const bToolKey *tkey)
case SPACE_NODE: {
return "builtin.select_box";
}
case SPACE_SEQ: {
switch (tkey->mode) {
case SEQ_VIEW_SEQUENCE:
return "builtin.select";
case SEQ_VIEW_PREVIEW:
return "builtin.annotate";
case SEQ_VIEW_SEQUENCE_PREVIEW:
return "builtin.select";
}
return "builtin.select_box";
}
}
return "builtin.select_box";