style cleanup: follow style guide for formatting of if/for/while loops, and else...
[blender.git] / source / blender / editors / interface / interface_handlers.c
index de5f12d597e94257fefd4d9f20ea91162370d603..21c3f4ca03832993a462057dda97c64c0ee4943c 100644 (file)
@@ -212,18 +212,18 @@ static int ui_but_editable(uiBut *but)
 
 static uiBut *ui_but_prev(uiBut *but)
 {
-       while(but->prev) {
+       while (but->prev) {
                but= but->prev;
-               if(!ui_but_editable(but)) return but;
+               if (!ui_but_editable(but)) return but;
        }
        return NULL;
 }
 
 static uiBut *ui_but_next(uiBut *but)
 {
-       while(but->next) {
+       while (but->next) {
                but= but->next;
-               if(!ui_but_editable(but)) return but;
+               if (!ui_but_editable(but)) return but;
        }
        return NULL;
 }
@@ -233,8 +233,8 @@ static uiBut *ui_but_first(uiBlock *block)
        uiBut *but;
        
        but= block->buttons.first;
-       while(but) {
-               if(!ui_but_editable(but)) return but;
+       while (but) {
+               if (!ui_but_editable(but)) return but;
                but= but->next;
        }
        return NULL;
@@ -245,8 +245,8 @@ static uiBut *ui_but_last(uiBlock *block)
        uiBut *but;
        
        but= block->buttons.last;
-       while(but) {
-               if(!ui_but_editable(but)) return but;
+       while (but) {
+               if (!ui_but_editable(but)) return but;
                but= but->prev;
        }
        return NULL;
@@ -254,8 +254,8 @@ static uiBut *ui_but_last(uiBlock *block)
 
 static int ui_is_a_warp_but(uiBut *but)
 {
-       if(U.uiflag & USER_CONTINUOUS_MOUSE)
-               if(ELEM4(but->type, NUM, NUMABS, HSVCIRCLE, TRACKPREVIEW))
+       if (U.uiflag & USER_CONTINUOUS_MOUSE)
+               if (ELEM4(but->type, NUM, NUMABS, HSVCIRCLE, TRACKPREVIEW))
                        return TRUE;
 
        return FALSE;
@@ -286,10 +286,10 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
         * handling is done, i.e. menus are closed, in order to avoid conflicts
         * with these functions removing the buttons we are working with */
 
-       if(but->func || but->funcN || block->handle_func || but->rename_func || (but->type == BUTM && block->butm_func) || but->optype || but->rnaprop) {
+       if (but->func || but->funcN || block->handle_func || but->rename_func || (but->type == BUTM && block->butm_func) || but->optype || but->rnaprop) {
                after= MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
 
-               if(but->func && ELEM(but, but->func_arg1, but->func_arg2)) {
+               if (but->func && ELEM(but, but->func_arg1, but->func_arg2)) {
                        /* exception, this will crash due to removed button otherwise */
                        but->func(C, but->func_arg1, but->func_arg2);
                }
@@ -311,7 +311,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
                after->handle_func_arg= block->handle_func_arg;
                after->retval= but->retval;
 
-               if(but->type == BUTM) {
+               if (but->type == BUTM) {
                        after->butm_func= block->butm_func;
                        after->butm_func_arg= block->butm_func_arg;
                        after->a2= but->a2;
@@ -324,7 +324,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
                after->rnapoin= but->rnapoin;
                after->rnaprop= but->rnaprop;
 
-               if(but->context)
+               if (but->context)
                        after->context= CTX_store_copy(but->context);
 
                but->optype= NULL;
@@ -340,17 +340,17 @@ static void ui_apply_autokey_undo(bContext *C, uiBut *but)
        Scene *scene= CTX_data_scene(C);
        uiAfterFunc *after;
 
-       if(but->flag & UI_BUT_UNDO) {
+       if (but->flag & UI_BUT_UNDO) {
                const char *str= NULL;
 
                /* define which string to use for undo */
                if ELEM(but->type, LINK, INLINK) str= "Add button link";
                else if ELEM(but->type, MENU, ICONTEXTROW) str= but->drawstr;
-               else if(but->drawstr[0]) str= but->drawstr;
+               else if (but->drawstr[0]) str= but->drawstr;
                else str= but->tip;
 
                /* fallback, else we don't get an undo! */
-               if(str == NULL || str[0] == '\0') {
+               if (str == NULL || str[0] == '\0') {
                        str= "Unknown Action";
                }
 
@@ -374,51 +374,51 @@ static void ui_apply_but_funcs_after(bContext *C)
        funcs= UIAfterFuncs;
        UIAfterFuncs.first= UIAfterFuncs.last= NULL;
 
-       for(afterf=funcs.first; afterf; afterf=after.next) {
+       for (afterf=funcs.first; afterf; afterf=after.next) {
                after= *afterf; /* copy to avoid memleak on exit() */
                BLI_freelinkN(&funcs, afterf);
 
-               if(after.context)
+               if (after.context)
                        CTX_store_set(C, after.context);
 
-               if(after.opptr) {
+               if (after.opptr) {
                        /* free in advance to avoid leak on exit */
                        opptr= *after.opptr,
                        MEM_freeN(after.opptr);
                }
 
-               if(after.optype)
+               if (after.optype)
                        WM_operator_name_call(C, after.optype->idname, after.opcontext, (after.opptr)? &opptr: NULL);
 
-               if(after.opptr)
+               if (after.opptr)
                        WM_operator_properties_free(&opptr);
 
-               if(after.rnapoin.data)
+               if (after.rnapoin.data)
                        RNA_property_update(C, &after.rnapoin, after.rnaprop);
 
-               if(after.context) {
+               if (after.context) {
                        CTX_store_set(C, NULL);
                        CTX_store_free(after.context);
                }
 
-               if(after.func)
+               if (after.func)
                        after.func(C, after.func_arg1, after.func_arg2);
-               if(after.funcN)
+               if (after.funcN)
                        after.funcN(C, after.func_argN, after.func_arg2);
-               if(after.func_argN)
+               if (after.func_argN)
                        MEM_freeN(after.func_argN);
                
-               if(after.handle_func)
+               if (after.handle_func)
                        after.handle_func(C, after.handle_func_arg, after.retval);
-               if(after.butm_func)
+               if (after.butm_func)
                        after.butm_func(C, after.butm_func_arg, after.a2);
                
-               if(after.rename_func)
+               if (after.rename_func)
                        after.rename_func(C, after.rename_arg1, after.rename_orig);
-               if(after.rename_orig)
+               if (after.rename_orig)
                        MEM_freeN(after.rename_orig);
                
-               if(after.undostr[0])
+               if (after.undostr[0])
                        ED_undo_push(C, after.undostr);
        }
 }
@@ -442,7 +442,7 @@ static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data)
 
 static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data)
 {
-       if(ELEM3(but->type, MENU, ICONROW, ICONTEXTROW))
+       if (ELEM3(but->type, MENU, ICONROW, ICONTEXTROW))
                ui_set_but_val(but, data->value);
 
        ui_check_but(but);
@@ -457,50 +457,50 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data)
        int w, lvalue, push;
        
        /* local hack... */
-       if(but->type==BUT_TOGDUAL && data->togdual) {
-               if(but->pointype==SHO)
+       if (but->type==BUT_TOGDUAL && data->togdual) {
+               if (but->pointype==SHO)
                        but->poin += 2;
-               else if(but->pointype==INT)
+               else if (but->pointype==INT)
                        but->poin += 4;
        }
        
        value= ui_get_but_val(but);
        lvalue= (int)value;
        
-       if(but->bit) {
+       if (but->bit) {
                w= BTST(lvalue, but->bitnr);
-               if(w) lvalue = BCLR(lvalue, but->bitnr);
+               if (w) lvalue = BCLR(lvalue, but->bitnr);
                else lvalue = BSET(lvalue, but->bitnr);
                
-               if(but->type==TOGR) {
-                       if(!data->togonly) {
+               if (but->type==TOGR) {
+                       if (!data->togonly) {
                                lvalue= 1<<(but->bitnr);
        
                                ui_set_but_val(but, (double)lvalue);
                        }
                        else {
-                               if(lvalue==0) lvalue= 1<<(but->bitnr);
+                               if (lvalue==0) lvalue= 1<<(but->bitnr);
                        }
                }
                
                ui_set_but_val(but, (double)lvalue);
-               if(but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but);
+               if (but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but);
        }
        else {
                
-               if(value==0.0) push= 1; 
+               if (value==0.0) push= 1; 
                else push= 0;
                
-               if(ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) push= !push;
+               if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) push= !push;
                ui_set_but_val(but, (double)push);
-               if(but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but);                
+               if (but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but);               
        }
        
        /* end local hack... */
-       if(but->type==BUT_TOGDUAL && data->togdual) {
-               if(but->pointype==SHO)
+       if (but->type==BUT_TOGDUAL && data->togdual) {
+               if (but->pointype==SHO)
                        but->poin -= 2;
-               else if(but->pointype==INT)
+               else if (but->pointype==INT)
                        but->poin -= 4;
        }
        
@@ -517,8 +517,8 @@ static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
        ui_set_but_val(but, but->hardmax);
        
        /* states of other row buttons */
-       for(bt= block->buttons.first; bt; bt= bt->next)
-               if(bt!=but && bt->poin==but->poin && ELEM(bt->type, ROW, LISTROW))
+       for (bt= block->buttons.first; bt; bt= bt->next)
+               if (bt!=but && bt->poin==but->poin && ELEM(bt->type, ROW, LISTROW))
                        ui_check_but(bt);
        
        ui_apply_but_func(C, but);
@@ -529,7 +529,7 @@ static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
 
 static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
 {
-       if(!data->str)
+       if (!data->str)
                return;
 
        ui_set_but_string(C, but, data->str);
@@ -548,8 +548,8 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
 
 static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
 {
-       if(data->str) {
-               if(ui_set_but_string(C, but, data->str)) {
+       if (data->str) {
+               if (ui_set_but_string(C, but, data->str)) {
                        data->value= ui_get_but_val(but);
                }
                else {
@@ -569,27 +569,29 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
 
 static void ui_apply_but_TOG3(bContext *C, uiBut *but, uiHandleButtonData *data)
 { 
-       if(but->pointype==SHO ) {
+       if (but->pointype==SHO ) {
                short *sp= (short *)but->poin;
                
-               if( BTST(sp[1], but->bitnr)) {
+               if ( BTST(sp[1], but->bitnr)) {
                        sp[1]= BCLR(sp[1], but->bitnr);
                        sp[0]= BCLR(sp[0], but->bitnr);
                }
-               else if( BTST(sp[0], but->bitnr)) {
+               else if ( BTST(sp[0], but->bitnr)) {
                        sp[1]= BSET(sp[1], but->bitnr);
-               } else {
+               }
+               else {
                        sp[0]= BSET(sp[0], but->bitnr);
                }
        }
        else {
-               if( BTST(*(but->poin+2), but->bitnr)) {
+               if ( BTST(*(but->poin+2), but->bitnr)) {
                        *(but->poin+2)= BCLR(*(but->poin+2), but->bitnr);
                        *(but->poin)= BCLR(*(but->poin), but->bitnr);
                }
-               else if( BTST(*(but->poin), but->bitnr)) {
+               else if ( BTST(*(but->poin), but->bitnr)) {
                        *(but->poin+2)= BSET(*(but->poin+2), but->bitnr);
-               } else {
+               }
+               else {
                        *(but->poin)= BSET(*(but->poin), but->bitnr);
                }
        }
@@ -654,8 +656,8 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event)
        rect.xmin = but->x1; rect.xmax = but->x2;
        rect.ymin = but->y1; rect.ymax = but->y2;
        
-       if(but->imb); /* use button size itself */
-       else if(but->flag & UI_ICON_LEFT) {
+       if (but->imb); /* use button size itself */
+       else if (but->flag & UI_ICON_LEFT) {
                rect.xmax = rect.xmin + (rect.ymax-rect.ymin);
        }
        else {
@@ -672,14 +674,14 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data,
        /* prevent other WM gestures to start while we try to drag */
        WM_gestures_remove(C);
 
-       if( ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold ) {
+       if ( ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold ) {
                wmDrag *drag;
                
                button_activate_state(C, but, BUTTON_STATE_EXIT);
                data->cancel= 1;
                
                drag= WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but));
-               if(but->imb)
+               if (but->imb)
                        WM_event_drag_image(drag, but->imb, but->imb_scale, but->x2-but->x1, but->y2-but->y1);
                return 1;
        }
@@ -697,31 +699,31 @@ static void ui_delete_active_linkline(uiBlock *block)
        int a, b;
        
        but= block->buttons.first;
-       while(but) {
-               if(but->type==LINK && but->link) {
+       while (but) {
+               if (but->type==LINK && but->link) {
                        line= but->link->lines.first;
-                       while(line) {
+                       while (line) {
                                
                                nline= line->next;
                                
-                               if(line->flag & UI_SELECT) {
+                               if (line->flag & UI_SELECT) {
                                        BLI_remlink(&but->link->lines, line);
                                        
                                        link= line->from->link;
                                        
                                        /* are there more pointers allowed? */
-                                       if(link->ppoin) {
+                                       if (link->ppoin) {
                                                
-                                               if(*(link->totlink)==1) {
+                                               if (*(link->totlink)==1) {
                                                        *(link->totlink)= 0;
                                                        MEM_freeN(*(link->ppoin));
                                                        *(link->ppoin)= NULL;
                                                }
                                                else {
                                                        b= 0;
-                                                       for(a=0; a< (*(link->totlink)); a++) {
+                                                       for (a=0; a< (*(link->totlink)); a++) {
                                                                
-                                                               if( (*(link->ppoin))[a] != line->to->poin ) {
+                                                               if ( (*(link->ppoin))[a] != line->to->poin ) {
                                                                        (*(link->ppoin))[b]= (*(link->ppoin))[a];
                                                                        b++;
                                                                }
@@ -749,10 +751,10 @@ static uiLinkLine *ui_is_a_link(uiBut *from, uiBut *to)
        uiLink *link;
        
        link= from->link;
-       if(link) {
+       if (link) {
                line= link->lines.first;
-               while(line) {
-                       if(line->from==from && line->to==to) return line;
+               while (line) {
+                       if (line->from==from && line->to==to) return line;
                        line= line->next;
                }
        }
@@ -772,7 +774,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
 
        uiLink *link= from->link;
 
-       if(link->ppoin)
+       if (link->ppoin)
                sens_from_links= (bController ***)(link->ppoin);
        else return;
 
@@ -790,7 +792,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
                if (ob) break;
        } CTX_DATA_END;
 
-       if(!ob) return;
+       if (!ob) return;
 
        /* (2) check if the sensor and the actuator are from the same object */
        for (act_iter= ob->actuators.first; act_iter; act_iter= (bActuator *)act_iter->next) {
@@ -799,7 +801,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
        }
 
        // only works if the sensor and the actuator are from the same object
-       if(!act_iter) return;
+       if (!act_iter) return;
 
        /* (3) add a new controller */
        if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED) {
@@ -831,7 +833,7 @@ static void ui_add_link(bContext *C, uiBut *from, uiBut *to)
        void **oldppoin;
        int a;
        
-       if( (line= ui_is_a_link(from, to)) ) {
+       if ( (line= ui_is_a_link(from, to)) ) {
                line->flag |= UI_SELECT;
                ui_delete_active_linkline(from->block);
                return;
@@ -841,13 +843,13 @@ static void ui_add_link(bContext *C, uiBut *from, uiBut *to)
                return;
        }
        else if (from->type==LINK && to->type==INLINK) {
-               if( from->link->tocode != (int)to->hardmin ) {
+               if ( from->link->tocode != (int)to->hardmin ) {
                        ui_add_smart_controller(C, from, to);
                        return;
                }
        }
-       else if(from->type==INLINK && to->type==LINK) {
-               if( to->link->tocode == (int)from->hardmin ) {
+       else if (from->type==INLINK && to->type==LINK) {
+               if ( to->link->tocode == (int)from->hardmin ) {
                        return;
                }
        }
@@ -855,18 +857,18 @@ static void ui_add_link(bContext *C, uiBut *from, uiBut *to)
        link= from->link;
        
        /* are there more pointers allowed? */
-       if(link->ppoin) {
+       if (link->ppoin) {
                oldppoin= *(link->ppoin);
                
                (*(link->totlink))++;
                *(link->ppoin)= MEM_callocN( *(link->totlink)*sizeof(void *), "new link");
                
-               for(a=0; a< (*(link->totlink))-1; a++) {
+               for (a=0; a< (*(link->totlink))-1; a++) {
                        (*(link->ppoin))[a]= oldppoin[a];
                }
                (*(link->ppoin))[a]= to->poin;
                
-               if(oldppoin) MEM_freeN(oldppoin);
+               if (oldppoin) MEM_freeN(oldppoin);
        }
        else {
                *(link->poin)= to->poin;
@@ -880,15 +882,15 @@ static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data)
        ARegion *ar= CTX_wm_region(C);
        uiBut *bt;
        
-       for(bt= but->block->buttons.first; bt; bt= bt->next) {
-               if( ui_mouse_inside_button(ar, bt, but->linkto[0]+ar->winrct.xmin, but->linkto[1]+ar->winrct.ymin) )
+       for (bt= but->block->buttons.first; bt; bt= bt->next) {
+               if ( ui_mouse_inside_button(ar, bt, but->linkto[0]+ar->winrct.xmin, but->linkto[1]+ar->winrct.ymin) )
                        break;
        }
-       if(bt && bt!=but) {
+       if (bt && bt!=but) {
                if (!ELEM(bt->type, LINK, INLINK) || !ELEM(but->type, LINK, INLINK))
                        return;
                
-               if(but->type==LINK) ui_add_link(C, but, bt);
+               if (but->type==LINK) ui_add_link(C, but, bt);
                else ui_add_link(C, bt, but);
 
                ui_apply_but_func(C, but);
@@ -938,11 +940,11 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
 
        /* if we cancel and have not applied yet, there is nothing to do,
         * otherwise we have to restore the original value again */
-       if(data->cancel) {
-               if(!data->applied)
+       if (data->cancel) {
+               if (!data->applied)
                        return;
 
-               if(data->str) MEM_freeN(data->str);
+               if (data->str) MEM_freeN(data->str);
                data->str= data->origstr;
                data->origstr= NULL;
                data->value= data->origvalue;
@@ -953,9 +955,9 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
        else {
                /* we avoid applying interactive edits a second time
                 * at the end with the appliedinteractive flag */
-               if(interactive)
+               if (interactive)
                        data->appliedinteractive= 1;
-               else if(data->appliedinteractive)
+               else if (data->appliedinteractive)
                        return;
        }
 
@@ -1076,13 +1078,13 @@ static void ui_but_drop(bContext *C, wmEvent *event, uiBut *but, uiHandleButtonD
        wmDrag *wmd;
        ListBase *drags= event->customdata; /* drop event type has listbase customdata by default */
        
-       for(wmd= drags->first; wmd; wmd= wmd->next) {
-               if(wmd->type==WM_DRAG_ID) {
+       for (wmd= drags->first; wmd; wmd= wmd->next) {
+               if (wmd->type==WM_DRAG_ID) {
                        /* align these types with UI_but_active_drop_name */
-                       if(ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
+                       if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
                                ID *id= (ID *)wmd->poin;
                                
-                               if(but->poin==NULL && but->rnapoin.data==NULL) {}
+                               if (but->poin==NULL && but->rnapoin.data==NULL) {}
                                button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                                BLI_strncpy(data->str, id->name+2, data->maxlen);
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -1100,14 +1102,14 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
        static ColorBand but_copypaste_coba = {0};
        char buf[UI_MAX_DRAW_STR+1]= {0};
 
-       if(mode=='v' && but->lock)
+       if (mode=='v' && but->lock)
                return;
 
-       if(mode=='v') {
+       if (mode=='v') {
                /* extract first line from clipboard in case of multi-line copies */
                char *p, *pbuf= WM_clipboard_text_get(0);
                p= pbuf;
-               if(p) {
+               if (p) {
                        int i = 0;
                        while (*p && *p!='\r' && *p!='\n' && i<UI_MAX_DRAW_STR) {
                                buf[i++]=*p;
@@ -1121,8 +1123,8 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
        /* numeric value */
        if ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI) {
                
-               if(but->poin==NULL && but->rnapoin.data==NULL);
-               else if(mode=='c') {
+               if (but->poin==NULL && but->rnapoin.data==NULL);
+               else if (mode=='c') {
                        ui_get_but_string(but, buf, sizeof(buf));
                        WM_clipboard_text_set(buf, 0);
                }
@@ -1139,11 +1141,11 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
        }
 
        /* RGB triple */
-       else if(but->type==COL) {
+       else if (but->type==COL) {
                float rgb[3];
                
-               if(but->poin==NULL && but->rnapoin.data==NULL);
-               else if(mode=='c') {
+               if (but->poin==NULL && but->rnapoin.data==NULL);
+               else if (mode=='c') {
 
                        ui_get_but_vectorf(but, rgb);
                        BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f]", rgb[0], rgb[1], rgb[2]);
@@ -1160,11 +1162,11 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
        }
 
        /* text/string and ID data */
-       else if(ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
+       else if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
                uiHandleButtonData *active_data= but->active;
 
-               if(but->poin==NULL && but->rnapoin.data==NULL);
-               else if(mode=='c') {
+               if (but->poin==NULL && but->rnapoin.data==NULL);
+               else if (mode=='c') {
                        button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                        BLI_strncpy(buf, active_data->str, UI_MAX_DRAW_STR);
                        WM_clipboard_text_set(active_data->str, 0);
@@ -1174,10 +1176,10 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
                else {
                        button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
 
-                       if(ui_is_but_utf8(but)) BLI_strncpy_utf8(active_data->str, buf, active_data->maxlen);
+                       if (ui_is_but_utf8(but)) BLI_strncpy_utf8(active_data->str, buf, active_data->maxlen);
                        else                    BLI_strncpy(active_data->str, buf, active_data->maxlen);
 
-                       if(but->type == SEARCH_MENU) {
+                       if (but->type == SEARCH_MENU) {
                                /* else uiSearchboxData.active member is not updated [#26856] */
                                ui_searchbox_update(C, data->searchbox, but, 1);
                        }
@@ -1185,18 +1187,18 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
                }
        }
        /* colorband (not supported by system clipboard) */
-       else if(but->type==BUT_COLORBAND) {
-               if(mode=='c') {
-                       if(but->poin==NULL)
+       else if (but->type==BUT_COLORBAND) {
+               if (mode=='c') {
+                       if (but->poin==NULL)
                                return;
 
                        memcpy(&but_copypaste_coba, but->poin, sizeof(ColorBand));
                }
                else {
-                       if(but_copypaste_coba.tot==0)
+                       if (but_copypaste_coba.tot==0)
                                return;
 
-                       if(!but->poin)
+                       if (!but->poin)
                                but->poin= MEM_callocN(sizeof(ColorBand), "colorband");
 
                        button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
@@ -1206,7 +1208,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
        }
        /* operator button (any type) */
        else if (but->optype) {
-               if(mode=='c') {
+               if (mode=='c') {
                        PointerRNA *opptr;
                        char *str;
                        opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
@@ -1228,7 +1230,7 @@ static int ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data)
        char *str= data->str;
        int len= strlen(str);
        int change= 0;
-       if(but->selsta != but->selend && len) {
+       if (but->selsta != but->selend && len) {
                memmove(str + but->selsta, str + but->selend, (len - but->selend) + 1);
                change= 1;
        }
@@ -1255,9 +1257,9 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
        BLI_strncpy(origstr, but->drawstr, data->maxlen);
        
        /* XXX solve generic */
-       if(but->type==NUM || but->type==NUMSLI)
+       if (but->type==NUM || but->type==NUMSLI)
                startx += (int)(0.5f*(but->y2 - but->y1));
-       else if(ELEM(but->type, TEX, SEARCH_MENU)) {
+       else if (ELEM(but->type, TEX, SEARCH_MENU)) {
                startx += 5;
                if (but->flag & UI_HAS_ICON)
                        startx += UI_DPI_ICON_SIZE;
@@ -1319,7 +1321,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
                        }
                }
                but->pos += but->ofs;
-               if(but->pos<0) but->pos= 0;
+               if (but->pos<0) but->pos= 0;
        }
        
        if (fstyle->kerning == 1)
@@ -1353,7 +1355,7 @@ static int ui_textedit_type_buf(uiBut *but, uiHandleButtonData *data,
        str= data->str;
        len= strlen(str);
 
-       if(len-(but->selend - but->selsta)+1 <= data->maxlen) {
+       if (len-(but->selend - but->selsta)+1 <= data->maxlen) {
                int step= utf8_buf_len;
 
                /* type over the current selection */
@@ -1362,7 +1364,7 @@ static int ui_textedit_type_buf(uiBut *but, uiHandleButtonData *data,
                        len= strlen(str);
                }
 
-               if(len + step < data->maxlen) {
+               if (len + step < data->maxlen) {
                        memmove(&str[but->pos + step], &str[but->pos], (len + 1) - but->pos);
                        memcpy(&str[but->pos], utf8_buf, step * sizeof(char));
                        but->pos += step;
@@ -1417,11 +1419,11 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJump
                BLI_str_cursor_step_utf8(str, len, &pos_i, direction, jump);
                but->pos = pos_i;
 
-               if(select) {
+               if (select) {
                        /* existing selection */
                        if (has_sel) {
 
-                               if(data->selextend == 0) {
+                               if (data->selextend == 0) {
                                        data->selextend= EXTEND_RIGHT;
                                }
 
@@ -1472,11 +1474,11 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio
        int changed= 0;
 
        if (jump == STRCUR_JUMP_ALL) {
-               if(len) changed=1;
+               if (len) changed=1;
                str[0]= '\0';
                but->pos= 0;
        }
-       else if(direction) { /* delete */
+       else if (direction) { /* delete */
                if ((but->selend - but->selsta) > 0) {
                        changed= ui_textedit_delete_selection(but, data);
                }
@@ -1494,7 +1496,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio
                        if ((but->selend - but->selsta) > 0) {
                                changed= ui_textedit_delete_selection(but, data);
                        }
-                       else if(but->pos>0) {
+                       else if (but->pos>0) {
                                int pos = but->pos;
                                int step;
 
@@ -1517,7 +1519,7 @@ static int ui_textedit_autocomplete(bContext *C, uiBut *but, uiHandleButtonData
 
        str= data->str;
 
-       if(data->searchbox)
+       if (data->searchbox)
                ui_searchbox_autocomplete(C, data->searchbox, but, data->str);
        else
                but->autocomplete_func(C, str, but->autofunc_arg);
@@ -1542,7 +1544,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
                /* extract the first line from the clipboard */
                p = pbuf= WM_clipboard_text_get(0);
 
-               if(p && p[0]) {
+               if (p && p[0]) {
                        unsigned int y;
                        i= 0;
                        while (*p && *p!='\r' && *p!='\n' && i<UI_MAX_DRAW_STR-1) {
@@ -1560,8 +1562,8 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
                        for (y=0; y<strlen(buf); y++)
                        {
                                /* add contents of buffer */
-                               if(len+1 < data->maxlen) {
-                                       for(x= data->maxlen; x>but->pos; x--)
+                               if (len+1 < data->maxlen) {
+                                       for (x= data->maxlen; x>but->pos; x--)
                                                str[x]= str[x-1];
                                        str[but->pos]= buf[y];
                                        but->pos++; 
@@ -1580,7 +1582,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
        /* cut & copy */
        else if (copy || cut) {
                /* copy the contents to the copypaste buffer */
-               for(x= but->selsta; x <= but->selend; x++) {
+               for (x= but->selsta; x <= but->selend; x++) {
                        if (x==but->selend)
                                buf[x] = '\0';
                        else
@@ -1590,8 +1592,8 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
                WM_clipboard_text_set(buf, 0);
                
                /* for cut only, delete the selection afterwards */
-               if(cut)
-                       if((but->selend - but->selsta) > 0)
+               if (cut)
+                       if ((but->selend - but->selsta) > 0)
                                changed= ui_textedit_delete_selection(but, data);
        } 
 
@@ -1602,7 +1604,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
 {
        int len;
 
-       if(data->str) {
+       if (data->str) {
                MEM_freeN(data->str);
                data->str= NULL;
        }
@@ -1612,7 +1614,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
        data->str= MEM_callocN(sizeof(char)*data->maxlen + 1, "textedit str");
        ui_get_but_string(but, data->str, data->maxlen);
 
-       if(ELEM3(but->type, NUM, NUMABS, NUMSLI)) {
+       if (ELEM3(but->type, NUM, NUMABS, NUMSLI)) {
                ui_convert_to_unit_alt_name(but, data->str, data->maxlen);
        }
 
@@ -1630,7 +1632,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
        but->selend = len;
 
        /* optional searchbox */
-       if(but->type==SEARCH_MENU) {
+       if (but->type==SEARCH_MENU) {
                data->searchbox= ui_searchbox_create(C, data->region, but);
                ui_searchbox_update(C, data->searchbox, but, 1); /* 1= reset */
        }
@@ -1642,18 +1644,18 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
 
 static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
 {
-       if(but) {
-               if(ui_is_but_utf8(but)) {
+       if (but) {
+               if (ui_is_but_utf8(but)) {
                        int strip= BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr));
                        /* not a file?, strip non utf-8 chars */
-                       if(strip) {
+                       if (strip) {
                                /* wont happen often so isn't that annoying to keep it here for a while */
                                printf("%s: invalid utf8 - stripped chars %d\n", __func__, strip);
                        }
                }
                
-               if(data->searchbox) {
-                       if(data->cancel==0)
+               if (data->searchbox) {
+                       if (data->cancel==0)
                                ui_searchbox_apply(but, data->searchbox);
 
                        ui_searchbox_free(C, data->searchbox);
@@ -1672,21 +1674,21 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
        uiBut *but;
 
        /* label and roundbox can overlap real buttons (backdrops...) */
-       if(ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
+       if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
                return;
 
-       for(but= actbut->next; but; but= but->next) {
-               if(ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
-                       if(!(but->flag & UI_BUT_DISABLED)) {
+       for (but= actbut->next; but; but= but->next) {
+               if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
+                       if (!(but->flag & UI_BUT_DISABLED)) {
                                data->postbut= but;
                                data->posttype= BUTTON_ACTIVATE_TEXT_EDITING;
                                return;
                        }
                }
        }
-       for(but= block->buttons.first; but!=actbut; but= but->next) {
-               if(ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
-                       if(!(but->flag & UI_BUT_DISABLED)) {
+       for (but= block->buttons.first; but!=actbut; but= but->next) {
+               if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
+                       if (!(but->flag & UI_BUT_DISABLED)) {
                                data->postbut= but;
                                data->posttype= BUTTON_ACTIVATE_TEXT_EDITING;
                                return;
@@ -1700,21 +1702,21 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
        uiBut *but;
 
        /* label and roundbox can overlap real buttons (backdrops...) */
-       if(ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
+       if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
                return;
 
-       for(but= actbut->prev; but; but= but->prev) {
-               if(ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
-                       if(!(but->flag & UI_BUT_DISABLED)) {
+       for (but= actbut->prev; but; but= but->prev) {
+               if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
+                       if (!(but->flag & UI_BUT_DISABLED)) {
                                data->postbut= but;
                                data->posttype= BUTTON_ACTIVATE_TEXT_EDITING;
                                return;
                        }
                }
        }
-       for(but= block->buttons.last; but!=actbut; but= but->prev) {
-               if(ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
-                       if(!(but->flag & UI_BUT_DISABLED)) {
+       for (but= block->buttons.last; but!=actbut; but= but->prev) {
+               if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
+                       if (!(but->flag & UI_BUT_DISABLED)) {
                                data->postbut= but;
                                data->posttype= BUTTON_ACTIVATE_TEXT_EDITING;
                                return;
@@ -1732,7 +1734,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                case WHEELUPMOUSE:
                case WHEELDOWNMOUSE:
                case MOUSEMOVE:
-                       if(data->searchbox)
+                       if (data->searchbox)
                                ui_searchbox_event(C, data->searchbox, but, event);
                        
                        break;
@@ -1746,10 +1748,10 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                case LEFTMOUSE: {
                        
                        /* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */
-                       if(data->searchbox)
+                       if (data->searchbox)
                                inbox= ui_searchbox_inside(data->searchbox, event->x, event->y);
 
-                       if(event->val==KM_PRESS) {
+                       if (event->val==KM_PRESS) {
                                mx= event->x;
                                my= event->y;
                                ui_window_to_block(data->region, block, &mx, &my);
@@ -1762,15 +1764,15 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                                        button_activate_state(C, but, BUTTON_STATE_TEXT_SELECTING);
                                        retval= WM_UI_HANDLER_BREAK;
                                }
-                               else if(inbox==0) {
+                               else if (inbox==0) {
                                        /* if searchbox, click outside will cancel */
-                                       if(data->searchbox)
+                                       if (data->searchbox)
                                                data->cancel= data->escapecancel= 1;
                                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                                        retval= WM_UI_HANDLER_BREAK;
                                }
                        }
-                       else if(inbox) {
+                       else if (inbox) {
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                                retval= WM_UI_HANDLER_BREAK;
                        }
@@ -1778,17 +1780,17 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                }
        }
 
-       if(event->val==KM_PRESS) {
+       if (event->val==KM_PRESS) {
                switch (event->type) {
                        case VKEY:
                        case XKEY:
                        case CKEY:
-                               if(event->ctrl || event->oskey) {
-                                       if(event->type == VKEY)
+                               if (event->ctrl || event->oskey) {
+                                       if (event->type == VKEY)
                                                changed= ui_textedit_copypaste(but, data, 1, 0, 0);
-                                       else if(event->type == CKEY)
+                                       else if (event->type == CKEY)
                                                changed= ui_textedit_copypaste(but, data, 0, 1, 0);
-                                       else if(event->type == XKEY)
+                                       else if (event->type == XKEY)
                                                changed= ui_textedit_copypaste(but, data, 0, 0, 1);
 
                                        retval= WM_UI_HANDLER_BREAK;
@@ -1803,7 +1805,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                                retval= WM_UI_HANDLER_BREAK;
                                break;
                        case DOWNARROWKEY:
-                               if(data->searchbox) {
+                               if (data->searchbox) {
                                        ui_searchbox_event(C, data->searchbox, but, event);
                                        break;
                                }
@@ -1813,7 +1815,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                                retval= WM_UI_HANDLER_BREAK;
                                break;
                        case UPARROWKEY:
-                               if(data->searchbox) {
+                               if (data->searchbox) {
                                        ui_searchbox_event(C, data->searchbox, but, event);
                                        break;
                                }
@@ -1839,12 +1841,12 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                                
                        case TABKEY:
                                /* there is a key conflict here, we can't tab with autocomplete */
-                               if(but->autocomplete_func || data->searchbox) {
+                               if (but->autocomplete_func || data->searchbox) {
                                        changed= ui_textedit_autocomplete(C, but, data);
                                        update= 1; /* do live update for tab key */
                                }
                                /* the hotkey here is not well defined, was G.qual so we check all */
-                               else if(event->shift || event->ctrl || event->alt || event->oskey) {
+                               else if (event->shift || event->ctrl || event->alt || event->oskey) {
                                        ui_textedit_prev_but(block, but, data);
                                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                                }
@@ -1856,20 +1858,20 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                                break;
                }
 
-               if((event->ascii || event->utf8_buf[0]) && (retval == WM_UI_HANDLER_CONTINUE)) {
+               if ((event->ascii || event->utf8_buf[0]) && (retval == WM_UI_HANDLER_CONTINUE)) {
                        char ascii = event->ascii;
                        const char *utf8_buf= event->utf8_buf;
 
                        /* exception that's useful for number buttons, some keyboard
                         * numpads have a comma instead of a period */
-                       if(ELEM3(but->type, NUM, NUMABS, NUMSLI)) { /* could use data->min*/
-                               if(event->type == PADPERIOD && ascii == ',') {
+                       if (ELEM3(but->type, NUM, NUMABS, NUMSLI)) { /* could use data->min*/
+                               if (event->type == PADPERIOD && ascii == ',') {
                                        ascii = '.';
                                        utf8_buf= NULL; /* force ascii fallback */
                                }
                        }
 
-                       if(utf8_buf && utf8_buf[0]) {
+                       if (utf8_buf && utf8_buf[0]) {
                                int utf8_buf_len= BLI_str_utf8_size(utf8_buf);
                                /* keep this printf until utf8 is well tested */
                                if (utf8_buf_len != 1) {
@@ -1887,21 +1889,21 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                        
                }
                /* textbutton with magnifier icon: do live update for search button */
-               if(but->icon==ICON_VIEWZOOM)
+               if (but->icon==ICON_VIEWZOOM)
                        update= 1;
        }
 
-       if(changed) {
+       if (changed) {
                /* only update when typing for TAB key */
-               if(update && data->interactive) ui_apply_button(C, block, but, data, 1);
+               if (update && data->interactive) ui_apply_button(C, block, but, data, 1);
                else ui_check_but(but);
                but->changed= TRUE;
                
-               if(data->searchbox)
+               if (data->searchbox)
                        ui_searchbox_update(C, data->searchbox, but, 1); /* 1 = reset */
        }
 
-       if(changed || (retval == WM_UI_HANDLER_BREAK))
+       if (changed || (retval == WM_UI_HANDLER_BREAK))
                ED_region_tag_redraw(data->region);
 }
 
@@ -1920,13 +1922,13 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u
                        break;
                }
                case LEFTMOUSE:
-                       if(event->val == KM_RELEASE)
+                       if (event->val == KM_RELEASE)
                                button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                        retval= WM_UI_HANDLER_BREAK;
                        break;
        }
 
-       if(retval == WM_UI_HANDLER_BREAK) {
+       if (retval == WM_UI_HANDLER_BREAK) {
                ui_check_but(but);
                ED_region_tag_redraw(data->region);
        }
@@ -1936,14 +1938,14 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u
 
 static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
 {
-       if(but->type == BUT_CURVE) {
+       if (but->type == BUT_CURVE) {
                but->editcumap= (CurveMapping*)but->poin;
        }
-       else if(but->type == BUT_COLORBAND) {
+       else if (but->type == BUT_COLORBAND) {
                data->coba= (ColorBand*)but->poin;
                but->editcoba= data->coba;
        }
-       else if(ELEM3(but->type, BUT_NORMAL, HSVCUBE, HSVCIRCLE)) {
+       else if (ELEM3(but->type, BUT_NORMAL, HSVCUBE, HSVCIRCLE)) {
                ui_get_but_vectorf(but, data->origvec);
                copy_v3_v3(data->vec, data->origvec);
                but->editvec= data->vec;
@@ -1984,7 +1986,7 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data)
 
 static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data)
 {
-       if(data->interactive) ui_apply_button(C, block, but, data, 1);
+       if (data->interactive) ui_apply_button(C, block, but, data, 1);
        else ui_check_but(but);
 
        ED_region_tag_redraw(data->region);
@@ -2003,7 +2005,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
        switch(but->type) {
                case BLOCK:
                case PULLDOWN:
-                       if(but->menu_create_func) {
+                       if (but->menu_create_func) {
                                menufunc= but->menu_create_func;
                                arg= but->poin;
                        }
@@ -2013,7 +2015,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
                        }
                        break;
                case MENU:
-                       if(but->menu_create_func) {
+                       if (but->menu_create_func) {
                                menufunc= but->menu_create_func;
                                arg= but->poin;
                        }
@@ -2043,14 +2045,14 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
                        break;
        }
 
-       if(func || handlefunc) {
+       if (func || handlefunc) {
                data->menu= ui_popup_block_create(C, data->region, but, func, handlefunc, arg);
-               if(but->block->handle)
+               if (but->block->handle)
                        data->menu->popup= but->block->handle->popup;
        }
-       else if(menufunc || menustr) {
+       else if (menufunc || menustr) {
                data->menu= ui_popup_menu_create(C, data->region, but, menufunc, arg, menustr);
-               if(but->block->handle)
+               if (but->block->handle)
                        data->menu->popup= but->block->handle->popup;
        }
 
@@ -2060,14 +2062,14 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
 
 static void ui_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data)
 {
-       if(but) {
+       if (but) {
                but->editval= NULL;
                but->editvec= NULL;
 
                but->block->auto_open_last= PIL_check_seconds_timer();
        }
 
-       if(data->menu) {
+       if (data->menu) {
                ui_popup_block_free(C, data->menu);
                data->menu= NULL;
        }
@@ -2077,23 +2079,23 @@ static void ui_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data)
 
 static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
 {
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type == LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type == LEFTMOUSE && event->val==KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE);
                        return WM_UI_HANDLER_BREAK;
                }
-               else if(event->type == LEFTMOUSE && but->block->handle) {
+               else if (event->type == LEFTMOUSE && but->block->handle) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                        return WM_UI_HANDLER_BREAK;
                }
-               else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) {
+               else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_WAIT_FLASH);
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_WAIT_RELEASE) {
-               if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
-                       if(!(but->flag & UI_SELECT))
+       else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
+               if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+                       if (!(but->flag & UI_SELECT))
                                data->cancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                        return WM_UI_HANDLER_BREAK;
@@ -2105,24 +2107,24 @@ static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEv
 
 static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
 {
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
                        but->drawstr[0]= 0;
                        but->modifier_key= 0;
                        button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_WAIT_KEY_EVENT) {
+       else if (data->state == BUTTON_STATE_WAIT_KEY_EVENT) {
                
-               if(event->type == MOUSEMOVE)
+               if (event->type == MOUSEMOVE)
                        return WM_UI_HANDLER_CONTINUE;
                
-               if(event->type == LEFTMOUSE && event->val==KM_PRESS) {
+               if (event->type == LEFTMOUSE && event->val==KM_PRESS) {
                        /* only cancel if click outside the button */
-                       if(ui_mouse_inside_button(but->active->region, but, event->x, event->y) == 0) {
+                       if (ui_mouse_inside_button(but->active->region, but, event->x, event->y) == 0) {
                                /* data->cancel doesnt work, this button opens immediate */
-                               if(but->flag & UI_BUT_IMMEDIATE)
+                               if (but->flag & UI_BUT_IMMEDIATE)
                                        ui_set_but_val(but, 0);
                                else
                                        data->cancel= 1;
@@ -2133,18 +2135,18 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
                
                /* always set */
                but->modifier_key = 0;
-               if(event->shift) but->modifier_key |= KM_SHIFT;
-               if(event->alt)   but->modifier_key |= KM_ALT;
-               if(event->ctrl)  but->modifier_key |= KM_CTRL;
-               if(event->oskey) but->modifier_key |= KM_OSKEY;
+               if (event->shift) but->modifier_key |= KM_SHIFT;
+               if (event->alt)   but->modifier_key |= KM_ALT;
+               if (event->ctrl)  but->modifier_key |= KM_CTRL;
+               if (event->oskey) but->modifier_key |= KM_OSKEY;
 
                ui_check_but(but);
                ED_region_tag_redraw(data->region);
                        
-               if(event->val==KM_PRESS) {
-                       if(ISHOTKEY(event->type)) { 
+               if (event->val==KM_PRESS) {
+                       if (ISHOTKEY(event->type)) { 
                                
-                               if(WM_key_event_string(event->type)[0])
+                               if (WM_key_event_string(event->type)[0])
                                        ui_set_but_val(but, event->type);
                                else
                                        data->cancel= 1;
@@ -2152,7 +2154,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                                return WM_UI_HANDLER_BREAK;
                        }
-                       else if(event->type == ESCKEY) {
+                       else if (event->type == ESCKEY) {
                                data->cancel= 1;
                                data->escapecancel= 1;
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -2166,18 +2168,18 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
 
 static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
 {
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_WAIT_KEY_EVENT) {
-               if(event->type == MOUSEMOVE)
+       else if (data->state == BUTTON_STATE_WAIT_KEY_EVENT) {
+               if (event->type == MOUSEMOVE)
                        return WM_UI_HANDLER_CONTINUE;
 
-               if(event->val==KM_PRESS) {
-                       if(WM_key_event_string(event->type)[0])
+               if (event->val==KM_PRESS) {
+                       if (WM_key_event_string(event->type)[0])
                                ui_set_but_val(but, event->type);
                        else
                                data->cancel= 1;
@@ -2191,20 +2193,20 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w
 
 static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
 {
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val==KM_PRESS) {
-                       if(but->dt == UI_EMBOSSN && !event->ctrl);
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val==KM_PRESS) {
+                       if (but->dt == UI_EMBOSSN && !event->ctrl);
                        else {
                                button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                                return WM_UI_HANDLER_BREAK;
                        }
                }
        }
-       else if(data->state == BUTTON_STATE_TEXT_EDITING) {
+       else if (data->state == BUTTON_STATE_TEXT_EDITING) {
                ui_do_but_textedit(C, block, but, data, event);
                return WM_UI_HANDLER_BREAK;
        }
-       else if(data->state == BUTTON_STATE_TEXT_SELECTING) {
+       else if (data->state == BUTTON_STATE_TEXT_SELECTING) {
                ui_do_but_textedit_select(C, block, but, data, event);
                return WM_UI_HANDLER_BREAK;
        }
@@ -2214,8 +2216,8 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
 
 static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
 {
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
                        data->togdual= event->ctrl;
                        data->togonly= !event->shift;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -2228,11 +2230,11 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, wmEv
 static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
 {
        
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
 
                /* first handle click on icondrag type button */
-               if(event->type==LEFTMOUSE && but->dragpoin) {
-                       if(ui_but_mouse_inside_icon(but, data->region, event)) {
+               if (event->type==LEFTMOUSE && but->dragpoin) {
+                       if (ui_but_mouse_inside_icon(but, data->region, event)) {
                                
                                /* tell the button to wait and keep checking further events to
                                 * see if it should start dragging */
@@ -2243,27 +2245,27 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
                        }
                }
                
-               if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+               if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
                        int ret = WM_UI_HANDLER_BREAK;
                        /* XXX (a bit ugly) Special case handling for filebrowser drag button */
-                       if(but->dragpoin && but->imb && ui_but_mouse_inside_icon(but, data->region, event)) {
+                       if (but->dragpoin && but->imb && ui_but_mouse_inside_icon(but, data->region, event)) {
                                ret = WM_UI_HANDLER_CONTINUE;
                        }
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                        return ret;
                }
        }
-       else if(data->state == BUTTON_STATE_WAIT_DRAG) {
+       else if (data->state == BUTTON_STATE_WAIT_DRAG) {
                
                /* this function also ends state */
-               if(ui_but_start_drag(C, but, data, event)) {
+               if (ui_but_start_drag(C, but, data, event)) {
                        return WM_UI_HANDLER_BREAK;
                }
                
                /* If the mouse has been pressed and released, getting to 
                 * this point without triggering a drag, then clear the 
                 * drag state for this button and continue to pass on the event */
-               if(event->type==LEFTMOUSE && event->val==KM_RELEASE) {
+               if (event->type==LEFTMOUSE && event->val==KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                        return WM_UI_HANDLER_CONTINUE;
                }
@@ -2279,25 +2281,25 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
 /* var names match ui_numedit_but_NUM */
 static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange, int snap)
 {
-       if(tempf==softmin || tempf==softmax || snap==0) {
+       if (tempf==softmin || tempf==softmax || snap==0) {
                /* pass */
        }
        else {
                float fac= 1.0f;
                
-               if(ui_is_but_unit(but)) {
+               if (ui_is_but_unit(but)) {
                        UnitSettings *unit= but->block->unit;
                        int unit_type= uiButGetUnitType(but)>>16;
 
-                       if(bUnit_IsValid(unit->system, unit_type)) {
+                       if (bUnit_IsValid(unit->system, unit_type)) {
                                fac= (float)bUnit_BaseScalar(unit->system, unit_type);
-                               if(ELEM3(unit_type, B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME)) {
+                               if (ELEM3(unit_type, B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME)) {
                                        fac /= unit->scale_length;
                                }
                        }
                }
 
-               if(fac != 1.0f) {
+               if (fac != 1.0f) {
                        /* snap in unit-space */
                        tempf /= fac;
                        /* softmin /= fac; */ /* UNUSED */
@@ -2305,18 +2307,18 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
                        softrange /= fac;
                }
 
-               if(snap==1) {
-                       if(softrange < 2.10f) tempf= 0.1f*floorf(10.0f*tempf);
-                       else if(softrange < 21.0f) tempf= floorf(tempf);
+               if (snap==1) {
+                       if (softrange < 2.10f) tempf= 0.1f*floorf(10.0f*tempf);
+                       else if (softrange < 21.0f) tempf= floorf(tempf);
                        else tempf= 10.0f*floorf(tempf/10.0f);
                }
-               else if(snap==2) {
-                       if(softrange < 2.10f) tempf= 0.01f*floorf(100.0f*tempf);
-                       else if(softrange < 21.0f) tempf= 0.1f*floorf(10.0f*tempf);
+               else if (snap==2) {
+                       if (softrange < 2.10f) tempf= 0.01f*floorf(100.0f*tempf);
+                       else if (softrange < 21.0f) tempf= 0.1f*floorf(10.0f*tempf);
                        else tempf= floor(tempf);
                }
                
-               if(fac != 1.0f)
+               if (fac != 1.0f)
                        tempf *= fac;
        }
 
@@ -2325,7 +2327,7 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
 
 static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int snap)
 {
-       if(temp==softmin || temp==softmax)
+       if (temp==softmin || temp==softmax)
                return temp;
 
        switch(snap) {
@@ -2347,13 +2349,13 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
        float deler, tempf, softmin, softmax, softrange;
        int lvalue, temp, changed= 0;
        
-       if(mx == data->draglastx)
+       if (mx == data->draglastx)
                return changed;
        
        /* drag-lock - prevent unwanted scroll adjustments */
        /* change value (now 3) to adjust threshold in pixels */
-       if(data->draglock) {
-               if(abs(mx-data->dragstartx) <= 3)
+       if (data->draglock) {
+               if (abs(mx-data->dragstartx) <= 3)
                        return changed;
 
                data->draglock= 0;
@@ -2364,19 +2366,20 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
        softmax= but->softmax;
        softrange= softmax - softmin;
 
-       if(ui_is_a_warp_but(but)) {
+       if (ui_is_a_warp_but(but)) {
                /* Mouse location isn't screen clamped to the screen so use a linear mapping
                 * 2px == 1-int, or 1px == 1-ClickStep */
-               if(ui_is_but_float(but)) {
+               if (ui_is_but_float(but)) {
                        fac *= 0.01f*but->a1;
                        tempf = (float)data->startvalue + ((float)(mx - data->dragstartx) * fac);
                        tempf= ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap);
 
 #if 1          /* fake moving the click start, nicer for dragging back after passing the limit */
-                       if(tempf < softmin) {
+                       if (tempf < softmin) {
                                data->dragstartx -= (softmin-tempf) / fac;
                                tempf= softmin;
-                       } else if (tempf > softmax) {
+                       }
+                       else if (tempf > softmax) {
                                data->dragstartx += (tempf-softmax) / fac;
                                tempf= softmax;
                        }
@@ -2384,25 +2387,26 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
                        CLAMP(tempf, softmin, softmax);
 #endif
 
-                       if(tempf != (float)data->value) {
+                       if (tempf != (float)data->value) {
                                data->dragchange= 1;
                                data->value= tempf;
                                changed= 1;
                        }
                }
                else {
-                       if(softrange > 256)             fac= 1.0;               /* 1px == 1 */
-                       else if(softrange > 32) fac= 1.0/2.0;   /* 2px == 1 */
+                       if (softrange > 256)            fac= 1.0;               /* 1px == 1 */
+                       else if (softrange > 32)        fac= 1.0/2.0;   /* 2px == 1 */
                        else                                    fac= 1.0/16.0;  /* 16px == 1? */
 
                        temp= data->startvalue + (((double)mx - data->dragstartx) * (double)fac);
                        temp= ui_numedit_apply_snap(temp, softmin, softmax, snap);
 
 #if 1          /* fake moving the click start, nicer for dragging back after passing the limit */
-                       if(temp < softmin) {
+                       if (temp < softmin) {
                                data->dragstartx -= (softmin-temp) / fac;
                                temp= softmin;
-                       } else if (temp > softmax) {
+                       }
+                       else if (temp > softmax) {
                                data->dragstartx += (temp-softmax) / fac;
                                temp= softmax;
                        }
@@ -2410,7 +2414,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
                        CLAMP(temp, softmin, softmax);
 #endif
 
-                       if(temp != data->value) {
+                       if (temp != data->value) {
                                data->dragchange= 1;
                                data->value= temp;
                                changed= 1;
@@ -2422,7 +2426,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
        else {
                /* Use a non-linear mapping of the mouse drag especially for large floats (normal behavior) */
                deler= 500;
-               if(!ui_is_but_float(but)) {
+               if (!ui_is_but_float(but)) {
                        /* prevent large ranges from getting too out of control */
                        if (softrange > 600) deler = powf(softrange, 0.75);
                        
@@ -2431,13 +2435,15 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
                }
                deler /= fac;
 
-               if(softrange > 11) {
+               if (softrange > 11) {
                        /* non linear change in mouse input- good for high precicsion */
                        data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabsf(data->dragstartx-mx)*0.002f);
-               } else if (softrange > 129) { /* only scale large int buttons */
+               }
+               else if (softrange > 129) { /* only scale large int buttons */
                        /* non linear change in mouse input- good for high precicsionm ints need less fine tuning */
                        data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabsf(data->dragstartx-mx)*0.004f);
-               } else {
+               }
+               else {
                        /*no scaling */
                        data->dragf += ((float)(mx - data->draglastx)) / deler;
                }
@@ -2447,7 +2453,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
                tempf= (softmin + data->dragf*softrange);
 
 
-               if(!ui_is_but_float(but)) {
+               if (!ui_is_but_float(but)) {
                        temp= floorf(tempf + 0.5f);
 
                        temp= ui_numedit_apply_snap(temp, softmin, softmax, snap);
@@ -2455,7 +2461,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
                        CLAMP(temp, softmin, softmax);
                        lvalue= (int)data->value;
                        
-                       if(temp != lvalue) {
+                       if (temp != lvalue) {
                                data->dragchange= 1;
                                data->value= (double)temp;
                                changed= 1;
@@ -2467,7 +2473,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
 
                        CLAMP(tempf, softmin, softmax);
 
-                       if(tempf != (float)data->value) {
+                       if (tempf != (float)data->value) {
                                data->dragchange= 1;
                                data->value= tempf;
                                changed= 1;
@@ -2491,27 +2497,27 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
 
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
                /* XXX hardcoded keymap check.... */
-               if(event->type == WHEELDOWNMOUSE && event->alt) {
+               if (event->type == WHEELDOWNMOUSE && event->alt) {
                        mx= but->x1;
                        click= 1;
                }
-               else if(event->type == WHEELUPMOUSE && event->alt) {
+               else if (event->type == WHEELUPMOUSE && event->alt) {
                        mx= but->x2;
                        click= 1;
                }
-               else if(event->val==KM_PRESS) {
-                       if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) {
+               else if (event->val==KM_PRESS) {
+                       if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) {
                                button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                                retval= WM_UI_HANDLER_BREAK;
                        }
-                       else if(event->type == LEFTMOUSE) {
+                       else if (event->type == LEFTMOUSE) {
                                data->dragstartx= data->draglastx= ui_is_a_warp_but(but) ? screen_mx:mx;
                                button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
                                retval= WM_UI_HANDLER_BREAK;
                        }
-                       else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS)
+                       else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS)
                                click= 1;
                        else if (event->type == MINUSKEY && event->val==KM_PRESS) {
                                button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
@@ -2522,43 +2528,43 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                }
                
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == ESCKEY) {
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == ESCKEY) {
                        data->cancel= 1;
                        data->escapecancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
-               else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
-                       if(data->dragchange)
+               else if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+                       if (data->dragchange)
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        else
                                click= 1;
                }
-               else if(event->type == MOUSEMOVE) {
+               else if (event->type == MOUSEMOVE) {
                        float fac;
                        int snap;
 
                        fac= 1.0f;
-                       if(event->shift) fac /= 10.0f;
-                       if(event->alt) fac /= 20.0f;
+                       if (event->shift) fac /= 10.0f;
+                       if (event->alt) fac /= 20.0f;
                        
                        snap= (event->ctrl)? (event->shift)? 2: 1: 0;
 
-                       if(ui_numedit_but_NUM(but, data, fac, snap, (ui_is_a_warp_but(but) ? screen_mx:mx)))
+                       if (ui_numedit_but_NUM(but, data, fac, snap, (ui_is_a_warp_but(but) ? screen_mx:mx)))
                                ui_numedit_apply(C, block, but, data);
                }
                retval= WM_UI_HANDLER_BREAK;
        }
-       else if(data->state == BUTTON_STATE_TEXT_EDITING) {
+       else if (data->state == BUTTON_STATE_TEXT_EDITING) {
                ui_do_but_textedit(C, block, but, data, event);
                retval= WM_UI_HANDLER_BREAK;
        }
-       else if(data->state == BUTTON_STATE_TEXT_SELECTING) {
+       else if (data->state == BUTTON_STATE_TEXT_SELECTING) {
                ui_do_but_textedit_select(C, block, but, data, event);
                retval= WM_UI_HANDLER_BREAK;
        }
        
-       if(click) {
+       if (click) {
                /* we can click on the side arrows to increment/decrement,
                 * or click inside to edit the value directly */
                float tempf, softmin, softmax;
@@ -2567,23 +2573,23 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                softmin= but->softmin;
                softmax= but->softmax;
 
-               if(!ui_is_but_float(but)) {
-                       if(mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) {
+               if (!ui_is_but_float(but)) {
+                       if (mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) {
                                button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 
                                temp= (int)data->value - 1;
-                               if(temp>=softmin && temp<=softmax)
+                               if (temp>=softmin && temp<=softmax)
                                        data->value= (double)temp;
                                else
                                        data->cancel= 1;
 
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        }
-                       else if(mx > (but->x1 + (2*(but->x2 - but->x1)/3) + 3)) {
+                       else if (mx > (but->x1 + (2*(but->x2 - but->x1)/3) + 3)) {
                                button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 
                                temp= (int)data->value + 1;
-                               if(temp>=softmin && temp<=softmax)
+                               if (temp>=softmin && temp<=softmax)
                                        data->value= (double)temp;
                                else
                                        data->cancel= 1;
@@ -2594,7 +2600,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                                button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                }
                else {
-                       if(mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) {
+                       if (mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) {
                                button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 
                                tempf= (float)data->value - 0.01f * but->a1;
@@ -2603,7 +2609,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
 
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        }
-                       else if(mx > but->x1 + (2*((but->x2 - but->x1)/3) + 3)) {
+                       else if (mx > but->x1 + (2*((but->x2 - but->x1)/3) + 3)) {
                                button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 
                                tempf= (float)data->value + 0.01f * but->a1;
@@ -2631,9 +2637,9 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
        softmax= but->softmax;
        softrange= softmax - softmin;
 
-       if(but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0f*but->aspect);
-       else if(but->type==HSVSLI) deler= ((but->x2-but->x1)/2.0f - 5.0f*but->aspect);
-       else if(but->type==SCROLL) {
+       if (but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0f*but->aspect);
+       else if (but->type==HSVSLI) deler= ((but->x2-but->x1)/2.0f - 5.0f*but->aspect);
+       else if (but->type==SCROLL) {
                int horizontal= (but->x2 - but->x1 > but->y2 - but->y1);
                float size= (horizontal)? (but->x2-but->x1): -(but->y2-but->y1);
                deler= size*(but->softmax - but->softmin)/(but->softmax - but->softmin + but->a1);
@@ -2642,26 +2648,26 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
 
        f= (float)(mx-data->dragstartx)/deler + data->dragfstart;
        
-       if(shift)
+       if (shift)
                f= (f-data->dragfstart)/10.0f + data->dragfstart;
 
        CLAMP(f, 0.0f, 1.0f);
        tempf= softmin + f*softrange;
        temp= floorf(tempf+0.5f);
 
-       if(ctrl) {
-               if(tempf==softmin || tempf==softmax);
-               else if(ui_is_but_float(but)) {
+       if (ctrl) {
+               if (tempf==softmin || tempf==softmax);
+               else if (ui_is_but_float(but)) {
 
-                       if(shift) {
-                               if(tempf==softmin || tempf==softmax);
-                               else if(softmax-softmin < 2.10f) tempf= 0.01f * floorf(100.0f*tempf);
-                               else if(softmax-softmin < 21.0f) tempf= 0.1f * floorf(10.0f*tempf);
+                       if (shift) {
+                               if (tempf==softmin || tempf==softmax);
+                               else if (softmax-softmin < 2.10f) tempf= 0.01f * floorf(100.0f*tempf);
+                               else if (softmax-softmin < 21.0f) tempf= 0.1f * floorf(10.0f*tempf);
                                else tempf= floorf(tempf);
                        }
                        else {
-                               if(softmax-softmin < 2.10f) tempf= 0.1f * floorf(10.0f*tempf);
-                               else if(softmax-softmin < 21.0f) tempf= floorf(tempf);
+                               if (softmax-softmin < 2.10f) tempf= 0.1f * floorf(10.0f*tempf);
+                               else if (softmax-softmin < 21.0f) tempf= floorf(tempf);
                                else tempf= 10.0f*floorf(tempf/10.0f);
                        }
                }
@@ -2671,12 +2677,12 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
                }
        }
 
-       if(!ui_is_but_float(but)) {
+       if (!ui_is_but_float(but)) {
                lvalue= floor(data->value+0.5);
 
                CLAMP(temp, softmin, softmax);
 
-               if(temp != lvalue) {
+               if (temp != lvalue) {
                        data->value= temp;
                        data->dragchange= 1;
                        changed= 1;
@@ -2685,7 +2691,7 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
        else {
                CLAMP(tempf, softmin, softmax);
 
-               if(tempf != (float)data->value) {
+               if (tempf != (float)data->value) {
                        data->value= tempf;
                        data->dragchange= 1;
                        changed= 1;
@@ -2704,23 +2710,23 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
                /* XXX hardcoded keymap check.... */
-               if(event->type == WHEELDOWNMOUSE && event->alt) {
+               if (event->type == WHEELDOWNMOUSE && event->alt) {
                        mx= but->x1;
                        click= 2;
                }
-               else if(event->type == WHEELUPMOUSE && event->alt) {
+               else if (event->type == WHEELUPMOUSE && event->alt) {
                        mx= but->x2;
                        click= 2;
                }
-               else if(event->val==KM_PRESS) {
-                       if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) {
+               else if (event->val==KM_PRESS) {
+                       if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) {
                                button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                                retval= WM_UI_HANDLER_BREAK;
                        }
                        /* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */
-                       else if(event->type == LEFTMOUSE && event->alt) {
+                       else if (event->type == LEFTMOUSE && event->alt) {
                                int halfpos = (but->x1 + but->x2) / 2;
                                click = 2;
                                if (mx < halfpos)
@@ -2728,13 +2734,13 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                                else
                                        mx = but->x2;
                        }
-                       else if(event->type == LEFTMOUSE) {
+                       else if (event->type == LEFTMOUSE) {
                                data->dragstartx= mx;
                                data->draglastx= mx;
                                button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
                                retval= WM_UI_HANDLER_BREAK;
                        }
-                       else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS)
+                       else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS)
                                click= 1;
                        else if (event->type == MINUSKEY && event->val==KM_PRESS) {
                                button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
@@ -2744,34 +2750,34 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                        }
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == ESCKEY) {
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == ESCKEY) {
                        data->cancel= 1;
                        data->escapecancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
-               else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
-                       if(data->dragchange)
+               else if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+                       if (data->dragchange)
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        else
                                click= 1;
                }
-               else if(event->type == MOUSEMOVE) {
-                       if(ui_numedit_but_SLI(but, data, event->shift, event->ctrl, mx))
+               else if (event->type == MOUSEMOVE) {
+                       if (ui_numedit_but_SLI(but, data, event->shift, event->ctrl, mx))
                                ui_numedit_apply(C, block, but, data);
                }
                retval= WM_UI_HANDLER_BREAK;
        }
-       else if(data->state == BUTTON_STATE_TEXT_EDITING) {
+       else if (data->state == BUTTON_STATE_TEXT_EDITING) {
                ui_do_but_textedit(C, block, but, data, event);
                retval= WM_UI_HANDLER_BREAK;
        }
-       else if(data->state == BUTTON_STATE_TEXT_SELECTING) {
+       else if (data->state == BUTTON_STATE_TEXT_SELECTING) {
                ui_do_but_textedit_select(C, block, but, data, event);
                retval= WM_UI_HANDLER_BREAK;
        }
 
-       if(click) {
+       if (click) {
                if (click==2) {
                        /* nudge slider to the left or right */
                        float f, tempf, softmin, softmax, softrange;
@@ -2787,7 +2793,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                        temp= (int)data->value;
 
 #if 0
-                       if(but->type==SLI) {
+                       if (but->type==SLI) {
                                f= (float)(mx-but->x1)/(but->x2-but->x1); /* same as below */
                        }
                        else
@@ -2798,20 +2804,20 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                        
                        f= softmin + f*softrange;
                        
-                       if(!ui_is_but_float(but)) {
-                               if(f<temp) temp--;
+                       if (!ui_is_but_float(but)) {
+                               if (f<temp) temp--;
                                else temp++;
                                
-                               if(temp>=softmin && temp<=softmax)
+                               if (temp>=softmin && temp<=softmax)
                                        data->value= temp;
                                else
                                        data->cancel= 1;
                        } 
                        else {
-                               if(f<tempf) tempf -= 0.01f;
+                               if (f<tempf) tempf -= 0.01f;
                                else tempf += 0.01f;
                                
-                               if(tempf>=softmin && tempf<=softmax)
+                               if (tempf>=softmin && tempf<=softmax)
                                        data->value= tempf;
                                else
                                        data->cancel= 1;
@@ -2840,10 +2846,10 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->val==KM_PRESS) {
-                       if(event->type == LEFTMOUSE) {
-                               if(horizontal) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->val==KM_PRESS) {
+                       if (event->type == LEFTMOUSE) {
+                               if (horizontal) {
                                        data->dragstartx= mx;
                                        data->draglastx= mx;
                                }
@@ -2856,22 +2862,22 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
                        }
                        /* UNUSED - otherwise code is ok, add back if needed */
 #if 0
-                       else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS)
+                       else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS)
                                click= 1;
 #endif
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == ESCKEY) {
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == ESCKEY) {
                        data->cancel= 1;
                        data->escapecancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
-               else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+               else if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
-               else if(event->type == MOUSEMOVE) {
-                       if(ui_numedit_but_SLI(but, data, 0, 0, (horizontal)? mx: my))
+               else if (event->type == MOUSEMOVE) {
+                       if (ui_numedit_but_SLI(but, data, 0, 0, (horizontal)? mx: my))
                                ui_numedit_apply(C, block, but, data);
                }
 
@@ -2885,11 +2891,11 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
 static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
 {
        
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
                
                /* first handle click on icondrag type button */
-               if(event->type==LEFTMOUSE && but->dragpoin && event->val==KM_PRESS) {
-                       if(ui_but_mouse_inside_icon(but, data->region, event)) {
+               if (event->type==LEFTMOUSE && but->dragpoin && event->val==KM_PRESS) {
+                       if (ui_but_mouse_inside_icon(but, data->region, event)) {
                                button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
                                data->dragstartx= event->x;
                                data->dragstarty= event->y;
@@ -2898,13 +2904,13 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm
                }
                
                /* regular open menu */
-               if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+               if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
                        return WM_UI_HANDLER_BREAK;
                }
-               else if(ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) {
+               else if (ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) {
                        
-                       if(event->type == WHEELDOWNMOUSE && event->alt) {
+                       if (event->type == WHEELDOWNMOUSE && event->alt) {
                                data->value= ui_step_name_menu(but, -1);
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                                ui_apply_button(C, but->block, but, data, 1);
@@ -2921,7 +2927,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm
 
                                return WM_UI_HANDLER_BREAK;
                        }
-                       else if(event->type == WHEELUPMOUSE && event->alt) {
+                       else if (event->type == WHEELUPMOUSE && event->alt) {
                                data->value= ui_step_name_menu(but, 1);
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                                ui_apply_button(C, but->block, but, data, 1);
@@ -2933,15 +2939,15 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm
                                return WM_UI_HANDLER_BREAK;
                        }
                }
-               else if(but->type==COL) {
-                       if( ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) {
+               else if (but->type==COL) {
+                       if ( ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) {
                                float *hsv= ui_block_hsv_get(but->block);
                                float col[3];
                                
                                ui_get_but_vectorf(but, col);
                                rgb_to_hsv_compat(col[0], col[1], col[2], hsv, hsv+1, hsv+2);
 
-                               if(event->type==WHEELDOWNMOUSE)
+                               if (event->type==WHEELDOWNMOUSE)
                                        hsv[2]= CLAMPIS(hsv[2]-0.05f, 0.0f, 1.0f);
                                else
                                        hsv[2]= CLAMPIS(hsv[2]+0.05f, 0.0f, 1.0f);
@@ -2955,21 +2961,21 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm
                        }
                }
        }
-       else if(data->state == BUTTON_STATE_WAIT_DRAG) {
+       else if (data->state == BUTTON_STATE_WAIT_DRAG) {
                
                /* this function also ends state */
-               if(ui_but_start_drag(C, but, data, event)) {
+               if (ui_but_start_drag(C, but, data, event)) {
                        return WM_UI_HANDLER_BREAK;
                }
                
                /* outside icon quit, not needed if drag activated */
-               if(0==ui_but_mouse_inside_icon(but, data->region, event)) {
+               if (0==ui_but_mouse_inside_icon(but, data->region, event)) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                        data->cancel= 1;
                        return WM_UI_HANDLER_BREAK;
                }
                
-               if(event->type==LEFTMOUSE && event->val==KM_RELEASE) {
+               if (event->type==LEFTMOUSE && event->val==KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
                        return WM_UI_HANDLER_BREAK;
                }
@@ -2994,11 +3000,11 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i
        rad= (but->x2 - but->x1);
        radsq= rad*rad;
        
-       if(fp[2]>0.0f) {
+       if (fp[2]>0.0f) {
                mdx= (rad*fp[0]);
                mdy= (rad*fp[1]);
        }
-       else if(fp[2]> -1.0f) {
+       else if (fp[2]> -1.0f) {
                mrad= rad/sqrtf(fp[0]*fp[0] + fp[1]*fp[1]);
                
                mdx= 2.0f*mrad*fp[0] - (rad*fp[0]);
@@ -3011,7 +3017,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i
 
        fp= data->vec;
        mrad= dx*dx+dy*dy;
-       if(mrad < radsq) {      /* inner circle */
+       if (mrad < radsq) {     /* inner circle */
                fp[0]= dx;
                fp[1]= dy;
                fp[2]= sqrt( radsq-dx*dx-dy*dy );
@@ -3024,7 +3030,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i
                dy*= (2.0f*mrad - 1.0f);
                
                mrad= dx*dx+dy*dy;
-               if(mrad < radsq) {
+               if (mrad < radsq) {
                        fp[0]= dx;
                        fp[1]= dy;
                        fp[2]= -sqrt( radsq-dx*dx-dy*dy );
@@ -3046,8 +3052,8 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
                        data->dragstartx= mx;
                        data->dragstarty= my;
                        data->draglastx= mx;
@@ -3055,20 +3061,20 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
                        button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 
                        /* also do drag the first time */
-                       if(ui_numedit_but_NORMAL(but, data, mx, my))
+                       if (ui_numedit_but_NORMAL(but, data, mx, my))
                                ui_numedit_apply(C, block, but, data);
                        
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == MOUSEMOVE) {
-                       if(mx!=data->draglastx || my!=data->draglasty) {
-                               if(ui_numedit_but_NORMAL(but, data, mx, my))
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == MOUSEMOVE) {
+                       if (mx!=data->draglastx || my!=data->draglasty) {
+                               if (ui_numedit_but_NORMAL(but, data, mx, my))
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if(event->type==LEFTMOUSE && event->val!=KM_PRESS)
+               else if (event->type==LEFTMOUSE && event->val!=KM_PRESS)
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
 
                return WM_UI_HANDLER_BREAK;
@@ -3212,8 +3218,8 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
                        data->dragstartx= mx;
                        data->dragstarty= my;
                        data->draglastx= mx;
@@ -3221,7 +3227,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
                        button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 
                        /* also do drag the first time */
-                       if(ui_numedit_but_HSVCUBE(but, data, mx, my))
+                       if (ui_numedit_but_HSVCUBE(but, data, mx, my))
                                ui_numedit_apply(C, block, but, data);
                        
                        return WM_UI_HANDLER_BREAK;
@@ -3238,7 +3244,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
                }
                /* XXX hardcoded keymap check.... */
                else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
-                       if (but->a1==UI_GRAD_V_ALT){
+                       if (but->a1==UI_GRAD_V_ALT) {
                                int len;
                                
                                /* reset only value */
@@ -3267,19 +3273,19 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
                        }
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == ESCKEY) {
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == ESCKEY) {
                        data->cancel= 1;
                        data->escapecancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
-               else if(event->type == MOUSEMOVE) {
-                       if(mx!=data->draglastx || my!=data->draglasty) {
-                               if(ui_numedit_but_HSVCUBE(but, data, mx, my))
+               else if (event->type == MOUSEMOVE) {
+                       if (mx!=data->draglastx || my!=data->draglasty) {
+                               if (ui_numedit_but_HSVCUBE(but, data, mx, my))
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if(event->type==LEFTMOUSE && event->val!=KM_PRESS)
+               else if (event->type==LEFTMOUSE && event->val!=KM_PRESS)
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                
                return WM_UI_HANDLER_BREAK;
@@ -3308,7 +3314,7 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx
                if (hsv[2] == 0.f) hsv[2] = 0.0001f;
        }
 
-       if(U.uiflag & USER_CONTINUOUS_MOUSE) {
+       if (U.uiflag & USER_CONTINUOUS_MOUSE) {
                float fac= shift ? 0.05f : 1.0f;
                /* slow down the mouse, this is fairly picky */
                mx = (data->dragstartx*(1.0f-fac) + mx*fac);
@@ -3317,12 +3323,12 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx
 
        ui_hsvcircle_vals_from_pos(hsv, hsv+1, &rect, (float)mx, (float)my);
 
-       if(but->flag & UI_BUT_COLOR_CUBIC)
+       if (but->flag & UI_BUT_COLOR_CUBIC)
                hsv[1]= 1.0f - sqrt3f(1.0f - hsv[1]);
 
        hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
 
-       if((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
+       if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
                normalize_v3(rgb);
                mul_v3_fl(rgb, but->a2);
        }
@@ -3379,7 +3385,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND
        
        hsv_to_rgb(hsv[0], hsv[1], hsv[2], data->vec, data->vec+1, data->vec+2);
        
-       if((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
+       if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
                normalize_v3(data->vec);
                mul_v3_fl(data->vec, but->a2);
        }
@@ -3395,8 +3401,8 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
        
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
                        data->dragstartx= mx;
                        data->dragstarty= my;
                        data->draglastx= mx;
@@ -3404,7 +3410,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
                        button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
                        
                        /* also do drag the first time */
-                       if(ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
+                       if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
                                ui_numedit_apply(C, block, but, data);
                        
                        return WM_UI_HANDLER_BREAK;
@@ -3448,32 +3454,32 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == ESCKEY) {
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == ESCKEY) {
                        data->cancel= 1;
                        data->escapecancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                /* XXX hardcoded keymap check.... */
-               else if(event->type == WHEELDOWNMOUSE) {
+               else if (event->type == WHEELDOWNMOUSE) {
                        float *hsv= ui_block_hsv_get(but->block);
                        hsv[2]= CLAMPIS(hsv[2]-0.05f, 0.0f, 1.0f);
                        ui_set_but_hsv(but);    // converts to rgb
                        ui_numedit_apply(C, block, but, data);
                }
-               else if(event->type == WHEELUPMOUSE) {
+               else if (event->type == WHEELUPMOUSE) {
                        float *hsv= ui_block_hsv_get(but->block);
                        hsv[2]= CLAMPIS(hsv[2]+0.05f, 0.0f, 1.0f);
                        ui_set_but_hsv(but);    // converts to rgb
                        ui_numedit_apply(C, block, but, data);
                }
-               else if(event->type == MOUSEMOVE) {
-                       if(mx!=data->draglastx || my!=data->draglasty) {
-                               if(ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
+               else if (event->type == MOUSEMOVE) {
+                       if (mx!=data->draglastx || my!=data->draglasty) {
+                               if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+               else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                return WM_UI_HANDLER_BREAK;
@@ -3488,7 +3494,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx
        float dx;
        int changed= 0;
 
-       if(data->draglastx == mx)
+       if (data->draglastx == mx)
                return changed;
 
        dx= ((float)(mx - data->draglastx))/(but->x2-but->x1);
@@ -3514,11 +3520,11 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
                        coba= (ColorBand*)but->poin;
 
-                       if(event->ctrl) {
+                       if (event->ctrl) {
                                /* insert new key on mouse location */
                                float pos= ((float)(mx - but->x1))/(but->x2-but->x1);
                                colorband_element_add(coba, pos);
@@ -3531,11 +3537,11 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
                                data->draglasty= my;
 
                                /* activate new key when mouse is close */
-                               for(a=0, cbd= coba->data; a<coba->tot; a++, cbd++) {
+                               for (a=0, cbd= coba->data; a<coba->tot; a++, cbd++) {
                                        xco= but->x1 + (cbd->pos*(but->x2-but->x1));
                                        xco= ABS(xco-mx);
-                                       if(a==coba->cur) xco+= 5; // selected one disadvantage
-                                       if(xco<mindist) {
+                                       if (a==coba->cur) xco+= 5; // selected one disadvantage
+                                       if (xco<mindist) {
                                                coba->cur= a;
                                                mindist= xco;
                                        }
@@ -3548,14 +3554,14 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == MOUSEMOVE) {
-                       if(mx!=data->draglastx || my!=data->draglasty) {
-                               if(ui_numedit_but_COLORBAND(but, data, mx))
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == MOUSEMOVE) {
+                       if (mx!=data->draglastx || my!=data->draglasty) {
+                               if (ui_numedit_but_COLORBAND(but, data, mx))
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if(event->type==LEFTMOUSE && event->val!=KM_PRESS)
+               else if (event->type==LEFTMOUSE && event->val!=KM_PRESS)
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                
                return WM_UI_HANDLER_BREAK;
@@ -3577,38 +3583,38 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
        /* offsx= cumap->curr.xmin; */
        /* offsy= cumap->curr.ymin; */
 
-       if(snap) {
+       if (snap) {
                float d[2];
 
                d[0]= mx - data->dragstartx;
                d[1]= my - data->dragstarty;
 
-               if(len_v2(d) < 3.0f)
+               if (len_v2(d) < 3.0f)
                        snap= 0;
        }
 
-       if(data->dragsel != -1) {
+       if (data->dragsel != -1) {
                int moved_point= 0;             /* for ctrl grid, can't use orig coords because of sorting */
                
                fx= (mx-data->draglastx)/zoomx;
                fy= (my-data->draglasty)/zoomy;
-               for(a=0; a<cuma->totpoint; a++) {
-                       if(cmp[a].flag & SELECT) {
+               for (a=0; a<cuma->totpoint; a++) {
+                       if (cmp[a].flag & SELECT) {
                                float origx= cmp[a].x, origy= cmp[a].y;
                                cmp[a].x+= fx;
                                cmp[a].y+= fy;
-                               if(snap) {
+                               if (snap) {
                                        cmp[a].x= 0.125f*floorf(0.5f + 8.0f*cmp[a].x);
                                        cmp[a].y= 0.125f*floorf(0.5f + 8.0f*cmp[a].y);
                                }
-                               if(cmp[a].x!=origx || cmp[a].y!=origy)
+                               if (cmp[a].x!=origx || cmp[a].y!=origy)
                                        moved_point= 1;
                        }
                }
 
                curvemapping_changed(cumap, 0); /* no remove doubles */
                
-               if(moved_point) {
+               if (moved_point) {
                        data->draglastx= mx;
                        data->draglasty= my;
                        changed= 1;
@@ -3621,14 +3627,14 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
                fy= (my-data->draglasty)/zoomy;
                
                /* clamp for clip */
-               if(cumap->flag & CUMA_DO_CLIP) {
-                       if(cumap->curr.xmin-fx < cumap->clipr.xmin)
+               if (cumap->flag & CUMA_DO_CLIP) {
+                       if (cumap->curr.xmin-fx < cumap->clipr.xmin)
                                fx= cumap->curr.xmin - cumap->clipr.xmin;
-                       else if(cumap->curr.xmax-fx > cumap->clipr.xmax)
+                       else if (cumap->curr.xmax-fx > cumap->clipr.xmax)
                                fx= cumap->curr.xmax - cumap->clipr.xmax;
-                       if(cumap->curr.ymin-fy < cumap->clipr.ymin)
+                       if (cumap->curr.ymin-fy < cumap->clipr.ymin)
                                fy= cumap->curr.ymin - cumap->clipr.ymin;
-                       else if(cumap->curr.ymax-fy > cumap->clipr.ymax)
+                       else if (cumap->curr.ymax-fy > cumap->clipr.ymax)
                                fy= cumap->curr.ymax - cumap->clipr.ymax;
                }                               
 
@@ -3654,8 +3660,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
                        CurveMapping *cumap= (CurveMapping*)but->poin;
                        CurveMap *cuma= cumap->cm+cumap->cur;
                        CurveMapPoint *cmp;
@@ -3668,7 +3674,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
                        offsx= cumap->curr.xmin;
                        offsy= cumap->curr.ymin;
 
-                       if(event->ctrl) {
+                       if (event->ctrl) {
                                fx= ((float)my - but->x1)/zoomx + offsx;
                                fy= ((float)my - but->y1)/zoomy + offsy;
                                
@@ -3679,11 +3685,11 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
 
                        /* check for selecting of a point */
                        cmp= cuma->curve;       /* ctrl adds point, new malloc */
-                       for(a=0; a<cuma->totpoint; a++) {
+                       for (a=0; a<cuma->totpoint; a++) {
                                fx= but->x1 + zoomx*(cmp[a].x-offsx);
                                fy= but->y1 + zoomy*(cmp[a].y-offsy);
                                dist= (fx-mx)*(fx-mx) + (fy-my)*(fy-my);
-                               if(dist < mindist) {
+                               if (dist < mindist) {
                                        sel= a;
                                        mindist= dist;
                                }
@@ -3701,7 +3707,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
 
                                /* loop through the curve segment table and find what's near the mouse.
                                 * 0.05 is kinda arbitrary, but seems to be what works nicely. */
-                               for(i=0; i<=CM_TABLE; i++) {
+                               for (i=0; i<=CM_TABLE; i++) {
                                        if ( (fabsf(fx - cmp[i].x) < 0.05f) &&
                                             (fabsf(fy - cmp[i].y) < 0.05f))
                                        {
@@ -3715,8 +3721,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
                                                cmp= cuma->curve;
                                                
                                                /* find newly added point and make it 'sel' */
-                                               for(a=0; a<cuma->totpoint; a++)
-                                                       if(cmp[a].x == fx)
+                                               for (a=0; a<cuma->totpoint; a++)
+                                                       if (cmp[a].x == fx)
                                                                sel = a;
                                                        
                                                break;
@@ -3724,11 +3730,11 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
                                }
                        }
 
-                       if(sel!= -1) {
+                       if (sel!= -1) {
                                /* ok, we move a point */
                                /* deselect all if this one is deselect. except if we hold shift */
-                               if(event->shift == FALSE) {
-                                       for(a=0; a<cuma->totpoint; a++)
+                               if (event->shift == FALSE) {
+                                       for (a=0; a<cuma->totpoint; a++)
                                                cmp[a].flag &= ~SELECT;
                                        cmp[sel].flag |= SELECT;
                                }
@@ -3751,23 +3757,23 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == MOUSEMOVE) {
-                       if(mx!=data->draglastx || my!=data->draglasty) {
-                               if(ui_numedit_but_CURVE(but, data, event->ctrl, mx, my))
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == MOUSEMOVE) {
+                       if (mx!=data->draglastx || my!=data->draglasty) {
+                               if (ui_numedit_but_CURVE(but, data, event->ctrl, mx, my))
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) {
-                       if(data->dragsel != -1) {
+               else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+                       if (data->dragsel != -1) {
                                CurveMapping *cumap= (CurveMapping*)but->poin;
                                CurveMap *cuma= cumap->cm+cumap->cur;
                                CurveMapPoint *cmp= cuma->curve;
 
-                               if(!data->dragchange) {
+                               if (!data->dragchange) {
                                        /* deselect all, select one */
-                                       if(event->shift == FALSE) {
-                                               for(a=0; a<cuma->totpoint; a++)
+                                       if (event->shift == FALSE) {
+                                               for (a=0; a<cuma->totpoint; a++)
                                                        cmp[a].flag &= ~SELECT;
                                                cmp[data->dragsel].flag |= SELECT;
                                        }
@@ -3811,7 +3817,8 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
        if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
                 /* resize histogram widget itself */
                hist->height = (but->y2 - but->y1) + (data->dragstarty - my);
-       } else {
+       }
+       else {
                /* scale histogram values */
                yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5f;
                hist->ymax += dy * yfac;
@@ -3833,8 +3840,8 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
        
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
                        data->dragstartx= mx;
                        data->dragstarty= my;
                        data->draglastx= mx;
@@ -3842,7 +3849,7 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle
                        button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
                        
                        /* also do drag the first time */
-                       if(ui_numedit_but_HISTOGRAM(but, data, mx, my))
+                       if (ui_numedit_but_HISTOGRAM(but, data, mx, my))
                                ui_numedit_apply(C, block, but, data);
                        
                        return WM_UI_HANDLER_BREAK;
@@ -3856,19 +3863,19 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == ESCKEY) {
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == ESCKEY) {
                        data->cancel= 1;
                        data->escapecancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
-               else if(event->type == MOUSEMOVE) {
-                       if(mx!=data->draglastx || my!=data->draglasty) {
-                               if(ui_numedit_but_HISTOGRAM(but, data, mx, my))
+               else if (event->type == MOUSEMOVE) {
+                       if (mx!=data->draglastx || my!=data->draglasty) {
+                               if (ui_numedit_but_HISTOGRAM(but, data, mx, my))
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+               else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                return WM_UI_HANDLER_BREAK;
@@ -3894,7 +3901,8 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx,
        if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
                 /* resize waveform widget itself */
                scopes->wavefrm_height = (but->y2 - but->y1) + (data->dragstarty - my);
-       } else {
+       }
+       else {
                /* scale waveform values */
                /* yfac = scopes->wavefrm_yfac; */ /* UNUSED */
                scopes->wavefrm_yfac += dy/200.0f;
@@ -3916,8 +3924,8 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
                        data->dragstartx= mx;
                        data->dragstarty= my;
                        data->draglastx= mx;
@@ -3925,7 +3933,7 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB
                        button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 
                        /* also do drag the first time */
-                       if(ui_numedit_but_WAVEFORM(but, data, mx, my))
+                       if (ui_numedit_but_WAVEFORM(but, data, mx, my))
                                ui_numedit_apply(C, block, but, data);
 
                        return WM_UI_HANDLER_BREAK;
@@ -3939,19 +3947,19 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == ESCKEY) {
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == ESCKEY) {
                        data->cancel= 1;
                        data->escapecancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
-               else if(event->type == MOUSEMOVE) {
-                       if(mx!=data->draglastx || my!=data->draglasty) {
-                               if(ui_numedit_but_WAVEFORM(but, data, mx, my))
+               else if (event->type == MOUSEMOVE) {
+                       if (mx!=data->draglastx || my!=data->draglasty) {
+                               if (ui_numedit_but_WAVEFORM(but, data, mx, my))
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+               else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                return WM_UI_HANDLER_BREAK;
@@ -3992,8 +4000,8 @@ static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHand
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
                        data->dragstartx= mx;
                        data->dragstarty= my;
                        data->draglastx= mx;
@@ -4001,25 +4009,25 @@ static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHand
                        button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 
                        /* also do drag the first time */
-                       if(ui_numedit_but_VECTORSCOPE(but, data, mx, my))
+                       if (ui_numedit_but_VECTORSCOPE(but, data, mx, my))
                                ui_numedit_apply(C, block, but, data);
 
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == ESCKEY) {
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == ESCKEY) {
                        data->cancel= 1;
                        data->escapecancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
-               else if(event->type == MOUSEMOVE) {
-                       if(mx!=data->draglastx || my!=data->draglasty) {
-                               if(ui_numedit_but_VECTORSCOPE(but, data, mx, my))
+               else if (event->type == MOUSEMOVE) {
+                       if (mx!=data->draglastx || my!=data->draglasty) {
+                               if (ui_numedit_but_VECTORSCOPE(but, data, mx, my))
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+               else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                return WM_UI_HANDLER_BREAK;
@@ -4042,8 +4050,8 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
                        /* Calculate the size of the button */
                        width = abs(but->x2 - but->x1);
                        height = abs(but->y2 - but->y1);
@@ -4065,30 +4073,30 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
 
                        che = cs + (y*12) + x;
 
-                       if(che > G.charmax)
+                       if (che > G.charmax)
                                che = 0;
 
-                       if(G.obedit) {
+                       if (G.obedit) {
                                do_textedit(0,0,che);
                        }
 
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                        return WM_UI_HANDLER_BREAK;
                }
-               else if(ELEM(event->type, WHEELUPMOUSE, PAGEUPKEY)) {
-                       for(but= block->buttons.first; but; but= but->next) {
-                               if(but->type == CHARTAB) {
+               else if (ELEM(event->type, WHEELUPMOUSE, PAGEUPKEY)) {
+                       for (but= block->buttons.first; but; but= but->next) {
+                               if (but->type == CHARTAB) {
                                        G.charstart = G.charstart - (12*6);
-                                       if(G.charstart < 0)
+                                       if (G.charstart < 0)
                                                G.charstart = 0;
-                                       if(G.charstart < G.charmin)
+                                       if (G.charstart < G.charmin)
                                                G.charstart = G.charmin;
                                        ui_draw_but(but);
 
                                        //Really nasty... to update the num button from the same butblock
-                                       for(bt= block->buttons.first; bt; bt= bt->next)
+                                       for (bt= block->buttons.first; bt; bt= bt->next)
                                        {
-                                               if(ELEM(bt->type, NUM, NUMABS)) {
+                                               if (ELEM(bt->type, NUM, NUMABS)) {
                                                        ui_check_but(bt);
                                                        ui_draw_but(bt);
                                                }
@@ -4100,19 +4108,19 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
 
                        return WM_UI_HANDLER_BREAK;
                }
-               else if(ELEM(event->type, WHEELDOWNMOUSE, PAGEDOWNKEY)) {
-                       for(but= block->buttons.first; but; but= but->next) {
-                               if(but->type == CHARTAB) {
+               else if (ELEM(event->type, WHEELDOWNMOUSE, PAGEDOWNKEY)) {
+                       for (but= block->buttons.first; but; but= but->next) {
+                               if (but->type == CHARTAB) {
                                        G.charstart = G.charstart + (12*6);
-                                       if(G.charstart > (0xffff - 12*6))
+                                       if (G.charstart > (0xffff - 12*6))
                                                G.charstart = 0xffff - (12*6);
-                                       if(G.charstart > G.charmax - 12*6)
+                                       if (G.charstart > G.charmax - 12*6)
                                                G.charstart = G.charmax - 12*6;
                                        ui_draw_but(but);
 
-                                       for(bt= block->buttons.first; bt; bt= bt->next)
+                                       for (bt= block->buttons.first; bt; bt= bt->next)
                                        {
-                                               if(ELEM(bt->type, NUM, NUMABS)) {
+                                               if (ELEM(bt->type, NUM, NUMABS)) {
                                                        ui_check_but(bt);
                                                        ui_draw_but(bt);
                                                }
@@ -4138,20 +4146,20 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
 {      
        VECCOPY2D(but->linkto, event->mval);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type == LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type == LEFTMOUSE && event->val==KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE);
                        return WM_UI_HANDLER_BREAK;
                }
-               else if(event->type == LEFTMOUSE && but->block->handle) {
+               else if (event->type == LEFTMOUSE && but->block->handle) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_WAIT_RELEASE) {
+       else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
                
-               if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
-                       if(!(but->flag & UI_SELECT))
+               if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+                       if (!(but->flag & UI_SELECT))
                                data->cancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                        return WM_UI_HANDLER_BREAK;
@@ -4170,7 +4178,7 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa
        dx = mx - data->draglastx;
        dy = my - data->draglasty;
 
-       if(shift) {
+       if (shift) {
                dx /= 5.0f;
                dy /= 5.0f;
        }
@@ -4178,9 +4186,10 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa
        if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
                 /* resize preview widget itself */
                scopes->track_preview_height = (but->y2 - but->y1) + (data->dragstarty - my);
-       } else {
-               if(scopes->marker) {
-                       if(scopes->marker->framenr!=scopes->framenr)
+       }
+       else {
+               if (scopes->marker) {
+                       if (scopes->marker->framenr!=scopes->framenr)
                                scopes->marker= BKE_tracking_ensure_marker(scopes->track, scopes->framenr);
 
                        scopes->marker->flag&= ~(MARKER_DISABLED|MARKER_TRACKED);
@@ -4207,8 +4216,8 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan
        my= event->y;
        ui_window_to_block(data->region, block, &mx, &my);
 
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
+               if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
                        data->dragstartx= mx;
                        data->dragstarty= my;
                        data->draglastx= mx;
@@ -4216,25 +4225,25 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan
                        button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 
                        /* also do drag the first time */
-                       if(ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
+                       if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
                                ui_numedit_apply(C, block, but, data);
 
                        return WM_UI_HANDLER_BREAK;
                }
        }
-       else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == ESCKEY) {
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
+               if (event->type == ESCKEY) {
                        data->cancel= 1;
                        data->escapecancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
-               else if(event->type == MOUSEMOVE) {
-                       if(mx!=data->draglastx || my!=data->draglasty) {
-                               if(ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
+               else if (event->type == MOUSEMOVE) {
+                       if (mx!=data->draglastx || my!=data->draglasty) {
+                               if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
                                        ui_numedit_apply(C, block, but, data);
                        }
                }
-               else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+               else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                }
                return WM_UI_HANDLER_BREAK;
@@ -4253,7 +4262,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
                IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
                
                /* complex code to change name of button */
-               if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
+               if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
                                                shortcut_str, sizeof(shortcut_str)))
                {
                        ui_but_add_shortcut(but, shortcut_str, TRUE);
@@ -4316,7 +4325,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
        kmi_id = kmi->id;
 
        /* copy properties, prop can be NULL for reset */       
-       if(prop)
+       if (prop)
                prop= IDP_CopyProperty(prop);
        WM_keymap_properties_reset(kmi, prop);
 
@@ -4379,12 +4388,12 @@ static int ui_but_menu(bContext *C, uiBut *but)
        int length;
        const char *name;
 
-       if((but->rnapoin.data && but->rnaprop)==0 && but->optype==NULL)
+       if ((but->rnapoin.data && but->rnaprop)==0 && but->optype==NULL)
                return 0;
        
        button_timers_tooltip_remove(C, but);
 
-       if(but->rnaprop)
+       if (but->rnaprop)
                name= RNA_property_ui_name(but->rnaprop);
        else if (but->optype)
                name= but->optype->name;
@@ -4396,19 +4405,19 @@ static int ui_but_menu(bContext *C, uiBut *but)
        
        uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
 
-       if(but->rnapoin.data && but->rnaprop) {
+       if (but->rnapoin.data && but->rnaprop) {
                short is_anim= RNA_property_animateable(&but->rnapoin, but->rnaprop);
 
                /* second slower test, saved people finding keyframe items in menus when its not possible */
-               if(is_anim)
+               if (is_anim)
                        is_anim= RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop);
 
                length= RNA_property_array_length(&but->rnapoin, but->rnaprop);
                
                /* Keyframes */
-               if(but->flag & UI_BUT_ANIMATED_KEY) {
+               if (but->flag & UI_BUT_ANIMATED_KEY) {
                        /* replace/delete keyfraemes */
-                       if(length) {
+                       if (length) {
                                uiItemBooleanO(layout, "Replace Keyframes", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1);
                                uiItemBooleanO(layout, "Replace Single Keyframe", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0);
                                uiItemBooleanO(layout, "Delete Keyframes", ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1);
@@ -4424,9 +4433,9 @@ static int ui_but_menu(bContext *C, uiBut *but)
                        
                        
                }
-               else if(but->flag & UI_BUT_DRIVEN);
-               else if(is_anim) {
-                       if(length) {
+               else if (but->flag & UI_BUT_DRIVEN);
+               else if (is_anim) {
+                       if (length) {
                                uiItemBooleanO(layout, "Insert Keyframes", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1);
                                uiItemBooleanO(layout, "Insert Single Keyframe", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0);
                        }
@@ -4435,10 +4444,10 @@ static int ui_but_menu(bContext *C, uiBut *but)
                }
                
                /* Drivers */
-               if(but->flag & UI_BUT_DRIVEN) {
+               if (but->flag & UI_BUT_DRIVEN) {
                        uiItemS(layout);
 
-                       if(length) {
+                       if (length) {
                                uiItemBooleanO(layout, "Delete Drivers", ICON_NONE, "ANIM_OT_driver_button_remove", "all", 1);
                                uiItemBooleanO(layout, "Delete Single Driver", ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0);
                        }
@@ -4449,11 +4458,11 @@ static int ui_but_menu(bContext *C, uiBut *but)
                        if (ANIM_driver_can_paste())
                                uiItemO(layout, "Paste Driver", ICON_NONE, "ANIM_OT_paste_driver_button");
                }
-               else if(but->flag & (UI_BUT_ANIMATED_KEY|UI_BUT_ANIMATED));
-               else if(is_anim) {
+               else if (but->flag & (UI_BUT_ANIMATED_KEY|UI_BUT_ANIMATED));
+               else if (is_anim) {
                        uiItemS(layout);
 
-                       if(length) {
+                       if (length) {
                                uiItemBooleanO(layout, "Add Drivers", ICON_NONE, "ANIM_OT_driver_button_add", "all", 1);
                                uiItemBooleanO(layout, "Add Single Driver", ICON_NONE, "ANIM_OT_driver_button_add", "all", 0);
                        }
@@ -4466,10 +4475,10 @@ static int ui_but_menu(bContext *C, uiBut *but)
                
                /* Keying Sets */
                // TODO: check on modifyability of Keying Set when doing this
-               if(is_anim) {
+               if (is_anim) {
                        uiItemS(layout);
 
-                       if(length) {
+                       if (length) {
                                uiItemBooleanO(layout, "Add All to Keying Set", ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 1);
                                uiItemBooleanO(layout, "Add Single to Keying Set", ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 0);
                                uiItemO(layout, "Remove from Keying Set", ICON_NONE, "ANIM_OT_keyingset_button_remove");
@@ -4487,7 +4496,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
                //Copy Property Value
                //Paste Property Value
                
-               if(length) {
+               if (length) {
                        uiItemBooleanO(layout, "Reset All to Default Values", ICON_NONE, "UI_OT_reset_default_button", "all", 1);
                        uiItemBooleanO(layout, "Reset Single to Default Value", ICON_NONE, "UI_OT_reset_default_button", "all", 0);
                }
@@ -4501,7 +4510,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
        }
 
        /* Operator buttons */
-       if(but->optype) {
+       if (but->optype) {
                uiBlock *block = uiLayoutGetBlock(layout);
                uiBut *but2;
                IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
@@ -4539,7 +4548,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
                char buf[512];
                PointerRNA ptr_props;
 
-               if(but->rnapoin.data && but->rnaprop) {
+               if (but->rnapoin.data && but->rnaprop) {
                        BLI_snprintf(buf, sizeof(buf), "%s.%s", RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop));
 
                        WM_operator_properties_create(&ptr_props, "WM_OT_doc_view");
@@ -4588,27 +4597,27 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
        data= but->active;
        retval= WM_UI_HANDLER_CONTINUE;
 
-       if(but->flag & UI_BUT_DISABLED)
+       if (but->flag & UI_BUT_DISABLED)
                return WM_UI_HANDLER_CONTINUE;
 
-       if    (data->state == BUTTON_STATE_HIGHLIGHT) &&
+       if (    (data->state == BUTTON_STATE_HIGHLIGHT) &&
                /* check prevval because of modal operators [#24016],
                 * modifier check is to allow Ctrl+C for copy.
                 * if this causes other problems, remove this check and suffer the bug :) - campbell */
                ((event->prevval != KM_PRESS) || (ISKEYMODIFIER(event->prevtype)) || (event->type == EVT_DROP))
        ) {
                /* handle copy-paste */
-               if(ELEM(event->type, CKEY, VKEY) && event->val==KM_PRESS && (event->ctrl || event->oskey)) {
+               if (ELEM(event->type, CKEY, VKEY) && event->val==KM_PRESS && (event->ctrl || event->oskey)) {
                        ui_but_copy_paste(C, but, data, (event->type == CKEY)? 'c': 'v');
                        return WM_UI_HANDLER_BREAK;
                }
                /* handle drop */
-               else if(event->type == EVT_DROP) {
+               else if (event->type == EVT_DROP) {
                        ui_but_drop     (C, event, but, data);
                }
                /* handle keyframing */
-               else if(event->type == IKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
-                       if(event->alt)
+               else if (event->type == IKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
+                       if (event->alt)
                                ui_but_anim_delete_keyframe(C);
                        else
                                ui_but_anim_insert_keyframe(C);
@@ -4618,8 +4627,8 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
                        return WM_UI_HANDLER_BREAK;
                }
                /* handle drivers */
-               else if(event->type == DKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
-                       if(event->alt)
+               else if (event->type == DKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
+                       if (event->alt)
                                ui_but_anim_remove_driver(C);
                        else
                                ui_but_anim_add_driver(C);
@@ -4629,8 +4638,8 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
                        return WM_UI_HANDLER_BREAK;
                }
                /* handle keyingsets */
-               else if(event->type == KKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
-                       if(event->alt)
+               else if (event->type == KKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
+                       if (event->alt)
                                ui_but_anim_remove_keyingset(C);
                        else
                                ui_but_anim_add_keyingset(C);
@@ -4641,13 +4650,13 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
                }
                /* reset to default */
                /* XXX hardcoded keymap check.... */
-               else if(event->type == BACKSPACEKEY && event->val == KM_PRESS) {
+               else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
                        /* ctrl+backspace = reset active button; backspace = reset a whole array*/
                        if (!(ELEM3(but->type, HSVCIRCLE, HSVCUBE, HISTOGRAM)))
                                ui_set_but_default(C, !event->ctrl);
                }
                /* handle menu */
-               else if(event->type == RIGHTMOUSE && event->val == KM_PRESS) {
+               else if (event->type == RIGHTMOUSE && event->val == KM_PRESS) {
                        /* RMB has two options now */
                        if (ui_but_menu(C, but)) {
                                return WM_UI_HANDLER_BREAK;
@@ -4656,16 +4665,16 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
        }
 
        /* verify if we can edit this button */
-       if(ELEM(event->type, LEFTMOUSE, RETKEY)) {
+       if (ELEM(event->type, LEFTMOUSE, RETKEY)) {
                /* this should become disabled button .. */
-               if(but->lock) {
-                       if(but->lockstr) {
+               if (but->lock) {
+                       if (but->lockstr) {
                                BKE_report(NULL, RPT_WARNING, but->lockstr);
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                                return WM_UI_HANDLER_BREAK;
                        }
                } 
-               else if(but->pointype && but->poin==NULL) {
+               else if (but->pointype && but->poin==NULL) {
                        /* there's a pointer needed */
                        BKE_reportf(NULL, RPT_WARNING, "DoButton pointer error: %s", but->str);
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -4741,7 +4750,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
                retval= ui_do_but_BUT(C, but, data, event);
                break;
        case COL:
-               if(but->a1 == UI_GRAD_V_ALT)  // signal to prevent calling up color picker
+               if (but->a1 == UI_GRAD_V_ALT)  // signal to prevent calling up color picker
                        retval= ui_do_but_EXIT(C, but, data, event);
                else
                        retval= ui_do_but_BLOCK(C, but, data, event);
@@ -4791,9 +4800,9 @@ static uiBut *ui_but_find_activated(ARegion *ar)
        uiBlock *block;
        uiBut *but;
 
-       for(block=ar->uiblocks.first; block; block=block->next)
-               for(but=block->buttons.first; but; but= but->next)
-                       if(but->active)
+       for (block=ar->uiblocks.first; block; block=block->next)
+               for (but=block->buttons.first; but; but= but->next)
+                       if (but->active)
                                return but;
 
        return NULL;
@@ -4809,15 +4818,15 @@ void uiFreeActiveButtons(const bContext *C, bScreen *screen)
 {
        ScrArea *sa= screen->areabase.first;
        
-       for(;sa; sa= sa->next) {
+       for (;sa; sa= sa->next) {
                ARegion *ar= sa->regionbase.first;
-               for(;ar; ar= ar->next) {
+               for (;ar; ar= ar->next) {
                        uiBut *but= ui_but_find_activated(ar);
-                       if(but) {
+                       if (but) {
                                uiHandleButtonData *data= but->active;
                                
-                               if(data->menu==NULL && data->searchbox==NULL)
-                                       if(data->state == BUTTON_STATE_HIGHLIGHT)
+                               if (data->menu==NULL && data->searchbox==NULL)
+                                       if (data->state == BUTTON_STATE_HIGHLIGHT)
                                                ui_button_active_free(C, but);
                        }
                }
@@ -4833,8 +4842,8 @@ int UI_but_active_drop_name(bContext *C)
        ARegion *ar= CTX_wm_region(C);
        uiBut *but= ui_but_find_activated(ar);
 
-       if(but) {
-               if(ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU))
+       if (but) {
+               if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU))
                        return 1;
        }
        
@@ -4845,12 +4854,12 @@ static void ui_blocks_set_tooltips(ARegion *ar, int enable)
 {
        uiBlock *block;
 
-       if(!ar)
+       if (!ar)
                return;
 
        /* we disabled buttons when when they were already shown, and
         * re-enable them on mouse move */
-       for(block=ar->uiblocks.first; block; block=block->next)
+       for (block=ar->uiblocks.first; block; block=block->next)
                block->tooltipdisabled= !enable;
 }
 
@@ -4859,8 +4868,8 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y)
        uiBlock *block;
        
        /* check if the mouse is in the region */
-       if(!BLI_in_rcti(&ar->winrct, x, y)) {
-               for(block=ar->uiblocks.first; block; block=block->next)
+       if (!BLI_in_rcti(&ar->winrct, x, y)) {
+               for (block=ar->uiblocks.first; block; block=block->next)
                        block->auto_open= FALSE;
                
                return 0;
@@ -4871,7 +4880,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y)
         * even when they are not visible, so we need to make a copy of the mask to
         * use to check
         */
-       if(ar->v2d.mask.xmin!=ar->v2d.mask.xmax) {
+       if (ar->v2d.mask.xmin!=ar->v2d.mask.xmax) {
                View2D *v2d= &ar->v2d;
                rcti mask_rct;
                int mx, my;
@@ -4901,7 +4910,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y)
                }
                
                /* check if in the rect */
-               if(!BLI_in_rcti(&mask_rct, mx, my)) 
+               if (!BLI_in_rcti(&mask_rct, mx, my)) 
                        return 0;
        }
        
@@ -4910,12 +4919,12 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y)
 
 static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y)
 {
-       if(!ui_mouse_inside_region(ar, x, y))
+       if (!ui_mouse_inside_region(ar, x, y))
                return 0;
 
        ui_window_to_block(ar, but->block, &x, &y);
 
-       if(!ui_but_contains_pt(but, x, y))
+       if (!ui_but_contains_pt(but, x, y))
                return 0;
        
        return 1;
@@ -4927,34 +4936,34 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y)
        uiBut *but, *butover= NULL;
        int mx, my;
 
-//     if(!win->active)
+//     if (!win->active)
 //             return NULL;
-       if(!ui_mouse_inside_region(ar, x, y))
+       if (!ui_mouse_inside_region(ar, x, y))
                return NULL;
 
-       for(block=ar->uiblocks.first; block; block=block->next) {
+       for (block=ar->uiblocks.first; block; block=block->next) {
                mx= x;
                my= y;
                ui_window_to_block(ar, block, &mx, &my);
 
-               for(but=block->buttons.first; but; but= but->next) {
+               for (but=block->buttons.first; but; but= but->next) {
                        /* note, LABEL is included for hilights, this allows drags */
-                       if(but->type==LABEL && but->dragpoin==NULL)
+                       if (but->type==LABEL && but->dragpoin==NULL)
                                continue;
-                       if(ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX))
+                       if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX))
                                continue;
-                       if(but->flag & UI_HIDDEN)
+                       if (but->flag & UI_HIDDEN)
                                continue;
-                       if(but->flag & UI_SCROLLED)
+                       if (but->flag & UI_SCROLLED)
                                continue;
-                       if(ui_but_contains_pt(but, mx, my))
+                       if (ui_but_contains_pt(but, mx, my))
                                butover= but;
                }
 
                /* CLIP_EVENTS prevents the event from reaching other blocks */
                if (block->flag & UI_BLOCK_CLIP_EVENTS) {
                        /* check if mouse is inside block */
-                       if(block->minx <= mx && block->maxx >= mx &&
+                       if (block->minx <= mx && block->maxx >= mx &&
                           block->miny <= my && block->maxy >= my)
                                break;
                }
@@ -4969,18 +4978,18 @@ static uiBut *ui_list_find_mouse_over(ARegion *ar, int x, int y)
        uiBut *but;
        int mx, my;
 
-//     if(!win->active)
+//     if (!win->active)
 //             return NULL;
-       if(!ui_mouse_inside_region(ar, x, y))
+       if (!ui_mouse_inside_region(ar, x, y))
                return NULL;
 
-       for(block=ar->uiblocks.first; block; block=block->next) {
+       for (block=ar->uiblocks.first; block; block=block->next) {
                mx= x;
                my= y;
                ui_window_to_block(ar, block, &mx, &my);
 
-               for(but=block->buttons.last; but; but= but->prev)
-                       if(but->type == LISTBOX && ui_but_contains_pt(but, mx, my))
+               for (but=block->buttons.last; but; but= but->prev)
+                       if (but->type == LISTBOX && ui_but_contains_pt(but, mx, my))
                                return but;
        }
 
@@ -5001,18 +5010,18 @@ static void button_timers_tooltip_remove(bContext *C, uiBut *but)
        uiHandleButtonData *data;
 
        data= but->active;
-       if(data) {
+       if (data) {
 
-               if(data->tooltiptimer) {
+               if (data->tooltiptimer) {
                        WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
                        data->tooltiptimer= NULL;
                }
-               if(data->tooltip) {
+               if (data->tooltip) {
                        ui_tooltip_free(C, data->tooltip);
                        data->tooltip= NULL;
                }
 
-               if(data->autoopentimer) {
+               if (data->autoopentimer) {
                        WM_event_remove_timer(data->wm, data->window, data->autoopentimer);
                        data->autoopentimer= NULL;
                }
@@ -5026,14 +5035,14 @@ static void button_tooltip_timer_reset(bContext *C, uiBut *but)
 
        data= but->active;
 
-       if(data->tooltiptimer) {
+       if (data->tooltiptimer) {
                WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
                data->tooltiptimer= NULL;
        }
 
-       if(U.flag & USER_TOOLTIPS)
-               if(!but->block->tooltipdisabled)
-                       if(!wm->drags.first)
+       if (U.flag & USER_TOOLTIPS)
+               if (!but->block->tooltipdisabled)
+                       if (!wm->drags.first)
                                data->tooltiptimer= WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_TOOLTIP_DELAY);
 }
 
@@ -5042,26 +5051,26 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
        uiHandleButtonData *data;
 
        data= but->active;
-       if(data->state == state)
+       if (data->state == state)
                return;
 
        /* highlight has timers for tooltips and auto open */
-       if(state == BUTTON_STATE_HIGHLIGHT) {
+       if (state == BUTTON_STATE_HIGHLIGHT) {
                but->flag &= ~UI_SELECT;
 
                button_tooltip_timer_reset(C, but);
 
                /* automatic open pulldown block timer */
-               if(ELEM3(but->type, BLOCK, PULLDOWN, ICONTEXTROW)) {
-                       if(data->used_mouse && !data->autoopentimer) {
+               if (ELEM3(but->type, BLOCK, PULLDOWN, ICONTEXTROW)) {
+                       if (data->used_mouse && !data->autoopentimer) {
                                int time;
 
-                               if(but->block->auto_open==TRUE) time= 1;    // test for toolbox
-                               else if((but->block->flag & UI_BLOCK_LOOP && but->type != BLOCK) || but->block->auto_open==TRUE) time= 5*U.menuthreshold2;
-                               else if(U.uiflag & USER_MENUOPENAUTO) time= 5*U.menuthreshold1;
+                               if (but->block->auto_open==TRUE) time= 1;    // test for toolbox
+                               else if ((but->block->flag & UI_BLOCK_LOOP && but->type != BLOCK) || but->block->auto_open==TRUE) time= 5*U.menuthreshold2;
+                               else if (U.uiflag & USER_MENUOPENAUTO) time= 5*U.menuthreshold1;
                                else time= -1;
 
-                               if(time >= 0)
+                               if (time >= 0)
                                        data->autoopentimer= WM_event_add_timer(data->wm, data->window, TIMER, 0.02*(double)time);
                        }
                }
@@ -5072,65 +5081,66 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
        }
        
        /* text editing */
-       if(state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING)
+       if (state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING)
                ui_textedit_begin(C, but, data);
-       else if(data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING)
+       else if (data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING)
                ui_textedit_end(C, but, data);
-       else if(data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING)
+       else if (data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING)
                ui_textedit_end(C, but, data);
        
        /* number editing */
-       if(state == BUTTON_STATE_NUM_EDITING) {
-               if(ui_is_a_warp_but(but))
+       if (state == BUTTON_STATE_NUM_EDITING) {
+               if (ui_is_a_warp_but(but))
                        WM_cursor_grab(CTX_wm_window(C), TRUE, TRUE, NULL);
                ui_numedit_begin(but, data);
-       } else if(data->state == BUTTON_STATE_NUM_EDITING) {
+       }
+       else if (data->state == BUTTON_STATE_NUM_EDITING) {
                ui_numedit_end(but, data);
-               if(ui_is_a_warp_but(but))
+               if (ui_is_a_warp_but(but))
                        WM_cursor_ungrab(CTX_wm_window(C));
        }
        /* menu open */
-       if(state == BUTTON_STATE_MENU_OPEN)
+       if (state == BUTTON_STATE_MENU_OPEN)
                ui_blockopen_begin(C, but, data);
-       else if(data->state == BUTTON_STATE_MENU_OPEN)
+       else if (data->state == BUTTON_STATE_MENU_OPEN)
                ui_blockopen_end(C, but, data);
 
        /* add a short delay before exiting, to ensure there is some feedback */
-       if(state == BUTTON_STATE_WAIT_FLASH) {
+       if (state == BUTTON_STATE_WAIT_FLASH) {
                data->flashtimer= WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_FLASH_DELAY);
        }
-       else if(data->flashtimer) {
+       else if (data->flashtimer) {
                WM_event_remove_timer(data->wm, data->window, data->flashtimer);
                data->flashtimer= NULL;
        }
 
        /* add a blocking ui handler at the window handler for blocking, modal states
         * but not for popups, because we already have a window level handler*/
-       if(!(but->block->handle && but->block->handle->popup)) {
-               if(button_modal_state(state)) {
-                       if(!button_modal_state(data->state))
+       if (!(but->block->handle && but->block->handle->popup)) {
+               if (button_modal_state(state)) {
+                       if (!button_modal_state(data->state))
                                WM_event_add_ui_handler(C, &data->window->modalhandlers, ui_handler_region_menu, NULL, data);
                }
                else {
-                       if(button_modal_state(data->state))
+                       if (button_modal_state(data->state))
                                WM_event_remove_ui_handler(&data->window->modalhandlers, ui_handler_region_menu, NULL, data, 1); /* 1 = postpone free */
                }
        }
        
        /* wait for mousemove to enable drag */
-       if(state == BUTTON_STATE_WAIT_DRAG) {
+       if (state == BUTTON_STATE_WAIT_DRAG) {
                but->flag &= ~UI_SELECT;
        }
 
        data->state= state;
 
-       if(state != BUTTON_STATE_EXIT) {
+       if (state != BUTTON_STATE_EXIT) {
                /* When objects for eg. are removed, running ui_check_but() can access
                 * the removed data - so disable update on exit. Also in case of
                 * highlight when not in a popup menu, we remove because data used in
                 * button below popup might have been removed by action of popup. Needs
                 * a more reliable solution... */
-               if(state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP))
+               if (state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP))
                        ui_check_but(but);
        }
 
@@ -5147,7 +5157,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
        data->wm= CTX_wm_manager(C);
        data->window= CTX_wm_window(C);
        data->region= ar;
-       if( ELEM(but->type, BUT_CURVE, SEARCH_MENU) );  // XXX curve is temp
+       if ( ELEM(but->type, BUT_CURVE, SEARCH_MENU) );  // XXX curve is temp
        else data->interactive= 1;
        
        data->state = BUTTON_STATE_INIT;
@@ -5159,42 +5169,42 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
        /* we disable auto_open in the block after a threshold, because we still
         * want to allow auto opening adjacent menus even if no button is activated
         * in between going over to the other button, but only for a short while */
-       if(type == BUTTON_ACTIVATE_OVER && but->block->auto_open==TRUE)
-               if(but->block->auto_open_last+BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer())
+       if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open==TRUE)
+               if (but->block->auto_open_last+BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer())
                        but->block->auto_open= FALSE;
 
-       if(type == BUTTON_ACTIVATE_OVER) {
+       if (type == BUTTON_ACTIVATE_OVER) {
                data->used_mouse= 1;
        }
        button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
        
        /* activate right away */
-       if(but->flag & UI_BUT_IMMEDIATE) {
-               if(but->type==HOTKEYEVT)
+       if (but->flag & UI_BUT_IMMEDIATE) {
+               if (but->type==HOTKEYEVT)
                        button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
                /* .. more to be added here */
        }
        
-       if(type == BUTTON_ACTIVATE_OPEN) {
+       if (type == BUTTON_ACTIVATE_OPEN) {
                button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
 
                /* activate first button in submenu */
-               if(data->menu && data->menu->region) {
+               if (data->menu && data->menu->region) {
                        ARegion *subar= data->menu->region;
                        uiBlock *subblock= subar->uiblocks.first;
                        uiBut *subbut;
                        
-                       if(subblock) {
+                       if (subblock) {
                                subbut= ui_but_first(subblock);
 
-                               if(subbut)
+                               if (subbut)
                                        ui_handle_button_activate(C, subar, subbut, BUTTON_ACTIVATE);
                        }
                }
        }
-       else if(type == BUTTON_ACTIVATE_TEXT_EDITING)
+       else if (type == BUTTON_ACTIVATE_TEXT_EDITING)
                button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
-       else if(type == BUTTON_ACTIVATE_APPLY)
+       else if (type == BUTTON_ACTIVATE_APPLY)
                button_activate_state(C, but, BUTTON_STATE_WAIT_FLASH);
 }
 
@@ -5204,18 +5214,18 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
        uiBut *bt;
 
        /* ensure we are in the exit state */
-       if(data->state != BUTTON_STATE_EXIT)
+       if (data->state != BUTTON_STATE_EXIT)
                button_activate_state(C, but, BUTTON_STATE_EXIT);
 
        /* apply the button action or value */
-       if(!onfree)
+       if (!onfree)
                ui_apply_button(C, block, but, data, 0);
 
        /* if this button is in a menu, this will set the button return
         * value to the button value and the menu return value to ok, the
         * menu return value will be picked up and the menu will close */
-       if(block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN)) {
-               if(!data->cancel || data->escapecancel) {
+       if (block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN)) {
+               if (!data->cancel || data->escapecancel) {
                        uiPopupBlockHandle *menu;
 
                        menu= block->handle;
@@ -5224,18 +5234,18 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
                }
        }
 
-       if(!onfree && !data->cancel) {
+       if (!onfree && !data->cancel) {
                /* autokey & undo push */
                ui_apply_autokey_undo(C, but);
 
                /* popup menu memory */
-               if(block->flag & UI_BLOCK_POPUP_MEMORY)
+               if (block->flag & UI_BLOCK_POPUP_MEMORY)
                        ui_popup_menu_memory(block, but);
        }
 
        /* disable tooltips until mousemove + last active flag */
-       for(block=data->region->uiblocks.first; block; block=block->next) {
-               for(bt=block->buttons.first; bt; bt=bt->next)
+       for (block=data->region->uiblocks.first; block; block=block->next) {
+               for (bt=block->buttons.first; bt; bt=bt->next)
                        bt->flag &= ~UI_BUT_LAST_ACTIVE;
 
                block->tooltipdisabled= 1;
@@ -5244,9 +5254,9 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
        ui_blocks_set_tooltips(data->region, 0);
 
        /* clean up */
-       if(data->str)
+       if (data->str)
                MEM_freeN(data->str);
-       if(data->origstr)
+       if (data->origstr)
                MEM_freeN(data->origstr);
 
        /* redraw (data is but->active!) */
@@ -5257,13 +5267,13 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
        but->active= NULL;
        but->flag &= ~(UI_ACTIVE|UI_SELECT);
        but->flag |= UI_BUT_LAST_ACTIVE;
-       if(!onfree)
+       if (!onfree)
                ui_check_but(but);
 
        /* adds empty mousemove in queue for re-init handler, in case mouse is
         * still over a button. we cannot just check for this ourselfs because
         * at this point the mouse may be over a button in another region */
-       if(mousemove)
+       if (mousemove)
                WM_event_add_mousemove(C);
 }
 
@@ -5274,7 +5284,7 @@ void ui_button_active_free(const bContext *C, uiBut *but)
        /* this gets called when the button somehow disappears while it is still
         * active, this is bad for user interaction, but we need to handle this
         * case cleanly anyway in case it happens */
-       if(but->active) {
+       if (but->active) {
                data= but->active;
                data->cancel= 1;
                button_activate_exit((bContext*)C, data, but, 0, 1);
@@ -5288,27 +5298,27 @@ static uiBut *ui_context_button_active(const bContext *C, int (*but_check_cb)(ui
 
        ARegion *ar= CTX_wm_region(C);
 
-       while(ar) {
+       while (ar) {
                uiBlock *block;
                uiBut *but, *activebut= NULL;
 
                /* find active button */
-               for(block=ar->uiblocks.first; block; block=block->next) {
-                       for(but=block->buttons.first; but; but= but->next) {
-                               if(but->active)
+               for (block=ar->uiblocks.first; block; block=block->next) {
+                       for (but=block->buttons.first; but; but= but->next) {
+                               if (but->active)
                                        activebut= but;
-                               else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
+                               else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
                                        activebut= but;
                        }
                }
 
-               if(activebut && (but_check_cb == NULL || but_check_cb(activebut))) {
+               if (activebut && (but_check_cb == NULL || but_check_cb(activebut))) {
                        uiHandleButtonData *data= activebut->active;
 
                        but_found= activebut;
 
                        /* recurse into opened menu, like colorpicker case */
-                       if(data && data->menu && (ar != data->menu->region)) {
+                       if (data && data->menu && (ar != data->menu->region)) {
                                ar = data->menu->region;
                        }
                        else {
@@ -5345,7 +5355,7 @@ void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct P
 
        memset(ptr, 0, sizeof(*ptr));
 
-       if(activebut && activebut->rnapoin.data) {
+       if (activebut && activebut->rnapoin.data) {
                *ptr= activebut->rnapoin;
                *prop= activebut->rnaprop;
                *index= activebut->rnaindex;
@@ -5359,7 +5369,7 @@ void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct P
 void uiContextActivePropertyHandle(bContext *C)
 {
        uiBut *activebut= ui_context_rna_button_active(C);
-       if(activebut) {
+       if (activebut) {
                /* TODO, look into a better way to handle the button change
                 * currently this is mainly so reset defaults works for the
                 * operator redo panel - campbell */
@@ -5381,7 +5391,7 @@ wmOperator *uiContextActiveOperator(const struct bContext *C)
        }
 
        /* scan active regions ui */
-       for(block=ar_ctx->uiblocks.first; block; block=block->next) {
+       for (block=ar_ctx->uiblocks.first; block; block=block->next) {
                if (block->ui_operator) {
                        return block->ui_operator;
                }
@@ -5396,7 +5406,7 @@ wmOperator *uiContextActiveOperator(const struct bContext *C)
                        if (ar == ar_ctx) {
                                continue;
                        }
-                       for(block=ar->uiblocks.first; block; block=block->next) {
+                       for (block=ar->uiblocks.first; block; block=block->next) {
                                if (block->ui_operator) {
                                        return block->ui_operator;
                                }
@@ -5415,26 +5425,26 @@ void uiContextAnimUpdate(const bContext *C)
        uiBlock *block;
        uiBut *but, *activebut;
 
-       while(ar) {
+       while (ar) {
                /* find active button */
                activebut= NULL;
 
-               for(block=ar->uiblocks.first; block; block=block->next) {
-                       for(but=block->buttons.first; but; but= but->next) {
+               for (block=ar->uiblocks.first; block; block=block->next) {
+                       for (but=block->buttons.first; but; but= but->next) {
                                ui_but_anim_flag(but, (scene)? scene->r.cfra: 0.0f);
                                ED_region_tag_redraw(ar);
                                
-                               if(but->active)
+                               if (but->active)
                                        activebut= but;
-                               else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
+                               else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
                                        activebut= but;
                        }
                }
 
-               if(activebut) {
+               if (activebut) {
                        /* always recurse into opened menu, so all buttons update (like colorpicker) */
                        uiHandleButtonData *data= activebut->active;
-                       if(data && data->menu)
+                       if (data && data->menu)
                                ar = data->menu->region;
                        else
                                return;
@@ -5453,9 +5463,9 @@ static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event)
        uiBlock *block;
        uiBut *but;
        
-       for(block=ar->uiblocks.first; block; block=block->next) {
-               for(but=block->buttons.first; but; but= but->next)
-                       if(but==event->customdata)
+       for (block=ar->uiblocks.first; block; block=block->next) {
+               for (but=block->buttons.first; but; but= but->next)
+                       if (but==event->customdata)
                                return but;
        }
        return NULL;
@@ -5465,14 +5475,14 @@ static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar)
 {
        uiBut *but;
 
-       if(event->type == MOUSEMOVE) {
+       if (event->type == MOUSEMOVE) {
                but= ui_but_find_mouse_over(ar, event->x, event->y);
-               if(but)
+               if (but)
                        button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
        }
-       else if(event->type == EVT_BUT_OPEN) {
+       else if (event->type == EVT_BUT_OPEN) {
                but= uit_but_find_open_event(ar, event);
-               if(but) {
+               if (but) {
                        button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
                        ui_do_button(C, but->block, but, event);
                }
@@ -5504,7 +5514,7 @@ static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiBu
        uiHandleButtonData *data;
 
        oldbut= ui_but_find_activated(ar);
-       if(oldbut) {
+       if (oldbut) {
                data= oldbut->active;
                data->cancel= 1;
                button_activate_exit(C, data, oldbut, 0, 0);
@@ -5530,7 +5540,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
 
        retval= WM_UI_HANDLER_CONTINUE;
        
-       if(data->state == BUTTON_STATE_HIGHLIGHT) {
+       if (data->state == BUTTON_STATE_HIGHLIGHT) {
                switch(event->type) {
                        case WINDEACTIVATE:
                        case EVT_BUT_CANCEL:
@@ -5540,15 +5550,15 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
                                break;
                        case MOUSEMOVE:
                                /* verify if we are still over the button, if not exit */
-                               if(!ui_mouse_inside_button(ar, but, event->x, event->y)) {
+                               if (!ui_mouse_inside_button(ar, but, event->x, event->y)) {
                                        data->cancel= 1;
                                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                                }
-                               else if(ui_but_find_mouse_over(ar, event->x, event->y) != but) {
+                               else if (ui_but_find_mouse_over(ar, event->x, event->y) != but) {
                                        data->cancel= 1;
                                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                                }
-                               else if(event->x!=event->prevx || event->y!=event->prevy) {
+                               else if (event->x!=event->prevx || event->y!=event->prevy) {
                                        /* re-enable tooltip on mouse move */
                                        ui_blocks_set_tooltips(ar, 1);
                                        button_tooltip_timer_reset(C, but);
@@ -5557,19 +5567,19 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
                                break;
                        case TIMER: {
                                /* handle tooltip timer */
-                               if(event->customdata == data->tooltiptimer) {
+                               if (event->customdata == data->tooltiptimer) {
                                        WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
                                        data->tooltiptimer= NULL;
 
-                                       if(!data->tooltip)
+                                       if (!data->tooltip)
                                                data->tooltip= ui_tooltip_create(C, data->region, but);
                                }
                                /* handle menu auto open timer */
-                               else if(event->customdata == data->autoopentimer) {
+                               else if (event->customdata == data->autoopentimer) {
                                        WM_event_remove_timer(data->wm, data->window, data->autoopentimer);
                                        data->autoopentimer= NULL;
 
-                                       if(ui_mouse_inside_button(ar, but, event->x, event->y))
+                                       if (ui_mouse_inside_button(ar, but, event->x, event->y))
                                                button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
                                }
 
@@ -5579,7 +5589,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
                        case WHEELDOWNMOUSE:
                        case MIDDLEMOUSE:
                                /* XXX hardcoded keymap check... but anyway, while view changes, tooltips should be removed */
-                               if(data->tooltiptimer) {
+                               if (data->tooltiptimer) {
                                        WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
                                        data->tooltiptimer= NULL;
                                }
@@ -5590,7 +5600,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
                        }
                }
        }
-       else if(data->state == BUTTON_STATE_WAIT_RELEASE) {
+       else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
                switch(event->type) {
                        case WINDEACTIVATE:
                                data->cancel= 1;
@@ -5598,7 +5608,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
                                break;
 
                        case MOUSEMOVE:
-                               if(ELEM(but->type,LINK, INLINK)) {
+                               if (ELEM(but->type,LINK, INLINK)) {
                                        but->flag |= UI_SELECT;
                                        ui_do_button(C, block, but, event);
                                        ED_region_tag_redraw(data->region);
@@ -5606,15 +5616,15 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
                                else {
                                        /* deselect the button when moving the mouse away */
                                        /* also de-activate for buttons that only show higlights */
-                                       if(ui_mouse_inside_button(ar, but, event->x, event->y)) {
-                                               if(!(but->flag & UI_SELECT)) {
+                                       if (ui_mouse_inside_button(ar, but, event->x, event->y)) {
+                                               if (!(but->flag & UI_SELECT)) {
                                                        but->flag |= (UI_SELECT|UI_ACTIVE);
                                                        data->cancel= 0;
                                                        ED_region_tag_redraw(data->region);
                                                }
                                        }
                                        else {
-                                               if(but->flag & UI_SELECT) {
+                                               if (but->flag & UI_SELECT) {
                                                        but->flag &= ~(UI_SELECT|UI_ACTIVE);
                                                        data->cancel= 1;
                                                        ED_region_tag_redraw(data->region);
@@ -5630,30 +5640,30 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
 
                retval= WM_UI_HANDLER_BREAK;
        }
-       else if(data->state == BUTTON_STATE_WAIT_FLASH) {
+       else if (data->state == BUTTON_STATE_WAIT_FLASH) {
                switch(event->type) {
                        case TIMER: {
-                               if(event->customdata == data->flashtimer)
+                               if (event->customdata == data->flashtimer)
                                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                        }
                }
 
                retval= WM_UI_HANDLER_CONTINUE;
        }
-       else if(data->state == BUTTON_STATE_MENU_OPEN) {
+       else if (data->state == BUTTON_STATE_MENU_OPEN) {
                /* check for exit because of mouse-over another button */
                switch(event->type) {
                        case MOUSEMOVE:
                                
-                               if(data->menu && data->menu->region)
-                                       if(ui_mouse_inside_region(data->menu->region, event->x, event->y))
+                               if (data->menu && data->menu->region)
+                                       if (ui_mouse_inside_region(data->menu->region, event->x, event->y))
                                                break;
                        
                        {
                                uiBut *bt= ui_but_find_mouse_over(ar, event->x, event->y);
 
-                               if(bt && bt->active != data) {
-                                       if(but->type != COL) /* exception */
+                               if (bt && bt->active != data) {
+                                       if (but->type != COL) /* exception */
                                                data->cancel= 1;
                                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                                }
@@ -5669,14 +5679,14 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
                // retval= WM_UI_HANDLER_BREAK; XXX why ? 
        }
 
-       if(data->state == BUTTON_STATE_EXIT) {
+       if (data->state == BUTTON_STATE_EXIT) {
                postbut= data->postbut;
                posttype= data->posttype;
 
                button_activate_exit(C, data, but, (postbut == NULL), 0);
 
                /* for jumping to the next button with tab while text editing */
-               if(postbut)
+               if (postbut)
                        button_activate_init(C, ar, postbut, posttype);
        }
 
@@ -5689,22 +5699,22 @@ static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar)
        int retval= WM_UI_HANDLER_CONTINUE;
        int value, min, max;
 
-       if(but && (event->val == KM_PRESS)) {
+       if (but && (event->val == KM_PRESS)) {
                Panel *pa= but->block->panel;
 
-               if(ELEM(event->type, UPARROWKEY, DOWNARROWKEY) ||
+               if (ELEM(event->type, UPARROWKEY, DOWNARROWKEY) ||
                   ((ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->alt))) {
                        /* activate up/down the list */
                        value= RNA_property_int_get(&but->rnapoin, but->rnaprop);
 
-                       if(ELEM(event->type, UPARROWKEY, WHEELUPMOUSE))
+                       if (ELEM(event->type, UPARROWKEY, WHEELUPMOUSE))
                                value--;
                        else
                                value++;
 
-                       if(value < pa->list_scroll)
+                       if (value < pa->list_scroll)
                                pa->list_scroll= value;
-                       else if(value >= pa->list_scroll+pa->list_size)
+                       else if (value >= pa->list_scroll+pa->list_size)
                                pa->list_scroll= value - pa->list_size + 1;
 
                        RNA_property_int_range(&but->rnapoin, but->rnaprop, &min, &max);
@@ -5716,12 +5726,12 @@ static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar)
 
                        retval= WM_UI_HANDLER_BREAK;
                }
-               else if(ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->shift) {
+               else if (ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->shift) {
                        /* silly replacement for proper grip */
-                       if(pa->list_grip_size == 0)
+                       if (pa->list_grip_size == 0)
                                pa->list_grip_size= pa->list_size;
 
-                       if(event->type == WHEELUPMOUSE)
+                       if (event->type == WHEELUPMOUSE)
                                pa->list_grip_size--;
                        else
                                pa->list_grip_size++;
@@ -5732,10 +5742,10 @@ static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar)
 
                        retval= WM_UI_HANDLER_BREAK;
                }
-               else if(ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) {
-                       if(pa->list_last_len > pa->list_size) {
+               else if (ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) {
+                       if (pa->list_last_len > pa->list_size) {
                                /* list template will clamp */
-                               if(event->type == WHEELUPMOUSE)
+                               if (event->type == WHEELUPMOUSE)
                                        pa->list_scroll--;
                                else
                                        pa->list_scroll++;
@@ -5759,29 +5769,29 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut *
        menu= data->menu;
 
        /* copy over return values from the closing menu */
-       if((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_UPDATE)) {
-               if(but->type == COL)
+       if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_UPDATE)) {
+               if (but->type == COL)
                        copy_v3_v3(data->vec, menu->retvec);
-               else if(ELEM3(but->type, MENU, ICONROW, ICONTEXTROW))
+               else if (ELEM3(but->type, MENU, ICONROW, ICONTEXTROW))
                        data->value= menu->retvalue;
        }
 
-       if(menu->menuretval & UI_RETURN_UPDATE) {
-               if(data->interactive) ui_apply_button(C, but->block, but, data, 1);
+       if (menu->menuretval & UI_RETURN_UPDATE) {
+               if (data->interactive) ui_apply_button(C, but->block, but, data, 1);
                else ui_check_but(but);
 
                menu->menuretval= 0;
        }
        
        /* now change button state or exit, which will close the submenu */
-       if((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) {
-               if(menu->menuretval != UI_RETURN_OK)
+       if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) {
+               if (menu->menuretval != UI_RETURN_OK)
                        data->cancel= 1;
 
                button_activate_exit(C, data, but, 1, 0);
        }
-       else if(menu->menuretval & UI_RETURN_OUT) {
-               if(event->type==MOUSEMOVE && ui_mouse_inside_button(data->region, but, event->x, event->y)) {
+       else if (menu->menuretval & UI_RETURN_OUT) {
+               if (event->type==MOUSEMOVE && ui_mouse_inside_button(data->region, but, event->x, event->y)) {
                        button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
                }
                else {
@@ -5811,12 +5821,12 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut *
 
 static void ui_mouse_motion_towards_init(uiPopupBlockHandle *menu, int mx, int my, int force)
 {
-       if(!menu->dotowards || force) {
+       if (!menu->dotowards || force) {
                menu->dotowards= 1;
                menu->towardsx= mx;
                menu->towardsy= my;
 
-               if(force)
+               if (force)
                        menu->towardstime= DBL_MAX; /* unlimited time */
                else
                        menu->towardstime= PIL_check_seconds_timer();
@@ -5828,7 +5838,7 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men
        float p1[2], p2[2], p3[2], p4[2], oldp[2], newp[2];
        int closer;
 
-       if(!menu->dotowards) return 0;
+       if (!menu->dotowards) return 0;
 
        /* verify that we are moving towards one of the edges of the
         * menu block, in other words, in the triangle formed by the
@@ -5851,7 +5861,7 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men
        newp[0]= mx;
        newp[1]= my;
 
-       if(len_v2v2(oldp, newp) < 4.0f)
+       if (len_v2v2(oldp, newp) < 4.0f)
                return menu->dotowards;
 
        closer= 0;
@@ -5860,11 +5870,11 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men
        closer |= isect_point_tri_v2(newp, oldp, p3, p4);
        closer |= isect_point_tri_v2(newp, oldp, p4, p1);
 
-       if(!closer)
+       if (!closer)
                menu->dotowards= 0;
 
        /* 1 second timer */
-       if(PIL_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH)
+       if (PIL_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH)
                menu->dotowards= 0;
 
        return menu->dotowards;
@@ -5872,12 +5882,12 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men
 
 static char ui_menu_scroll_test(uiBlock *block, int my)
 {
-       if(block->flag & (UI_BLOCK_CLIPTOP|UI_BLOCK_CLIPBOTTOM)) {
-               if(block->flag & UI_BLOCK_CLIPTOP) 
-                       if(my > block->maxy-14)
+       if (block->flag & (UI_BLOCK_CLIPTOP|UI_BLOCK_CLIPBOTTOM)) {
+               if (block->flag & UI_BLOCK_CLIPTOP) 
+                       if (my > block->maxy-14)
                                return 't';
-               if(block->flag & UI_BLOCK_CLIPBOTTOM)
-                       if(my < block->miny+14)
+               if (block->flag & UI_BLOCK_CLIPBOTTOM)
+                       if (my < block->miny+14)
                                return 'b';
        }
        return 0;
@@ -5887,7 +5897,7 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my)
 {
        char test= ui_menu_scroll_test(block, my);
        
-       if(test) {
+       if (test) {
                uiBut *b1= block->buttons.first;
                uiBut *b2= block->buttons.last;
                uiBut *bnext;
@@ -5895,36 +5905,36 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my)
                int dy= 0;
                
                /* get first and last visible buttons */
-               while(b1 && ui_but_next(b1) && (b1->flag & UI_SCROLLED))
+               while (b1 && ui_but_next(b1) && (b1->flag & UI_SCROLLED))
                        b1= ui_but_next(b1);
-               while(b2 && ui_but_prev(b2) && (b2->flag & UI_SCROLLED))
+               while (b2 && ui_but_prev(b2) && (b2->flag & UI_SCROLLED))
                        b2= ui_but_prev(b2);
                /* skips separators */
                bnext= ui_but_next(b1);
                bprev= ui_but_prev(b2);
                
-               if(bnext==NULL || bprev==NULL)
+               if (bnext==NULL || bprev==NULL)
                        return 0;
                
-               if(test=='t') {
+               if (test=='t') {
                        /* bottom button is first button */
-                       if(b1->y1 < b2->y1)
+                       if (b1->y1 < b2->y1)
                                dy= bnext->y1 - b1->y1;
                        /* bottom button is last button */
                        else 
                                dy= bprev->y1 - b2->y1;
                }
-               else if(test=='b') {
+               else if (test=='b') {
                        /* bottom button is first button */
-                       if(b1->y1 < b2->y1)
+                       if (b1->y1 < b2->y1)
                                dy= b1->y1 - bnext->y1;
                        /* bottom button is last button */
                        else 
                                dy= b2->y1 - bprev->y1;
                }
-               if(dy) {
+               if (dy) {
                        
-                       for(b1= block->buttons.first; b1; b1= b1->next) {
+                       for (b1= block->buttons.first; b1; b1= b1->next) {
                                b1->y1 -= dy;
                                b1->y2 -= dy;
                        }
@@ -5959,43 +5969,43 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
 
        /* check if mouse is inside block */
        inside= 0;
-       if(block->minx <= mx && block->maxx >= mx)
-               if(block->miny <= my && block->maxy >= my)
+       if (block->minx <= mx && block->maxx >= mx)
+               if (block->miny <= my && block->maxy >= my)
                        inside= 1;
 
        /* if there's an active modal button, don't check events or outside, except for search menu */
        but= ui_but_find_activated(ar);
-       if(but && button_modal_state(but->active->state) && but->type!=SEARCH_MENU) {
+       if (but && button_modal_state(but->active->state) && but->type!=SEARCH_MENU) {
                /* if a button is activated modal, always reset the start mouse
                 * position of the towards mechanism to avoid loosing focus,
                 * and don't handle events */
                ui_mouse_motion_towards_init(menu, mx, my, 1);
        }
-       else if(event->type == TIMER) {
-               if(event->customdata == menu->scrolltimer)
+       else if (event->type == TIMER) {
+               if (event->customdata == menu->scrolltimer)
                        ui_menu_scroll(ar, block, my);
        }
        else {
                /* for ui_mouse_motion_towards_block */
-               if(event->type == MOUSEMOVE) {
+               if (event->type == MOUSEMOVE) {
                        ui_mouse_motion_towards_init(menu, mx, my, 0);
                        
                        /* add menu scroll timer, if needed */
-                       if(ui_menu_scroll_test(block, my))
-                               if(menu->scrolltimer==NULL)
+                       if (ui_menu_scroll_test(block, my))
+                               if (menu->scrolltimer==NULL)
                                        menu->scrolltimer= 
                                        WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, MENU_SCROLL_INTERVAL);
                }
                
                /* first block own event func */
-               if(block->block_event_func && block->block_event_func(C, block, event));
+               if (block->block_event_func && block->block_event_func(C, block, event));
                /* events not for active search menu button */
-               else if(but==NULL || but->type!=SEARCH_MENU) {
+               else if (but==NULL || but->type!=SEARCH_MENU) {
                        switch(event->type) {
                                /* closing sublevels of pulldowns */
                                case LEFTARROWKEY:
-                                       if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP))
-                                               if(block->saferct.first)
+                                       if (event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP))
+                                               if (block->saferct.first)
                                                        menu->menuretval= UI_RETURN_OUT;
 
                                        retval= WM_UI_HANDLER_BREAK;
@@ -6003,16 +6013,16 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
 
                                /* opening sublevels of pulldowns */
                                case RIGHTARROWKEY:     
-                                       if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
+                                       if (event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
                                                but= ui_but_find_activated(ar);
 
-                                               if(!but) {
+                                               if (!but) {
                                                        /* no item active, we make first active */
-                                                       if(block->direction & UI_TOP) but= ui_but_last(block);
+                                                       if (block->direction & UI_TOP) but= ui_but_last(block);
                                                        else but= ui_but_first(block);
                                                }
 
-                                               if(but && ELEM(but->type, BLOCK, PULLDOWN))
+                                               if (but && ELEM(but->type, BLOCK, PULLDOWN))
                                                        ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN);
                                        }
 
@@ -6024,40 +6034,40 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
                                case WHEELUPMOUSE:
                                case WHEELDOWNMOUSE:
                                        /* arrowkeys: only handle for block_loop blocks */
-                                       if(event->alt || event->shift || event->ctrl || event->oskey);
-                                       else if(inside || (block->flag & UI_BLOCK_LOOP)) {
-                                               if(event->val==KM_PRESS) {
+                                       if (event->alt || event->shift || event->ctrl || event->oskey);
+                                       else if (inside || (block->flag & UI_BLOCK_LOOP)) {
+                                               if (event->val==KM_PRESS) {
                                                        but= ui_but_find_activated(ar);
-                                                       if(but) {
+                                                       if (but) {
                                                                /* is there a situation where UI_LEFT or UI_RIGHT would also change navigation direction? */
-                                                               if    ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DOWN)) ||
+                                                               if (    ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DOWN)) ||
                                                                        ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_RIGHT)) ||
                                                                        ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_TOP))
                                                                ) {
                                                                        /* the following is just a hack - uiBut->type set to BUT and BUTM have there menus built 
                                                                         * opposite ways - this should be changed so that all popup-menus use the same uiBlock->direction */
-                                                                       if(but->type & BUT)
+                                                                       if (but->type & BUT)
                                                                                but= ui_but_next(but);
                                                                        else
                                                                                but= ui_but_prev(but);
                                                                }
                                                                else {
-                                                                       if(but->type & BUT)
+                                                                       if (but->type & BUT)
                                                                                but= ui_but_prev(but);
                                                                        else
                                                                                but= ui_but_next(but);
                                                                }
 
-                                                               if(but)
+                                                               if (but)
                                                                        ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE);
                                                        }
 
-                                                       if(!but) {
-                                                               if    ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DOWN)) ||
+                                                       if (!but) {
+                                                               if (    ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DOWN)) ||
                                                                        ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_RIGHT)) ||
                                                                        ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_TOP))
                                                                ) {
-                                                                       if((bt= ui_but_first(block)) && (bt->type & BUT)) {
+                                                                       if ((bt= ui_but_first(block)) && (bt->type & BUT)) {
                                                                                bt= ui_but_last(block);
                                                                        }
                                                                        else {
@@ -6065,7 +6075,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
                                                                        }
                                                                }
                                                                else {
-                                                                       if((bt= ui_but_first(block)) && (bt->type & BUT)) {
+                                                                       if ((bt= ui_but_first(block)) && (bt->type & BUT)) {
                                                                                /* keep ui_but_first() */
                                                                        }
                                                                        else {
@@ -6073,7 +6083,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
                                                                        }
                                                                }
 
-                                                               if(bt)
+                                                               if (bt)
                                                                        ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE);
                                                        }
                                                }
@@ -6086,50 +6096,50 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
                                case ONEKEY:    case PAD1:
                                        act= 1;
                                case TWOKEY:    case PAD2:
-                                       if(act==0) act= 2;
+                                       if (act==0) act= 2;
                                case THREEKEY:  case PAD3:
-                                       if(act==0) act= 3;
+                                       if (act==0) act= 3;
                                case FOURKEY:   case PAD4:
-                                       if(act==0) act= 4;
+                                       if (act==0) act= 4;
                                case FIVEKEY:   case PAD5:
-                                       if(act==0) act= 5;
+                                       if (act==0) act= 5;
                                case SIXKEY:    case PAD6:
-                                       if(act==0) act= 6;
+                                       if (act==0) act= 6;
                                case SEVENKEY:  case PAD7:
-                                       if(act==0) act= 7;
+                                       if (act==0) act= 7;
                                case EIGHTKEY:  case PAD8:
-                                       if(act==0) act= 8;
+                                       if (act==0) act= 8;
                                case NINEKEY:   case PAD9:
-                                       if(act==0) act= 9;
+                                       if (act==0) act= 9;
                                case ZEROKEY:   case PAD0:
-                                       if(act==0) act= 10;
+                                       if (act==0) act= 10;
                                
-                                       if((block->flag & UI_BLOCK_NUMSELECT) && event->val==KM_PRESS) {
-                                               if(event->alt) act+= 10;
+                                       if ((block->flag & UI_BLOCK_NUMSELECT) && event->val==KM_PRESS) {
+                                               if (event->alt) act+= 10;
                                                
                                                count= 0;
-                                               for(but= block->buttons.first; but; but= but->next) {
+                                               for (but= block->buttons.first; but; but= but->next) {
                                                        int doit= 0;
                                                        
-                                                       if(but->type!=LABEL && but->type!=SEPR)
+                                                       if (but->type!=LABEL && but->type!=SEPR)
                                                                count++;
                                                        
                                                        /* exception for rna layer buts */
-                                                       if(but->rnapoin.data && but->rnaprop) {
+                                                       if (but->rnapoin.data && but->rnaprop) {
                                                                if (ELEM(RNA_property_subtype(but->rnaprop), PROP_LAYER, PROP_LAYER_MEMBER)) {
                                                                        if (but->rnaindex== act-1)
                                                                                doit=1;
                                                                }
                                                        }
                                                        /* exception for menus like layer buts, with button aligning they're not drawn in order */
-                                                       else if(but->type==TOGR) {
-                                                               if(but->bitnr==act-1)
+                                                       else if (but->type==TOGR) {
+                                                               if (but->bitnr==act-1)
                                                                        doit= 1;
                                                        }
-                                                       else if(count==act)
+                                                       else if (count==act)
                                                                doit=1;
                                                        
-                                                       if(doit) {
+                                                       if (doit) {
                                                                ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY);
                                                                break;
                                                        }
@@ -6167,19 +6177,19 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
                                case YKEY:
                                case ZKEY:
                                {
-                                       if    (event->val == KM_PRESS) &&
+                                       if (    (event->val == KM_PRESS) &&
                                            (event->shift == FALSE) &&
                                            (event->ctrl ==  FALSE) &&
                                            (event->oskey == FALSE)
                                        ) {
-                                               for(but= block->buttons.first; but; but= but->next) {
+                                               for (but= block->buttons.first; but; but= but->next) {
 
-                                                       if(but->menu_key==event->type) {
-                                                               if(but->type == BUT) {
+                                                       if (but->menu_key==event->type) {
+                                                               if (but->type == BUT) {
                                                                        /* mainly for operator buttons */
                                                                        ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY);
                                                                }
-                                                               else if(ELEM(but->type, BLOCK, PULLDOWN)) {
+                                                               else if (ELEM(but->type, BLOCK, PULLDOWN)) {
                                                                        /* open submenus (like right arrow key) */
                                                                        ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN);
                                                                }
@@ -6203,15 +6213,15 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
                }
                
                /* here we check return conditions for menus */
-               if(block->flag & UI_BLOCK_LOOP) {
+               if (block->flag & UI_BLOCK_LOOP) {
                        /* if we click outside the block, verify if we clicked on the
                         * button that opened us, otherwise we need to close */
-                       if(inside==0) {
+                       if (inside==0) {
                                uiSafetyRct *saferct= block->saferct.first;
 
-                               if(ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) && event->val==KM_PRESS) {
-                                       if(saferct && !BLI_in_rctf(&saferct->parent, event->x, event->y)) {
-                                               if(block->flag & (UI_BLOCK_OUT_1))
+                               if (ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) && event->val==KM_PRESS) {
+                                       if (saferct && !BLI_in_rctf(&saferct->parent, event->x, event->y)) {
+                                               if (block->flag & (UI_BLOCK_OUT_1))
                                                        menu->menuretval= UI_RETURN_OK;
                                                else
                                                        menu->menuretval= UI_RETURN_OUT;
@@ -6219,45 +6229,45 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
                                }
                        }
 
-                       if(menu->menuretval);
-                       else if(event->type==ESCKEY && event->val==KM_PRESS) {
+                       if (menu->menuretval);
+                       else if (event->type==ESCKEY && event->val==KM_PRESS) {
                                /* esc cancels this and all preceding menus */
                                menu->menuretval= UI_RETURN_CANCEL;
                        }
-                       else if(ELEM(event->type, RETKEY, PADENTER) && event->val==KM_PRESS) {
+                       else if (ELEM(event->type, RETKEY, PADENTER) && event->val==KM_PRESS) {
                                /* enter will always close this block, we let the event
                                 * get handled by the button if it is activated, otherwise we cancel */
-                               if(!ui_but_find_activated(ar))
+                               if (!ui_but_find_activated(ar))
                                        menu->menuretval= UI_RETURN_CANCEL | UI_RETURN_POPUP_OK;
                        }
                        else {
                                ui_mouse_motion_towards_check(block, menu, mx, my);
 
                                /* check mouse moving outside of the menu */
-                               if(inside==0 && (block->flag & UI_BLOCK_MOVEMOUSE_QUIT)) {
+                               if (inside==0 && (block->flag & UI_BLOCK_MOVEMOUSE_QUIT)) {
                                        uiSafetyRct *saferct;
                                        
                                        /* check for all parent rects, enables arrowkeys to be used */
-                                       for(saferct=block->saferct.first; saferct; saferct= saferct->next) {
+                                       for (saferct=block->saferct.first; saferct; saferct= saferct->next) {
                                                /* for mouse move we only check our own rect, for other
                                                 * events we check all preceding block rects too to make
                                                 * arrow keys navigation work */
-                                               if(event->type!=MOUSEMOVE || saferct==block->saferct.first) {
-                                                       if(BLI_in_rctf(&saferct->parent, (float)event->x, (float)event->y))
+                                               if (event->type!=MOUSEMOVE || saferct==block->saferct.first) {
+                                                       if (BLI_in_rctf(&saferct->parent, (float)event->x, (float)event->y))
                                                                break;
-                                                       if(BLI_in_rctf(&saferct->safety, (float)event->x, (float)event->y))
+                                                       if (BLI_in_rctf(&saferct->safety, (float)event->x, (float)event->y))
                                                                break;
                                                }
                                        }
 
                                        /* strict check, and include the parent rect */
-                                       if(!menu->dotowards && !saferct) {
-                                               if(block->flag & (UI_BLOCK_OUT_1))
+                                       if (!menu->dotowards && !saferct) {
+                                               if (block->flag & (UI_BLOCK_OUT_1))
                                                        menu->menuretval= UI_RETURN_OK;
                                                else
                                                        menu->menuretval= UI_RETURN_OUT;
                                        }
-                                       else if(menu->dotowards && event->type==MOUSEMOVE)
+                                       else if (menu->dotowards && event->type==MOUSEMOVE)
                                                retval= WM_UI_HANDLER_BREAK;
                                }
                        }
@@ -6268,20 +6278,20 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
         * buttons inside this region. disabled inside check .. not sure
         * anymore why it was there? but it meant enter didn't work
         * for example when mouse was not over submenu */
-       if((/*inside &&*/ (!menu->menuretval || (menu->menuretval & UI_RETURN_UPDATE)) && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) {
+       if ((/*inside &&*/ (!menu->menuretval || (menu->menuretval & UI_RETURN_UPDATE)) && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) {
                but= ui_but_find_activated(ar);
 
-               if(but) {
+               if (but) {
                        ScrArea *ctx_area= CTX_wm_area(C);
                        ARegion *ctx_region= CTX_wm_region(C);
                        
-                       if(menu->ctx_area) CTX_wm_area_set(C, menu->ctx_area);
-                       if(menu->ctx_region) CTX_wm_region_set(C, menu->ctx_region);
+                       if (menu->ctx_area) CTX_wm_area_set(C, menu->ctx_area);
+                       if (menu->ctx_region) CTX_wm_region_set(C, menu->ctx_region);
                        
                        retval= ui_handle_button_event(C, event, but);
                        
-                       if(menu->ctx_area) CTX_wm_area_set(C, ctx_area);
-                       if(menu->ctx_region) CTX_wm_region_set(C, ctx_region);
+                       if (menu->ctx_area) CTX_wm_area_set(C, ctx_area);
+                       if (menu->ctx_region) CTX_wm_region_set(C, ctx_region);
                }
                else
                        retval= ui_handle_button_over(C, event, ar);
@@ -6290,9 +6300,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
        /* if we set a menu return value, ensure we continue passing this on to
         * lower menus and buttons, so always set continue then, and if we are
         * inside the region otherwise, ensure we swallow the event */
-       if(menu->menuretval)
+       if (menu->menuretval)
                return WM_UI_HANDLER_CONTINUE;
-       else if(inside)
+       else if (inside)
                return WM_UI_HANDLER_BREAK;
        else
                return retval;
@@ -6314,11 +6324,11 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo
        data= but->active;
        submenu= data->menu;
 
-       if(submenu->menuretval) {
+       if (submenu->menuretval) {
                /* first decide if we want to close our own menu cascading, if
                 * so pass on the sub menu return value to our own menu handle */
-               if((submenu->menuretval & UI_RETURN_OK) || (submenu->menuretval & UI_RETURN_CANCEL)) {
-                       if(!(block->flag & UI_BLOCK_KEEP_OPEN)) {
+               if ((submenu->menuretval & UI_RETURN_OK) || (submenu->menuretval & UI_RETURN_CANCEL)) {
+                       if (!(block->flag & UI_BLOCK_KEEP_OPEN)) {
                                menu->menuretval= submenu->menuretval;
                                menu->butretval= data->retval;
                        }
@@ -6330,7 +6340,7 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo
                 * will actually close the submenu too */
                ui_handle_button_return_submenu(C, event, but);
 
-               if(update)
+               if (update)
                        submenu->menuretval = 0;
        }
 
@@ -6341,7 +6351,7 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo
        ui_window_to_block(ar, block, &mx, &my);
        ui_mouse_motion_towards_init(menu, mx, my, 1);
 
-       if(menu->menuretval)
+       if (menu->menuretval)
                return WM_UI_HANDLER_CONTINUE;
        else
                return WM_UI_HANDLER_BREAK;
@@ -6359,12 +6369,12 @@ static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHa
        data= (but)? but->active: NULL;
        submenu= (data)? data->menu: NULL;
 
-       if(submenu)
+       if (submenu)
                retval= ui_handle_menus_recursive(C, event, submenu);
 
        /* now handle events for our own menu */
-       if(retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
-               if(submenu && submenu->menuretval)
+       if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
+               if (submenu && submenu->menuretval)
                        retval= ui_handle_menu_return_submenu(C, event, menu);
                else
                        retval= ui_handle_menu_event(C, event, menu, (submenu == NULL));
@@ -6385,26 +6395,26 @@ static int ui_handler_region(bContext *C, wmEvent *event, void *UNUSED(userdata)
        ar= CTX_wm_region(C);
        retval= WM_UI_HANDLER_CONTINUE;
 
-       if(ar==NULL) return retval;
-       if(ar->uiblocks.first==NULL) return retval;
+       if (ar==NULL) return retval;
+       if (ar->uiblocks.first==NULL) return retval;
 
        /* either handle events for already activated button or try to activate */
        but= ui_but_find_activated(ar);
 
        retval= ui_handler_panel_region(C, event);
 
-       if(retval == WM_UI_HANDLER_CONTINUE)
+       if (retval == WM_UI_HANDLER_CONTINUE)
                retval= ui_handle_list_event(C, event, ar);
 
-       if(retval == WM_UI_HANDLER_CONTINUE) {
-               if(but)
+       if (retval == WM_UI_HANDLER_CONTINUE) {
+               if (but)
                        retval= ui_handle_button_event(C, event, but);
                else
                        retval= ui_handle_button_over(C, event, ar);
        }
 
        /* re-enable tooltips */
-       if(event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy))
+       if (event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy))
                ui_blocks_set_tooltips(ar, 1);
        
        /* delayed apply callbacks */
@@ -6419,17 +6429,17 @@ static void ui_handler_remove_region(bContext *C, void *UNUSED(userdata))
        ARegion *ar;
 
        ar= CTX_wm_region(C);
-       if(ar == NULL) return;
+       if (ar == NULL) return;
 
        uiFreeBlocks(C, &ar->uiblocks);
        
        sc= CTX_wm_screen(C);
-       if(sc == NULL) return;
+       if (sc == NULL) return;
 
        /* delayed apply callbacks, but not for screen level regions, those
         * we rather do at the very end after closing them all, which will
         * be done in ui_handler_region/window */
-       if(BLI_findindex(&sc->regionbase, ar) == -1)
+       if (BLI_findindex(&sc->regionbase, ar) == -1)
                ui_apply_but_funcs_after(C);
 }
 
@@ -6443,23 +6453,23 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user
        /* here we handle buttons at the window level, modal, for example
         * while number sliding, text editing, or when a menu block is open */
        ar= CTX_wm_menu(C);
-       if(!ar)
+       if (!ar)
                ar= CTX_wm_region(C);
 
        but= ui_but_find_activated(ar);
 
-       if(but) {
+       if (but) {
                /* handle activated button events */
                data= but->active;
 
-               if(data->state == BUTTON_STATE_MENU_OPEN) {
+               if (data->state == BUTTON_STATE_MENU_OPEN) {
                        /* handle events for menus and their buttons recursively,
                         * this will handle events from the top to the bottom menu */
                        retval= ui_handle_menus_recursive(C, event, data->menu);
 
                        /* handle events for the activated button */
-                       if(retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
-                               if(data->menu->menuretval)
+                       if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
+                               if (data->menu->menuretval)
                                        ui_handle_button_return_submenu(C, event, but);
                                else
                                        ui_handle_button_event(C, event, but);
@@ -6472,7 +6482,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user
        }
 
        /* re-enable tooltips */
-       if(event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy))
+       if (event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy))
                ui_blocks_set_tooltips(ar, 1);
 
        /* delayed apply callbacks */
@@ -6490,25 +6500,25 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
        ui_handle_menus_recursive(C, event, menu);
 
        /* free if done, does not free handle itself */
-       if(menu->menuretval) {
+       if (menu->menuretval) {
                /* copy values, we have to free first (closes region) */
                uiPopupBlockHandle temp= *menu;
                
                ui_popup_block_free(C, menu);
                UI_remove_popup_handlers(&CTX_wm_window(C)->modalhandlers, menu);
 
-               if((temp.menuretval & UI_RETURN_OK) || (temp.menuretval & UI_RETURN_POPUP_OK)) {
-                       if(temp.popup_func)
+               if ((temp.menuretval & UI_RETURN_OK) || (temp.menuretval & UI_RETURN_POPUP_OK)) {
+                       if (temp.popup_func)
                                temp.popup_func(C, temp.popup_arg, temp.retvalue);
-                       if(temp.optype)
+                       if (temp.optype)
                                WM_operator_name_call(C, temp.optype->idname, temp.opcontext, NULL);
                }
-               else if(temp.cancel_func)
+               else if (temp.cancel_func)
                        temp.cancel_func(temp.popup_arg);
        }
        else {
                /* re-enable tooltips */
-               if(event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy))
+               if (event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy))
                        ui_blocks_set_tooltips(menu->region, 1);
        }