no functional changes.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 24 Jan 2011 02:56:23 +0000 (02:56 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 24 Jan 2011 02:56:23 +0000 (02:56 +0000)
- remove unneeded casts to (char*) in interface code.
- replace strcmp(.., "") with checks on the first char of the string.

source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_utils.c

index 43919617047abb0c80ba50e1ce079123e4e80bff..52e9ae6894e7dd7f6ac08049d6360d1098652a71 100644 (file)
@@ -1703,7 +1703,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
        }
        else if(but->type == IDPOIN) {
                /* ID pointer */
-               but->idpoin_func(C, (char*)str, but->idpoin_idpp);
+               but->idpoin_func(C, str, but->idpoin_idpp);
                return 1;
        }
        else if(but->type == TEX) {
@@ -2574,18 +2574,18 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
                                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) {
-                                               str= (char*)item[i].name;
+                                               str= item[i].name;
                                                icon= item[i].icon;
                                        }
                                }
 
                                if(!str)
-                                       str= (char*)RNA_property_ui_name(prop);
+                                       str= RNA_property_ui_name(prop);
                                if(free)
                                        MEM_freeN(item);
                        }
                        else {
-                               str= (char*)RNA_property_ui_name(prop);
+                               str= RNA_property_ui_name(prop);
                                icon= RNA_property_ui_icon(prop);
                        }
                }
@@ -2600,7 +2600,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
                                for(i=0; i<totitem; i++) {
                                        if(item[i].identifier[0] && item[i].value == (int)max) {
                                                if(item[i].description[0])
-                                                       tip= (char*)item[i].description;
+                                                       tip= item[i].description;
                                                break;
                                        }
                                }
@@ -2611,7 +2611,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
                }
                
                if(!tip)
