Beispiel #1
0
/**
 * Recursively get the count of collections
 */
static int collection_count(ListBase *lb)
{
  int i = 0;
  for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
    i += collection_count(&lc->layer_collections) + 1;
  }
  return i;
}
Beispiel #2
0
/**
 * Get the total number of collections
 * (including all the nested collections)
 */
int BKE_layer_collection_count(ViewLayer *view_layer)
{
  return collection_count(&view_layer->layer_collections);
}
Beispiel #3
0
void _create_collection()
{
  collection_t* collection = create_collection(0, 0);
  assert(collection);
  assert(collection_count(collection) == 0);
}
Beispiel #4
0
} test_obj_t;

void _create_collection()
{
  collection_t* collection = create_collection(0, 0);
  assert(collection);
  assert(collection_count(collection) == 0);
}

void _add_item_to_collection()
{
  test_obj_t test_obj = { .name="_add_item_to_collection" };
  collection_t* collection = create_collection(1, sizeof(test_obj_t));
  collection_push(collection, &test_obj);

  assert(collection_count(collection) == 1);
  assert(collection_any(collection));
}

void _get_first_item_from_collection()
{
	assert(collection_first(0) == 0);

	collection_t* collection = create_collection(1, sizeof(test_obj_t));
	assert(collection_first(collection) == 0);

	test_obj_t test_obj = { .name = "_get_first_item_from_collection" };
	collection_push(collection, &test_obj);

	test_obj_t* result = collection_pop(collection);
	assert(_stricmp(result->name, test_obj.name) == 0);