[Bf-blender-cvs] [e86e0aad556] master: Cleanup: use braces for interface code

Campbell Barton noreply at git.blender.org
Mon Mar 25 01:21:58 CET 2019


Commit: e86e0aad55675a5c4473d0538146dbccda7613e8
Author: Campbell Barton
Date:   Mon Mar 25 10:15:20 2019 +1100
Branches: master
https://developer.blender.org/rBe86e0aad55675a5c4473d0538146dbccda7613e8

Cleanup: use braces for interface code

===================================================================

M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_align.c
M	source/blender/editors/interface/interface_anim.c
M	source/blender/editors/interface/interface_context_menu.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_eyedropper.c
M	source/blender/editors/interface/interface_eyedropper_driver.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_query.c
M	source/blender/editors/interface/interface_region_color_picker.c
M	source/blender/editors/interface/interface_region_menu_pie.c
M	source/blender/editors/interface/interface_region_menu_popup.c
M	source/blender/editors/interface/interface_region_popover.c
M	source/blender/editors/interface/interface_region_popup.c
M	source/blender/editors/interface/interface_region_search.c
M	source/blender/editors/interface/interface_region_tooltip.c
M	source/blender/editors/interface/interface_regions.c
M	source/blender/editors/interface/interface_style.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/interface_utils.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/interface/resources.c
M	source/blender/editors/interface/view2d.c
M	source/blender/editors/interface/view2d_ops.c

===================================================================

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index c4a81b529a9..48a3e08cbd4 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -88,7 +88,10 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
 
 /* avoid unneeded calls to ui_but_value_get */
 #define UI_BUT_VALUE_UNSET DBL_MAX
-#define UI_GET_BUT_VALUE_INIT(_but, _value) if (_value == DBL_MAX) {  (_value) = ui_but_value_get(_but); } (void)0
+#define UI_GET_BUT_VALUE_INIT(_but, _value) \
+	if (_value == DBL_MAX) { \
+		(_value) = ui_but_value_get(_but); \
+	} ((void)0)
 
 #define B_NOP -1
 
@@ -345,8 +348,9 @@ static void ui_block_bounds_calc_text(uiBlock *block, float offset)
 		if (!ELEM(bt->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER)) {
 			j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr));
 
