code cleanup: comments and some minor edits to interface code.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 25 Aug 2012 20:49:51 +0000 (20:49 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 25 Aug 2012 20:49:51 +0000 (20:49 +0000)
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_layout.c

index 37a110ba33b376707c8537082edb54b98674fb00..afbabaaa8d78e5e97cf3fba4447599911c9d8647 100644 (file)
@@ -510,18 +510,18 @@ static void ui_draw_links(uiBlock *block)
 
        /* Draw the inactive lines (lines with neither button being hovered over).
         * As we go, remember if we see any active or selected lines. */
-       int foundselectline = 0;
-       int foundactiveline = 0;
+       int foundselectline = FALSE;
+       int foundactiveline = FALSE;
        for (but = block->buttons.first; but; but = but->next) {
                if (but->type == LINK && but->link) {
                        for (line = but->link->lines.first; line; line = line->next) {
                                if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE))
                                        ui_draw_linkline(line, 0);
                                else
-                                       foundactiveline = 1;
+                                       foundactiveline = TRUE;
 
                                if ((line->from->flag & UI_SELECT) || (line->to->flag & UI_SELECT))
-                                       foundselectline = 1;
+                                       foundselectline = TRUE;
                        }
                }
        }       
@@ -680,28 +680,27 @@ int uiButActiveOnly(const bContext *C, uiBlock *block, uiBut *but)
 {
        uiBlock *oldblock;
        uiBut *oldbut;
-       int activate = 0, found = 0, isactive = 0;
+       int activate = FALSE, found = FALSE, isactive = FALSE;
        
        oldblock = block->oldblock;
        if (!oldblock)
-               activate = 1;
+               activate = TRUE;
        else {
                for (oldbut = oldblock->buttons.first; oldbut; oldbut = oldbut->next) {
                        if (ui_but_equals_old(oldbut, but)) {
-                               found = 1;
+                               found = TRUE;
                                
                                if (oldbut->active)
-                                       isactive = 1;
+                                       isactive = TRUE;
                                
                                break;
                        }
                }
        }
-       if (activate || found == 0) {
+       if ((activate == TRUE) || (found == FALSE)) {
                ui_button_activate_do((bContext *)C, CTX_wm_region(C), but);
        }
-       else if (found && isactive == 0) {
-               
+       else if ((found == TRUE) && (isactive == FALSE)) {
                BLI_remlink(&block->buttons, but);
                ui_free_but(C, but);
                return 0;
@@ -911,7 +910,7 @@ void uiEndBlock(const bContext *C, uiBlock *block)
 
                        if (ot == NULL || WM_operator_poll_context((bContext *)C, ot, but->opcontext) == 0) {
                                but->flag |= UI_BUT_DISABLED;
-                               but->lock = 1;
+                               but->lock = TRUE;
                        }
 
                        if (but->context)
@@ -1067,9 +1066,12 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
 
 static void ui_is_but_sel(uiBut *but, double *value)
 {
-       short is_push = 0, is_true = 1;
+       short is_push = 0;  /* (0 == UNSELECT), (1 == SELECT), (2 == DO-NOHING) */
+       short is_true = TRUE;
 
-       if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) is_true = 0;
+       if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) {
+               is_true = FALSE;
+       }
 
        if (but->bit) {
                int lvalue;
@@ -1198,14 +1200,14 @@ void uiComposeLinks(uiBlock *block)
 void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr)
 {
        if (val) {
-               block->lock = val ? 1 : 0;
+               block->lock = val ? TRUE : FALSE;
                block->lockstr = lockstr;
        }
 }
 
 void uiBlockClearButLock(uiBlock *block)
 {
-       block->lock = 0;
+       block->lock = FALSE;
        block->lockstr = NULL;
 }
 
@@ -1515,10 +1517,15 @@ void ui_set_but_val(uiBut *but, double value)
                if (but->pointype == CHA)
                        value = (char)floor(value + 0.5);
                else if (but->pointype == SHO) {
-                       /* gcc 3.2.1 seems to have problems 
+                       /* gcc 3.2.1 seems to have problems
                         * casting a double like 32772.0 to
-                        * a short so we cast to an int, then 
-                        * to a short */
+                        * a short so we cast to an int, then
+                        * to a short.
+                        *
+                        * Update: even in gcc.4.6 using intermediate int cast gives -32764,
+                        * where as a direct cast from double to short gives -32768,
+                        * if this difference isn't important we could remove this hack,
+                        * since we dont support gcc3 anymore - Campbell */
                        int gcckludge;
                        gcckludge = (int) floor(value + 0.5);
                        value = (short)gcckludge;
@@ -2625,7 +2632,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
 
        but->flag |= (block->flag & UI_BUT_ALIGN);
 
-       if (but->lock) {
+       if (but->lock == TRUE) {
                if (but->lockstr) {
                        but->flag |= UI_BUT_DISABLED;
                }
@@ -2855,7 +2862,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *
 
        if (!ot) {
                but->flag |= UI_BUT_DISABLED;
-               but->lock = 1;
+               but->lock = TRUE;
                but->lockstr = "";
        }
 
@@ -2894,7 +2901,7 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn
 
        if (!ot) {
                but->flag |= UI_BUT_DISABLED;
-               but->lock = 1;
+               but->lock = TRUE;
                but->lockstr = "";
        }
 
index 9227ad158fdd7ec504ba6756f84f08436ca232f8..ca52daa8cd2f9cd15c64a3d7bf6832cdbfb9a539 100644 (file)
@@ -1140,8 +1140,9 @@ 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  == TRUE) {
                return;
+       }
 
        if (mode == 'v') {
                /* extract first line from clipboard in case of multi-line copies */
@@ -4793,7 +4794,7 @@ 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)) {
                /* this should become disabled button .. */
-               if (but->lock) {
+               if (but->lock == TRUE) {
                        if (but->lockstr) {
                                BKE_report(NULL, RPT_WARNING, but->lockstr);
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
index 13d05ca617c90ecbf32f67e25e416b827957869e..567109e26d05b0fc7635c72bd714343362421913 100644 (file)
@@ -303,27 +303,27 @@ struct uiBlock {
        const char *lockstr;
 
        char lock;
-       char active;                // to keep blocks while drawing and free them afterwards
-       char tooltipdisabled;       // to avoid tooltip after click
-       char endblock;              // uiEndBlock done?
-       
-       float xofs, yofs;           // offset to parent button
-       int dobounds, mx, my;       // for doing delayed
-       int bounds, minbounds;      // for doing delayed
+       char active;                /* to keep blocks while drawing and free them afterwards */
+       char tooltipdisabled;       /* to avoid tooltip after click */
+       char endblock;              /* uiEndBlock done? */
+
+       float xofs, yofs;           /* offset to parent button */
+       int dobounds, mx, my;       /* for doing delayed */
+       int bounds, minbounds;      /* for doing delayed */
 
-       rctf safety;                // pulldowns, to detect outside, can differ per case how it is created
-       ListBase saferct;           // uiSafetyRct list
+       rctf safety;                /* pulldowns, to detect outside, can differ per case how it is created */
+       ListBase saferct;           /* uiSafetyRct list */
 
-       uiPopupBlockHandle *handle; // handle
+       uiPopupBlockHandle *handle; /* handle */
 
-       struct wmOperator *ui_operator; // use so presets can find the operator,
-                                      // across menus and from nested popups which fail for operator context.
+       struct wmOperator *ui_operator; /* use so presets can find the operator, */
+                                       /* across menus and from nested popups which fail for operator context. */
 
-       void *evil_C;               // XXX hack for dynamic operator enums
+       void *evil_C;               /* XXX hack for dynamic operator enums */
 
-       struct UnitSettings *unit;  // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time.
-       float _hsv[3];              // XXX, only access via ui_block_hsv_get()
-       char color_profile;         // color profile for correcting linear colors for display
+       struct UnitSettings *unit;  /* unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. */
+       float _hsv[3];              /* XXX, only access via ui_block_hsv_get() */
+       char color_profile;         /* color profile for correcting linear colors for display */
 };
 
 typedef struct uiSafetyRct {
index deef36de56165534d42de5e56b5704c195afc48d..b68e14898d0396654bb6f568b780987503639679 100644 (file)
@@ -630,7 +630,7 @@ static void ui_item_disabled(uiLayout *layout, const char *name)
 
        but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
        but->flag |= UI_BUT_DISABLED;
-       but->lock = 1;
+       but->lock = TRUE;
        but->lockstr = "";
 }