[Bf-blender-cvs] [f55d2175982] TEMP-UI-DECOR: TMP

Campbell Barton noreply at git.blender.org
Sat Jun 16 10:40:26 CEST 2018


Commit: f55d217598268de59bb831f2ce2e73cbe6d8beb5
Author: Campbell Barton
Date:   Sat Jun 16 10:25:46 2018 +0200
Branches: TEMP-UI-DECOR
https://developer.blender.org/rBf55d217598268de59bb831f2ce2e73cbe6d8beb5

TMP

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_layout.c
M	source/blender/makesrna/intern/rna_ui.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 876a382bb7c..ec5480765a7 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -964,6 +964,7 @@ void uiLayoutSetScaleX(uiLayout *layout, float scale);
 void uiLayoutSetScaleY(uiLayout *layout, float scale);
 void uiLayoutSetEmboss(uiLayout *layout, char emboss);
 void uiLayoutSetPropSep(uiLayout *layout, bool is_sep);
+void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep);
 
 int uiLayoutGetOperatorContext(uiLayout *layout);
 bool uiLayoutGetActive(uiLayout *layout);
@@ -976,6 +977,7 @@ float uiLayoutGetScaleX(uiLayout *layout);
 float uiLayoutGetScaleY(uiLayout *layout);
 int uiLayoutGetEmboss(uiLayout *layout);
 bool uiLayoutGetPropSep(uiLayout *layout);
+bool uiLayoutGetPropDecorate(uiLayout *layout);
 
 /* layout specifiers */
 uiLayout *uiLayoutRow(uiLayout *layout, int align);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index ac7bbb12912..4368af6ed84 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -132,6 +132,7 @@ enum {
 
 	UI_ITEM_BOX_ITEM  = 1 << 2, /* The item is "inside" a box item */
 	UI_ITEM_PROP_SEP  = 1 << 3,
+	UI_ITEM_PROP_DECORATE = 1 << 4,
 };
 
 typedef struct uiButtonItem {
@@ -1468,6 +1469,7 @@ static void ui_item_rna_size(
 
 void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag, const char *name, int icon)
 {
+	layout->item.flag |= UI_ITEM_PROP_DECORATE;
 	uiBlock *block = layout->root->block;
 	uiBut *but = NULL;
 	PropertyType type;
@@ -1476,9 +1478,10 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 	bool slider, toggle, expand, icon_only, no_bg, compact;
 	bool is_array;
 	const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
+	const bool use_prop_decor = use_prop_sep;
 
 	UI_block_layout_set_current(block, layout);
-
+	uiLayout *layout_decor = NULL;
 	/* retrieve info */
 	type = RNA_property_type(prop);
 	is_array = RNA_property_array_check(prop);
@@ -1557,15 +1560,35 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 	}
 
 	/* Split the label / property. */
+	int prop_sep_len = -1;
 	if (use_prop_sep) {
+		uiLayout *layout_row = NULL;
+
 		if (name[0] == '\0') {
+			if (use_prop_decor) {
+				layout_row = uiLayoutRow(layout, true);
+				layout_row->space = 0;
+			}
+
 			/* Ensure we get a column when text is not set. */
-			layout = uiLayoutColumn(layout, true);
+			layout = uiLayoutColumn(
+			        use_prop_decor ? layout_row : layout, true);
 			layout->space = 0;
+			if (use_prop_decor) {
+				layout_decor = uiLayoutColumn(layout_row, true);
+				layout_decor->space = 0;
+			}
 		}
 		else {
+			if (use_prop_decor) {
+				layout_row = uiLayoutRow(layout, true);
+				layout_row->space = 0;
+			}
+
 			const PropertySubType subtype = RNA_property_subtype(prop);
-			uiLayout *layout_split = uiLayoutSplit(layout, UI_ITEM_PROP_SEP_DIVIDE, true);
+			uiLayout *layout_split = uiLayoutSplit(
+			        use_prop_decor ? layout_row : layout,
+			        UI_ITEM_PROP_SEP_DIVIDE, true);
 			layout_split->space = 0;
 			uiLayout *layout_sub = uiLayoutColumn(layout_split, true);
 			layout_sub->space = 0;
@@ -1573,6 +1596,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 			if ((index == RNA_NO_INDEX && is_array) &&
 			    ((!expand && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA, PROP_DIRECTION)) == 0))
 			{
+				prop_sep_len = len;
 				char name_with_suffix[UI_MAX_DRAW_STR + 2];
 				char str[2] = {'\0'};
 				for (int a = 0; a < len; a++) {
@@ -1593,6 +1617,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 				}
 			}
 			else {
+				prop_sep_len = 1;
 				if (name) {
 					but = uiDefBut(
 					        block, UI_BTYPE_LABEL, 0, name,
@@ -1602,6 +1627,10 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 				}
 			}
 
+			if (use_prop_decor) {
+				layout_decor = uiLayoutColumn(layout_row, true);
+				layout_decor->space = 0;
+			}
 			/* Watch out! We can only write into the new column now. */
 			layout = uiLayoutColumn(layout_split, true);
 			layout->space = 0;
@@ -1655,6 +1684,23 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 		UI_but_flag_enable(but, UI_BUT_LIST_ITEM);
 	}
 
+	if (use_prop_decor) {
+		uiLayout *layout_col = uiLayoutColumn(layout_decor, false);
+		layout_col->space = 0;
+		layout_col->emboss = UI_EMBOSS_NONE;
+		for (int a = 0; a < prop_sep_len; a++) {
+			// if (layout->item.flag & UI_ITEM_PROP_DECORATE) {
+				// but = uiDefBut(
+				//         block, UI_BTYPE_LABEL, 0, NULL,
+				//         0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+			but = uiDefIconBut(
+			        block, UI_BTYPE_BUT, 0, ICON_DOT, 0, 0, UI_UNIT_X, UI_UNIT_Y,
+			        NULL, 0.0, 0.0, 0.0, 0.0, TIP_("XXX"));
+			// ICON_SPACE3 ICON_SPACE2
+			// }
+		}
+	}
+
 	if (no_bg) {
 		layout->emboss = prev_emboss;
 	}
@@ -3700,6 +3746,16 @@ void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
 	SET_FLAG_FROM_TEST(layout->item.flag, is_sep, UI_ITEM_PROP_SEP);
 }
 
