[Bf-blender-cvs] [42143ce] pie-menus: Add internal operator for enum pies supporting paths.

Antony Riakiotakis noreply at git.blender.org
Tue Jul 8 21:30:40 CEST 2014


Commit: 42143ce873a8cd7a0344d8c1aea33864e1ee9886
Author: Antony Riakiotakis
Date:   Tue Jul 8 22:30:23 2014 +0300
https://developer.blender.org/rB42143ce873a8cd7a0344d8c1aea33864e1ee9886

Add internal operator for enum pies supporting paths.

Used in proportinal editing in edit mode currently.

Also moved all macro definitions after python initialization to enable
referencing of python defined operators in all macros.

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

M	source/blender/editors/include/ED_space_api.h
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_regions.c
M	source/blender/editors/object/object_ops.c
M	source/blender/editors/space_api/spacetypes.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_init_exit.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/wm.h

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

diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index 4fbe01a..d268c57 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -35,6 +35,7 @@ struct ARegionType;
 struct bContext;
 
 void ED_spacetypes_init(void);
+void ED_spacemacros_init(void);
 
 /* the pluginnable API for export to editors */
 
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 7b40aa6..500d16a 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -361,6 +361,8 @@ typedef struct uiPieMenu uiPieMenu;
 void uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event, bool force_click);
 void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname,
                              const char *propname, const struct wmEvent *event, bool force_click);
+void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, const struct wmEvent *event, bool force_click);
+
 uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const struct wmEvent *event, bool force_hold) ATTR_NONNULL();
 void uiPieMenuEnd(struct bContext *C, uiPieMenu *pie);
 struct uiLayout *uiPieMenuLayout(struct uiPieMenu *pie);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 1c9d9a4..4f169e5 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2766,6 +2766,35 @@ void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *
 	uiPieMenuEnd(C, pie);
 }
 
+void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path,
+                     const wmEvent *event, bool force_click)
+{
+	PointerRNA ctx_ptr;
+	PointerRNA r_ptr;
+	PropertyRNA *r_prop;
+	uiPieMenu *pie;
+	uiLayout *layout;
+
+	RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);
+
+	if (!RNA_path_resolve(&ctx_ptr, path, &r_ptr, &r_prop)) {
+		return;
+	}
+
+	/* invalid property, only accept enums */
+	if (RNA_property_type(r_prop) != PROP_ENUM)
+		return;
+
+	pie = uiPieMenuBegin(C, IFACE_(title), ICON_NONE, event, force_click);
+	layout = uiPieMenuLayout(pie);
+
+	layout = uiLayoutRadial(layout);
+	uiItemFullR(layout, &r_ptr, r_prop, RNA_NO_INDEX, 0, UI_ITEM_R_EXPAND, NULL, 0);
+
+	uiPieMenuEnd(C, pie);
+}
+
+
 /*************************** Standard Popup Menus ****************************/
 
 void uiPupMenuReports(bContext *C, ReportList *reports)
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index b9ea191..455baf1 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -273,7 +273,7 @@ void ED_operatormacros_object(void)
 		RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
 	}
 
-	ptr = WM_operator_enum_pie_macro("OBJECT_OT_pie_mode_set", "Set Mode",
+	ptr = WM_operator_property_pie_macro("OBJECT_OT_pie_mode_set", "Set Mode",
 	                                 "Set the mode of interaction for the selected object",
 	                                  OPTYPE_UNDO | OPTYPE_REGISTER, "Interaction Mode",
 	                                 "OBJECT_OT_mode_set", "mode");
@@ -282,6 +282,17 @@ void ED_operatormacros_object(void)
 		RNA_enum_set(ptr, "mode", OB_MODE_EDIT);
 		RNA_boolean_set(ptr, "toggle", true);
 	}
+
+	ptr = WM_operator_enum_pie_macro("WM_OT_proportional_mode_sticky", "Proportional Mode Sticky",
+	                                 "Set the mode of interaction for the proportional editing",
+	                                  OPTYPE_UNDO | OPTYPE_REGISTER, "Proportional Mode",
+	                                 "WM_OT_context_toggle_enum", "tool_settings.proportional_edit");
+
+	if (ptr) {
+		RNA_string_set(ptr, "data_path", "tool_settings.proportional_edit");
+		RNA_string_set(ptr, "value_1", "DISABLED");
+		RNA_string_set(ptr, "value_2", "ENABLED");
+	}
 }
 
 static int object_mode_poll(bContext *C)
