Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_context.c
| Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | if (obact && (obact->mode != OB_MODE_OBJECT)) { | ||||
| } | } | ||||
| FOREACH_OBJECT_IN_MODE_END; | FOREACH_OBJECT_IN_MODE_END; | ||||
| } | } | ||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) { | if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) { | ||||
| bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; | bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; | ||||
| EditBone *ebone, *flipbone = NULL; | EditBone *flipbone = NULL; | ||||
| const bool editable_bones = CTX_data_equals(member, "editable_bones"); | const bool editable_bones = CTX_data_equals(member, "editable_bones"); | ||||
| if (arm && arm->edbo) { | if (arm && arm->edbo) { | ||||
| uint objects_len; | uint objects_len; | ||||
| Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( | Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( | ||||
| view_layer, CTX_wm_view3d(C), &objects_len); | view_layer, CTX_wm_view3d(C), &objects_len); | ||||
| for (uint i = 0; i < objects_len; i++) { | for (uint i = 0; i < objects_len; i++) { | ||||
| Object *ob = objects[i]; | Object *ob = objects[i]; | ||||
| arm = ob->data; | arm = ob->data; | ||||
| /* Attention: X-Axis Mirroring is also handled here... */ | /* Attention: X-Axis Mirroring is also handled here... */ | ||||
| for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { | LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { | ||||
| /* first and foremost, bone must be visible and selected */ | /* first and foremost, bone must be visible and selected */ | ||||
| if (EBONE_VISIBLE(arm, ebone)) { | if (EBONE_VISIBLE(arm, ebone)) { | ||||
| /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled | /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled | ||||
| * so that most users of this data don't need to explicitly check for it themselves. | * so that most users of this data don't need to explicitly check for it themselves. | ||||
| * | * | ||||
| * We need to make sure that these mirrored copies are not selected, otherwise some | * We need to make sure that these mirrored copies are not selected, otherwise some | ||||
| * bones will be operated on twice. | * bones will be operated on twice. | ||||
| */ | */ | ||||
| Show All 29 Lines | if (arm && arm->edbo) { | ||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| return -1; /* found but not available */ | return -1; /* found but not available */ | ||||
| } | } | ||||
| if (CTX_data_equals(member, "selected_bones") || | if (CTX_data_equals(member, "selected_bones") || | ||||
| CTX_data_equals(member, "selected_editable_bones")) { | CTX_data_equals(member, "selected_editable_bones")) { | ||||
| bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; | bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; | ||||
| EditBone *ebone, *flipbone = NULL; | EditBone *flipbone = NULL; | ||||
| const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones"); | const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones"); | ||||
| if (arm && arm->edbo) { | if (arm && arm->edbo) { | ||||
| uint objects_len; | uint objects_len; | ||||
| Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( | Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( | ||||
| view_layer, CTX_wm_view3d(C), &objects_len); | view_layer, CTX_wm_view3d(C), &objects_len); | ||||
| for (uint i = 0; i < objects_len; i++) { | for (uint i = 0; i < objects_len; i++) { | ||||
| Object *ob = objects[i]; | Object *ob = objects[i]; | ||||
| arm = ob->data; | arm = ob->data; | ||||
| /* Attention: X-Axis Mirroring is also handled here... */ | /* Attention: X-Axis Mirroring is also handled here... */ | ||||
| for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { | LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { | ||||
| /* first and foremost, bone must be visible and selected */ | /* first and foremost, bone must be visible and selected */ | ||||
| if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) { | if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) { | ||||
| /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled | /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled | ||||
| * so that most users of this data don't need to explicitly check for it themselves. | * so that most users of this data don't need to explicitly check for it themselves. | ||||
| * | * | ||||
| * We need to make sure that these mirrored copies are not selected, otherwise some | * We need to make sure that these mirrored copies are not selected, otherwise some | ||||
| * bones will be operated on twice. | * bones will be operated on twice. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | if (CTX_data_equals(member, "pose_object")) { | ||||
| if (obpose) { | if (obpose) { | ||||
| CTX_data_id_pointer_set(result, &obpose->id); | CTX_data_id_pointer_set(result, &obpose->id); | ||||
| } | } | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| if (CTX_data_equals(member, "sequences")) { | if (CTX_data_equals(member, "sequences")) { | ||||
| Editing *ed = BKE_sequencer_editing_get(scene, false); | Editing *ed = BKE_sequencer_editing_get(scene, false); | ||||
| if (ed) { | if (ed) { | ||||
| Sequence *seq; | LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) { | ||||
| for (seq = ed->seqbasep->first; seq; seq = seq->next) { | |||||
| CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); | CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); | ||||
| } | } | ||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| return -1; /* found but not available */ | return -1; /* found but not available */ | ||||
| } | } | ||||
| if (CTX_data_equals(member, "selected_sequences")) { | if (CTX_data_equals(member, "selected_sequences")) { | ||||
| Editing *ed = BKE_sequencer_editing_get(scene, false); | Editing *ed = BKE_sequencer_editing_get(scene, false); | ||||
| if (ed) { | if (ed) { | ||||
| Sequence *seq; | LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) { | ||||
| for (seq = ed->seqbasep->first; seq; seq = seq->next) { | |||||
| if (seq->flag & SELECT) { | if (seq->flag & SELECT) { | ||||
| CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); | CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); | ||||
| } | } | ||||
| } | } | ||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| return -1; /* found but not available */ | return -1; /* found but not available */ | ||||
| } | } | ||||
| if (CTX_data_equals(member, "selected_editable_sequences")) { | if (CTX_data_equals(member, "selected_editable_sequences")) { | ||||
| Editing *ed = BKE_sequencer_editing_get(scene, false); | Editing *ed = BKE_sequencer_editing_get(scene, false); | ||||
| if (ed) { | if (ed) { | ||||
| Sequence *seq; | LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) { | ||||
| for (seq = ed->seqbasep->first; seq; seq = seq->next) { | |||||
| if (seq->flag & SELECT && !(seq->flag & SEQ_LOCK)) { | if (seq->flag & SELECT && !(seq->flag & SEQ_LOCK)) { | ||||
| CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); | CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); | ||||
| } | } | ||||
| } | } | ||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| return -1; /* found but not available */ | return -1; /* found but not available */ | ||||
| } | } | ||||
| if (CTX_data_equals(member, "selected_nla_strips")) { | if (CTX_data_equals(member, "selected_nla_strips")) { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| if (ANIM_animdata_get_context(C, &ac) != 0) { | if (ANIM_animdata_get_context(C, &ac) != 0) { | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| bAnimListElem *ale; | |||||
| ANIM_animdata_filter(&ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac.data, ac.datatype); | ANIM_animdata_filter(&ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac.data, ac.datatype); | ||||
| for (ale = anim_data.first; ale; ale = ale->next) { | LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { | ||||
| if (ale->datatype != ALE_NLASTRIP) { | if (ale->datatype != ALE_NLASTRIP) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| NlaTrack *nlt = (NlaTrack *)ale->data; | NlaTrack *nlt = (NlaTrack *)ale->data; | ||||
| NlaStrip *strip; | LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) { | ||||
| for (strip = nlt->strips.first; strip; strip = strip->next) { | |||||
| if (strip->flag & NLASTRIP_FLAG_SELECT) { | if (strip->flag & NLASTRIP_FLAG_SELECT) { | ||||
| CTX_data_list_add(result, &scene->id, &RNA_NlaStrip, strip); | CTX_data_list_add(result, &scene->id, &RNA_NlaStrip, strip); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | if (gpd) { | ||||
| } | } | ||||
| } | } | ||||
| return -1; /* found but not available */ | return -1; /* found but not available */ | ||||
| } | } | ||||
| if (CTX_data_equals(member, "visible_gpencil_layers")) { | if (CTX_data_equals(member, "visible_gpencil_layers")) { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); | bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); | ||||
| if (gpd) { | if (gpd) { | ||||
| bGPDlayer *gpl; | LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { | ||||
| for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { | |||||
| if ((gpl->flag & GP_LAYER_HIDE) == 0) { | if ((gpl->flag & GP_LAYER_HIDE) == 0) { | ||||
| CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl); | CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl); | ||||
| } | } | ||||
| } | } | ||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| return -1; /* found but not available */ | return -1; /* found but not available */ | ||||
| } | } | ||||
| if (CTX_data_equals(member, "editable_gpencil_layers")) { | if (CTX_data_equals(member, "editable_gpencil_layers")) { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); | bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); | ||||
| if (gpd) { | if (gpd) { | ||||
| bGPDlayer *gpl; | LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { | ||||
| for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { | |||||
| if (BKE_gpencil_layer_is_editable(gpl)) { | if (BKE_gpencil_layer_is_editable(gpl)) { | ||||
| CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl); | CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl); | ||||
| } | } | ||||
| } | } | ||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| return -1; /* found but not available */ | return -1; /* found but not available */ | ||||
| } | } | ||||
| if (CTX_data_equals(member, "editable_gpencil_strokes")) { | if (CTX_data_equals(member, "editable_gpencil_strokes")) { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); | bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact); | ||||
| const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); | const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); | ||||
| if (gpd) { | if (gpd) { | ||||
| bGPDlayer *gpl; | LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { | ||||
| for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { | |||||
| if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe)) { | if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe)) { | ||||
| bGPDframe *gpf; | bGPDframe *gpf; | ||||
| bGPDstroke *gps; | |||||
| bGPDframe *init_gpf = gpl->actframe; | bGPDframe *init_gpf = gpl->actframe; | ||||
| if (is_multiedit) { | if (is_multiedit) { | ||||
| init_gpf = gpl->frames.first; | init_gpf = gpl->frames.first; | ||||
| } | } | ||||
| for (gpf = init_gpf; gpf; gpf = gpf->next) { | for (gpf = init_gpf; gpf; gpf = gpf->next) { | ||||
| if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { | if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { | ||||
| for (gps = gpf->strokes.first; gps; gps = gps->next) { | LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { | ||||
| if (ED_gpencil_stroke_can_use_direct(area, gps)) { | if (ED_gpencil_stroke_can_use_direct(area, gps)) { | ||||
| /* check if the color is editable */ | /* check if the color is editable */ | ||||
| if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) { | if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| CTX_data_list_add(result, &gpd->id, &RNA_GPencilStroke, gps); | CTX_data_list_add(result, &gpd->id, &RNA_GPencilStroke, gps); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines | |||||