UI: fix two issues with expanded enum property buttons:
* they were too slow for dynamic python enums, calling the callback to list the items for each button, to get a tooltip * enum tooltips sometimes were showing the same description twice
This commit is contained in:
@@ -1668,7 +1668,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ui_set_but_default(bContext *C, uiBut *UNUSED(but), short all)
|
||||
void ui_set_but_default(bContext *C, short all)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
|
||||
@@ -2481,28 +2481,8 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
|
||||
icon= RNA_property_ui_icon(prop);
|
||||
}
|
||||
}
|
||||
|
||||
if(!tip) {
|
||||
if(type == ROW && proptype == PROP_ENUM) {
|
||||
EnumPropertyItem *item;
|
||||
int i, totitem, free;
|
||||
|
||||
RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free);
|
||||
|
||||
for(i=0; i<totitem; i++) {
|
||||
if(item[i].identifier[0] && item[i].value == (int)max) {
|
||||
if(item[i].description[0])
|
||||
tip= item[i].description;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(free)
|
||||
MEM_freeN(item);
|
||||
}
|
||||
}
|
||||
|
||||
if(!tip)
|
||||
if(!tip && proptype != PROP_ENUM)
|
||||
tip= RNA_property_ui_description(prop);
|
||||
|
||||
if(min == max || a1 == -1 || a2 == -1) {
|
||||
|
||||
@@ -4445,7 +4445,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
|
||||
else if(ELEM(event->type, DELKEY, PADPERIOD) && event->val == KM_PRESS) {
|
||||
/* ctrl+del - reset active button; del - reset a whole array*/
|
||||
if (!(ELEM3(but->type, HSVCIRCLE, HSVCUBE, HISTOGRAM)))
|
||||
ui_set_but_default(C, but, !event->ctrl);
|
||||
ui_set_but_default(C, !event->ctrl);
|
||||
}
|
||||
/* handle menu */
|
||||
else if(event->type == RIGHTMOUSE && event->val == KM_PRESS) {
|
||||
|
||||
@@ -369,7 +369,7 @@ extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen);
|
||||
extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
|
||||
extern int ui_get_but_string_max_length(uiBut *but);
|
||||
|
||||
extern void ui_set_but_default(struct bContext *C, uiBut *but, short all);
|
||||
extern void ui_set_but_default(struct bContext *C, short all);
|
||||
|
||||
extern void ui_set_but_soft_range(uiBut *but, double value);
|
||||
|
||||
|
||||
@@ -370,6 +370,27 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
|
||||
data->color[data->totline]= 0xFFFFFF;
|
||||
data->totline++;
|
||||
}
|
||||
|
||||
if(but->type == ROW) {
|
||||
EnumPropertyItem *item;
|
||||
int i, totitem, free;
|
||||
|
||||
RNA_property_enum_items(C, &but->rnapoin, but->rnaprop, &item, &totitem, &free);
|
||||
|
||||
for(i=0; i<totitem; i++) {
|
||||
if(item[i].identifier[0] && item[i].value == (int)but->hardmax) {
|
||||
if(item[i].description[0]) {
|
||||
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "%s: %s", item[i].name, item[i].description);
|
||||
data->color[data->totline]= 0xFFFFFF;
|
||||
data->totline++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(free)
|
||||
MEM_freeN(item);
|
||||
}
|
||||
}
|
||||
|
||||
if(but->tip && strlen(but->tip)) {
|
||||
|
||||
Reference in New Issue
Block a user