diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-04-04 06:05:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-04-04 06:05:11 +0400 |
commit | 7bbaf4853ae81344761fceac90b08785520c18d0 (patch) | |
tree | fdfb403a573188312e43bf134a13c9a2e0d36e7e /source/blender/editors/interface | |
parent | 47fffc86bc94318aa34f50c035c99cfe8c7bad42 (diff) |
code cleanup: use bools in UI and WM code, quiet some shadow warnings, remove unused function uiEmboss()
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 126 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 26 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 26 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 22 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 54 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 22 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 18 |
9 files changed, 138 insertions, 164 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index be51651dee7..0c484a82778 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -549,22 +549,22 @@ static void ui_draw_links(uiBlock *block) /* ************** BLOCK ENDING FUNCTION ************* */ /* NOTE: if but->poin is allocated memory for every defbut, things fail... */ -static int ui_but_equals_old(uiBut *but, uiBut *oldbut) +static bool ui_but_equals_old(uiBut *but, uiBut *oldbut) { /* various properties are being compared here, hopefully sufficient * to catch all cases, but it is simple to add more checks later */ - if (but->retval != oldbut->retval) return 0; - if (but->rnapoin.data != oldbut->rnapoin.data) return 0; + if (but->retval != oldbut->retval) return false; + if (but->rnapoin.data != oldbut->rnapoin.data) return false; if (but->rnaprop != oldbut->rnaprop) - if (but->rnaindex != oldbut->rnaindex) return 0; - if (but->func != oldbut->func) return 0; - if (but->funcN != oldbut->funcN) return 0; - if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return 0; - if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return 0; - if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) || but->pointype != oldbut->pointype)) return 0; - if (but->optype != oldbut->optype) return 0; + if (but->rnaindex != oldbut->rnaindex) return false; + if (but->func != oldbut->func) return false; + if (but->funcN != oldbut->funcN) return false; + if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return false; + if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return false; + if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) || but->pointype != oldbut->pointype)) return false; + if (but->optype != oldbut->optype) return false; - return 1; + return true; } /* oldbut is being inserted in new block, so we use the lines from new button, and replace button pointers */ @@ -682,37 +682,38 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut /* needed for temporarily rename buttons, such as in outliner or file-select, * they should keep calling uiDefButs to keep them alive */ /* returns 0 when button removed */ -int uiButActiveOnly(const bContext *C, ARegion *ar, uiBlock *block, uiBut *but) +bool uiButActiveOnly(const bContext *C, ARegion *ar, uiBlock *block, uiBut *but) { uiBlock *oldblock; uiBut *oldbut; - int activate = FALSE, found = FALSE, isactive = FALSE; + bool activate = false, found = false, isactive = false; oldblock = block->oldblock; - if (!oldblock) - activate = TRUE; + if (!oldblock) { + activate = true; + } else { for (oldbut = oldblock->buttons.first; oldbut; oldbut = oldbut->next) { if (ui_but_equals_old(oldbut, but)) { - found = TRUE; + found = true; if (oldbut->active) - isactive = TRUE; + isactive = true; break; } } } - if ((activate == TRUE) || (found == FALSE)) { + if ((activate == true) || (found == false)) { ui_button_activate_do((bContext *)C, ar, but); } - else if ((found == TRUE) && (isactive == FALSE)) { + else if ((found == true) && (isactive == false)) { BLI_remlink(&block->buttons, but); ui_free_but(C, but); - return 0; + return false; } - return 1; + return true; } /* simulate button click */ @@ -1243,17 +1244,17 @@ void uiComposeLinks(uiBlock *block) /* ************************************************ */ -void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr) +void uiBlockSetButLock(uiBlock *block, bool val, const char *lockstr) { if (val) { - block->lock = val ? TRUE : FALSE; + block->lock = val; block->lockstr = lockstr; } } void uiBlockClearButLock(uiBlock *block) { - block->lock = FALSE; + block->lock = false; block->lockstr = NULL; } @@ -1392,63 +1393,63 @@ void ui_set_but_vectorf(uiBut *but, const float vec[3]) } } -int ui_is_but_float(uiBut *but) +bool ui_is_but_float(uiBut *but) { if (but->pointype == UI_BUT_POIN_FLOAT && but->poin) - return 1; + return true; if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT) - return 1; + return true; - return 0; + return false; } -int ui_is_but_bool(uiBut *but) +bool ui_is_but_bool(uiBut *but) { if (ELEM5(but->type, TOG, TOGN, TOGR, ICONTOG, ICONTOGN)) - return 1; + return true; if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_BOOLEAN) - return 1; + return true; - return 0; + return false; } -int ui_is_but_unit(uiBut *but) +bool ui_is_but_unit(uiBut *but) { UnitSettings *unit = but->block->unit; const int unit_type = uiButGetUnitType(but); if (unit_type == PROP_UNIT_NONE) - return 0; + return false; #if 1 /* removed so angle buttons get correct snapping */ if (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION) - return 0; + return false; #endif /* for now disable time unit conversion */ if (unit_type == PROP_UNIT_TIME) - return 0; + return false; if (unit->system == USER_UNIT_NONE) { if (unit_type != PROP_UNIT_ROTATION) { - return 0; + return false; } } - return 1; + return true; } -int ui_is_but_rna_valid(uiBut *but) +bool ui_is_but_rna_valid(uiBut *but) { if (but->rnaprop == NULL || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) { - return TRUE; + return true; } else { printf("property removed %s: %p\n", but->drawstr, but->rnaprop); - return FALSE; + return false; } } @@ -1789,7 +1790,7 @@ void ui_get_but_string(uiBut *but, char *str, const size_t maxlen) #ifdef WITH_PYTHON -static int ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *str, double *value) +static bool ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *str, double *value) { char str_unit_convert[256]; const int unit_type = uiButGetUnitType(but); @@ -1807,9 +1808,9 @@ static int ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char * #endif /* WITH_PYTHON */ -int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double *value) +bool ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double *value) { - int ok = FALSE; + bool ok = false; #ifdef WITH_PYTHON @@ -1825,7 +1826,7 @@ int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double ok = ui_set_but_string_eval_num_unit(C, but, str_new, value); } else { - ok = TRUE; /* parse normal string via py (no unit conversion needed) */ + ok = true; /* parse normal string via py (no unit conversion needed) */ } } else if (is_unit_but) { @@ -1848,7 +1849,7 @@ int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double } -int ui_set_but_string(bContext *C, uiBut *but, const char *str) +bool ui_set_but_string(bContext *C, uiBut *but, const char *str) { if (but->rnaprop && ELEM4(but->type, TEX, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) { if (RNA_property_editable(&but->rnapoin, but->rnaprop)) { @@ -1859,7 +1860,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) if (type == PROP_STRING) { /* RNA string */ RNA_property_string_set(&but->rnapoin, but->rnaprop, str); - return 1; + return true; } else if (type == PROP_POINTER) { /* RNA pointer */ @@ -1868,7 +1869,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) if (str == NULL || str[0] == '\0') { RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL); - return 1; + return true; } else { ptr = but->rnasearchpoin; @@ -1877,18 +1878,18 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr); - return 1; + return true; } - return 0; + return false; } else if (type == PROP_ENUM) { int value; if (RNA_property_enum_value(but->block->evil_C, &but->rnapoin, but->rnaprop, str, &value)) { RNA_property_enum_set(&but->rnapoin, but->rnaprop, value); - return 1; + return true; } - return 0; + return false; } else { BLI_assert(0); @@ -1898,23 +1899,23 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) else if (but->type == IDPOIN) { /* ID pointer */ but->idpoin_func(C, str, but->idpoin_idpp); - return 1; + return true; } else if (but->type == TEX) { /* string */ if (ui_is_but_utf8(but)) BLI_strncpy_utf8(but->poin, str, but->hardmax); else BLI_strncpy(but->poin, str, but->hardmax); - return 1; + return true; } else if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) { /* string */ BLI_strncpy(but->poin, str, but->hardmax); - return 1; + return true; } else if (ui_but_anim_expression_set(but, str)) { /* driver expression */ - return 1; + return true; } else if (str[0] == '#') { /* shortcut to create new driver expression (versus immediate Py-execution) */ @@ -1924,8 +1925,8 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) /* number editing */ double value; - if (ui_set_but_string_eval_num(C, but, str, &value) == FALSE) { - return 0; + if (ui_set_but_string_eval_num(C, but, str, &value) == false) { + return false; } if (!ui_is_but_float(but)) value = (int)floor(value + 0.5); @@ -1936,10 +1937,10 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) if (value > (double)but->hardmax) value = but->hardmax; ui_set_but_val(but, value); - return 1; + return true; } - return 0; + return false; } void ui_set_but_default(bContext *C, short all) @@ -2464,15 +2465,14 @@ void uiBlockBeginAlign(uiBlock *block) /* buttons declared after this call will get this align nr */ // XXX flag? } -static int buts_are_horiz(uiBut *but1, uiBut *but2) +static bool buts_are_horiz(uiBut *but1, uiBut *but2) { float dx, dy; dx = fabs(but1->rect.xmax - but2->rect.xmin); dy = fabs(but1->rect.ymin - but2->rect.ymax); - if (dx > dy) return 0; - return 1; + return (dx <= dy); } void uiBlockEndAlign(uiBlock *block) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index c0f1ed28b3f..cd2a2161315 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -393,32 +393,6 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad) ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad, roundboxtype & UI_RB_ALPHA); } - -/* ************** generic embossed rect, for window sliders etc ************* */ - - -/* text_draw.c uses this */ -void uiEmboss(float x1, float y1, float x2, float y2, int sel) -{ - - /* below */ - if (sel) glColor3ub(200, 200, 200); - else glColor3ub(50, 50, 50); - fdrawline(x1, y1, x2, y1); - - /* right */ - fdrawline(x2, y1, x2, y2); - - /* top */ - if (sel) glColor3ub(50, 50, 50); - else glColor3ub(200, 200, 200); - fdrawline(x1, y2, x2, y2); - - /* left */ - fdrawline(x1, y1, x1, y2); - -} - /* ************** SPECIAL BUTTON DRAWING FUNCTIONS ************* */ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 6d30db9c4d6..a644feca080 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -215,8 +215,8 @@ typedef struct uiAfterFunc { int autokey; } uiAfterFunc; -static int ui_but_contains_pt(uiBut *but, int mx, int my); -static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y); +static bool ui_but_contains_pt(uiBut *but, int mx, int my); +static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y); static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state); static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *userdata); static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type); @@ -333,7 +333,7 @@ static void ui_mouse_scale_warp(uiHandleButtonData *data, } /* file selectors are exempt from utf-8 checks */ -int ui_is_but_utf8(uiBut *but) +bool ui_is_but_utf8(uiBut *but) { if (but->rnaprop) { const int subtype = RNA_property_subtype(but->rnaprop); @@ -5507,7 +5507,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * /* ************************ button utilities *********************** */ -static int ui_but_contains_pt(uiBut *but, int mx, int my) +static bool ui_but_contains_pt(uiBut *but, int mx, int my) { return BLI_rctf_isect_pt(&but->rect, mx, my); } @@ -5525,7 +5525,7 @@ static uiBut *ui_but_find_activated(ARegion *ar) return NULL; } -int ui_button_is_active(ARegion *ar) +bool ui_button_is_active(ARegion *ar) { return (ui_but_find_activated(ar) != NULL); } @@ -5580,7 +5580,7 @@ static void ui_blocks_set_tooltips(ARegion *ar, int enable) block->tooltipdisabled = !enable; } -static int ui_mouse_inside_region(ARegion *ar, int x, int y) +static bool ui_mouse_inside_region(ARegion *ar, int x, int y) { uiBlock *block; @@ -5589,7 +5589,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) for (block = ar->uiblocks.first; block; block = block->next) block->auto_open = FALSE; - return 0; + return false; } /* also, check that with view2d, that the mouse is not over the scrollbars @@ -5608,23 +5608,23 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) /* check if in the rect */ if (!BLI_rcti_isect_pt(&v2d->mask, mx, my)) - return 0; + return false; } - return 1; + return true; } -static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y) +static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y) { if (!ui_mouse_inside_region(ar, x, y)) - return 0; + return false; ui_window_to_block(ar, but->block, &x, &y); if (!ui_but_contains_pt(but, x, y)) - return 0; + return false; - return 1; + return true; } /** diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 09686d7b416..52710a62855 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1164,7 +1164,7 @@ static void ui_id_preview_image_render_size(bContext *C, ID *id, PreviewImage *p } } -static void ui_id_icon_render(bContext *C, ID *id, int big) +static void ui_id_icon_render(bContext *C, ID *id, const bool big) { PreviewImage *pi = BKE_previewimg_get(id); @@ -1248,7 +1248,7 @@ static int ui_id_brush_get_icon(bContext *C, ID *id) return id->icon_id; } -int ui_id_icon_get(bContext *C, ID *id, int big) +int ui_id_icon_get(bContext *C, ID *id, const bool big) { int iconid = 0; @@ -1273,7 +1273,7 @@ int ui_id_icon_get(bContext *C, ID *id, int big) return iconid; } -int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, int big) +int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big) { ID *id = NULL; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index e7b659f99fc..41ceeb141c9 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -391,18 +391,18 @@ extern void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rc extern void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision); extern void ui_get_but_string(uiBut *but, char *str, const size_t maxlen); extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen); -extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str); -extern int ui_get_but_string_max_length(uiBut *but); -extern int ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char *str, double *value); +extern bool ui_set_but_string(struct bContext *C, uiBut *but, const char *str); +extern bool ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char *str, double *value); +extern int ui_get_but_string_max_length(uiBut *but); extern void ui_set_but_default(struct bContext *C, short all); extern void ui_check_but(uiBut *but); -extern int ui_is_but_float(uiBut *but); -extern int ui_is_but_bool(uiBut *but); -extern int ui_is_but_unit(uiBut *but); -extern int ui_is_but_rna_valid(uiBut *but); -extern int ui_is_but_utf8(uiBut *but); +extern bool ui_is_but_float(uiBut *but); +extern bool ui_is_but_bool(uiBut *but); +extern bool ui_is_but_unit(uiBut *but); +extern bool ui_is_but_rna_valid(uiBut *but); +extern bool ui_is_but_utf8(uiBut *but); extern bool ui_is_but_interactive(uiBut *but); extern int ui_is_but_push_ex(uiBut *but, double *value); @@ -464,7 +464,7 @@ void ui_popup_block_scrolltest(struct uiBlock *block); /* searchbox for string button */ ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but); -int ui_searchbox_inside(struct ARegion *ar, int x, int y); +bool ui_searchbox_inside(struct ARegion *ar, int x, int y); void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset); void ui_searchbox_autocomplete(struct bContext *C, struct ARegion *ar, uiBut *but, char *str); void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, const struct wmEvent *event); @@ -511,7 +511,7 @@ extern void ui_pan_to_scroll(const struct wmEvent *event, int *type, int *val); extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but); extern void ui_button_execute_do(struct bContext *C, struct ARegion *ar, uiBut *but); extern void ui_button_active_free(const struct bContext *C, uiBut *but); -extern int ui_button_is_active(struct ARegion *ar); +extern bool ui_button_is_active(struct ARegion *ar); extern int ui_button_open_menu_direction(uiBut *but); extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, int restore); @@ -544,7 +544,7 @@ extern unsigned char checker_stipple_sml[32 * 32 / 8]; void uiStyleInit(void); /* interface_icons.c */ -int ui_id_icon_get(struct bContext *C, struct ID *id, int preview); +int ui_id_icon_get(struct bContext *C, struct ID *id, const bool big); /* resources.c */ void init_userdef_do_versions(void); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 53887163778..4b1b96f7975 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -140,11 +140,11 @@ struct uiLayout { int x, y, w, h; float scale[2]; short space; - char align; - char active; - char enabled; - char redalert; - char keepaspect; + bool align; + bool active; + bool enabled; + bool redalert; + bool keepaspect; char alignment; }; @@ -1333,7 +1333,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s BLI_strncpy(name_ui, id->name + 2, sizeof(name_ui)); #endif name = BLI_strdup(name_ui); - iconid = ui_id_icon_get((bContext *)C, id, 0); + iconid = ui_id_icon_get((bContext *)C, id, false); } else { name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */ @@ -1359,7 +1359,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s /* add search items from temporary list */ for (cis = items_list->first; cis; cis = cis->next) { - if (!uiSearchItemAdd(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) { + if (false == uiSearchItemAdd(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) { break; } } @@ -2267,8 +2267,8 @@ uiLayout *uiLayoutRow(uiLayout *layout, int align) litem->item.type = ITEM_LAYOUT_ROW; litem->root = layout->root; litem->align = align; - litem->active = 1; - litem->enabled = 1; + litem->active = true; + litem->enabled = true; litem->context = layout->context; litem->space = (align) ? 0 : layout->root->style->buttonspacex; litem->redalert = layout->redalert; @@ -2288,8 +2288,8 @@ uiLayout *uiLayoutColumn(uiLayout *layout, int align) litem->item.type = ITEM_LAYOUT_COLUMN; litem->root = layout->root; litem->align = align; - litem->active = 1; - litem->enabled = 1; + litem->active = true; + litem->enabled = true; litem->context = layout->context; litem->space = (litem->align) ? 0 : layout->root->style->buttonspacey; litem->redalert = layout->redalert; @@ -2309,8 +2309,8 @@ uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align) flow->litem.item.type = ITEM_LAYOUT_COLUMN_FLOW; flow->litem.root = layout->root; flow->litem.align = align; - flow->litem.active = 1; - flow->litem.enabled = 1; + flow->litem.active = true; + flow->litem.enabled = true; flow->litem.context = layout->context; flow->litem.space = (flow->litem.align) ? 0 : layout->root->style->columnspace; flow->litem.redalert = layout->redalert; @@ -2402,8 +2402,8 @@ uiLayout *uiLayoutOverlap(uiLayout *layout) litem = MEM_callocN(sizeof(uiLayout), "uiLayoutOverlap"); litem->item.type = ITEM_LAYOUT_OVERLAP; litem->root = layout->root; - litem->active = 1; - litem->enabled = 1; + litem->active = true; + litem->enabled = true; litem->context = layout->context; litem->redalert = layout->redalert; BLI_addtail(&layout->items, litem); @@ -2421,8 +2421,8 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align) split->litem.item.type = ITEM_LAYOUT_SPLIT; split->litem.root = layout->root; split->litem.align = align; - split->litem.active = 1; - split->litem.enabled = 1; + split->litem.active = true; + split->litem.enabled = true; split->litem.context = layout->context; split->litem.space = layout->root->style->columnspace; split->litem.redalert = layout->redalert; @@ -2435,27 +2435,27 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align) return &split->litem; } -void uiLayoutSetActive(uiLayout *layout, int active) +void uiLayoutSetActive(uiLayout *layout, bool active) { layout->active = active; } -void uiLayoutSetEnabled(uiLayout *layout, int enabled) +void uiLayoutSetEnabled(uiLayout *layout, bool enabled) { layout->enabled = enabled; } -void uiLayoutSetRedAlert(uiLayout *layout, int redalert) +void uiLayoutSetRedAlert(uiLayout *layout, bool redalert) { layout->redalert = redalert; } -void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect) +void uiLayoutSetKeepAspect(uiLayout *layout, bool keepaspect) { layout->keepaspect = keepaspect; } -void uiLayoutSetAlignment(uiLayout *layout, int alignment) +void uiLayoutSetAlignment(uiLayout *layout, char alignment) { layout->alignment = alignment; } @@ -2470,22 +2470,22 @@ void uiLayoutSetScaleY(uiLayout *layout, float scale) layout->scale[1] = scale; } -int uiLayoutGetActive(uiLayout *layout) +bool uiLayoutGetActive(uiLayout *layout) { return layout->active; } -int uiLayoutGetEnabled(uiLayout *layout) +bool uiLayoutGetEnabled(uiLayout *layout) { return layout->enabled; } -int uiLayoutGetRedAlert(uiLayout *layout) +bool uiLayoutGetRedAlert(uiLayout *layout) { return layout->redalert; } -int uiLayoutGetKeepAspect(uiLayout *layout) +bool uiLayoutGetKeepAspect(uiLayout *layout) { return layout->keepaspect; } @@ -2937,7 +2937,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, /* poll() on this operator may still fail, at the moment there is no nice feedback when this happens * just fails silently */ if (!WM_operator_repeat_check(C, op)) { - uiBlockSetButLock(uiLayoutGetBlock(layout), TRUE, "Operator can't' redo"); + uiBlockSetButLock(uiLayoutGetBlock(layout), true, "Operator can't' redo"); /* XXX, could give some nicer feedback or not show redo panel at all? */ uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 145deb35667..52a26f4f528 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -716,7 +716,7 @@ struct uiEditSourceButStore { /* should only ever be set while the edit source operator is running */ static struct uiEditSourceStore *ui_editsource_info = NULL; -int UI_editsource_enable_check(void) +bool UI_editsource_enable_check(void) { return (ui_editsource_info != NULL); } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index febd1820e5c..8d7edf1b044 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -514,7 +514,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ /* so the context is passed to itemf functions (some py itemf functions use it) */ - WM_operator_properties_sanitize(opptr, FALSE); + WM_operator_properties_sanitize(opptr, false); str = WM_operator_pystring(C, but->optype, opptr, 0); @@ -751,12 +751,12 @@ typedef struct uiSearchboxData { /* exported for use by search callbacks */ /* returns zero if nothing to add */ -int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid) +bool uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid) { /* hijack for autocomplete */ if (items->autocpl) { autocomplete_do_name(items->autocpl, name); - return 1; + return true; } /* hijack for finding active item */ @@ -764,18 +764,18 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int icon if (poin == items->active) items->offset_i = items->totitem; items->totitem++; - return 1; + return true; } if (items->totitem >= items->maxitem) { items->more = 1; - return 0; + return false; } /* skip first items in list */ if (items->offset_i > 0) { items->offset_i--; - return 1; + return true; } if (items->names) @@ -787,7 +787,7 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int icon items->totitem++; - return 1; + return true; } int uiSearchBoxHeight(void) @@ -867,11 +867,11 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) } /* x and y in screencoords */ -int ui_searchbox_inside(ARegion *ar, int x, int y) +bool ui_searchbox_inside(ARegion *ar, int x, int y) { uiSearchboxData *data = ar->regiondata; - return(BLI_rcti_isect_pt(&data->bbox, x - ar->winrct.xmin, y - ar->winrct.ymin)); + return BLI_rcti_isect_pt(&data->bbox, x - ar->winrct.xmin, y - ar->winrct.ymin); } /* string validated to be of correct length (but->hardmax) */ @@ -2236,7 +2236,7 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_ { uiBut *but = arg_but; uiBlock *block; - int show_picker = TRUE; + bool show_picker = true; block = uiBeginBlock(C, handle->region, __func__, UI_EMBOSS); @@ -2703,7 +2703,7 @@ void uiPupMenuInvoke(bContext *C, const char *idname) uiPopupMenu *pup; uiLayout *layout; Menu menu; - MenuType *mt = WM_menutype_find(idname, TRUE); + MenuType *mt = WM_menutype_find(idname, true); if (mt == NULL) { printf("%s: named menu \"%s\" not found\n", __func__, idname); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 7d8be7ae9c9..84811dc8366 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -106,7 +106,7 @@ typedef struct TemplateID { ListBase *idlb; int prv_rows, prv_cols; - int preview; + bool preview; } TemplateID; /* Search browse menu, assign */ @@ -156,7 +156,7 @@ static void id_search_cb(const bContext *C, void *arg_template, const char *str, iconid = ui_id_icon_get((bContext *)C, id, template->preview); - if (!uiSearchItemAdd(items, name_ui, id, iconid)) + if (false == uiSearchItemAdd(items, name_ui, id, iconid)) break; } } @@ -411,13 +411,13 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str type = idptr.type; if (flag & UI_ID_PREVIEWS) { - template->preview = TRUE; + template->preview = true; but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, TIP_(template_id_browse_tip(type))); if (type) { but->icon = RNA_struct_ui_icon(type); - if (id) but->icon = ui_id_icon_get(C, id, 1); + if (id) but->icon = ui_id_icon_get(C, id, true); uiButSetFlag(but, UI_HAS_ICON | UI_ICON_PREVIEW); } if ((idfrom && idfrom->lib) || !editable) @@ -1214,7 +1214,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) /* Set but-locks for protected settings (magic numbers are used here!) */ if (proxy_protected) - uiBlockSetButLock(block, 1, IFACE_("Cannot edit Proxy-Protected Constraint")); + uiBlockSetButLock(block, true, IFACE_("Cannot edit Proxy-Protected Constraint")); /* Draw constraint data */ if ((con->flag & CONSTRAINT_EXPAND) == 0) { @@ -2628,7 +2628,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co sub = uiLayoutRow(overlap, FALSE); - icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, FALSE); + icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false); if (icon == ICON_DOT) icon = ICON_NONE; draw_item(ui_list, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i); @@ -2662,7 +2662,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co found = (activei == i); if (found) { - icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, FALSE); + icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false); if (icon == ICON_DOT) icon = ICON_NONE; draw_item(ui_list, C, row, dataptr, &itemptr, icon, active_dataptr, active_propname, i); @@ -2709,7 +2709,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co sub = uiLayoutRow(overlap, FALSE); - icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, FALSE); + icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, false); draw_item(ui_list, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i); i++; @@ -2757,7 +2757,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char } } - if (0 == uiSearchItemAdd(items, name, ot, 0)) + if (false == uiSearchItemAdd(items, name, ot, 0)) break; } } |