diff options
author | Germano Cavalcante <mano-wii> | 2021-08-13 21:51:02 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-08-13 23:28:46 +0300 |
commit | 0ed2df81cc3878d83a179ade256ba2d690ce9cde (patch) | |
tree | fa362ab365177f0b6a1cb75b3e5f0ad724e18973 /source/blender/editors/space_outliner | |
parent | 5655b3d1c55a1fb631a8eb40ac96d875b2ab213d (diff) |
Fix T90637: Outliner: VSE context menu options are not working
Some of the enum options in the context menu operations are not
supported for all element types.
`TSE_SEQUENCE`, for example, only supports the `Select` option.
So, populate the enum list dynamically depending on the type.
Also add some calls that were missing for the `TSE_SEQUENCE` type.
(`WM_event_add_notifier` and `ED_undo_push`).
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tools.c | 80 |
1 files changed, 62 insertions, 18 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index a994368a0ec..2474b54384d 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -78,6 +78,8 @@ #include "ED_sequencer.h" #include "ED_undo.h" +#include "SEQ_relations.h" + #include "WM_api.h" #include "WM_message.h" #include "WM_types.h" @@ -1281,18 +1283,31 @@ static void ebone_fn(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), } } -static void sequence_fn(int event, TreeElement *te, TreeStoreElem *tselem, void *scene_ptr) +static void sequence_fn(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *scene_ptr) { Sequence *seq = (Sequence *)te->directdata; - if (event == OL_DOP_SELECT) { - Scene *scene = (Scene *)scene_ptr; - Editing *ed = SEQ_editing_get(scene, false); - if (BLI_findindex(ed->seqbasep, seq) != -1) { + Scene *scene = (Scene *)scene_ptr; + Editing *ed = SEQ_editing_get(scene, false); + if (BLI_findindex(ed->seqbasep, seq) != -1) { + if (event == OL_DOP_SELECT) { ED_sequencer_select_sequence_single(scene, seq, true); } + else if (event == OL_DOP_DESELECT) { + seq->flag &= ~SELECT; + } + else if (event == OL_DOP_HIDE) { + if (!(seq->flag & SEQ_MUTE)) { + seq->flag |= SEQ_MUTE; + SEQ_relations_invalidate_dependent(scene, seq); + } + } + else if (event == OL_DOP_UNHIDE) { + if (seq->flag & SEQ_MUTE) { + seq->flag &= ~SEQ_MUTE; + SEQ_relations_invalidate_dependent(scene, seq); + } + } } - - (void)tselem; } static void gpencil_layer_fn(int event, @@ -2709,16 +2724,6 @@ void OUTLINER_OT_modifier_operation(wmOperatorType *ot) /** \name Data Menu Operator * \{ */ -/* XXX: select linked is for RNA structs only. */ -static const EnumPropertyItem prop_data_op_types[] = { - {OL_DOP_SELECT, "SELECT", 0, "Select", ""}, - {OL_DOP_DESELECT, "DESELECT", 0, "Deselect", ""}, - {OL_DOP_HIDE, "HIDE", 0, "Hide", ""}, - {OL_DOP_UNHIDE, "UNHIDE", 0, "Unhide", ""}, - {OL_DOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""}, - {0, NULL, 0, NULL, NULL}, -}; - static int outliner_data_operation_exec(bContext *C, wmOperator *op) { SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); @@ -2762,6 +2767,8 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); outliner_do_data_operation( space_outliner, datalevel, event, &space_outliner->tree, sequence_fn, scene); + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); + ED_undo_push(C, "Sequencer operation"); break; } @@ -2789,6 +2796,42 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +/* Dynamically populate an enum of Keying Sets */ +static const EnumPropertyItem *outliner_data_op_sets_enum_item_fn(bContext *C, + PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), + bool *UNUSED(r_free)) +{ + /* Check for invalid states. */ + if (C == NULL) { + return DummyRNA_DEFAULT_items; + } + + SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); + if (space_outliner == NULL) { + return DummyRNA_DEFAULT_items; + } + + static const EnumPropertyItem optype_sel_and_hide[] = { + {OL_DOP_SELECT, "SELECT", 0, "Select", ""}, + {OL_DOP_DESELECT, "DESELECT", 0, "Deselect", ""}, + {OL_DOP_HIDE, "HIDE", 0, "Hide", ""}, + {OL_DOP_UNHIDE, "UNHIDE", 0, "Unhide", ""}, + {0, NULL, 0, NULL, NULL}}; + + static const EnumPropertyItem optype_sel_linked[] = { + {OL_DOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""}, {0, NULL, 0, NULL, NULL}}; + + TreeElement *te = get_target_element(space_outliner); + TreeStoreElem *tselem = TREESTORE(te); + + if (tselem->type == TSE_RNA_STRUCT) { + return optype_sel_linked; + } + + return optype_sel_and_hide; +} + void OUTLINER_OT_data_operation(wmOperatorType *ot) { /* identifiers */ @@ -2802,7 +2845,8 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot) ot->flag = 0; - ot->prop = RNA_def_enum(ot->srna, "type", prop_data_op_types, 0, "Data Operation", ""); + ot->prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Data Operation", ""); + RNA_def_enum_funcs(ot->prop, outliner_data_op_sets_enum_item_fn); } /** \} */ |