Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_ops.c
| Show First 20 Lines • Show All 709 Lines • ▼ Show 20 Lines | |||||
| #define NOT_RNA_NULL(assignment) ((assignment).data != NULL) | #define NOT_RNA_NULL(assignment) ((assignment).data != NULL) | ||||
| static void ui_context_selected_bones_via_pose(bContext *C, ListBase *r_lb) | static void ui_context_selected_bones_via_pose(bContext *C, ListBase *r_lb) | ||||
| { | { | ||||
| ListBase lb; | ListBase lb; | ||||
| lb = CTX_data_collection_get(C, "selected_pose_bones"); | lb = CTX_data_collection_get(C, "selected_pose_bones"); | ||||
| if (!BLI_listbase_is_empty(&lb)) { | if (!BLI_listbase_is_empty(&lb)) { | ||||
| CollectionPointerLink *link; | LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) { | ||||
| for (link = lb.first; link; link = link->next) { | |||||
| bPoseChannel *pchan = link->ptr.data; | bPoseChannel *pchan = link->ptr.data; | ||||
| RNA_pointer_create(link->ptr.owner_id, &RNA_Bone, pchan->bone, &link->ptr); | RNA_pointer_create(link->ptr.owner_id, &RNA_Bone, pchan->bone, &link->ptr); | ||||
| } | } | ||||
| } | } | ||||
| *r_lb = lb; | *r_lb = lb; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | if (RNA_struct_is_a(ptr->type, &RNA_NodeSocket)) { | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| node = ptr->data; | node = ptr->data; | ||||
| } | } | ||||
| /* Now filter by type */ | /* Now filter by type */ | ||||
| if (node) { | if (node) { | ||||
| CollectionPointerLink *link, *link_next; | |||||
| lb = CTX_data_collection_get(C, "selected_nodes"); | lb = CTX_data_collection_get(C, "selected_nodes"); | ||||
| for (link = lb.first; link; link = link_next) { | LISTBASE_FOREACH_MUTABLE (CollectionPointerLink *, link, &lb) { | ||||
| bNode *node_data = link->ptr.data; | bNode *node_data = link->ptr.data; | ||||
| link_next = link->next; | |||||
| if (node_data->type != node->type) { | if (node_data->type != node->type) { | ||||
| BLI_remlink(&lb, link); | BLI_remlink(&lb, link); | ||||
| MEM_freeN(link); | MEM_freeN(link); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Show All 11 Lines | else if (ptr->owner_id) { | ||||
| else if (OB_DATA_SUPPORT_ID(GS(id->name))) { | else if (OB_DATA_SUPPORT_ID(GS(id->name))) { | ||||
| /* check we're using the active object */ | /* check we're using the active object */ | ||||
| const short id_code = GS(id->name); | const short id_code = GS(id->name); | ||||
| ListBase lb = CTX_data_collection_get(C, "selected_editable_objects"); | ListBase lb = CTX_data_collection_get(C, "selected_editable_objects"); | ||||
| char *path = RNA_path_from_ID_to_property(ptr, prop); | char *path = RNA_path_from_ID_to_property(ptr, prop); | ||||
| /* de-duplicate obdata */ | /* de-duplicate obdata */ | ||||
| if (!BLI_listbase_is_empty(&lb)) { | if (!BLI_listbase_is_empty(&lb)) { | ||||
| CollectionPointerLink *link, *link_next; | LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) { | ||||
| for (link = lb.first; link; link = link->next) { | |||||
| Object *ob = (Object *)link->ptr.owner_id; | Object *ob = (Object *)link->ptr.owner_id; | ||||
| if (ob->data) { | if (ob->data) { | ||||
| ID *id_data = ob->data; | ID *id_data = ob->data; | ||||
| id_data->tag |= LIB_TAG_DOIT; | id_data->tag |= LIB_TAG_DOIT; | ||||
| } | } | ||||
| } | } | ||||
| for (link = lb.first; link; link = link_next) { | LISTBASE_FOREACH_MUTABLE (CollectionPointerLink *, link, &lb) { | ||||
| Object *ob = (Object *)link->ptr.owner_id; | Object *ob = (Object *)link->ptr.owner_id; | ||||
| ID *id_data = ob->data; | ID *id_data = ob->data; | ||||
| link_next = link->next; | |||||
| if ((id_data == NULL) || (id_data->tag & LIB_TAG_DOIT) == 0 || ID_IS_LINKED(id_data) || | if ((id_data == NULL) || (id_data->tag & LIB_TAG_DOIT) == 0 || ID_IS_LINKED(id_data) || | ||||
| (GS(id_data->name) != id_code)) { | (GS(id_data->name) != id_code)) { | ||||
| BLI_remlink(&lb, link); | BLI_remlink(&lb, link); | ||||
| MEM_freeN(link); | MEM_freeN(link); | ||||
| } | } | ||||
| else { | else { | ||||
| /* avoid prepending 'data' to the path */ | /* avoid prepending 'data' to the path */ | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | static bool copy_to_selected_button(bContext *C, bool all, bool poll) | ||||
| /* try to reset the nominated setting to its default value */ | /* try to reset the nominated setting to its default value */ | ||||
| UI_context_active_but_prop_get(C, &ptr, &prop, &index); | UI_context_active_but_prop_get(C, &ptr, &prop, &index); | ||||
| /* if there is a valid property that is editable... */ | /* if there is a valid property that is editable... */ | ||||
| if (ptr.data && prop) { | if (ptr.data && prop) { | ||||
| char *path = NULL; | char *path = NULL; | ||||
| bool use_path_from_id; | bool use_path_from_id; | ||||
| CollectionPointerLink *link; | |||||
| ListBase lb = {NULL}; | ListBase lb = {NULL}; | ||||
| if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) && | if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) && | ||||
| !BLI_listbase_is_empty(&lb)) { | !BLI_listbase_is_empty(&lb)) { | ||||
| for (link = lb.first; link; link = link->next) { | LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) { | ||||
| if (link->ptr.data != ptr.data) { | if (link->ptr.data != ptr.data) { | ||||
| if (use_path_from_id) { | if (use_path_from_id) { | ||||
| /* Path relative to ID. */ | /* Path relative to ID. */ | ||||
| lprop = NULL; | lprop = NULL; | ||||
| RNA_id_pointer_create(link->ptr.owner_id, &idptr); | RNA_id_pointer_create(link->ptr.owner_id, &idptr); | ||||
| RNA_path_resolve_property(&idptr, path, &lptr, &lprop); | RNA_path_resolve_property(&idptr, path, &lptr, &lprop); | ||||
| } | } | ||||
| else if (path) { | else if (path) { | ||||
| ▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static int editsource_text_edit(bContext *C, | static int editsource_text_edit(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const char filepath[FILE_MAX], | const char filepath[FILE_MAX], | ||||
| const int line) | const int line) | ||||
| { | { | ||||
| struct Main *bmain = CTX_data_main(C); | struct Main *bmain = CTX_data_main(C); | ||||
| Text *text; | Text *text = NULL; | ||||
| /* Developers may wish to copy-paste to an external editor. */ | /* Developers may wish to copy-paste to an external editor. */ | ||||
| printf("%s:%d\n", filepath, line); | printf("%s:%d\n", filepath, line); | ||||
| for (text = bmain->texts.first; text; text = text->id.next) { | LISTBASE_FOREACH (Text *, text_iter, &bmain->texts) { | ||||
| if (text->filepath && BLI_path_cmp(text->filepath, filepath) == 0) { | if (text_iter->filepath && BLI_path_cmp(text_iter->filepath, filepath) == 0) { | ||||
| text = text_iter; | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (text == NULL) { | if (text == NULL) { | ||||
| text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain)); | text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain)); | ||||
| id_us_ensure_real(&text->id); | id_us_ensure_real(&text->id); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 546 Lines • Show Last 20 Lines | |||||