-			if (j > i)
+			if (j > i) {
 				i = j;
+			}
 		}
 
 		if (bt->next && bt->rect.xmin < bt->next->rect.xmin) {
@@ -403,8 +407,12 @@ void ui_block_bounds_calc(uiBlock *block)
 
 	/* hardcoded exception... but that one is annoying with larger safety */
 	bt = block->buttons.first;
-	if (bt && STREQLEN(bt->str, "ERROR", 5)) xof = 10;
-	else xof = 40;
+	if (bt && STREQLEN(bt->str, "ERROR", 5)) {
+		xof = 10;
+	}
+	else {
+		xof = 40;
+	}
 
 	block->safety.xmin = block->rect.xmin - xof;
 	block->safety.ymin = block->rect.ymin - xof;
@@ -523,8 +531,9 @@ static void ui_block_bounds_calc_popup(
 /* used for various cases */
 void UI_block_bounds_set_normal(uiBlock *block, int addval)
 {
-	if (block == NULL)
+	if (block == NULL) {
 		return;
+	}
 
 	block->bounds = addval;
 	block->bounds_type = UI_BLOCK_BOUNDS;
@@ -610,16 +619,16 @@ static bool ui_but_equals_old(const uiBut *but, const 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 false;
-	if (but->rnapoin.data != oldbut->rnapoin.data) return false;
-	if (but->rnaprop != oldbut->rnaprop || 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->retval != oldbut->retval) { return false; }
+	if (but->rnapoin.data != oldbut->rnapoin.data) { return false; }
+	if (but->rnaprop != oldbut->rnaprop || 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;
+	                    (but->pointype != oldbut->pointype))) { return false; }
+	if (but->optype != oldbut->optype) { return false; }
 
 	return true;
 }
@@ -888,8 +897,9 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
 	int tot_missing = 0;
 
 	/* only do it before bounding */
-	if (block->rect.xmin != block->rect.xmax)
+	if (block->rect.xmin != block->rect.xmax) {
 		return;
+	}
 
 	for (pass = 0; pass < 2; pass++) {
 		/* 2 Passes, on for first letter only, second for any letter if first fails
@@ -916,11 +926,13 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
 
 						if (pass == 0) {
 							/* Skip to next delimiter on first pass (be picky) */
-							while (isalpha(*str_pt))
+							while (isalpha(*str_pt)) {
 								str_pt++;
+							}
 
-							if (*str_pt)
+							if (*str_pt) {
 								str_pt++;
+							}
 						}
 						else {
 							/* just step over every char second pass and find first usable key */
@@ -1402,8 +1414,9 @@ void UI_block_update_from_old(const bContext *C, uiBlock *block)
 	uiBut *but_old;
 	uiBut *but;
 
-	if (!block->oldblock)
+	if (!block->oldblock) {
 		return;
+	}
 
 	but_old = block->oldblock->buttons.first;
 
@@ -1450,15 +1463,17 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
 		if (but->optype) {
 			wmOperatorType *ot = but->optype;
 
-			if (but->context)
+			if (but->context) {
 				CTX_store_set((bContext *)C, but->context);
+			}
 
 			if (ot == NULL || WM_operator_poll_context((bContext *)C, ot, but->opcontext) == 0) {
 				but->flag |= UI_BUT_DISABLED;
 			}
 
-			if (but->context)
+			if (but->context) {
 				CTX_store_set((bContext *)C, NULL);
+			}
 		}
 
 		ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f);
@@ -1538,10 +1553,12 @@ void ui_fontscale(short *points, float aspect)
 		//aspect = sqrt(aspect);
 		pointsf /= aspect;
 
-		if (aspect > 1.0f)
+		if (aspect > 1.0f) {
 			*points = ceilf(pointsf);
-		else
+		}
+		else {
 			*points = floorf(pointsf);
+		}
 	}
 }
 
@@ -1565,11 +1582,13 @@ void UI_block_draw(const bContext *C, uiBlock *block)
 
 	/* get menu region or area region */
 	ar = CTX_wm_menu(C);
-	if (!ar)
+	if (!ar) {
 		ar = CTX_wm_region(C);
+	}
 
-	if (!block->endblock)
+	if (!block->endblock) {
 		UI_block_end(C, block);
+	}
 
 	/* we set this only once */
 	GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
@@ -1591,12 +1610,15 @@ void UI_block_draw(const bContext *C, uiBlock *block)
 	wmOrtho2_region_pixelspace(ar);
 
 	/* back */
-	if (block->flag & UI_BLOCK_RADIAL)
+	if (block->flag & UI_BLOCK_RADIAL) {
 		ui_draw_pie_center(block);
-	else if (block->flag & UI_BLOCK_POPOVER)
+	}
+	else if (block->flag & UI_BLOCK_POPOVER) {
 		ui_draw_popover_back(ar, &style, block, &rect);
-	else if (block->flag & UI_BLOCK_LOOP)
+	}
+	else if (block->flag & UI_BLOCK_LOOP) {
 		ui_draw_menu_back(&style, block, &rect);
+	}
 	else if (block->panel) {
 		bool show_background = ar->alignment != RGN_ALIGN_FLOAT;
 		ui_draw_aligned_panel(
@@ -1615,8 +1637,9 @@ void UI_block_draw(const bContext *C, uiBlock *block)
 
 			/* XXX: figure out why invalid coordinates happen when closing render window */
 			/* and material preview is redrawn in main window (temp fix for bug #23848) */
-			if (rect.xmin < rect.xmax && rect.ymin < rect.ymax)
+			if (rect.xmin < rect.xmax && rect.ymin < rect.ymax) {
 				ui_draw_but(C, ar, &style, but, &rect);
+			}
 		}
 	}
 
