[Bf-blender-cvs] [813694e07b5] master: UI: use checkbox text for property split layout

Campbell Barton noreply at git.blender.org
Fri Mar 22 05:46:56 CET 2019


Commit: 813694e07b57e45ae3e4e2b707932fac73cab217
Author: Campbell Barton
Date:   Fri Mar 22 15:29:25 2019 +1100
Branches: master
https://developer.blender.org/rB813694e07b57e45ae3e4e2b707932fac73cab217

UI: use checkbox text for property split layout

Use right aligned checkboxes when 'use_property_split' is enabled
instead of a separate label.

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

M	source/blender/editors/interface/interface_layout.c

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

diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index ebff54ee6ae..8329ddfed48 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1572,6 +1572,13 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 	bool is_array;
 	const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
 
+	/* By default 'use_prop_sep' uses a separate column for labels.
+	 * This is an exception for check-boxes otherwise only the small checkbox region is clickable.
+	 *
+	 * Keep using 'use_prop_sep' instead of disabling it entirely because
+	 * we need the ability to have decorators still. */
+	bool use_prop_set_split_label = use_prop_sep;
+
 #ifdef UI_PROP_DECORATE
 	struct {
 		bool use_prop_decorate;
@@ -1602,6 +1609,14 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 		}
 	}
 
+#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION
+	if (use_prop_sep) {
+		if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) {
+			use_prop_set_split_label = false;
+		}
+	}
+#endif
+
 	if (icon == ICON_NONE)
 		icon = RNA_property_ui_icon(prop);
 
@@ -1691,25 +1706,16 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 		}
 #endif  /* UI_PROP_DECORATE */
 
-		if (name[0] == '\0') {
+		if ((name[0] == '\0') || (use_prop_set_split_label == false)) {
 			/* Ensure we get a column when text is not set. */
 			layout = uiLayoutColumn(layout_row ? layout_row : layout, true);
 			layout->space = 0;
 		}
 		else {
 			const PropertySubType subtype = RNA_property_subtype(prop);
-			uiLayout *layout_split;
-#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION
-			if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) {
-				layout_split = uiLayoutRow(layout_row ? layout_row : layout, true);
-			}
-			else
-#endif  /* UI_PROP_SEP_ICON_WIDTH_EXCEPTION */
-			{
-				layout_split = uiLayoutSplit(
-				        layout_row ? layout_row : layout,
-				        UI_ITEM_PROP_SEP_DIVIDE, true);
-			}
+			uiLayout *layout_split = uiLayoutSplit(
+			        layout_row ? layout_row : layout,
+			        UI_ITEM_PROP_SEP_DIVIDE, true);
 			layout_split->space = 0;
 			uiLayout *layout_sub = uiLayoutColumn(layout_split, true);
 			layout_sub->space = 0;
@@ -1771,12 +1777,6 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 				layout = uiLayoutColumn(layout_split, true);
 			}
 			layout->space = 0;
-
-#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION
-			if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) {
-				w = UI_UNIT_X;
-			}
-#endif  /* UI_PROP_SEP_ICON_WIDTH_EXCEPTION */
 		}
 
 #ifdef UI_PROP_DECORATE
@@ -1797,7 +1797,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 	if (index == RNA_NO_INDEX && is_array) {
 		ui_item_array(
 		        layout, block, name, icon, ptr, prop, len, 0, 0, w, h,
-		        expand, slider, toggle, icon_only, compact, !use_prop_sep);
+		        expand, slider, toggle, icon_only, compact, !use_prop_set_split_label);
 	}
 	/* enum item */
 	else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) {
@@ -1838,6 +1838,13 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 
 		if (layout->activate_init)
 			UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
+
+		if (use_prop_set_split_label == false) {
+			/* When the button uses it's own text right align it. */
+			but->drawflag |= UI_BUT_TEXT_RIGHT;
+			but->drawflag &= ~UI_BUT_TEXT_LEFT;
+		}
+
 	}
 
 	/* Mark non-embossed textfields inside a listbox. */



More information about the Bf-blender-cvs mailing list