RNA
* RNA_enum_items_add_value and RNA_enum_item_add_separator utility functions, to add an item from an existing array with a certain value, and to add a separator.
This commit is contained in:
		@@ -5796,19 +5796,12 @@ static EnumPropertyItem merge_type_items[]= {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *ptr, int *free)
 | 
					static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *ptr, int *free)
 | 
				
			||||||
{	
 | 
					{	
 | 
				
			||||||
 | 
						Object *obedit;
 | 
				
			||||||
	EnumPropertyItem *item= NULL;
 | 
						EnumPropertyItem *item= NULL;
 | 
				
			||||||
	int totitem= 0;
 | 
						int totitem= 0;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	Object *obedit;
 | 
						if(!C) /* needed for docs */
 | 
				
			||||||
	
 | 
							return merge_type_items;
 | 
				
			||||||
	if(C==NULL) {
 | 
					 | 
				
			||||||
		/* needed for doc generation */
 | 
					 | 
				
			||||||
		RNA_enum_items_add(&item, &totitem, merge_type_items);
 | 
					 | 
				
			||||||
		RNA_enum_item_end(&item, &totitem);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		*free= 1;
 | 
					 | 
				
			||||||
		return item;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	obedit= CTX_data_edit_object(C);
 | 
						obedit= CTX_data_edit_object(C);
 | 
				
			||||||
	if(obedit && obedit->type == OB_MESH) {
 | 
						if(obedit && obedit->type == OB_MESH) {
 | 
				
			||||||
@@ -5817,18 +5810,18 @@ static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *ptr, int *fre
 | 
				
			|||||||
		if(em->selectmode & SCE_SELECT_VERTEX) {
 | 
							if(em->selectmode & SCE_SELECT_VERTEX) {
 | 
				
			||||||
			if(em->selected.first && em->selected.last &&
 | 
								if(em->selected.first && em->selected.last &&
 | 
				
			||||||
				((EditSelection*)em->selected.first)->type == EDITVERT && ((EditSelection*)em->selected.last)->type == EDITVERT) {
 | 
									((EditSelection*)em->selected.first)->type == EDITVERT && ((EditSelection*)em->selected.last)->type == EDITVERT) {
 | 
				
			||||||
				RNA_enum_item_add(&item, &totitem, &merge_type_items[0]);
 | 
									RNA_enum_items_add_value(&item, &totitem, merge_type_items, 6);
 | 
				
			||||||
				RNA_enum_item_add(&item, &totitem, &merge_type_items[1]);
 | 
									RNA_enum_items_add_value(&item, &totitem, merge_type_items, 1);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else if(em->selected.first && ((EditSelection*)em->selected.first)->type == EDITVERT)
 | 
								else if(em->selected.first && ((EditSelection*)em->selected.first)->type == EDITVERT)
 | 
				
			||||||
				RNA_enum_item_add(&item, &totitem, &merge_type_items[1]);
 | 
									RNA_enum_items_add_value(&item, &totitem, merge_type_items, 1);
 | 
				
			||||||
			else if(em->selected.last && ((EditSelection*)em->selected.last)->type == EDITVERT)
 | 
								else if(em->selected.last && ((EditSelection*)em->selected.last)->type == EDITVERT)
 | 
				
			||||||
				RNA_enum_item_add(&item, &totitem, &merge_type_items[0]);
 | 
									RNA_enum_items_add_value(&item, &totitem, merge_type_items, 6);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		RNA_enum_item_add(&item, &totitem, &merge_type_items[2]);
 | 
							RNA_enum_items_add_value(&item, &totitem, merge_type_items, 3);
 | 
				
			||||||
		RNA_enum_item_add(&item, &totitem, &merge_type_items[3]);
 | 
							RNA_enum_items_add_value(&item, &totitem, merge_type_items, 4);
 | 
				
			||||||
		RNA_enum_item_add(&item, &totitem, &merge_type_items[4]);
 | 
							RNA_enum_items_add_value(&item, &totitem, merge_type_items, 5);
 | 
				
			||||||
		RNA_enum_item_end(&item, &totitem);
 | 
							RNA_enum_item_end(&item, &totitem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		*free= 1;
 | 
							*free= 1;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -366,7 +366,6 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
 | 
				
			|||||||
	EnumPropertyItem normal = {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""};
 | 
						EnumPropertyItem normal = {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""};
 | 
				
			||||||
	EnumPropertyItem local = {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""};
 | 
						EnumPropertyItem local = {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""};
 | 
				
			||||||
	EnumPropertyItem view = {V3D_MANIP_VIEW, "VIEW", 0, "View", ""};
 | 
						EnumPropertyItem view = {V3D_MANIP_VIEW, "VIEW", 0, "View", ""};
 | 
				
			||||||
	EnumPropertyItem sepr = {0, "", 0, NULL, NULL};
 | 
					 | 
				
			||||||
	EnumPropertyItem tmp = {0, "", 0, "", ""};
 | 
						EnumPropertyItem tmp = {0, "", 0, "", ""};
 | 
				
			||||||
	EnumPropertyItem *item= NULL;
 | 
						EnumPropertyItem *item= NULL;
 | 
				
			||||||
	int i = V3D_MANIP_CUSTOM, totitem= 0;
 | 
						int i = V3D_MANIP_CUSTOM, totitem= 0;
 | 
				
			||||||
@@ -386,7 +385,7 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	if(ts)
 | 
						if(ts)
 | 
				
			||||||
		RNA_enum_item_add(&item, &totitem, &sepr);
 | 
							RNA_enum_item_add_separator(&item, &totitem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for(; ts; ts = ts->next) {
 | 
						for(; ts; ts = ts->next) {
 | 
				
			||||||
		tmp.identifier = "CUSTOM";
 | 
							tmp.identifier = "CUSTOM";
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -164,7 +164,9 @@ void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
 | 
				
			|||||||
 * strings are not freed, assumed pointing to static location. */
 | 
					 * strings are not freed, assumed pointing to static location. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item);
 | 
					void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item);
 | 
				
			||||||
 | 
					void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem);
 | 
				
			||||||
void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item);
 | 
					void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item);
 | 
				
			||||||
 | 
					void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item, int value);
 | 
				
			||||||
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem);
 | 
					void RNA_enum_item_end(EnumPropertyItem **items, int *totitem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2284,12 +2284,25 @@ void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem
 | 
				
			|||||||
	*totitem= tot+1;
 | 
						*totitem= tot+1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						static EnumPropertyItem sepr = {0, "", 0, NULL, NULL};
 | 
				
			||||||
 | 
						RNA_enum_item_add(items, totitem, &sepr);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item)
 | 
					void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	for(; item->identifier; item++)
 | 
						for(; item->identifier; item++)
 | 
				
			||||||
		RNA_enum_item_add(items, totitem, item);
 | 
							RNA_enum_item_add(items, totitem, item);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item, int value)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						for(; item->identifier; item++)
 | 
				
			||||||
 | 
							if(item->value == value)
 | 
				
			||||||
 | 
								RNA_enum_item_add(items, totitem, item);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
 | 
					void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static EnumPropertyItem empty = {0, NULL, 0, NULL, NULL};
 | 
						static EnumPropertyItem empty = {0, NULL, 0, NULL, NULL};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user