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`).
This commit is contained in:
parent
5655b3d1c5
commit
0ed2df81cc
Notes:
blender-bot
2023-02-14 02:41:05 +01:00
Referenced by issue #90637, Outliner: VSE context menu options are not working
|
@ -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);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
Loading…
Reference in New Issue