-                       tip= (char*)RNA_property_ui_description(prop);
+                       tip= RNA_property_ui_description(prop);
 
                if(min == max || a1 == -1 || a2 == -1) {
                        if(proptype == PROP_INT) {
@@ -2654,7 +2654,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
        }
        else {
                printf("ui_def_but_rna: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
-               str= (char*)propname;
+               str= propname;
        }
 
        /* now create button */
index d49e786626838e75b87b6dcc7fba4fdd0b1cd644..222cce15f6fe1b17b968fae56f21864e55bbda58 100644 (file)
@@ -4115,7 +4115,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
        button_timers_tooltip_remove(C, but);
 
        if(but->rnaprop)
-               name= (char*)RNA_property_ui_name(but->rnaprop);
+               name= RNA_property_ui_name(but->rnaprop);
        else if (but->optype)
                name= but->optype->name;
        else
index d67946752daff735cc612fdaa4eaa899fc830a70..f6fc5364b813d657391f636cf43653b9f8044985 100644 (file)
@@ -345,7 +345,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
        uiBlockSetCurLayout(block, sub);
 
        /* create label */
-       if(strcmp(name, "") != 0)
+       if(name[0])
                uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
 
        /* create buttons */
@@ -464,12 +464,12 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt
                if(!item[a].identifier[0])
                        continue;
 
-               name= (!uiname || uiname[0])? (char*)item[a].name: "";
+               name= (!uiname || uiname[0])? item[a].name: "";
                icon= item[a].icon;
                value= item[a].value;
                itemw= ui_text_icon_width(block->curlayout, name, icon, 0);
 
-               if(icon && strcmp(name, "") != 0 && !icon_only)
+               if(icon && name[0] && !icon_only)
                        but= uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
                else if(icon)
                        but= uiDefIconButR(block, ROW, 0, icon, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
@@ -508,7 +508,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
        sub= uiLayoutRow(layout, 0);
        uiBlockSetCurLayout(block, sub);
 
-       if(strcmp(name, "") != 0) {
+       if(name[0]) {
                /* XXX UI_GetStringWidth is not accurate
                labelw= UI_GetStringWidth(name);
                CLAMP(labelw, w/4, 3*w/4);*/
@@ -596,7 +596,7 @@ static void ui_item_disabled(uiLayout *layout, const char *name)
 
        w= ui_text_icon_width(layout, name, 0, 0);
 
-       but= uiDefBut(block, LABEL, 0, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+       but= uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
        but->flag |= UI_BUT_DISABLED;
        but->lock = 1;
        but->lockstr = "";
@@ -628,12 +628,12 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, i
        if (flag & UI_ITEM_R_NO_BG)
                uiBlockSetEmboss(block, UI_EMBOSSN);
 
-       if(icon && strcmp(name, "") != 0)
-               but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL);
+       if(icon && name[0])
+               but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL);
        else if(icon)
                but= uiDefIconButO(block, BUT, ot->idname, context, icon, 0, 0, w, UI_UNIT_Y, NULL);
        else
-               but= uiDefButO(block, BUT, ot->idname, context, (char*)name, 0, 0, w, UI_UNIT_Y, NULL);
+               but= uiDefButO(block, BUT, ot->idname, context, name, 0, 0, w, UI_UNIT_Y, NULL);
        
        /* text alignment for toolbar buttons */
        if((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon)
@@ -680,7 +680,7 @@ static const char *ui_menu_enumpropname(uiLayout *layout, const char *opname, co
                RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free);
                if(RNA_enum_name(item, retval, &name)) {
                        if(free) MEM_freeN(item);
-                       return (char*)name;
+                       return name;
                }
                
                if(free)
@@ -740,10 +740,10 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
                                        tptr.data= IDP_CopyProperty(properties);
                                        RNA_enum_set(&tptr, propname, item[i].value);
 
-                                       uiItemFullO(column, opname, (char*)item[i].name, item[i].icon, tptr.data, context, flag);
+                                       uiItemFullO(column, opname, item[i].name, item[i].icon, tptr.data, context, flag);
                                }
                                else
-                                       uiItemEnumO(column, opname, (char*)item[i].name, item[i].icon, propname, item[i].value);
+                                       uiItemEnumO(column, opname, item[i].name, item[i].icon, propname, item[i].value);
                        }
                        else {
                                if(item[i].name) {
@@ -753,7 +753,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
                                                block->flag |= UI_BLOCK_NO_FLIP;
                                        }
 
-                                       uiItemL(column, (char*)item[i].name, ICON_NULL);
+                                       uiItemL(column, item[i].name, ICON_NULL);
                                        bt= block->buttons.last;
                                        bt->flag= UI_TEXT_LEFT;
                                }
@@ -889,7 +889,7 @@ static void ui_item_rna_size(uiLayout *layout, const char *name, int icon, Point
                        h += len*UI_UNIT_Y;
        }
        else if(ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
-               if(type == PROP_BOOLEAN && strcmp(name, "") != 0)
+               if(type == PROP_BOOLEAN && name[0])
                        w += UI_UNIT_X/5;
                else if(type == PROP_ENUM)
                        w += UI_UNIT_X/4;
@@ -917,7 +917,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
 
        /* set name and icon */
        if(!name)
-               name= (char*)RNA_property_ui_name(prop);
+               name= RNA_property_ui_name(prop);
        if(icon == ICON_NULL)
                icon= RNA_property_ui_icon(prop);
        
@@ -959,9 +959,9 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
                ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only);
        /* enum item */
        else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) {
-               char *identifier= (char*)RNA_property_identifier(prop);
+               const char *identifier= RNA_property_identifier(prop);
 
-               if(icon && strcmp(name, "") != 0 && !icon_only)
+               if(icon && name[0] && !icon_only)
                        uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
                else if(icon)
                        uiDefIconButR(block, ROW, 0, icon, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
@@ -981,7 +981,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
        }
        /* single button */
        else {
-               but= uiDefAutoButR(block, ptr, prop, index, (char*)name, icon, 0, 0, w, h);
+               but= uiDefAutoButR(block, ptr, prop, index, name, icon, 0, 0, w, h);
 
                if(slider && but->type==NUM)
                        but->type= NUMSLI;
@@ -1046,7 +1046,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr
 
        for(a=0; item[a].identifier; a++) {
                if(item[a].value == ivalue) {
-                       uiItemFullR(layout, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, name ? name : (char*)item[a].name, icon ? icon : item[a].icon);
+                       uiItemFullR(layout, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, name ? name : item[a].name, icon ? icon : item[a].icon);
                        break;
                }
        }
@@ -1078,7 +1078,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
 
                for(i=0; i<totitem; i++) {
                        if(item[i].identifier[0]) {
-                               uiItemEnumR(column, (char*)item[i].name, ICON_NULL, ptr, propname, item[i].value);
+                               uiItemEnumR(column, item[i].name, ICON_NULL, ptr, propname, item[i].value);
                        }
                        else {
                                if(item[i].name) {
@@ -1088,7 +1088,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
                                                block->flag |= UI_BLOCK_NO_FLIP;
                                        }
 
-                                       uiItemL(column, (char*)item[i].name, ICON_NULL);
+                                       uiItemL(column, item[i].name, ICON_NULL);
                                        bt= block->buttons.last;
                                        bt->flag= UI_TEXT_LEFT;
                                }
@@ -1285,7 +1285,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
                icon= RNA_struct_ui_icon(icontype);
        }
        if(!name)
-               name= (char*)RNA_property_ui_name(prop);
+               name= RNA_property_ui_name(prop);
 
        /* create button */
        block= uiLayoutGetBlock(layout);
@@ -1330,11 +1330,11 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre
                w -= 10;
 
        if(name[0] && icon)
-               but= uiDefIconTextMenuBut(block, func, arg, icon, (char*)name, 0, 0, w, h, "");
+               but= uiDefIconTextMenuBut(block, func, arg, icon, name, 0, 0, w, h, "");
        else if(icon)
                but= uiDefIconMenuBut(block, func, arg, icon, 0, 0, w, h, "");
        else
-               but= uiDefMenuBut(block, func, arg, (char*)name, 0, 0, w, h, "");
+               but= uiDefMenuBut(block, func, arg, name, 0, 0, w, h, "");
 
        if(argN) { /* ugly .. */
                but->poin= (char*)but;
@@ -1384,7 +1384,7 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
 
        w= ui_text_icon_width(layout, name, icon, 0);
 
-       if(icon && strcmp(name, "") != 0)
+       if(icon && name[0])
                but= uiDefIconTextBut(block, LABEL, 0, icon, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
        else if(icon)
                but= uiDefIconBut(block, LABEL, 0, icon, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
@@ -1426,12 +1426,12 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval)
 
        w= ui_text_icon_width(layout, name, icon, 0);
 
-       if(icon && strcmp(name, "") != 0)
-               uiDefIconTextButF(block, BUTM, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, "");
+       if(icon && name[0])
+               uiDefIconTextButF(block, BUTM, 0, icon, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, "");
        else if(icon)
                uiDefIconButF(block, BUTM, 0, icon, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, "");
        else
-               uiDefButF(block, BUTM, 0, (char*)name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, "");
+               uiDefButF(block, BUTM, 0, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, "");
 }
 
 /* separator item */
@@ -1510,7 +1510,7 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propn
        }
 
        if(!name)
-               name= (char*)RNA_property_ui_name(prop);
+               name= RNA_property_ui_name(prop);
        if(layout->root->type == UI_LAYOUT_MENU && !icon)
                icon= ICON_BLANK1;
 
index 4b855b88ecebb84d53b34eb024474372b4f5e324..e8a383dbe1508865550f18ba2a41598f4657b8b3 100644 (file)
@@ -2231,7 +2231,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
                        uiDefIconTextBut(pup->block, LABEL, 0, icon, titlestr, 0, 0, 200, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
                }
                else {
-                       but= uiDefBut(pup->block, LABEL, 0, (char*)title, 0, 0, 200, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
+                       but= uiDefBut(pup->block, LABEL, 0, title, 0, 0, 200, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
                        but->flag= UI_TEXT_LEFT;
                }
        }
index 9a6a54bb8ef9ce6ccd3d5fddf37ffc56b1ee8769..842dc40a39f217ef8aacc4d2a2f8ffa4f00cdc8c 100644 (file)
@@ -82,7 +82,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
                                but= uiDefButR(block, NUM, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
                        break;
                case PROP_ENUM:
-                       if(icon && name && strcmp(name, "") == 0)
+                       if(icon && name && name[0] == '\0')
                                but= uiDefIconButR(block, MENU, 0, icon, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
                        else if(icon)
                                but= uiDefIconTextButR(block, MENU, 0, icon, NULL, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
@@ -90,7 +90,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
                                but= uiDefButR(block, MENU, 0, NULL, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
                        break;
                case PROP_STRING:
-                       if(icon && name && strcmp(name, "") == 0)
+                       if(icon && name && name[0] == '\0')
                                but= uiDefIconButR(block, TEX, 0, icon, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
                        else if(icon)
                                but= uiDefIconTextButR(block, TEX, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);