Fix [#34545] Render layer name is unwantedly translated in composite node editor

Some enums' items actually are generated from data (like the render layers of compo nodes), so they should not be translated. Added a PROP_ENUM_NO_TRANSLATE new RNA flag to tag those enums (only found those for nodes, but may be more of them around).

Also fix similar issue in main list of render layers (Py UI code! :P ).
This commit is contained in:
Bastien Montagne 2013-04-25 17:40:08 +00:00
parent ed68497700
commit e22c52af16
4 changed files with 7 additions and 4 deletions

@ -38,7 +38,7 @@ class RENDERLAYER_UL_renderlayers(UIList):
# assert(isinstance(item, bpy.types.SceneRenderLayer)
layer = item
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.label(layer.name, icon_value=icon)
layout.label(layer.name, icon_value=icon, translate=False)
layout.prop(layer, "use", text="", index=index)
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'

@ -146,7 +146,7 @@ typedef enum PropertySubType {
} PropertySubType;
/* Make sure enums are updated with thses */
/* HIGHEST FLAG IN USE: 1 << 28 */
/* HIGHEST FLAG IN USE: 1 << 29 */
typedef enum PropertyFlag {
/* editable means the property is editable in the user
* interface, properties are editable by default except
@ -226,7 +226,8 @@ typedef enum PropertyFlag {
PROP_RAW_ARRAY = (1 << 14),
PROP_FREE_POINTERS = (1 << 15),
PROP_DYNAMIC = (1 << 17), /* for dynamic arrays, and retvals of type string */
PROP_ENUM_NO_CONTEXT = (1 << 24) /* for enum that shouldn't be contextual */
PROP_ENUM_NO_CONTEXT = (1 << 24), /* for enum that shouldn't be contextual */
PROP_ENUM_NO_TRANSLATE = (1 << 29), /* for enums that shouldn't be translated (e.g. renderlayers' names in nodes) */
} PropertyFlag;
typedef struct CollectionPropertyIterator {

@ -1256,7 +1256,7 @@ void RNA_property_enum_items_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA
RNA_property_enum_items(C, ptr, prop, item, totitem, free);
#ifdef WITH_INTERNATIONAL
{
if (!(prop->flag & PROP_ENUM_NO_TRANSLATE)) {
int i;
/* Note: Only do those tests once, and then use BLF_pgettext. */
int do_iface = BLF_translate_iface();

@ -3715,6 +3715,7 @@ static void def_node_image_user(StructRNA *srna)
RNA_def_property_enum_sdna(prop, NULL, "layer");
RNA_def_property_enum_items(prop, prop_image_layer_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_image_layer_itemf");
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
RNA_def_property_ui_text(prop, "Layer", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_image_layer_update");
}
@ -3769,6 +3770,7 @@ static void def_cmp_render_layers(StructRNA *srna)
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, prop_scene_layer_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_scene_layer_itemf");
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
RNA_def_property_ui_text(prop, "Layer", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}