Fix #103269: node group asset description not showing as tooltip in the Add menu #104968
|
@ -6515,6 +6515,8 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
|
|||
va_list args;
|
||||
uiStringInfo *si;
|
||||
|
||||
PointerRNA *opptr = UI_but_operator_ptr_get(but);
|
||||
|
||||
const EnumPropertyItem *items = nullptr, *item = nullptr;
|
||||
int totitems;
|
||||
bool free_items = false;
|
||||
|
@ -6593,10 +6595,13 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
|
|||
}
|
||||
else if (but->optype) {
|
||||
if (type == BUT_GET_RNA_LABEL) {
|
||||
tmp = BLI_strdup(WM_operatortype_name(but->optype, but->opptr));
|
||||
tmp = BLI_strdup(WM_operatortype_name(but->optype, opptr));
|
||||
}
|
||||
else {
|
||||
tmp = WM_operatortype_description(C, but->optype, but->opptr);
|
||||
bContextStore *previous_ctx = CTX_store_get(C);
|
||||
CTX_store_set(C, but->context);
|
||||
tmp = WM_operatortype_description(C, but->optype, opptr);
|
||||
CTX_store_set(C, previous_ctx);
|
||||
}
|
||||
}
|
||||
else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER)) {
|
||||
|
@ -6679,7 +6684,6 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
|
|||
int(ui_but_value_get(but));
|
||||
}
|
||||
else if (but->optype) {
|
||||
PointerRNA *opptr = UI_but_operator_ptr_get(but);
|
||||
wmOperatorType *ot = but->optype;
|
||||
|
||||
/* So the context is passed to `itemf` functions. */
|
||||
|
|
|
@ -456,6 +456,22 @@ static int node_add_group_asset_invoke(bContext *C, wmOperator *op, const wmEven
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static char *node_add_group_asset_get_description(struct bContext *C,
|
||||
struct wmOperatorType * /*op*/,
|
||||
struct PointerRNA * /*values*/)
|
||||
{
|
||||
bool is_valid;
|
||||
const AssetHandle handle = CTX_wm_asset_handle(C, &is_valid);
|
||||
if (!is_valid) {
|
||||
return nullptr;
|
||||
}
|
||||
const AssetMetaData &asset_data = *ED_asset_handle_get_metadata(&handle);
|
||||
if (!asset_data.description) {
|
||||
return nullptr;
|
||||
}
|
||||
return BLI_strdup(asset_data.description);
|
||||
}
|
||||
|
||||
void NODE_OT_add_group_asset(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Add Node Group Asset";
|
||||
|
@ -464,6 +480,7 @@ void NODE_OT_add_group_asset(wmOperatorType *ot)
|
|||
|
||||
ot->invoke = node_add_group_asset_invoke;
|
||||
ot->poll = node_add_group_poll;
|
||||
ot->get_description = node_add_group_asset_get_description;
|
||||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue