Display enum descriptions in tooltips for operators using a "type" or "mode"
property Changes: This commit adds a second line to the tooltips (below the generic operator description) showing the appropriate description for each enum option. This brings it more into line enum properties in Blender which also show this sort of information. Rationale: Operators such as Snap and Mirror in the Action and Graph Editors use an enum to control their behaviour (respectively, "how to snap" or "what to use as the mirror line"). In the menus, these options are displayed using a submenu, but hovering over each of these items for more information from a tooltip only shows the (relatively unhelpful) generic operator tooltip/description. Another area where these descriptions are useful is for Keying Sets, where it's now possible to see the descriptions for what each Keying Set does/affects/requires. Again, this is more helpful than just the generic tooltip, which would be something like "Insert keyframes using a Keying Set".
This commit is contained in:
@@ -3869,12 +3869,41 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...)
|
||||
}
|
||||
}
|
||||
else if (ELEM3(type, BUT_GET_RNAENUM_IDENTIFIER, BUT_GET_RNAENUM_LABEL, BUT_GET_RNAENUM_TIP)) {
|
||||
PointerRNA *ptr = NULL;
|
||||
PropertyRNA *prop = NULL;
|
||||
int value = 0;
|
||||
|
||||
/* get the enum property... */
|
||||
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) {
|
||||
/* enum property */
|
||||
ptr = &but->rnapoin;
|
||||
prop = but->rnaprop;
|
||||
value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but);
|
||||
}
|
||||
else if (but->optype) {
|
||||
PointerRNA *opptr = uiButGetOperatorPtrRNA(but);
|
||||
wmOperatorType *ot = but->optype;
|
||||
|
||||
/* if the default property of the operator is enum and it is set,
|
||||
* fetch the tooltip of the selected value so that "Snap" and "Mirror"
|
||||
* operator menus in the Anim Editors will show tooltips for the different
|
||||
* operations instead of the meaningless generic operator tooltip
|
||||
*/
|
||||
if (ot->prop && RNA_property_type(ot->prop) == PROP_ENUM) {
|
||||
if (RNA_struct_contains_property(opptr, ot->prop)) {
|
||||
ptr = opptr;
|
||||
prop = ot->prop;
|
||||
value = RNA_property_enum_get(opptr, ot->prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* get strings from matching enum item */
|
||||
if (ptr && prop) {
|
||||
if (!item) {
|
||||
int i;
|
||||
int value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but);
|
||||
RNA_property_enum_items_gettexted(C, &but->rnapoin, but->rnaprop, &items, &totitems, &free_items);
|
||||
|
||||
|
||||
RNA_property_enum_items_gettexted(C, ptr, prop, &items, &totitems, &free_items);
|
||||
for (i = 0, item = items; i < totitems; i++, item++) {
|
||||
if (item->identifier[0] && item->value == value)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user