UI: enable string properties for alt-click buttons for multiple objects

This came up in #106591 which reported that changing a Light Group would
not work when alt-clicking the property field (which is the usual method
to edit a property for multiple objects at once).

This is because string properties were not supported in
`ui_selectcontext_apply` which is now done.

Similar to 1318660b04 [which added support for pointer properties].

Adding general support for string properties means this method can now
be used for many more things:
- changing all sorts of ID names (objects, meshes, ...)
- many settings in modifiers (e.g. vertexgroups)
- geometry nodes modifier properties (e.g. attribute names)
- ...

Fixes #106591

Pull Request: https://projects.blender.org/blender/blender/pulls/106599
This commit is contained in:
Philipp Oeser
2023-04-11 10:27:51 +02:00
committed by Philipp Oeser
parent 17e2862603
commit 43eb3fe21a

View File

@@ -1918,6 +1918,7 @@ static void ui_selectcontext_apply(bContext *C,
bool b;
int i;
float f;
char *str;
PointerRNA p;
} delta, min, max;
@@ -1950,6 +1951,10 @@ static void ui_selectcontext_apply(bContext *C,
/* Not a delta in fact. */
delta.p = RNA_property_pointer_get(&but->rnapoin, prop);
}
else if (rna_type == PROP_STRING) {
/* Not a delta in fact. */
delta.str = RNA_property_string_get_alloc(&but->rnapoin, prop, nullptr, 0, nullptr);
}
# ifdef USE_ALLSELECT_LAYER_HACK
/* make up for not having 'handle_layer_buttons' */
@@ -2023,9 +2028,16 @@ static void ui_selectcontext_apply(bContext *C,
const PointerRNA other_value = delta.p;
RNA_property_pointer_set(&lptr, lprop, other_value, nullptr);
}
else if (rna_type == PROP_STRING) {
const char *other_value = delta.str;
RNA_property_string_set(&lptr, lprop, other_value);
}
RNA_property_update(C, &lptr, prop);
}
if (rna_type == PROP_STRING) {
MEM_freeN(delta.str);
}
}
}