+bool uiLayoutGetPropDecorate(uiLayout *layout)
+{
+	return (layout->item.flag & UI_ITEM_PROP_DECORATE) != 0;
+}
+
+void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
+{
+	SET_FLAG_FROM_TEST(layout->item.flag, is_sep, UI_ITEM_PROP_DECORATE);
+}
+
 bool uiLayoutGetActive(uiLayout *layout)
 {
 	return layout->active;
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 8083ae35dc1..70aa4709d8c 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -963,6 +963,16 @@ static void rna_UILayout_property_split_set(PointerRNA *ptr, int value)
 	uiLayoutSetPropSep(ptr->data, value);
 }
 
+static int rna_UILayout_property_decorate_get(PointerRNA *ptr)
+{
+	return uiLayoutGetPropDecorate(ptr->data);
+}
+
+static void rna_UILayout_property_decorate_set(PointerRNA *ptr, int value)
+{
+	uiLayoutSetPropDecorate(ptr->data, value);
+}
+
 #else /* RNA_RUNTIME */
 
 static void rna_def_ui_layout(BlenderRNA *brna)
@@ -1030,6 +1040,9 @@ static void rna_def_ui_layout(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "use_property_split", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_funcs(prop, "rna_UILayout_property_split_get", "rna_UILayout_property_split_set");
+
+	prop = RNA_def_property(srna, "use_property_decorate", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_funcs(prop, "rna_UILayout_property_decorate_get", "rna_UILayout_property_decorate_set");
 }
 
 static void rna_def_panel(BlenderRNA *brna)



More information about the Bf-blender-cvs mailing list