diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-04 10:16:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-04 11:10:01 +0400 |
commit | b9114cb609698bdd40175b79c017b8ec8d10b518 (patch) | |
tree | 98dc331711dcd06fb69f905ebdaf7937a4d23379 /source/blender/editors/interface/interface.c | |
parent | 091740f858c1b6d3016e38fc3186cce737d9ff2c (diff) |
UI: Use bool rather then int/short's where possible
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r-- | source/blender/editors/interface/interface.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index cf71e18472c..af303e807b6 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -522,30 +522,31 @@ 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 = FALSE; - int foundactiveline = FALSE; + bool found_selectline = false; + bool found_activeline = 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 = TRUE; + found_activeline = true; if ((line->from->flag & UI_SELECT) || (line->to->flag & UI_SELECT)) - foundselectline = TRUE; + found_selectline = true; } } } /* Draw any active lines (lines with either button being hovered over). * Do this last so they appear on top of inactive lines. */ - if (foundactiveline) { + if (found_activeline) { 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, !foundselectline); + ui_draw_linkline(line, !found_selectline); } } } @@ -741,8 +742,8 @@ void uiButExecute(const bContext *C, uiBut *but) } /* use to check if we need to disable undo, but don't make any changes - * returns FALSE if undo needs to be disabled. */ -static int ui_is_but_rna_undo(const uiBut *but) + * returns false if undo needs to be disabled. */ +static bool ui_is_but_rna_undo(const uiBut *but) { if (but->rnapoin.id.data) { /* avoid undo push for buttons who's ID are screen or wm level @@ -750,18 +751,18 @@ static int ui_is_but_rna_undo(const uiBut *but) * unforeseen consequences, so best check for ID's we _know_ are not * handled by undo - campbell */ ID *id = but->rnapoin.id.data; - if (ID_CHECK_UNDO(id) == FALSE) { - return FALSE; + if (ID_CHECK_UNDO(id) == false) { + return false; } else { - return TRUE; + return true; } } else if (but->rnapoin.type && !RNA_struct_undo_check(but->rnapoin.type)) { - return FALSE; + return false; } - return TRUE; + return true; } /* assigns automatic keybindings to menu items for fast access @@ -1027,10 +1028,10 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) for (but = block->buttons.first; but; but = but->next) { if (ui_but_event_operator_string(C, but, buf, sizeof(buf))) { - ui_but_add_shortcut(but, buf, FALSE); + ui_but_add_shortcut(but, buf, false); } else if (ui_but_event_property_operator_string(C, but, buf, sizeof(buf))) { - ui_but_add_shortcut(but, buf, FALSE); + ui_but_add_shortcut(but, buf, false); } } } @@ -1057,7 +1058,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 = TRUE; + but->lock = true; } if (but->context) @@ -1789,7 +1790,7 @@ void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen) /** * \param float_precision Override the button precision. */ -static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, int pad, int float_precision) +static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, bool pad, int float_precision) { UnitSettings *unit = but->block->unit; int do_split = unit->flag & USER_UNIT_OPT_SPLIT; @@ -1893,7 +1894,7 @@ void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int if (ui_is_but_float(but)) { if (ui_is_but_unit(but)) { - ui_get_but_string_unit(but, str, maxlen, value, 0, float_precision); + ui_get_but_string_unit(but, str, maxlen, value, false, float_precision); } else { const int prec = (float_precision == -1) ? ui_but_float_precision(but, value) : float_precision; @@ -1923,7 +1924,7 @@ static bool ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), but->block->unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type)); - return (BPY_button_exec(C, str_unit_convert, value, TRUE) != -1); + return (BPY_button_exec(C, str_unit_convert, value, true) != -1); } #endif /* WITH_PYTHON */ @@ -1959,7 +1960,7 @@ bool ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double #else /* WITH_PYTHON */ *value = atof(str); - ok = TRUE; + ok = true; (void)C; (void)but; @@ -2335,7 +2336,7 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor block->evil_C = (void *)C; /* XXX */ if (scn) { - block->color_profile = TRUE; + block->color_profile = true; /* store display device name, don't lookup for transformations yet * block could be used for non-color displays where looking up for transformation @@ -2369,7 +2370,7 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor wm_subwindow_getsize(window, window->screen->mainwin, &getsizex, &getsizey); block->aspect = 2.0f / fabsf(getsizex * block->winmat[0][0]); - block->auto_open = TRUE; + block->auto_open = true; block->flag |= UI_BLOCK_LOOP; /* tag as menu */ } @@ -2462,7 +2463,7 @@ void ui_check_but(uiBut *but) /* support length type buttons */ else if (ui_is_but_unit(but)) { char new_str[sizeof(but->drawstr)]; - ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE, -1); + ui_get_but_string_unit(but, new_str, sizeof(new_str), value, true, -1); slen += BLI_strncpy_rlen(but->drawstr + slen, new_str, sizeof(but->drawstr) - slen); } else { @@ -2811,7 +2812,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, /* we could do some more error checks here */ if ((type & BUTTYPE) == LABEL) { - BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == FALSE); + BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == false); } if (type & UI_BUT_POIN_TYPES) { /* a pointer is required */ @@ -2896,7 +2897,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->drawflag |= (block->flag & UI_BUT_ALIGN); - if (but->lock == TRUE) { + if (but->lock == true) { if (but->lockstr) { but->flag |= UI_BUT_DISABLED; } @@ -3076,7 +3077,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s ui_def_but_rna__disable(but); } - if (but->flag & UI_BUT_UNDO && (ui_is_but_rna_undo(but) == FALSE)) { + if (but->flag & UI_BUT_UNDO && (ui_is_but_rna_undo(but) == false)) { but->flag &= ~UI_BUT_UNDO; } @@ -3131,7 +3132,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * if (!ot) { but->flag |= UI_BUT_DISABLED; - but->lock = TRUE; + but->lock = true; but->lockstr = ""; } @@ -3974,7 +3975,7 @@ void uiButSetFocusOnEnter(wmWindow *win, uiBut *but) event.type = EVT_BUT_OPEN; event.val = KM_PRESS; event.customdata = but; - event.customdatafree = FALSE; + event.customdatafree = false; wm_event_add(win, &event); } |