[Bf-blender-cvs] [91240f15c54] blender2.8: UI: add UILayout.direction

Campbell Barton noreply at git.blender.org
Thu Dec 20 02:03:18 CET 2018


Commit: 91240f15c54632409da3f09d1c3eb40e6f66e52d
Author: Campbell Barton
Date:   Thu Dec 20 11:59:31 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB91240f15c54632409da3f09d1c3eb40e6f66e52d

UI: add UILayout.direction

Read only attribute, needed for introspection.

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

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 80ac5e72868..31956877d1b 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1003,6 +1003,7 @@ void uiLayoutSetUnitsY(uiLayout *layout, float unit);
 void uiLayoutSetEmboss(uiLayout *layout, char emboss);
 void uiLayoutSetPropSep(uiLayout *layout, bool is_sep);
 void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep);
+int uiLayoutGetLocalDir(const uiLayout *layout);
 
 int uiLayoutGetOperatorContext(uiLayout *layout);
 bool uiLayoutGetActive(uiLayout *layout);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index afcbcbbdf52..9b145fdba92 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -380,7 +380,7 @@ static void ui_item_move(uiItem *item, int delta_xmin, int delta_xmax)
 
 /******************** Special RNA Items *********************/
 
-static int ui_layout_local_dir(uiLayout *layout)
+int uiLayoutGetLocalDir(const uiLayout *layout)
 {
 	switch (layout->item.type) {
 		case ITEM_LAYOUT_ROW:
@@ -402,7 +402,7 @@ static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, bool
 {
 	uiLayout *sub;
 
-	if (ui_layout_local_dir(test) == UI_LAYOUT_HORIZONTAL)
+	if (uiLayoutGetLocalDir(test) == UI_LAYOUT_HORIZONTAL)
 		sub = uiLayoutRow(layout, align);
 	else
 		sub = uiLayoutColumn(layout, align);
@@ -731,7 +731,7 @@ static void ui_item_enum_expand_exec(
 			UI_but_func_set(but, ui_item_enum_expand_handle, but, POINTER_FROM_INT(value));
 		}
 
-		if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL)
+		if (uiLayoutGetLocalDir(layout) != UI_LAYOUT_HORIZONTAL)
 			but->drawflag |= UI_BUT_TEXT_LEFT;
 
 		/* Allow quick, inaccurate swipe motions to switch tabs (no need to keep cursor over them). */
@@ -1749,7 +1749,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 				/* Expanded enums each have their own name. */
 
 				/* Often expanded enum's are better arranged into a row, so check the existing layout. */
-				if (ui_layout_local_dir(layout) == UI_LAYOUT_HORIZONTAL) {
+				if (uiLayoutGetLocalDir(layout) == UI_LAYOUT_HORIZONTAL) {
 					layout = uiLayoutRow(layout_split, true);
 				}
 				else {
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index ea39ce72598..7c792f04f02 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -950,6 +950,11 @@ static void rna_UILayout_alignment_set(PointerRNA *ptr, int value)
 	uiLayoutSetAlignment(ptr->data, value);
 }
 
+static int rna_UILayout_direction_get(PointerRNA *ptr)
+{
+	return uiLayoutGetLocalDir(ptr->data);
+}
+
 static float rna_UILayout_scale_x_get(PointerRNA *ptr)
 {
 	return uiLayoutGetScaleX(ptr->data);
@@ -1035,6 +1040,12 @@ static void rna_def_ui_layout(BlenderRNA *brna)
 		{0, NULL, 0, NULL, NULL}
 	};
 
+	static const EnumPropertyItem direction_items[] = {
+		{UI_LAYOUT_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""},
+		{UI_LAYOUT_VERTICAL, "VERTICAL", 0, "Vertical", ""},
+		{0, NULL, 0, NULL, NULL}
+	};
+
 	static const EnumPropertyItem emboss_items[] = {
 		{UI_EMBOSS, "NORMAL", 0, "Normal", "Draw standard button emboss style"},
 		{UI_EMBOSS_NONE, "NONE", 0, "None", "Draw only text and icons"},
@@ -1067,6 +1078,11 @@ static void rna_def_ui_layout(BlenderRNA *brna)
 	RNA_def_property_enum_items(prop, alignment_items);
 	RNA_def_property_enum_funcs(prop, "rna_UILayout_alignment_get", "rna_UILayout_alignment_set", NULL);
 
+	prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_items(prop, direction_items);
+	RNA_def_property_enum_funcs(prop, "rna_UILayout_direction_get", NULL, NULL);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
 #if 0
 	prop = RNA_def_property(srna, "keep_aspect", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_funcs(prop, "rna_UILayout_keep_aspect_get", "rna_UILayout_keep_aspect_set");



More information about the Bf-blender-cvs mailing list