UI: fix two issues with expanded enum property buttons:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 2 Jun 2011 14:18:51 +0000 (14:18 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 2 Jun 2011 14:18:51 +0000 (14:18 +0000)
* 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

source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_regions.c

index 3e65e707682a6afab480cdaeb7b770739dc6ad78..d139eafc09de46c29e9e6005ee56dc0b5ce438b3 100644 (file)
@@ -1668,7 +1668,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
        return 0;
 }
 
        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;
 
 {
        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);
                        }
                }
                                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) {
                        tip= RNA_property_ui_description(prop);
 
                if(min == max || a1 == -1 || a2 == -1) {
index 55ae6af750f7938f1a7d707c41d26fbc571fd41c..531c9dbf79953add3a85625e0a884e9ecba47872 100644 (file)
@@ -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)))
                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) {
                }
                /* handle menu */
                else if(event->type == RIGHTMOUSE && event->val == KM_PRESS) {
index 6cca689d1153207422d651f66663d3cbcff97d25..e95b544d0c0251fc50789f4f2fd3cb0be8571859 100644 (file)
@@ -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 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);
 
 
 extern void ui_set_but_soft_range(uiBut *but, double value);
 
index 624f06db3c131622899a110c3dad269b8a9d306e..8b20406e03681b3eeed06f119acfce431be5e12a 100644 (file)
@@ -370,6 +370,27 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                        data->color[data->totline]= 0xFFFFFF;
                        data->totline++;
                }
                        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)) {
        }
        
        if(but->tip && strlen(but->tip)) {