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

Campbell Barton noreply at git.blender.org
Fri Jul 13 12:39:10 CEST 2018


Commit: 2ead3f0765a15cce5367c4701539b6900299a97f
Author: Campbell Barton
Date:   Fri Jul 13 12:38:24 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2ead3f0765a15cce5367c4701539b6900299a97f

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/windowmanager/CMakeLists.txt
index 8fc46b6ce3f,810cceb5fc3..eb01332fc26
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@@ -68,22 -64,16 +67,26 @@@ set(SR
  	intern/wm_init_exit.c
  	intern/wm_jobs.c
  	intern/wm_keymap.c
+ 	intern/wm_menu_type.c
  	intern/wm_operator_props.c
+ 	intern/wm_operator_type.c
  	intern/wm_operators.c
- 	intern/wm_subwindow.c
- 	intern/wm_window.c
+ 	intern/wm_playanim.c
  	intern/wm_stereo.c
+ 	intern/wm_subwindow.c
 +	intern/wm_toolsystem.c
  	intern/wm_tooltip.c
+ 	intern/wm_uilist_type.c
+ 	intern/wm_window.c
 +	manipulators/intern/wm_manipulator.c
 +	manipulators/intern/wm_manipulator_group.c
 +	manipulators/intern/wm_manipulator_group_type.c
 +	manipulators/intern/wm_manipulator_map.c
 +	manipulators/intern/wm_manipulator_target_props.c
 +	manipulators/intern/wm_manipulator_type.c
 +	message_bus/intern/wm_message_bus.c
 +	message_bus/intern/wm_message_bus_rna.c
 +	message_bus/intern/wm_message_bus_static.c
  
  	WM_api.h
  	WM_keymap.h
diff --cc source/blender/windowmanager/intern/wm_init_exit.c
index 183e58e5a15,088327fa611..6c374f3d8d4
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@@ -207,10 -166,10 +207,12 @@@ void WM_init(bContext *C, int argc, con
  	BKE_addon_pref_type_init();
  
  	wm_operatortype_init();
+ 	wm_operatortypes_register();
+ 
  	WM_menutype_init();
  	WM_uilisttype_init();
 +	wm_manipulatortype_init();
 +	wm_manipulatorgrouptype_init();
  
  	ED_undosys_type_init();
  
diff --cc source/blender/windowmanager/intern/wm_operator_type.c
index 00000000000,35efdb2c4a2..e0d3c4a6727
mode 000000,100644..100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@@ -1,0 -1,483 +1,546 @@@
+ /*
+  * ***** BEGIN GPL LICENSE BLOCK *****
+  *
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+  * as published by the Free Software Foundation; either version 2
+  * of the License, or (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program; if not, write to the Free Software Foundation,
+  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+  *
+  * ***** END GPL LICENSE BLOCK *****
+  */
+ 
+ /** \file blender/windowmanager/intern/wm_operator_type.c
+  *  \ingroup wm
+  *
+  * Operator Registry.
+  */
+ 
+ #include "MEM_guardedalloc.h"
+ 
+ #include "CLG_log.h"
+ 
+ #include "DNA_ID.h"
+ #include "DNA_screen_types.h"
+ #include "DNA_scene_types.h"
+ #include "DNA_userdef_types.h"
+ #include "DNA_windowmanager_types.h"
+ 
+ #include "BLT_translation.h"
+ 
+ #include "BLI_blenlib.h"
+ #include "BLI_utildefines.h"
+ #include "BLI_ghash.h"
+ 
+ #include "BKE_context.h"
+ #include "BKE_idprop.h"
+ #include "BKE_library.h"
+ 
+ #include "RNA_access.h"
+ #include "RNA_define.h"
++#include "RNA_enum_types.h"
+ 
+ #include "WM_api.h"
+ #include "WM_types.h"
+ 
+ #include "wm.h"
+ #include "wm_event_system.h"
+ 
+ #define UNDOCUMENTED_OPERATOR_TIP N_("(undocumented operator)")
+ 
+ static void wm_operatortype_free_macro(wmOperatorType *ot);
+ 
+ /* -------------------------------------------------------------------- */
+ /** \name Operator Type Registry
+  * \{ */
+ 
+ static GHash *global_ops_hash = NULL;
++/** Counter for operator-properties that should not be tagged with #OP_PROP_TAG_ADVANCED. */
++static int ot_prop_basic_count = -1;
+ 
+ wmOperatorType *WM_operatortype_find(const char *idname, bool quiet)
+ {
+ 	if (idname[0]) {
+ 		wmOperatorType *ot;
+ 
+ 		/* needed to support python style names without the _OT_ syntax */
+ 		char idname_bl[OP_MAX_TYPENAME];
+ 		WM_operator_bl_idname(idname_bl, idname);
+ 
+ 		ot = BLI_ghash_lookup(global_ops_hash, idname_bl);
+ 		if (ot) {
+ 			return ot;
+ 		}
+ 
+ 		if (!quiet) {
+ 			CLOG_INFO(WM_LOG_OPERATORS, 0, "search for unknown operator '%s', '%s'\n", idname_bl, idname);
+ 		}
+ 	}
+ 	else {
+ 		if (!quiet) {
+ 			CLOG_INFO(WM_LOG_OPERATORS, 0, "search for empty operator");
+ 		}
+ 	}
+ 
+ 	return NULL;
+ }
+ 
+ /* caller must free */
+ void WM_operatortype_iter(GHashIterator *ghi)
+ {
+ 	BLI_ghashIterator_init(ghi, global_ops_hash);
+ }
+ 
 -/* all ops in 1 list (for time being... needs evaluation later) */
 -void WM_operatortype_append(void (*opfunc)(wmOperatorType *))
++/** \name Operator Type Append
++ * \{ */
++
++static wmOperatorType *wm_operatortype_append__begin(void)
+ {
 -	wmOperatorType *ot;
++	wmOperatorType *ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
++
++	BLI_assert(ot_prop_basic_count == -1);
+ 
 -	ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
+ 	ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
++	RNA_def_struct_property_tags(ot->srna, rna_enum_operator_property_tags);
+ 	/* Set the default i18n context now, so that opfunc can redefine it if needed! */
+ 	RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+ 	ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
 -	opfunc(ot);
+ 
++	return ot;
++}
++static void wm_operatortype_append__end(wmOperatorType *ot)
++{
+ 	if (ot->name == NULL) {
+ 		CLOG_ERROR(WM_LOG_OPERATORS, "Operator '%s' has no name property", ot->idname);
+ 	}
+ 
++	/* Allow calling _begin without _end in operatortype creation. */
++	WM_operatortype_props_advanced_end(ot);
++
+ 	/* XXX All ops should have a description but for now allow them not to. */
+ 	RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
+ 	RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
+ 
+ 	BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
+ }
+ 
 -void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata)
++/* all ops in 1 list (for time being... needs evaluation later) */
++void WM_operatortype_append(void (*opfunc)(wmOperatorType *))
+ {
 -	wmOperatorType *ot;
++	wmOperatorType *ot = wm_operatortype_append__begin();
++	opfunc(ot);
++	wm_operatortype_append__end(ot);
++}
+ 
 -	ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
 -	ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
 -	/* Set the default i18n context now, so that opfunc can redefine it if needed! */
 -	RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
 -	ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
++void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata)
++{
++	wmOperatorType *ot = wm_operatortype_append__begin();
+ 	opfunc(ot, userdata);
 -	RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
 -	RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
 -
 -	BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
++	wm_operatortype_append__end(ot);
+ }
+ 
++/** \} */
++
+ 
+ /* called on initialize WM_exit() */
+ void WM_operatortype_remove_ptr(wmOperatorType *ot)
+ {
+ 	BLI_assert(ot == WM_operatortype_find(ot->idname, false));
+ 
+ 	RNA_struct_free(&BLENDER_RNA, ot->srna);
+ 
+ 	if (ot->last_properties) {
+ 		IDP_FreeProperty(ot->last_properties);
+ 		MEM_freeN(ot->last_properties);
+ 	}
+ 
+ 	if (ot->macro.first)
+ 		wm_operatortype_free_macro(ot);
+ 
+ 	BLI_ghash_remove(global_ops_hash, ot->idname, NULL, NULL);
+ 
+ 	WM_keyconfig_update_operatortype();
+ 
+ 	MEM_freeN(ot);
+ }
+ 
+ bool WM_operatortype_remove(const char *idname)
+ {
+ 	wmOperatorType *ot = WM_operatortype_find(idname, 0);
+ 
+ 	if (ot == NULL)
+ 		return false;
+ 
+ 	WM_operatortype_remove_ptr(ot);
+ 
+ 	return true;
+ }
+ 
+ /* called on initialize WM_init() */
+ void wm_operatortype_init(void)
+ {
+ 	/* reserve size is set based on blender default setup */
+ 	global_ops_hash = BLI_ghash_str_new_ex("wm_operatortype_init gh", 2048);
+ }
+ 
+ static void operatortype_ghash_free_cb(wmOperatorType *ot)
+ {
+ 	if (ot->last_properties) {
+ 		IDP_FreeProperty(ot->last_properties);
+ 		MEM_freeN(ot->last_properties);
+ 	}
+ 
+ 	if (ot->macro.first)
+ 		wm_operatortype_free_macro(ot);
+ 
+ 	if (ot->ext.srna) /* python operator, allocs own string */
+ 		MEM_freeN((void *)ot->idname);
+ 
+ 	MEM_freeN(ot);
+ }
+ 
+ void wm_operatortype_free(void)
+ {
+ 	BLI_ghash_free(global_ops_hash, NULL, (GHashValFreeFP)operatortype_ghash_free_cb);
+ 	global_ops_hash = NULL;
+ }
+ 
++/**
++ * Tag all operator-properties of \a ot defined after calling this, until
++ * the next #WM_operatortype_props_advanced_end call (if available), with
++ * #OP_PROP_TAG_ADVANCED. Previously defined ones properties not touched.
++ *
++ * Calling this multiple times without a call to #WM_operatortype_props_advanced_end,
++ * all calls after the first one are ignored. Meaning all propereties defined after the
++ * first call are tagged as advanced.
++ *
++ * This doesn't do the actual tagging, #WM_operatortype_props_advanced_end does which is
++ * called for all operators during registration (see #wm_operatortype_append__end).
++ */
++void WM_operatortype_props_advanced_begin(wmOperatorType *ot)
++{
++	if (ot_prop_basic_count == -1) { /* Don't do anything if _begin was called before, but not _end  */
++		ot_prop_basic_count = RNA_struct_count_properties(ot->srna);
++	}
++}
++
++/**
++ * Tags all operator-properties of \ot defined since the first #WM_operatortype_props_advanced_begin
++ * call, or the last #WM_operatortype_props_advanced_end call, with #OP_PROP_TAG_ADVANCED.
++ * Note that this is called for all operators during registration (see #wm_operatortype_append__end).
++ * So it does not need to be explicitly called in operator-type definition.
++ */
++void WM_operatortype_props_advanced_end(wmOperatorType *ot)
++{
++	PointerRNA struct_ptr;
++	int cou

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list