Пример #1
0
static int copy_to_selected_list(bContext *C, PointerRNA *ptr, ListBase *lb)
{
	if(RNA_struct_is_a(ptr->type, &RNA_Object))
		*lb = CTX_data_collection_get(C, "selected_editable_objects");
	else if(RNA_struct_is_a(ptr->type, &RNA_EditBone))
		*lb = CTX_data_collection_get(C, "selected_editable_bones");
	else if(RNA_struct_is_a(ptr->type, &RNA_PoseBone))
		*lb = CTX_data_collection_get(C, "selected_pose_bones");
	else if(RNA_struct_is_a(ptr->type, &RNA_Sequence))
		*lb = CTX_data_collection_get(C, "selected_editable_sequences");
	else
		return 0;
	
	return 1;
}
Пример #2
0
static bool copy_to_selected_list(
        bContext *C, PointerRNA *ptr, PropertyRNA *prop,
        ListBase *r_lb, bool *r_use_path_from_id, char **r_path)
{
	*r_use_path_from_id = false;
	*r_path = NULL;

	if (RNA_struct_is_a(ptr->type, &RNA_EditBone)) {
		*r_lb = CTX_data_collection_get(C, "selected_editable_bones");
	}
	else if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) {
		*r_lb = CTX_data_collection_get(C, "selected_pose_bones");
	}
	else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) {
		*r_lb = CTX_data_collection_get(C, "selected_editable_sequences");
	}
	else if (ptr->id.data) {
		ID *id = ptr->id.data;

		if (GS(id->name) == ID_OB) {
			*r_lb = CTX_data_collection_get(C, "selected_editable_objects");
			*r_use_path_from_id = true;
			*r_path = RNA_path_from_ID_to_property(ptr, prop);
		}
		else if (GS(id->name) == ID_SCE) {
			/* Sequencer's ID is scene :/ */
			/* Try to recursively find an RNA_Sequence ancestor, to handle situations like T41062... */
			if ((*r_path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Sequence)) != NULL) {
				*r_lb = CTX_data_collection_get(C, "selected_editable_sequences");
			}
		}
		return (*r_path != NULL);
	}
	else {
		return false;
	}

	return true;
}
Пример #3
0
static int copy_to_selected_list(bContext *C, PointerRNA *ptr, ListBase *lb, int *use_path)
{
	*use_path = FALSE;

	if (RNA_struct_is_a(ptr->type, &RNA_EditBone))
		*lb = CTX_data_collection_get(C, "selected_editable_bones");
	else if (RNA_struct_is_a(ptr->type, &RNA_PoseBone))
		*lb = CTX_data_collection_get(C, "selected_pose_bones");
	else if (RNA_struct_is_a(ptr->type, &RNA_Sequence))
		*lb = CTX_data_collection_get(C, "selected_editable_sequences");
	else {
		ID *id = ptr->id.data;

		if (id && GS(id->name) == ID_OB) {
			*lb = CTX_data_collection_get(C, "selected_editable_objects");
			*use_path = TRUE;
		}
		else
			return 0;
	}
	
	return 1;
}
Пример #4
0
bool UI_context_copy_to_selected_list(bContext *C,
                                      PointerRNA *ptr,
                                      PropertyRNA *prop,
                                      ListBase *r_lb,
                                      bool *r_use_path_from_id,
                                      char **r_path)
{
  *r_use_path_from_id = false;
  *r_path = NULL;

  if (RNA_struct_is_a(ptr->type, &RNA_EditBone)) {
    *r_lb = CTX_data_collection_get(C, "selected_editable_bones");
  }
  else if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) {
    *r_lb = CTX_data_collection_get(C, "selected_pose_bones");
  }
  else if (RNA_struct_is_a(ptr->type, &RNA_Bone)) {
    ListBase lb;
    lb = CTX_data_collection_get(C, "selected_pose_bones");

    if (!BLI_listbase_is_empty(&lb)) {
      CollectionPointerLink *link;
      for (link = lb.first; link; link = link->next) {
        bPoseChannel *pchan = link->ptr.data;
        RNA_pointer_create(link->ptr.id.data, &RNA_Bone, pchan->bone, &link->ptr);
      }
    }

    *r_lb = lb;
  }
  else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) {
    *r_lb = CTX_data_collection_get(C, "selected_editable_sequences");
  }
  else if (RNA_struct_is_a(ptr->type, &RNA_FCurve)) {
    *r_lb = CTX_data_collection_get(C, "selected_editable_fcurves");
  }
  else if (RNA_struct_is_a(ptr->type, &RNA_Node) || RNA_struct_is_a(ptr->type, &RNA_NodeSocket)) {
    ListBase lb = {NULL, NULL};
    char *path = NULL;
    bNode *node = NULL;

    /* Get the node we're editing */
    if (RNA_struct_is_a(ptr->type, &RNA_NodeSocket)) {
      bNodeTree *ntree = ptr->id.data;
      bNodeSocket *sock = ptr->data;
      if (nodeFindNode(ntree, sock, &node, NULL)) {
        if ((path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Node)) != NULL) {
          /* we're good! */
        }
        else {
          node = NULL;
        }
      }
    }
    else {
      node = ptr->data;
    }

    /* Now filter by type */
    if (node) {
      CollectionPointerLink *link, *link_next;
      lb = CTX_data_collection_get(C, "selected_nodes");

      for (link = lb.first; link; link = link_next) {
        bNode *node_data = link->ptr.data;
        link_next = link->next;

        if (node_data->type != node->type) {
          BLI_remlink(&lb, link);
          MEM_freeN(link);
        }
      }
    }

    *r_lb = lb;
    *r_path = path;
  }
  else if (ptr->id.data) {
    ID *id = ptr->id.data;

    if (GS(id->name) == ID_OB) {
      *r_lb = CTX_data_collection_get(C, "selected_editable_objects");
      *r_use_path_from_id = true;
      *r_path = RNA_path_from_ID_to_property(ptr, prop);
    }
    else if (OB_DATA_SUPPORT_ID(GS(id->name))) {
      /* check we're using the active object */
      const short id_code = GS(id->name);
      ListBase lb = CTX_data_collection_get(C, "selected_editable_objects");
      char *path = RNA_path_from_ID_to_property(ptr, prop);

      /* de-duplicate obdata */
      if (!BLI_listbase_is_empty(&lb)) {
        CollectionPointerLink *link, *link_next;

        for (link = lb.first; link; link = link->next) {
          Object *ob = link->ptr.id.data;
          if (ob->data) {
            ID *id_data = ob->data;
            id_data->tag |= LIB_TAG_DOIT;
          }
        }

        for (link = lb.first; link; link = link_next) {
          Object *ob = link->ptr.id.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) ||
              (GS(id_data->name) != id_code)) {
            BLI_remlink(&lb, link);
            MEM_freeN(link);
          }
          else {
            /* avoid prepending 'data' to the path */
            RNA_id_pointer_create(id_data, &link->ptr);
          }

          if (id_data) {
            id_data->tag &= ~LIB_TAG_DOIT;
          }
        }
      }

      *r_lb = lb;
      *r_path = path;
    }
    else if (GS(id->name) == ID_SCE) {
      /* Sequencer's ID is scene :/ */
      /* Try to recursively find an RNA_Sequence ancestor,
       * to handle situations like T41062... */
      if ((*r_path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Sequence)) != NULL) {
        *r_lb = CTX_data_collection_get(C, "selected_editable_sequences");
      }
    }
    return (*r_path != NULL);
  }
  else {
    return false;
  }

  return true;
}