@@ -1699,13 +1722,17 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
 			case UI_BTYPE_ICON_TOGGLE:
 			case UI_BTYPE_CHECKBOX:
 				UI_GET_BUT_VALUE_INIT(but, *value);
-				if (*value != (double)but->hardmin) is_push = true;
+				if (*value != (double)but->hardmin) {
+					is_push = true;
+				}
 				break;
 			case UI_BTYPE_ICON_TOGGLE_N:
 			case UI_BTYPE_TOGGLE_N:
 			case UI_BTYPE_CHECKBOX_N:
 				UI_GET_BUT_VALUE_INIT(but, *value);
-				if (*value == 0.0) is_push = true;
+				if (*value == 0.0) {
+					is_push = true;
+				}
 				break;
 			case UI_BTYPE_ROW:
 			case UI_BTYPE_LISTROW:
@@ -1728,10 +1755,14 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
 				UI_GET_BUT_VALUE_INIT(but, *value);
 				/* support for rna enum buts */
 				if (but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) {
-					if ((int)*value & (int)but->hardmax) is_push = true;
+					if ((int)*value & (int)but->hardmax) {
+						is_push = true;
+					}
 				}
 				else {
-					if (*value == (double)but->hardmax) is_push = true;
+					if (*value == (double)but->hardmax) {
+						is_push = true;
+					}
 				}
 				break;
 			default:
@@ -1945,25 +1976,30 @@ void ui_but_v3_set(uiBut *but, const float vec[3])
 
 bool ui_but_is_float(const uiBut *but)
 {
-	if (but->pointype == UI_BUT_POIN_FLOAT && but->poin)
+	if (but->pointype == UI_BUT_POIN_FLOAT && but->poin) {
 		return true;
+	}
 
-	if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT)
+	if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT) {
 		return true;
+	}
 
 	return false;
 }
 
 bool ui_but_is_bool(const uiBut *but)
 {
-	if (ELEM(but->type, UI_BTYPE_TOGGLE, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_TAB))
+	if (ELEM(but->type, UI_BTYPE_TOGGLE, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_TAB)) {
 		return true;
+	}
 
-	if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_BOOLEAN)
+	if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_BOOLEAN) {
 		return true;
+	}
 
-	if ((but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) && (but->type == UI_BTYPE_ROW))
+	if ((but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) && (but->type == UI_BTYPE_ROW)) {
 		return true;
+	}
 
 	return false;
 }
@@ -1974,17 +2010,20 @@ bool ui_but_is_unit(const uiBut *but)
 	UnitSettings *unit = but->block->unit;
 	const int unit_type = UI_but_unit_type_get(but);
 
-	if (unit_type == PROP_UNIT_NONE)
+	if (unit_type == PROP_UNIT_NONE) {
 		return false;
+	}
 
 #if 1 /* removed so angle buttons get correct snapping */
-	if (ui_but_is_unit_radians_ex(unit, unit_type))
+	if (ui_but_is_unit_radians_ex(unit, unit_type)) {
 		return false;
+	}
 #endif
 
 	/* for now disable time unit conversion */
-	if (unit_type == PROP_UNIT_TIME)
+	if (unit_type == PROP_UNIT_TIME) {
 		return false;
+	}
 
 	if (unit->system == USER_UNIT_NONE) {
 		if (unit_type != PROP_UNIT_ROTATION) {
@@ -2000,20 +2039,25 @@ bool ui_but_is_unit(const uiBut *but)
  */
 bool ui_but_is_compatible(const uiBut *but_a, const uiBut *but_b)
 {
-	if (but_a->type != but_b->type)
+	if (but_a->type != but_b->type) {
 		return false;
-	if (but_a->pointype != but_b->pointype)
+	}
+	if (but_a->pointype != but_b->pointype) {
 		return false;
+	}
 
 	if (but_a->rnaprop) {
 		/* skip 'rnapoin.data', 'rnapoin.id.data'
 		 * allow different data to have the same props edited at once */
-		if (but_a->rnapoin.type != but_b->rnapoin.type)
+		if (but_a->rnapoin.type != but_b->rnapoin.type) {
 			return false;
-	

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list