include menu ID's in tooltips when python tips are enabled, there was no way to find the ID of a menu which become annoying if you wanted to reference it from a script.

This commit is contained in:
2011-07-26 09:19:51 +00:00
parent 7c9033d606
commit 06ae122f60
4 changed files with 19 additions and 1 deletions

View File

@@ -484,6 +484,17 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
}
}
}
else if (ELEM(but->type, MENU, PULLDOWN)) {
if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
if(but->menu_create_func && WM_menutype_contains((MenuType *)but->poin)) {
MenuType *mt= (MenuType *)but->poin;
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", mt->idname);
data->color[data->totline]= 0x888888;
data->totline++;
}
}
}
assert(data->totline < MAX_TOOLTIP_LINES);

View File

@@ -940,7 +940,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *
rna_Operator_unregister(bmain, ot->ext.srna);
}
/* create a new menu type */
/* create a new operator type */
dummyot.ext.srna= RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator");
RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */
dummyot.ext.data= data;

View File

@@ -272,6 +272,7 @@ void WM_operator_py_idname(char *to, const char *from);
/* *************** menu types ******************** */
struct MenuType *WM_menutype_find(const char *idname, int quiet);
int WM_menutype_add(struct MenuType* mt);
int WM_menutype_contains(struct MenuType* mt);
void WM_menutype_freelink(struct MenuType* mt);
void WM_menutype_free(void);

View File

@@ -175,6 +175,12 @@ int WM_menutype_add(MenuType* mt)
return 1;
}
/* inefficient but only used for tooltip code */
int WM_menutype_contains(MenuType* mt)
{
return (mt != NULL && BLI_findindex(&menutypes, mt) != -1);
}
void WM_menutype_freelink(MenuType* mt)
{
BLI_freelinkN(&menutypes, mt);