[Bf-blender-cvs] [f20bb6c63f4] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Wed Jan 3 14:03:01 CET 2018


Commit: f20bb6c63f40a3944ceaf976d5c8aa6613477132
Author: Campbell Barton
Date:   Thu Jan 4 00:09:10 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBf20bb6c63f40a3944ceaf976d5c8aa6613477132

Merge branch 'master' into blender2.8

===================================================================



===================================================================

diff --cc release/scripts/startup/bl_ui/properties_object.py
index de608c42cb5,5e7f1b068e2..2742ef9f297
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@@ -40,7 -40,7 +40,7 @@@ class OBJECT_PT_context_object(ObjectBu
              layout.template_ID(space, "pin_id")
          else:
              row = layout.row()
-             row.template_ID(context.view_layer.objects, "active")
 -            row.template_ID(context.scene.objects, "active", filter='AVAILABLE')
++            row.template_ID(context.view_layer.objects, "active", filter='AVAILABLE')
  
  
  class OBJECT_PT_transform(ObjectButtonsPanel, Panel):
diff --cc source/blender/editors/include/UI_interface.h
index c94a890b357,c07fa2913b6..5d7a45a7e48
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@@ -668,9 -659,17 +668,18 @@@ void UI_but_string_info_get(struct bCon
  #define UI_ID_FAKE_USER     (1 << 8)
  #define UI_ID_PIN           (1 << 9)
  #define UI_ID_PREVIEWS      (1 << 10)
 +#define UI_ID_OVERRIDE      (1 << 11)
  #define UI_ID_FULL          (UI_ID_RENAME | UI_ID_BROWSE | UI_ID_ADD_NEW | UI_ID_OPEN | UI_ID_ALONE | UI_ID_DELETE | UI_ID_LOCAL)
  
+ /**
+  * Ways to limit what is displayed in ID-search popup.
+  * \note We may want to add LOCAL, LIBRARY ... as needed.
+  */
+ enum {
+ 	UI_TEMPLATE_ID_FILTER_ALL = 0,
+ 	UI_TEMPLATE_ID_FILTER_AVAILABLE = 1,
+ };
+ 
  int UI_icon_from_id(struct ID *id);
  int UI_icon_from_report_type(int type);
  
@@@ -926,25 -927,17 +935,28 @@@ uiLayout *uiLayoutRadial(uiLayout *layo
  
  /* templates */
  void uiTemplateHeader(uiLayout *layout, struct bContext *C);
- void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
-                   const char *newop, const char *openop, const char *unlinkop);
- void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
-                         const char *newop, const char *openop, const char *unlinkop);
- void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
-                          const char *newop, const char *openop, const char *unlinkop, int rows, int cols);
+ void uiTemplateID(
+         uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
+         const char *newop, const char *openop, const char *unlinkop, int filter);
+ void uiTemplateIDBrowse(
+         uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
+         const char *newop, const char *openop, const char *unlinkop, int filter);
+ void uiTemplateIDPreview(
+         uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
+         const char *newop, const char *openop, const char *unlinkop, int rows, int cols, int filter);
  void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname, 
                       const char *proptypename, const char *text);
 +void uiTemplateSearch(
 +        uiLayout *layout, struct bContext *C,
 +        struct PointerRNA *ptr, const char *propname,
 +        struct PointerRNA *searchptr, const char *searchpropname,
 +        const char *newop, const char *unlinkop);
 +void uiTemplateSearchPreview(
 +        uiLayout *layout, struct bContext *C,
 +        struct PointerRNA *ptr, const char *propname,
 +        struct PointerRNA *searchptr, const char *searchpropname,
 +        const char *newop, const char *unlinkop,
 +        const int rows, const int cols);
  void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname, 
                             struct PointerRNA *root_ptr, const char *text);
  uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