@@ -483,10 +494,13 @@ void ED_keymap_proportional_editmode(struct wmKeyConfig *UNUSED(keyconf), struct
 {
 	wmKeyMapItem *kmi;
 
-	kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0);
+	kmi = WM_keymap_add_item(keymap, "WM_OT_proportional_mode_sticky", OKEY, KM_PRESS, 0, 0);
+
+	/*
 	RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit");
 	RNA_string_set(kmi->ptr, "value_1", "DISABLED");
 	RNA_string_set(kmi->ptr, "value_2", "ENABLED");
+	*/
 
 	/* for modes/object types that allow 'connected' mode, add the Alt O key */
 	if (do_connected) {
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 7a74a58..45afd68 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -130,8 +130,21 @@ void ED_spacetypes_init(void)
 			type->operatortypes();
 	}
 
-	/* Macros's must go last since they reference other operators
-	 * maybe we'll need to have them go after python operators too? */
+	/* register dropboxes (can use macros) */
+	spacetypes = BKE_spacetypes_list();
+	for (type = spacetypes->first; type; type = type->next) {
+		if (type->dropboxes)
+			type->dropboxes();
+	}
+	
+	/* register internal render callbacks */
+	ED_render_internal_init();
+}
+
+void ED_spacemacros_init(void)
+{
+	/* Macros's must go last since they reference other operators.
+	 * We need to have them go after python operators too */
 	ED_operatormacros_armature();
 	ED_operatormacros_mesh();
 	ED_operatormacros_metaball();
@@ -144,16 +157,7 @@ void ED_spacetypes_init(void)
 	ED_operatormacros_curve();
 	ED_operatormacros_mask();
 	ED_operatormacros_sequencer();
-
-	/* register dropboxes (can use macros) */
-	spacetypes = BKE_spacetypes_list();
-	for (type = spacetypes->first; type; type = type->next) {
-		if (type->dropboxes)
-			type->dropboxes();
-	}
-	
-	/* register internal render callbacks */
-	ED_render_internal_init();
+	ED_operatormacros_screen();
 }
 
 /* called in wm.c */
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index eb92918..b27eb9b 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -269,11 +269,17 @@ wmOperator *WM_operator_last_redo(const struct bContext *C);
 bool        WM_operator_last_properties_init(struct wmOperator *op);
 bool        WM_operator_last_properties_store(struct wmOperator *op);
 
+/* call operator or call custom pie menu */
 struct PointerRNA *WM_operator_pie_macro(const char *idname, const char *name, const char *description,
                                          int flag, const char *opname, const char *piename);
-struct PointerRNA *WM_operator_enum_pie_macro(const char *idname, const char *name, const char *description,
+
+/* call operator or call pie menu from expanded operator enum property */
+struct PointerRNA *WM_operator_property_pie_macro(const char *idname, const char *name, const char *description,
                                               int flag, const char *piename, const char *opname, const char *propname);
 
+/* call operator or call pie menu from expanded enum path property */
+struct PointerRNA *WM_operator_enum_pie_macro(const char *idname, const char *name, const char *description,
+                                              int flag, const char *piename, const char *opname, const char *path);
 /* MOVE THIS SOMEWHERE ELSE */
 #define	SEL_TOGGLE		0
 #define	SEL_SELECT		1
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 083f7b6..100d6d9 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -3409,7 +3409,7 @@ PointerRNA *WM_operator_pie_macro(const char *idname, const char *name, const ch
                                   description, flag);
 
 	if (ot) {
-		otmacro = WM_operatortype_macro_define(ot, "WM_OT_call_pie_menu_timer");
+		otmacro = WM_operatortype_macro_define(ot, "WM_OT_sticky_pie_menu");
 		RNA_string_set(otmacro->ptr, "name", piename);
 		otmacro = WM_operatortype_macro_define(ot, opname);
 		return otmacro->ptr;
@@ -3418,7 +3418,7 @@ PointerRNA *WM_operator_pie_macro(const char *idname, const char *name, const ch
 }
 
 
-struct PointerRNA *WM_operator_enum_pie_macro(const char *idname, const char *name, const char *description,
+struct PointerRNA *WM_operator_property_pie_macro(const char *idname, const char *name, const char *description,
                                               int flag, const char *piename, const char *opname, const char *propname)
 {
 	wmOperatorType *ot;
@@ -3428,11 +3428,33 @@ struct PointerRNA *WM_operator_enum_pie_macro(const char *idname, const char *na
                                   description, flag);
 
 	if (ot) {
-		otmacro = WM_operatortype_macro_define(ot, "WM_OT_call_pie_menu_timer");
+		otmacro = WM_operatortype_macro_define(ot, "WM_OT_sticky_pie_menu");
 		RNA_string_set(otmacro->ptr, "name", piename);
 		RNA_string_set(otmacro->ptr, "op_name", opname);
 		RNA_string_set(otmacro->ptr, "prop_name", propname);
-		RNA_boolean_set(otmacro->ptr, "use_property", true);
+		RNA_enum_set(otmacro->ptr, "mode", STICKY_PIE_PROPERTY);
+		otmacro = WM_operatortype_macro_define(ot, opname);
+		return otmacro->ptr;
+	}
+	return NULL;
+}
+
+
+/* call operator or call pie menu from expanded enum path property */
+struct PointerRNA *WM_operator_enum_pie_macro(const char *idname, const char *name, const char *description,
+                                              int flag, const char *piename, const char *opname, const char *path)
+{
+	wmOperatorType *ot;
+	wmOperatorTypeMacro *otmacro;
+
+	ot = WM_operatortype_append_macro(idname, name,
+                                  description, flag);
+
+	if (ot) {
+		otmacro = WM_operatortype_macro_define(ot, "WM_OT_sticky_pie_menu");
+		RNA_string_set(otmacro->ptr, "name", piename);
+		RNA_string_set(otmacro->

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list