[Bf-blender-cvs] [a2ce84c089c] userpref_redesign: Get rid of uiLayout.prop group parameter

Severin noreply at git.blender.org
Mon Mar 19 01:53:41 CET 2018


Commit: a2ce84c089c16389517a25873ffb0b51cfb98ede
Author: Severin
Date:   Mon Mar 19 01:49:10 2018 +0100
Branches: userpref_redesign
https://developer.blender.org/rBa2ce84c089c16389517a25873ffb0b51cfb98ede

Get rid of uiLayout.prop group parameter

Just always use the grouping behavior, that should be fine. Also add colons to
the group title.

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

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_layout.c
M	source/blender/makesrna/intern/rna_ui_api.c

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

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 9a79ae0c4b7..6194941bd38 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -89,7 +89,7 @@ class USERPREF_PT_navigation(Panel):
 
         col = layout.column()
 
-        col.prop(userpref, "active_section", expand=True, group=True)
+        col.prop(userpref, "active_section", expand=True)
 
 
 class USERPREF_MT_interaction_presets(Menu):
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 3d2f692a202..7bc12ed8a80 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -858,8 +858,7 @@ void UI_exit(void);
 #define UI_ITEM_R_FULL_EVENT    (1 << 6)
 #define UI_ITEM_R_NO_BG         (1 << 7)
 #define UI_ITEM_R_IMMEDIATE     (1 << 8)
-#define UI_ITEM_R_GROUP         (1 << 9)
-#define UI_ITEM_O_DEPRESS       (1 << 10)
+#define UI_ITEM_O_DEPRESS       (1 << 9)
 
 /* uiTemplateOperatorPropertyButs flags */
 #define UI_TEMPLATE_OP_PROPS_SHOW_TITLE 1
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 9a150cec869..a7ea42e0fab 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -581,7 +581,7 @@ static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2)
 }
 static void ui_item_enum_expand(
         uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop,
-        const char *uiname, int h, bool icon_only, bool group)
+        const char *uiname, int h, bool icon_only)
 {
 	/* XXX The way this function currently handles uiname parameter is insane and inconsistent with general UI API:
 	 *     * uiname is the *enum property* label.
@@ -628,11 +628,15 @@ static void ui_item_enum_expand(
 		const bool is_first = item == item_array;
 
 		if (!item->identifier[0]) {
-			if (group && name) {
+			if (name) {
+				size_t group_name_len = strlen(item->name) + 2;
+				char *group_name = alloca(group_name_len);
+
 				if (!is_first) {
 					uiItemS(block->curlayout);
 				}
-				uiItemL(block->curlayout, item->name, ICON_NONE);
+				BLI_snprintf(group_name, group_name_len, "%s:", item->name);
+				uiItemL(block->curlayout, group_name, ICON_NONE);
 			}
 			else if (radial && layout_radial) {
 				uiItemS(layout_radial);
@@ -1390,7 +1394,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 	PropertyType type;
 	char namestr[UI_MAX_NAME_STR];
 	int len, w, h;
-	bool slider, toggle, expand, icon_only, no_bg, group;
+	bool slider, toggle, expand, icon_only, no_bg;
 	bool is_array;
 
 	UI_block_layout_set_current(block, layout);
@@ -1451,7 +1455,6 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 	expand = (flag & UI_ITEM_R_EXPAND) != 0;
 	icon_only = (flag & UI_ITEM_R_ICON_ONLY) != 0;
 	no_bg = (flag & UI_ITEM_R_NO_BG) != 0;
-	group = expand && ((flag & UI_ITEM_R_GROUP) != 0);
 
 	/* get size */
 	ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, &w, &h);
@@ -1473,7 +1476,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 	}
 	/* expanded enum */
 	else if (type == PROP_ENUM && (expand || RNA_property_flag(prop) & PROP_ENUM_FLAG))
-		ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only, group);
+		ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only);
 	/* property with separate label */
 	else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {
 		but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 05cb680da3d..5fc263ae171 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -95,10 +95,8 @@ const char *rna_translate_ui_text(
 	return BLT_pgettext(BLT_I18NCONTEXT_DEFAULT, text);
 }
 
-static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname,
-                        const char *name, const char *text_ctxt,
-                        int translate, int icon, int expand, int group,
-                        int slider, int toggle, int icon_only, int event,
+static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, const char *text_ctxt,
+                        int translate, int icon, int expand, int slider, int toggle, int icon_only, int event,
                         int full_event, int emboss, int index, int icon_value)
 {
 	PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
@@ -118,7 +116,6 @@ static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname,
 
 	flag |= (slider) ? UI_ITEM_R_SLIDER : 0;
 	flag |= (expand) ? UI_ITEM_R_EXPAND : 0;
-	flag |= (group) ? UI_ITEM_R_GROUP : 0;
 	flag |= (toggle) ? UI_ITEM_R_TOGGLE : 0;
 	flag |= (icon_only) ? UI_ITEM_R_ICON_ONLY : 0;
 	flag |= (event) ? UI_ITEM_R_EVENT : 0;
@@ -553,8 +550,6 @@ void RNA_api_ui_layout(StructRNA *srna)
 	api_ui_item_rna_common(func);
 	api_ui_item_common(func);
 	RNA_def_boolean(func, "expand", false, "", "Expand button to show more detail");
-	RNA_def_boolean(func, "group", false, "", "Allow grouping together enum items if the enum allows it "
-	                "(requires expand option to be enabled)");
 	RNA_def_boolean(func, "slider", false, "", "Use slider widget for numeric values");
 	RNA_def_boolean(func, "toggle", false, "", "Use toggle widget for boolean values");
 	RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in buttons, no text");



More information about the Bf-blender-cvs mailing list