Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_tools.c
| Show All 14 Lines | |||||
| * | * | ||||
| * The Original Code is Copyright (C) 2004 Blender Foundation. | * The Original Code is Copyright (C) 2004 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup spoutliner | * \ingroup spoutliner | ||||
| */ | */ | ||||
| #include <string.h> | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "CLG_log.h" | #include "CLG_log.h" | ||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| ▲ Show 20 Lines • Show All 1,245 Lines • ▼ Show 20 Lines | else if (event == OL_DOP_HIDE) { | ||||
| ebone->flag |= BONE_HIDDEN_A; | ebone->flag |= BONE_HIDDEN_A; | ||||
| ebone->flag &= ~BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; | ebone->flag &= ~BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; | ||||
| } | } | ||||
| else if (event == OL_DOP_UNHIDE) { | else if (event == OL_DOP_UNHIDE) { | ||||
| ebone->flag &= ~BONE_HIDDEN_A; | ebone->flag &= ~BONE_HIDDEN_A; | ||||
| } | } | ||||
| } | } | ||||
| 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; | Sequence *seq = (Sequence *)te->directdata; | ||||
| if (event == OL_DOP_SELECT) { | |||||
| Scene *scene = (Scene *)scene_ptr; | Scene *scene = (Scene *)scene_ptr; | ||||
| Editing *ed = SEQ_editing_get(scene, false); | Editing *ed = SEQ_editing_get(scene, false); | ||||
| if (BLI_findindex(ed->seqbasep, seq) != -1) { | if (BLI_findindex(ed->seqbasep, seq) != -1) { | ||||
| if (event == OL_DOP_SELECT) { | |||||
| ED_sequencer_select_sequence_single(scene, seq, true); | ED_sequencer_select_sequence_single(scene, seq, true); | ||||
| } | } | ||||
| else { | |||||
| BLI_assert(event == OL_DOP_DESELECT); | |||||
| seq->flag &= ~SELECT; | |||||
| } | |||||
| } | } | ||||
| (void)tselem; | |||||
| } | } | ||||
| static void gpencil_layer_fn(int event, | static void gpencil_layer_fn(int event, | ||||
| TreeElement *te, | TreeElement *te, | ||||
| TreeStoreElem *UNUSED(tselem), | TreeStoreElem *UNUSED(tselem), | ||||
| void *UNUSED(arg)) | void *UNUSED(arg)) | ||||
| { | { | ||||
| bGPDlayer *gpl = (bGPDlayer *)te->directdata; | bGPDlayer *gpl = (bGPDlayer *)te->directdata; | ||||
| ▲ Show 20 Lines • Show All 1,400 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Data Menu Operator | /** \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) | static int outliner_data_operation_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); | SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); | ||||
| int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; | int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; | ||||
| /* check for invalid states */ | /* check for invalid states */ | ||||
| if (space_outliner == NULL) { | if (space_outliner == NULL) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| Show All 27 Lines | case TSE_EBONE: { | ||||
| ED_undo_push(C, "EditBone operation"); | ED_undo_push(C, "EditBone operation"); | ||||
| break; | break; | ||||
| } | } | ||||
| case TSE_SEQUENCE: { | case TSE_SEQUENCE: { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| outliner_do_data_operation( | outliner_do_data_operation( | ||||
| space_outliner, datalevel, event, &space_outliner->tree, sequence_fn, scene); | 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; | break; | ||||
| } | } | ||||
| case TSE_GP_LAYER: { | case TSE_GP_LAYER: { | ||||
| outliner_do_data_operation( | outliner_do_data_operation( | ||||
| space_outliner, datalevel, event, &space_outliner->tree, gpencil_layer_fn, NULL); | space_outliner, datalevel, event, &space_outliner->tree, gpencil_layer_fn, NULL); | ||||
| WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL); | WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL); | ||||
| ED_undo_push(C, "Grease Pencil Layer operation"); | ED_undo_push(C, "Grease Pencil Layer operation"); | ||||
| Show All 11 Lines | switch (datalevel) { | ||||
| default: | default: | ||||
| BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); | BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); | ||||
| break; | break; | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | 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 *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; | |||||
| } | |||||
| /* The maximum possible is 4 items at the moment. */ | |||||
| static EnumPropertyItem prop_data_op_types[5]; | |||||
| EnumPropertyItem sel_op_types[] = {{OL_DOP_SELECT, "SELECT", 0, "Select", ""}, | |||||
| {OL_DOP_DESELECT, "DESELECT", 0, "Deselect", ""}}; | |||||
| EnumPropertyItem hid_op_types[] = {{OL_DOP_HIDE, "HIDE", 0, "Hide", ""}, | |||||
| {OL_DOP_UNHIDE, "UNHIDE", 0, "Unhide", ""}}; | |||||
| EnumPropertyItem slink_op_type = {OL_DOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""}; | |||||
| int totitem = 0; | |||||
| TreeElement *te = get_target_element(space_outliner); | |||||
| TreeStoreElem *tselem = TREESTORE(te); | |||||
| const int datalevel = tselem->type; | |||||
| if (ELEM(datalevel, TSE_POSE_CHANNEL, TSE_BONE, TSE_EBONE, TSE_SEQUENCE, TSE_GP_LAYER)) { | |||||
| memcpy(&prop_data_op_types[totitem], sel_op_types, sizeof(sel_op_types)); | |||||
| totitem += 2; | |||||
| if (datalevel != TSE_SEQUENCE) { | |||||
| memcpy(&prop_data_op_types[totitem], hid_op_types, sizeof(hid_op_types)); | |||||
| totitem += 2; | |||||
| } | |||||
| } | |||||
| if (ELEM(datalevel, TSE_RNA_STRUCT)) { | |||||
| memcpy(&prop_data_op_types[totitem++], &slink_op_type, sizeof(slink_op_type)); | |||||
| } | |||||
| memset(&prop_data_op_types[totitem], 0, sizeof(EnumPropertyItem)); | |||||
| *r_free = false; | |||||
| return prop_data_op_types; | |||||
| } | |||||
| void OUTLINER_OT_data_operation(wmOperatorType *ot) | void OUTLINER_OT_data_operation(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Outliner Data Operation"; | ot->name = "Outliner Data Operation"; | ||||
| ot->idname = "OUTLINER_OT_data_operation"; | ot->idname = "OUTLINER_OT_data_operation"; | ||||
| /* callbacks */ | /* callbacks */ | ||||
| ot->invoke = WM_menu_invoke; | ot->invoke = WM_menu_invoke; | ||||
| ot->exec = outliner_data_operation_exec; | ot->exec = outliner_data_operation_exec; | ||||
| ot->poll = ED_operator_outliner_active; | ot->poll = ED_operator_outliner_active; | ||||
| ot->flag = 0; | 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); | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Context Menu Operator | /** \name Context Menu Operator | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines | |||||