diff --cc source/blender/editors/interface/interface_templates.c
index 7d378a11a23,1a1f2b42322..140cd97f517
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@@ -262,50 -186,125 +305,83 @@@ static void id_search_cb(const bContex
  
  	/* ID listbase */
  	for (id = lb->first; id; id = id->next) {
- 		if (!((flag & PROP_ID_SELF_CHECK) && id == id_from)) {
- 
- 			/* use filter */
- 			if (RNA_property_type(template_ui->prop) == PROP_POINTER) {
- 				PointerRNA ptr;
- 				RNA_id_pointer_create(id, &ptr);
- 				if (RNA_property_pointer_poll(&template_ui->ptr, template_ui->prop, &ptr) == 0)
- 					continue;
+ 		if (!id_search_add(C, template_ui, flag, str, items, id)) {
+ 			break;
+ 		}
+ 	}
+ }
+ 
+ /**
+  * Use id tags for filtering.
+  */
+ static void id_search_cb_tagged(const bContext *C, void *arg_template, const char *str, uiSearchItems *items)
+ {
+ 	TemplateID *template_ui = (TemplateID *)arg_template;
+ 	ListBase *lb = template_ui->idlb;
+ 	ID *id;
+ 	int flag = RNA_property_flag(template_ui->prop);
+ 
+ 	/* ID listbase */
+ 	for (id = lb->first; id; id = id->next) {
+ 		if (id->tag & LIB_TAG_DOIT) {
+ 			if (!id_search_add(C, template_ui, flag, str, items, id)) {
+ 				break;
  			}
+ 			id->tag &= ~LIB_TAG_DOIT;
+ 		}
+ 	}
+ }
  
- 			/* hide dot-datablocks, but only if filter does not force it visible */
- 			if (U.uiflag & USER_HIDE_DOT)
- 				if ((id->name[2] == '.') && (str[0] != '.'))
- 					continue;
+ /**
+  * A version of 'id_search_cb' that lists scene objects.
+  */
+ static void id_search_cb_objects_from_scene(const bContext *C, void *arg_template, const char *str, uiSearchItems *items)
+ {
+ 	TemplateID *template_ui = (TemplateID *)arg_template;
+ 	ListBase *lb = template_ui->idlb;
+ 	Scene *scene = NULL;
+ 	ID *id_from = template_ui->ptr.id.data;
  
- 			if (*str == '\0' || BLI_strcasestr(id->name + 2, str)) {
- 				/* +1 is needed because BKE_id_ui_prefix used 3 letter prefix
- 				 * followed by ID_NAME-2 characters from id->name
- 				 */
- 				char name_ui[MAX_ID_NAME + 1];
- 				BKE_id_ui_prefix(name_ui, id);
+ 	if (id_from && GS(id_from->name) == ID_SCE) {
+ 		scene = (Scene *)id_from;
+ 	}
+ 	else {
+ 		scene = CTX_data_scene(C);
+ 	}
  
- 				iconid = ui_id_icon_get(C, id, template_ui->preview);
+ 	BKE_main_id_flag_listbase(lb, LIB_TAG_DOIT, false);
 -	for (Base *base = scene->base.first; base; base = base->next) {
 -		base->object->id.tag |= LIB_TAG_DOIT;
 +
- 				if (false == UI_search_item_add(items, name_ui, id, iconid))
- 					break;
- 			}
- 		}
++	FOREACH_SCENE_OBJECT(scene, ob_iter)
++	{
++		ob_iter->id.tag |= LIB_TAG_DOIT;
  	}
++	FOREACH_SCENE_OBJECT_END
+ 	id_search_cb_tagged(C, arg_template, str, items);
  }
  
  /* ID Search browse menu, open */
  static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
  {
 -	static char search[256];
  	static TemplateID template_ui;
 -	PointerRNA idptr;
 -	wmWindow *win = CTX_wm_window(C);
 -	uiBlock *block;
 -	uiBut *but;
 +	PointerRNA active_item_ptr;
+ 	void (*id_search_cb_p)(const bContext *, void *, const char *, uiSearchItems *) = id_search_cb;
  
 -	/* clear initial search string, then all items show */
 -	search[0] = 0;
  	/* arg_litem is malloced, can be freed by parent button */
  	template_ui = *((TemplateID *)arg_litem);
 -	
 -	/* get active id for showing first item */
 -	idptr = RNA_property_pointer_get(&template_ui.ptr, template_ui.prop);
 +	active_item_ptr = RNA_property_pointer_get(&template_ui.ptr, template_ui.prop);
  
+ 	if (template_ui.filter) {
+ 		/* Currently only used for objects. */
+ 		if (template_ui.idcode == ID_OB) {
+ 			if (template_ui.filter == UI_TEMPLATE_ID_FILTER_AVAILABLE) {
+ 				id_search_cb_p = id_search_cb_objects_from_scene;
+ 			}
+ 		}
+ 	}
+ 
 -	block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
 -	UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU);
 -	
 -	/* preview thumbnails */
 -	if (template_ui.prv_rows > 0 && template_ui.prv_cols > 0) {
 -		int w = 4 * U.widget_unit * template_ui.prv_cols;
 -		int h = 5 * U.widget_unit * template_ui.prv_rows;
 -		
 -		/* fake button, it holds space for search items */
 -		uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, NULL, 0, 0, 0, 0, NULL);
 -		
 -		but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, UI_UNIT_Y,
 -		                     template_ui.prv_rows, template_ui.prv_cols, "");
 -		UI_but_func_search_set(
 -		        but, ui_searchbox_create_generic, id_search_cb_p,
 -		        &template_ui, id_search_call_cb, idptr.data);
 -	}
 -	/* list view */
 -	else {
 -		const int searchbox_width  = UI_searchbox_size_x();
 -		const int searchbox_height = UI_searchbox_size_y();
 -		
 -		/* fake button, it holds space for search items */
 -		uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, searchbox_width, searchbox_height, NULL, 0, 0, 0, 0, NULL);
 -		but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, searchbox_width, UI_UNIT_Y - 1, 0, 0, "");
 -		UI_but_func_search_set(
 -		        but, ui_searchbox_create_generic, id_search_cb_p,
 -		        &template_ui, id_search_call_cb, idptr.data);
 -	}
 -		
 -	
 -	UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);
 -	UI_block_direction_set(block, UI_DIR_DOWN);
 -	
 -	/* give search-field focus */
 -	UI_but_focus_on_enter_event(win, but);
 -	/* this type of search menu requires undo */
 -	but->flag |= UI_BUT_UNDO;
 -	
 -	return block;
 +	return template_common_search_menu(
- 	               C, ar, id_search_cb, &template_ui, id_search_call_cb, active_item_ptr.data,
++	               C, ar, id_search_cb_p, &template_ui, id_search_call_cb, active_item_ptr.data,
 +	               template_ui.prv_rows, template_ui.prv_cols);
  }
  
  /************************ ID Template ***************************/
diff --cc source/blender/windowmanager/WM_api.h
index 7671fbeb926,96ed179c8f4..1db84b7d2ee
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@@ -256,7 -230,7 +256,8 @@@ void		WM_operator_view3d_unit_defaults(
  int			WM_operator_smooth_viewtx_get(const struct wmOperator *op);
  int			WM_menu_invoke_ex(struct bContext *C, struct wmOperator *op, int opcontext);
  int			WM_menu_invoke			(struct bContext *C, struct wmOp

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list