From e86e0aad55675a5c4473d0538146dbccda7613e8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 25 Mar 2019 10:15:20 +1100 Subject: Cleanup: use braces for interface code --- source/blender/editors/interface/interface_utils.c | 81 ++++++++++++++-------- 1 file changed, 54 insertions(+), 27 deletions(-) (limited to 'source/blender/editors/interface/interface_utils.c') diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 74f65220433..65abac968e3 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -61,15 +61,19 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind switch (RNA_property_type(prop)) { case PROP_BOOLEAN: { - if (RNA_property_array_check(prop) && index == -1) + if (RNA_property_array_check(prop) && index == -1) { return NULL; + } - if (icon && name && name[0] == '\0') + if (icon && name && name[0] == '\0') { but = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); - else if (icon) + } + else if (icon) { but = uiDefIconTextButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); - else + } + else { but = uiDefButR_prop(block, UI_BTYPE_CHECKBOX, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); + } break; } case PROP_INT: @@ -83,10 +87,12 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind return NULL; } } - else if (RNA_property_subtype(prop) == PROP_PERCENTAGE || RNA_property_subtype(prop) == PROP_FACTOR) + else if (RNA_property_subtype(prop) == PROP_PERCENTAGE || RNA_property_subtype(prop) == PROP_FACTOR) { but = uiDefButR_prop(block, UI_BTYPE_NUM_SLIDER, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); - else + } + else { but = uiDefButR_prop(block, UI_BTYPE_NUM, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); + } if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) { UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE); @@ -94,20 +100,26 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind break; } case PROP_ENUM: - if (icon && name && name[0] == '\0') + if (icon && name && name[0] == '\0') { but = uiDefIconButR_prop(block, UI_BTYPE_MENU, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); - else if (icon) + } + else if (icon) { but = uiDefIconTextButR_prop(block, UI_BTYPE_MENU, 0, icon, NULL, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); - else + } + else { but = uiDefButR_prop(block, UI_BTYPE_MENU, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); + } break; case PROP_STRING: - if (icon && name && name[0] == '\0') + if (icon && name && name[0] == '\0') { but = uiDefIconButR_prop(block, UI_BTYPE_TEXT, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); - else if (icon) + } + else if (icon) { but = uiDefIconTextButR_prop(block, UI_BTYPE_TEXT, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); - else + } + else { but = uiDefButR_prop(block, UI_BTYPE_TEXT, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); + } if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) { /* TEXTEDIT_UPDATE is usually used for search buttons. For these we also want @@ -121,8 +133,9 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind PointerRNA pptr = RNA_property_pointer_get(ptr, prop); icon = RNA_struct_ui_icon(pptr.type ? pptr.type : RNA_property_pointer_type(ptr, prop)); } - if (icon == ICON_DOT) + if (icon == ICON_DOT) { icon = 0; + } but = uiDefIconTextButR_prop(block, UI_BTYPE_SEARCH_MENU, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); break; @@ -183,8 +196,9 @@ eAutoPropButsReturn uiDefAutoButsRNA( if (label_align == UI_BUT_LABEL_ALIGN_COLUMN) { col = uiLayoutColumn(layout, true); - if (!is_boolean) + if (!is_boolean) { uiItemL(col, name, ICON_NONE); + } } else { BLI_assert(label_align == UI_BUT_LABEL_ALIGN_SPLIT_COLUMN); @@ -247,10 +261,12 @@ static int sort_search_items_list(const void *a, const void *b) const CollItemSearch *cis1 = a; const CollItemSearch *cis2 = b; - if (BLI_strcasecmp(cis1->name, cis2->name) > 0) + if (BLI_strcasecmp(cis1->name, cis2->name) > 0) { return 1; - else + } + else { return 0; + } } void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char *str, uiSearchItems *items) @@ -266,14 +282,17 @@ void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char RNA_PROP_BEGIN (&data->search_ptr, itemptr, data->search_prop) { - if (flag & PROP_ID_SELF_CHECK) - if (itemptr.data == data->target_ptr.id.data) + if (flag & PROP_ID_SELF_CHECK) { + if (itemptr.data == data->target_ptr.id.data) { continue; + } + } /* use filter */ if (RNA_property_type(data->target_prop) == PROP_POINTER) { - if (RNA_property_pointer_poll(&data->target_ptr, data->target_prop, &itemptr) == 0) + if (RNA_property_pointer_poll(&data->target_ptr, data->target_prop, &itemptr) == 0) { continue; + } } name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */ @@ -322,8 +341,9 @@ int UI_icon_from_id(ID *id) PointerRNA ptr; short idcode; - if (id == NULL) + if (id == NULL) { return ICON_NONE; + } idcode = GS(id->name); @@ -331,10 +351,12 @@ int UI_icon_from_id(ID *id) if (idcode == ID_OB) { ob = (Object *)id; - if (ob->type == OB_EMPTY) + if (ob->type == OB_EMPTY) { return ICON_EMPTY_DATA; - else + } + else { return UI_icon_from_id(ob->data); + } } /* otherwise get it through RNA, creating the pointer @@ -347,14 +369,18 @@ int UI_icon_from_id(ID *id) /* see: report_type_str */ int UI_icon_from_report_type(int type) { - if (type & RPT_ERROR_ALL) + if (type & RPT_ERROR_ALL) { return ICON_ERROR; - else if (type & RPT_WARNING_ALL) + } + else if (type & RPT_WARNING_ALL) { return ICON_ERROR; - else if (type & RPT_INFO_ALL) + } + else if (type & RPT_INFO_ALL) { return ICON_INFO; - else + } + else { return ICON_NONE; + } } /********************************** Misc **************************************/ @@ -598,8 +624,9 @@ void UI_butstore_update(uiBlock *block) } } - if (LIKELY(block->butstore.first == NULL)) + if (LIKELY(block->butstore.first == NULL)) { return; + } /* warning, loop-in-loop, in practice we only store <10 buttons at a time, * so this isn't going to be a problem, if that changes old-new mapping can be cached first */ -- cgit v1.2.3