[Bf-blender-cvs] [6466454] master: Fix T38706: dropdown labels in popups not updating

Campbell Barton noreply at git.blender.org
Wed Feb 19 01:36:18 CET 2014


Commit: 64664541b696998e3b12bfcd43fa9cc892d1e758
Author: Campbell Barton
Date:   Wed Feb 19 11:30:06 2014 +1100
https://developer.blender.org/rB64664541b696998e3b12bfcd43fa9cc892d1e758

Fix T38706: dropdown labels in popups not updating

Caused by own recent changes to menu handling

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

M	source/blender/editors/interface/interface.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_access.c

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

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 68dd50f..2e7bfb1 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2491,6 +2491,25 @@ void ui_check_but(uiBut *but)
 	
 	/* name: */
 	switch (but->type) {
+
+		case MENU:
+			if (BLI_rctf_size_x(&but->rect) > 24.0f) {
+				/* only needed for menus in popup blocks that don't recreate buttons on redraw */
+				if (but->block->flag & UI_BLOCK_LOOP) {
+					if (but->rnaprop && (RNA_property_type(but->rnaprop) == PROP_ENUM)) {
+						int value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
+						const char *buf;
+						if (RNA_property_enum_name_gettexted(but->block->evil_C,
+						                                     &but->rnapoin, but->rnaprop, value, &buf))
+						{
+							BLI_strncpy(but->str, buf, sizeof(but->strdata));
+						}
+					}
+				}
+				BLI_strncpy(but->drawstr, but->str, sizeof(but->drawstr));
+			}
+			break;
+
 		case NUM:
 		case NUMSLI:
 
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 0941f02..17dbd99 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -793,6 +793,7 @@ void RNA_property_enum_items_gettexted(struct bContext *C, PointerRNA *ptr, Prop
 bool RNA_property_enum_value(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *r_value);
 bool RNA_property_enum_identifier(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier);
 bool RNA_property_enum_name(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **name);
+bool RNA_property_enum_name_gettexted(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **name);
 int RNA_property_enum_bitflag_identifiers(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier);
 
 StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop);
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 0ea55a0..4bb04b7 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1437,6 +1437,19 @@ bool RNA_property_enum_name(bContext *C, PointerRNA *ptr, PropertyRNA *prop, con
 	return false;
 }
 
+bool RNA_property_enum_name_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **name)
+{
+	bool result;
+
+	result = RNA_property_enum_name(C, ptr, prop, value, name);
+
+	if (result) {
+		*name = BLF_pgettext(prop->translation_context, *name);
+	}
+
+	return result;
+}
+
 int RNA_property_enum_bitflag_identifiers(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value,
                                           const char **identifier)
 {




More information about the Bf-blender-cvs mailing list