[Bf-blender-cvs] [98052162e13] master: UI: replace UI_ITEM_O_RETURN_PROPS /w return arg
Campbell Barton
noreply at git.blender.org
Tue Oct 31 07:00:40 CET 2017
Commit: 98052162e1338cb8f97832c3e7e1d65d8bfd9b3f
Author: Campbell Barton
Date: Tue Oct 31 16:58:26 2017 +1100
Branches: master
https://developer.blender.org/rB98052162e1338cb8f97832c3e7e1d65d8bfd9b3f
UI: replace UI_ITEM_O_RETURN_PROPS /w return arg
Means we can have a version of this function that returns the button
and avoids returning a struct that often isn't used.
===================================================================
M source/blender/editors/armature/pose_lib.c
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_handlers.c
M source/blender/editors/interface/interface_layout.c
M source/blender/editors/interface/interface_templates.c
M source/blender/editors/object/object_relations.c
M source/blender/editors/screen/screen_ops.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/space_node/drawnode.c
M source/blender/editors/space_node/node_buttons.c
M source/blender/editors/space_outliner/outliner_edit.c
M source/blender/editors/space_view3d/view3d_buttons.c
M source/blender/editors/space_view3d/view3d_toolbar.c
M source/blender/editors/util/ed_util.c
M source/blender/makesrna/intern/rna_ui_api.c
M source/blender/windowmanager/intern/wm_operators.c
===================================================================
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 13feec2c523..9cd5a0aed30 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -410,11 +410,10 @@ static void poselib_add_menu_invoke__replacemenu(bContext *C, uiLayout *layout,
/* add each marker to this menu */
for (marker = act->markers.first; marker; marker = marker->next) {
PointerRNA props_ptr;
-
- props_ptr = uiItemFullO_ptr(layout, ot,
- marker->name, ICON_ARMATURE_DATA, NULL,
- WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
-
+ uiItemFullO_ptr(
+ layout, ot,
+ marker->name, ICON_ARMATURE_DATA, NULL,
+ WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_int_set(&props_ptr, "frame", marker->frame);
RNA_string_set(&props_ptr, "name", marker->name);
}
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 98e278e5570..8b4f094cb8d 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -819,7 +819,6 @@ void UI_exit(void);
#define UI_LAYOUT_ALIGN_CENTER 2
#define UI_LAYOUT_ALIGN_RIGHT 3
-#define UI_ITEM_O_RETURN_PROPS (1 << 0)
#define UI_ITEM_R_EXPAND (1 << 1)
#define UI_ITEM_R_SLIDER (1 << 2)
#define UI_ITEM_R_TOGGLE (1 << 3)
@@ -981,8 +980,14 @@ void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname
void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value);
void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value);
-PointerRNA uiItemFullO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, struct IDProperty *properties, int context, int flag);
-PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag);
+void uiItemFullO_ptr(
+ uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon,
+ struct IDProperty *properties, int context, int flag,
+ PointerRNA *r_opptr);
+void uiItemFullO(
+ uiLayout *layout, const char *idname, const char *name, int icon,
+ struct IDProperty *properties, int context, int flag,
+ PointerRNA *r_opptr);
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon);
void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, const char *name, int icon);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 9e93b02a8cd..0dec751526a 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -6738,16 +6738,15 @@ static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, Pr
if (file[0]) {
BLI_assert(subtype == PROP_FILEPATH);
-
- props_ptr = uiItemFullO_ptr(
- layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open File Externally"),
- ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ uiItemFullO_ptr(
+ layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open File Externally"),
+ ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr);
RNA_string_set(&props_ptr, "filepath", filepath);
}
- props_ptr = uiItemFullO_ptr(
- layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Location Externally"),
- ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ uiItemFullO_ptr(
+ layout, ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Location Externally"),
+ ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &props_ptr);
RNA_string_set(&props_ptr, "filepath", dir);
}
@@ -7028,21 +7027,23 @@ static bool ui_but_menu(bContext *C, uiBut *but)
{ /* Docs */
char buf[512];
- PointerRNA ptr_props;
if (UI_but_online_manual_id(but, buf, sizeof(buf))) {
+ PointerRNA ptr_props;
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Manual"),
ICON_URL, "WM_OT_doc_view_manual_ui_context");
- ptr_props = uiItemFullO(layout, "WM_OT_doc_view",
- CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Python Reference"),
- ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ uiItemFullO(
+ layout, "WM_OT_doc_view",
+ CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Python Reference"),
+ ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &ptr_props);
RNA_string_set(&ptr_props, "doc_id", buf);
/* XXX inactive option, not for public! */
#if 0
- ptr_props = uiItemFullO(layout, "WM_OT_doc_edit",
- "Submit Description", ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+ uiItemFullO(
+ layout, "WM_OT_doc_edit", "Submit Description", ICON_NONE,
+ NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr_props);
RNA_string_set(&ptr_props, "doc_id", buf);
RNA_string_set(&ptr_props, "doc_new", RNA_property_description(but->rnaprop));
#endif
@@ -7056,9 +7057,9 @@ static bool ui_but_menu(bContext *C, uiBut *but)
/* perhaps we should move this into (G.debug & G_DEBUG) - campbell */
if (ui_block_is_menu(but->block) == false) {
- uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0);
+ uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL);
}
- uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0);
+ uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL);
mt = WM_menutype_find("WM_MT_button_context", true);
if (mt) {
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b43892053ce..a0840f7fb34 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -790,9 +790,17 @@ static void ui_item_disabled(uiLayout *layout, const char *name)
but->disabled_info = "";
}
-/* operator items */
-PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag)
+/**
+ * Operator Item
+ * \param r_opptr: Optional, initialize with operator properties when not NULL.
+ * Will always be written to even in the case of errors.
+ */
+void uiItemFullO_ptr(
+ uiLayout *layout, wmOperatorType *ot,
+ const char *name, int icon, IDProperty *properties, int context, int flag,
+ PointerRNA *r_opptr)
{
+ /* Take care to fill 'r_opptr' whatever happens. */
uiBlock *block = layout->root->block;
uiBut *but;
int w;
@@ -841,9 +849,8 @@ PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *nam
UI_but_flag_enable(but, UI_BUT_REDALERT);
/* assign properties */
- if (properties || (flag & UI_ITEM_O_RETURN_PROPS)) {
+ if (properties || r_opptr) {
PointerRNA *opptr = UI_but_operator_ptr_get(but);
-
if (properties) {
opptr->data = properties;
}
@@ -851,20 +858,28 @@ PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *nam
IDPropertyTemplate val = {0};
opptr->data = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
}
-
- return *opptr;
+ if (r_opptr) {
+ *r_opptr = *opptr;
+ }
}
-
- return PointerRNA_NULL;
}
-PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, IDProperty *properties, int context, int flag)
+void uiItemFullO(
+ uiLayout *layout, const char *opname,
+ const char *name, int icon, IDProperty *properties, int context, int flag,
+ PointerRNA *r_opptr)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
- UI_OPERATOR_ERROR_RET(ot, opname, return PointerRNA_NULL);
+ UI_OPERATOR_ERROR_RET(
+ ot, opname, {
+ if (r_opptr) {
+ *r_opptr = PointerRNA_NULL;
+ };
+ return;
+ });
- return uiItemFullO_ptr(layout, ot, name, icon, properties, context, flag);
+ uiItemFullO_ptr(layout, ot, name, icon, properties, context, flag, r_opptr);
}
static const char *ui_menu_enumpropname(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int retval)
@@ -908,7 +923,7 @@ void uiItemEnumO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int
if (!name)
name = ui_menu_enumpropname(layout, &ptr, prop, value);
- uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
}
void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value)
{
@@ -1002,7 +1017,7 @@ void uiItemsFullEnumO_items(
}
RNA_property_enum_set(&tptr, prop, item->value);
- uiItemFullO_ptr(target, ot, item->name, item->icon, tptr.data, context, flag);
+ uiItemFullO_ptr(target, ot, item->name, item->icon, tptr.data, context, flag, NULL);
ui_but_tip_from_enum_item(block->buttons.last, item);
}
@@ -1132,7 +1147,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char
if (!name)
name = ui_menu_enumpropname(layout, &ptr, prop, value);
- uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
}
void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value_str)
@@ -1176,7 +1191,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char
if (!name)
name = ui_menu_enumpropname(layout, &ptr, prop, value);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list