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.c | 432 ++++++---- source/blender/editors/interface/interface_align.c | 42 +- source/blender/editors/interface/interface_anim.c | 21 +- .../editors/interface/interface_context_menu.c | 6 +- source/blender/editors/interface/interface_draw.c | 131 ++- .../editors/interface/interface_eyedropper.c | 6 +- .../interface/interface_eyedropper_driver.c | 14 +- .../blender/editors/interface/interface_handlers.c | 893 ++++++++++++++------- source/blender/editors/interface/interface_icons.c | 95 ++- .../blender/editors/interface/interface_layout.c | 405 +++++++--- source/blender/editors/interface/interface_ops.c | 54 +- source/blender/editors/interface/interface_panel.c | 347 +++++--- source/blender/editors/interface/interface_query.c | 64 +- .../interface/interface_region_color_picker.c | 33 +- .../editors/interface/interface_region_menu_pie.c | 6 +- .../interface/interface_region_menu_popup.c | 3 +- .../editors/interface/interface_region_popover.c | 3 +- .../editors/interface/interface_region_popup.c | 146 ++-- .../editors/interface/interface_region_search.c | 33 +- .../editors/interface/interface_region_tooltip.c | 21 +- .../blender/editors/interface/interface_regions.c | 3 +- source/blender/editors/interface/interface_style.c | 37 +- .../editors/interface/interface_templates.c | 283 ++++--- source/blender/editors/interface/interface_utils.c | 81 +- .../blender/editors/interface/interface_widgets.c | 309 ++++--- source/blender/editors/interface/resources.c | 54 +- source/blender/editors/interface/view2d.c | 384 ++++++--- source/blender/editors/interface/view2d_ops.c | 221 +++-- 28 files changed, 2819 insertions(+), 1308 deletions(-) (limited to 'source/blender/editors/interface') 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; - if (RNA_property_type(but_a->rnaprop) != RNA_property_type(but_b->rnaprop)) + } + if (RNA_property_type(but_a->rnaprop) != RNA_property_type(but_b->rnaprop)) { return false; - if (RNA_property_subtype(but_a->rnaprop) != RNA_property_subtype(but_b->rnaprop)) + } + if (RNA_property_subtype(but_a->rnaprop) != RNA_property_subtype(but_b->rnaprop)) { return false; + } } return true; @@ -2046,8 +2090,12 @@ double ui_but_value_get(uiBut *but) PropertyRNA *prop; double value = 0.0; - if (but->editval) { return *(but->editval); } - if (but->poin == NULL && but->rnapoin.data == NULL) return 0.0; + if (but->editval) { + return *(but->editval); + } + if (but->poin == NULL && but->rnapoin.data == NULL) { + return 0.0; + } if (but->rnaprop) { prop = but->rnaprop; @@ -2058,22 +2106,28 @@ double ui_but_value_get(uiBut *but) switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_check(prop)) + if (RNA_property_array_check(prop)) { value = RNA_property_boolean_get_index(&rnapoin_eval, prop, but->rnaindex); - else + } + else { value = RNA_property_boolean_get(&rnapoin_eval, prop); + } break; case PROP_INT: - if (RNA_property_array_check(prop)) + if (RNA_property_array_check(prop)) { value = RNA_property_int_get_index(&rnapoin_eval, prop, but->rnaindex); - else + } + else { value = RNA_property_int_get(&rnapoin_eval, prop); + } break; case PROP_FLOAT: - if (RNA_property_array_check(prop)) + if (RNA_property_array_check(prop)) { value = RNA_property_float_get_index(&rnapoin_eval, prop, but->rnaindex); - else + } + else { value = RNA_property_float_get(&rnapoin_eval, prop); + } break; case PROP_ENUM: value = RNA_property_enum_get(&rnapoin_eval, prop); @@ -2110,22 +2164,28 @@ void ui_but_value_set(uiBut *but, double value) if (RNA_property_editable(&but->rnapoin, prop)) { switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_check(prop)) + if (RNA_property_array_check(prop)) { RNA_property_boolean_set_index(&but->rnapoin, prop, but->rnaindex, value); - else + } + else { RNA_property_boolean_set(&but->rnapoin, prop, value); + } break; case PROP_INT: - if (RNA_property_array_check(prop)) + if (RNA_property_array_check(prop)) { RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, (int)value); - else + } + else { RNA_property_int_set(&but->rnapoin, prop, (int)value); + } break; case PROP_FLOAT: - if (RNA_property_array_check(prop)) + if (RNA_property_array_check(prop)) { RNA_property_float_set_index(&but->rnapoin, prop, but->rnaindex, value); - else + } + else { RNA_property_float_set(&but->rnapoin, prop, value); + } break; case PROP_ENUM: if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { @@ -2163,21 +2223,29 @@ void ui_but_value_set(uiBut *but, double value) } else if (but->pointype == UI_BUT_POIN_FLOAT) { float fval = (float)value; - if (fval >= -0.00001f && fval <= 0.00001f) fval = 0.0f; /* prevent negative zero */ + if (fval >= -0.00001f && fval <= 0.00001f) { + /* prevent negative zero */ + fval = 0.0f; + } value = fval; } /* then set value with possible edit override */ - if (but->editval) + if (but->editval) { value = *but->editval = value; - else if (but->pointype == UI_BUT_POIN_CHAR) + } + else if (but->pointype == UI_BUT_POIN_CHAR) { value = *((char *)but->poin) = (char)value; - else if (but->pointype == UI_BUT_POIN_SHORT) + } + else if (but->pointype == UI_BUT_POIN_SHORT) { value = *((short *)but->poin) = (short)value; - else if (but->pointype == UI_BUT_POIN_INT) + } + else if (but->pointype == UI_BUT_POIN_INT) { value = *((int *)but->poin) = (int)value; - else if (but->pointype == UI_BUT_POIN_FLOAT) + } + else if (but->pointype == UI_BUT_POIN_FLOAT) { value = *((float *)but->poin) = (float)value; + } } ui_but_update_select_flag(but, &value); @@ -2185,10 +2253,12 @@ void ui_but_value_set(uiBut *but, double value) int ui_but_string_get_max_length(uiBut *but) { - if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) + if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { return but->hardmax; - else + } + else { return UI_MAX_DRAW_STR; + } } uiBut *ui_but_drag_multi_edit_get(uiBut *but) @@ -2313,14 +2383,20 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va int unit_type = UI_but_unit_type_get(but); int precision; - if (unit->scale_length < 0.0001f) unit->scale_length = 1.0f; // XXX do_versions + if (unit->scale_length < 0.0001f) { + unit->scale_length = 1.0f; // XXX do_versions + } /* Use precision override? */ if (float_precision == -1) { /* Sanity checks */ precision = (int)but->a2; - if (precision > UI_PRECISION_FLOAT_MAX) precision = UI_PRECISION_FLOAT_MAX; - else if (precision == -1) precision = 2; + if (precision > UI_PRECISION_FLOAT_MAX) { + precision = UI_PRECISION_FLOAT_MAX; + } + else if (precision == -1) { + precision = 2; + } } else { precision = float_precision; @@ -2776,8 +2852,8 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str) } /* not that we use hard limits here */ - if (value < (double)but->hardmin) value = but->hardmin; - if (value > (double)but->hardmax) value = but->hardmax; + if (value < (double)but->hardmin) { value = but->hardmin; } + if (value > (double)but->hardmax) { value = but->hardmax; } ui_but_value_set(but, value); return true; @@ -2810,12 +2886,15 @@ static double soft_range_round_up(double value, double max) * checking for 0.0 prevents floating point exceptions */ double newmax = (value != 0.0) ? pow(10.0, ceil(log(value) / M_LN10)) : 0.0; - if (newmax * 0.2 >= max && newmax * 0.2 >= value) + if (newmax * 0.2 >= max && newmax * 0.2 >= value) { return newmax * 0.2; - else if (newmax * 0.5 >= max && newmax * 0.5 >= value) + } + else if (newmax * 0.5 >= max && newmax * 0.5 >= value) { return newmax * 0.5; - else + } + else { return newmax; + } } static double soft_range_round_down(double value, double max) @@ -2824,12 +2903,15 @@ static double soft_range_round_down(double value, double max) * checking for 0.0 prevents floating point exceptions */ double newmax = (value != 0.0) ? pow(10.0, floor(log(value) / M_LN10)) : 0.0; - if (newmax * 5.0 <= max && newmax * 5.0 <= value) + if (newmax * 5.0 <= max && newmax * 5.0 <= value) { return newmax * 5.0; - else if (newmax * 2.0 <= max && newmax * 2.0 <= value) + } + else if (newmax * 2.0 <= max && newmax * 2.0 <= value) { return newmax * 2.0; - else + } + else { return newmax; + } } /* note: this could be split up into functions which handle arrays and not */ @@ -2893,22 +2975,28 @@ static void ui_set_but_soft_range(uiBut *but) /* if the value goes out of the soft/max range, adapt the range */ if (value_min + 1e-10 < softmin) { - if (value_min < 0.0) + if (value_min < 0.0) { softmin = -soft_range_round_up(-value_min, -softmin); - else + } + else { softmin = soft_range_round_down(value_min, softmin); + } - if (softmin < (double)but->hardmin) + if (softmin < (double)but->hardmin) { softmin = (double)but->hardmin; + } } if (value_max - 1e-10 > softmax) { - if (value_max < 0.0) + if (value_max < 0.0) { softmax = -soft_range_round_down(-value_max, -softmax); - else + } + else { softmax = soft_range_round_up(value_max, softmax); + } - if (softmax > (double)but->hardmax) + if (softmax > (double)but->hardmax) { softmax = but->hardmax; + } } but->softmin = softmin; @@ -3053,8 +3141,9 @@ void UI_blocklist_free_inactive(const bContext *C, ListBase *lb) BLI_remlink(lb, block); UI_block_free(C, block); } - else + else { block->active = 0; + } } } } @@ -3114,8 +3203,9 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, sh BLI_strncpy(block->name, name, sizeof(block->name)); - if (region) + if (region) { UI_block_region_set(block, region); + } /* Set window matrix and aspect for region and OpenGL state. */ ui_update_window_matrix(window, region, block); @@ -3348,14 +3438,18 @@ static void ui_but_update_ex(uiBut *but, const bool validate) char *str = but->drawstr; but->drawstr[0] = '\0'; - if (but->modifier_key & KM_SHIFT) + if (but->modifier_key & KM_SHIFT) { str += BLI_strcpy_rlen(str, "Shift "); - if (but->modifier_key & KM_CTRL) + } + if (but->modifier_key & KM_CTRL) { str += BLI_strcpy_rlen(str, "Ctrl "); - if (but->modifier_key & KM_ALT) + } + if (but->modifier_key & KM_ALT) { str += BLI_strcpy_rlen(str, "Alt "); - if (but->modifier_key & KM_OSKEY) + } + if (but->modifier_key & KM_OSKEY) { str += BLI_strcpy_rlen(str, "Cmd "); + } (void)str; /* UNUSED */ } @@ -3363,8 +3457,9 @@ static void ui_but_update_ex(uiBut *but, const bool validate) BLI_strncpy(but->drawstr, "Press a key", UI_MAX_DRAW_STR); } } - else + else { BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); + } break; @@ -3378,8 +3473,9 @@ static void ui_but_update_ex(uiBut *but, const bool validate) } /* if we are doing text editing, this will override the drawstr */ - if (but->editstr) + if (but->editstr) { but->drawstr[0] = '\0'; + } /* text clipping moved to widget drawing code itself */ } @@ -3397,7 +3493,9 @@ void ui_but_update_edited(uiBut *but) void UI_block_align_begin(uiBlock *block) { /* if other align was active, end it */ - if (block->flag & UI_BUT_ALIGN) UI_block_align_end(block); + if (block->flag & UI_BUT_ALIGN) { + UI_block_align_end(block); + } block->flag |= UI_BUT_ALIGN_DOWN; block->alignnr++; @@ -3497,16 +3595,18 @@ static uiBut *ui_def_but( but->block = block; /* pointer back, used for frontbuffer status, and picker */ - if ((block->flag & UI_BUT_ALIGN) && ui_but_can_align(but)) + if ((block->flag & UI_BUT_ALIGN) && ui_but_can_align(but)) { but->alignnr = block->alignnr; + } but->func = block->func; but->func_arg1 = block->func_arg1; but->func_arg2 = block->func_arg2; but->funcN = block->funcN; - if (block->func_argN) + if (block->func_argN) { but->func_argN = MEM_dupallocN(block->func_argN); + } but->pos = -1; /* cursor invisible */ @@ -3565,8 +3665,9 @@ static uiBut *ui_def_but( BLI_addtail(&block->buttons, but); - if (block->curlayout) + if (block->curlayout) { ui_layout_add_but(block->curlayout, but); + } #ifdef WITH_PYTHON /* if the 'UI_OT_editsource' is running, extract the source info from the button */ @@ -3637,16 +3738,20 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu /* Columns and row estimation. Ignore simple separators here. */ columns = (nbr_entries_nosepr + 20) / 20; - if (columns < 1) + if (columns < 1) { columns = 1; - if (columns > 8) + } + if (columns > 8) { columns = (nbr_entries_nosepr + 25) / 25; + } rows = totitems / columns; - if (rows < 1) + if (rows < 1) { rows = 1; - while (rows * columns < totitems) + } + while (rows * columns < totitems) { rows++; + } if (block->flag & UI_BLOCK_NO_FLIP) { /* Title at the top for menus with categories. */ @@ -3810,8 +3915,9 @@ static uiBut *ui_def_but_rna( icon = RNA_property_ui_icon(prop); } - if (!tip && proptype != PROP_ENUM) + if (!tip && proptype != PROP_ENUM) { tip = RNA_property_ui_description(prop); + } if (min == max || a1 == -1 || a2 == -1) { if (proptype == PROP_INT) { @@ -3824,10 +3930,12 @@ static uiBut *ui_def_but_rna( min = hardmin; max = hardmax; } - if (a1 == -1) + if (a1 == -1) { a1 = step; - if (a2 == -1) + } + if (a2 == -1) { a2 = 0; + } } else if (proptype == PROP_FLOAT) { float hardmin, hardmax, softmin, softmax, step, precision; @@ -3839,10 +3947,12 @@ static uiBut *ui_def_but_rna( min = hardmin; max = hardmax; } - if (a1 == -1) + if (a1 == -1) { a1 = step; - if (a2 == -1) + } + if (a2 == -1) { a2 = precision; + } } else if (proptype == PROP_STRING) { min = 0; @@ -3857,10 +3967,12 @@ static uiBut *ui_def_but_rna( but->rnapoin = *ptr; but->rnaprop = prop; - if (RNA_property_array_check(but->rnaprop)) + if (RNA_property_array_check(but->rnaprop)) { but->rnaindex = index; - else + } + else { but->rnaindex = 0; + } if (icon) { ui_def_but_icon(but, icon, UI_HAS_ICON); @@ -3922,10 +4034,12 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * uiBut *but; if (!str) { - if (ot && ot->srna) + if (ot && ot->srna) { str = RNA_struct_ui_name(ot->srna); - else + } + else { str = ""; + } } if ((!tip || tip[0] == '\0') && ot && ot->srna) { @@ -4009,15 +4123,17 @@ void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name) int a; for (a = 0; a < autocpl->maxlen - 1; a++) { - if (startname[a] == 0 || startname[a] != name[a]) + if (startname[a] == 0 || startname[a] != name[a]) { break; + } } /* found a match */ if (startname[a] == 0) { autocpl->matches++; /* first match */ - if (truncate[0] == 0) + if (truncate[0] == 0) { BLI_strncpy(truncate, name, autocpl->maxlen); + } else { /* remove from truncate what is not in bone->name */ for (a = 0; a < autocpl->maxlen - 1; a++) { @@ -4025,8 +4141,9 @@ void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name) truncate[a] = 0; break; } - else if (truncate[a] != name[a]) + else if (truncate[a] != name[a]) { truncate[a] = 0; + } } } } @@ -4131,7 +4248,9 @@ uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); - if (str == NULL && ot == NULL) str = opname; + if (str == NULL && ot == NULL) { + str = opname; + } return uiDefButO_ptr(block, type, ot, opcontext, str, x, y, width, height, tip); } @@ -4291,8 +4410,9 @@ uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int o uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); - if (str && str[0] == '\0') + if (str && str[0] == '\0') { return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x, y, width, height, tip); + } return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x, y, width, height, tip); } @@ -4305,9 +4425,11 @@ int UI_blocklist_min_y_get(ListBase *lb) uiBlock *block; int min = 0; - for (block = lb->first; block; block = block->next) - if (block == lb->first || block->rect.ymin < min) + for (block = lb->first; block; block = block->next) { + if (block == lb->first || block->rect.ymin < min) { min = block->rect.ymin; + } + } return min; } @@ -4323,15 +4445,23 @@ void UI_block_order_flip(uiBlock *block) uiBut *but; float centy, miny = 10000, maxy = -10000; - if (U.uiflag & USER_MENUFIXEDORDER) + if (U.uiflag & USER_MENUFIXEDORDER) { return; - else if (block->flag & UI_BLOCK_NO_FLIP) + } + else if (block->flag & UI_BLOCK_NO_FLIP) { return; + } for (but = block->buttons.first; but; but = but->next) { - if (but->drawflag & UI_BUT_ALIGN) return; - if (but->rect.ymin < miny) miny = but->rect.ymin; - if (but->rect.ymax > maxy) maxy = but->rect.ymax; + if (but->drawflag & UI_BUT_ALIGN) { + return; + } + if (but->rect.ymin < miny) { + miny = but->rect.ymin; + } + if (but->rect.ymax > maxy) { + maxy = but->rect.ymax; + } } /* mirror trick */ centy = (miny + maxy) / 2.0f; @@ -4748,8 +4878,9 @@ void UI_but_func_search_set( /* search buttons show red-alert if item doesn't exist, not for menus */ if (0 == (but->block->flag & UI_BLOCK_LOOP)) { /* skip empty buttons, not all buttons need input, we only show invalid */ - if (but->drawstr[0]) + if (but->drawstr[0]) { ui_but_search_refresh(but); + } } } @@ -4778,8 +4909,9 @@ static void operator_enum_search_cb(const struct bContext *C, void *but, const c /* note: need to give the index rather than the * identifier because the enum can be freed */ if (BLI_strcasestr(item->name, str)) { - if (false == UI_search_item_add(items, item->name, POINTER_FROM_INT(item->value), item->icon)) + if (false == UI_search_item_add(items, item->name, POINTER_FROM_INT(item->value), item->icon)) { break; + } } } @@ -4898,21 +5030,26 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) if (but->tip_func) { tmp = but->tip_func(C, but->tip_argN, but->tip); } - else if (but->tip && but->tip[0]) + else if (but->tip && but->tip[0]) { tmp = BLI_strdup(but->tip); - else + } + else { type = BUT_GET_RNA_TIP; /* Fail-safe solution... */ + } } if (type == BUT_GET_RNAPROP_IDENTIFIER) { - if (but->rnaprop) + if (but->rnaprop) { tmp = BLI_strdup(RNA_property_identifier(but->rnaprop)); + } } else if (type == BUT_GET_RNASTRUCT_IDENTIFIER) { - if (but->rnaprop && but->rnapoin.data) + if (but->rnaprop && but->rnapoin.data) { tmp = BLI_strdup(RNA_struct_identifier(but->rnapoin.type)); - else if (but->optype) + } + else if (but->optype) { tmp = BLI_strdup(but->optype->idname); + } else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) { MenuType *mt = UI_but_menutype_get(but); if (mt) { @@ -4928,21 +5065,25 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) } else if (ELEM(type, BUT_GET_RNA_LABEL, BUT_GET_RNA_TIP)) { if (but->rnaprop) { - if (type == BUT_GET_RNA_LABEL) + if (type == BUT_GET_RNA_LABEL) { tmp = BLI_strdup(RNA_property_ui_name(but->rnaprop)); + } else { const char *t = RNA_property_ui_description(but->rnaprop); - if (t && t[0]) + if (t && t[0]) { tmp = BLI_strdup(t); + } } } else if (but->optype) { - if (type == BUT_GET_RNA_LABEL) + if (type == BUT_GET_RNA_LABEL) { tmp = BLI_strdup(RNA_struct_ui_name(but->optype->srna)); + } else { const char *t = RNA_struct_ui_description(but->optype->srna); - if (t && t[0]) + if (t && t[0]) { tmp = BLI_strdup(t); + } } } else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) { @@ -4950,12 +5091,14 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) if (mt) { /* not all menus are from python */ if (mt->ext.srna) { - if (type == BUT_GET_RNA_LABEL) + if (type == BUT_GET_RNA_LABEL) { tmp = BLI_strdup(RNA_struct_ui_name(mt->ext.srna)); + } else { const char *t = RNA_struct_ui_description(mt->ext.srna); - if (t && t[0]) + if (t && t[0]) { tmp = BLI_strdup(t); + } } } } @@ -4963,14 +5106,17 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) } else if (type == BUT_GET_RNA_LABEL_CONTEXT) { const char *_tmp = BLT_I18NCONTEXT_DEFAULT; - if (but->rnaprop) + if (but->rnaprop) { _tmp = RNA_property_translation_context(but->rnaprop); - else if (but->optype) + } + else if (but->optype) { _tmp = RNA_struct_translation_context(but->optype->srna); + } else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) { MenuType *mt = UI_but_menutype_get(but); - if (mt) + if (mt) { _tmp = RNA_struct_translation_context(mt->ext.srna); + } } if (BLT_is_default_context(_tmp)) { _tmp = BLT_I18NCONTEXT_DEFAULT_BPYRNA; @@ -5017,17 +5163,21 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) RNA_property_enum_items_gettexted(C, ptr, prop, &items, &totitems, &free_items); for (i = 0, item = items; i < totitems; i++, item++) { - if (item->identifier[0] && item->value == value) + if (item->identifier[0] && item->value == value) { break; + } } } if (item && item->identifier) { - if (type == BUT_GET_RNAENUM_IDENTIFIER) + if (type == BUT_GET_RNAENUM_IDENTIFIER) { tmp = BLI_strdup(item->identifier); - else if (type == BUT_GET_RNAENUM_LABEL) + } + else if (type == BUT_GET_RNAENUM_LABEL) { tmp = BLI_strdup(item->name); - else if (item->description && item->description[0]) + } + else if (item->description && item->description[0]) { tmp = BLI_strdup(item->description); + } } } } diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c index 9fc8c8f4bb1..8e7dc792da6 100644 --- a/source/blender/editors/interface/interface_align.c +++ b/source/blender/editors/interface/interface_align.c @@ -555,8 +555,12 @@ static void ui_block_align_calc_but(uiBut *first, short nr) for (but = first; but && but->alignnr == nr; but = but->next) { if (but->next && but->next->alignnr == nr) { - if (buts_are_horiz(but, but->next)) cols++; - else rows++; + if (buts_are_horiz(but, but->next)) { + cols++; + } + else { + rows++; + } } } @@ -565,8 +569,9 @@ static void ui_block_align_calc_but(uiBut *first, short nr) /* note; how it uses 'flag' in loop below (either set it, or OR it) is confusing */ for (but = first, prev = NULL; but && but->alignnr == nr; prev = but, but = but->next) { next = but->next; - if (next && next->alignnr != nr) + if (next && next->alignnr != nr) { next = NULL; + } /* clear old flag */ but->drawflag &= ~UI_BUT_ALIGN; @@ -574,10 +579,12 @@ static void ui_block_align_calc_but(uiBut *first, short nr) if (flag == 0) { /* first case */ if (next) { if (buts_are_horiz(but, next)) { - if (rows == 0) + if (rows == 0) { flag = UI_BUT_ALIGN_RIGHT; - else + } + else { flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_RIGHT; + } } else { flag = UI_BUT_ALIGN_DOWN; @@ -587,10 +594,12 @@ static void ui_block_align_calc_but(uiBut *first, short nr) else if (next == NULL) { /* last case */ if (prev) { if (buts_are_horiz(prev, but)) { - if (rows == 0) + if (rows == 0) { flag = UI_BUT_ALIGN_LEFT; - else + } + else { flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT; + } } else { flag = UI_BUT_ALIGN_TOP; @@ -611,7 +620,9 @@ static void ui_block_align_calc_but(uiBut *first, short nr) } bt = bt->next; } - if (bt == NULL || bt->alignnr != nr) flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT; + if (bt == NULL || bt->alignnr != nr) { + flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT; + } } } else { @@ -624,8 +635,9 @@ static void ui_block_align_calc_but(uiBut *first, short nr) } else { /* next button switches to new row */ - if (prev && buts_are_horiz(prev, but)) + if (prev && buts_are_horiz(prev, but)) { flag |= UI_BUT_ALIGN_LEFT; + } else { flag &= ~UI_BUT_ALIGN_LEFT; flag |= UI_BUT_ALIGN_TOP; @@ -633,18 +645,21 @@ static void ui_block_align_calc_but(uiBut *first, short nr) if ((flag & UI_BUT_ALIGN_TOP) == 0) { /* still top row */ if (prev) { - if (next && buts_are_horiz(but, next)) + if (next && buts_are_horiz(but, next)) { flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT; + } else { /* last button in top row */ flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_LEFT; } } - else + else { flag |= UI_BUT_ALIGN_DOWN; + } } - else + else { flag |= UI_BUT_ALIGN_TOP; + } } } @@ -674,8 +689,9 @@ static void ui_block_align_calc_but(uiBut *first, short nr) prev->rect.ymin = but->rect.ymax; but->rect.xmin = prev->rect.xmin; - if (next && buts_are_horiz(but, next) == 0) + if (next && buts_are_horiz(but, next) == 0) { but->rect.xmax = prev->rect.xmax; + } } else { /* the previous button is not a single one in its row */ diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index c8a9f3b9446..a4476b4d2f1 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -86,16 +86,19 @@ void ui_but_anim_flag(uiBut *but, float cfra) * we need to correct the frame number to "look inside" the * remapped action */ - if (adt) + if (adt) { cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); + } - if (fcurve_frame_has_keyframe(fcu, cfra, 0)) + if (fcurve_frame_has_keyframe(fcu, cfra, 0)) { but->flag |= UI_BUT_ANIMATED_KEY; + } /* XXX: this feature is totally broken and useless with NLA */ if (adt == NULL || adt->nla_tracks.first == NULL) { - if (fcurve_is_changed(but->rnapoin, but->rnaprop, fcu, cfra)) + if (fcurve_is_changed(but->rnapoin, but->rnaprop, fcu, cfra)) { but->drawflag |= UI_BUT_ANIMATED_CHANGED; + } } } else { @@ -196,15 +199,17 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str) /* button must have RNA-pointer to a numeric-capable property */ if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("ERROR: create expression failed - button has no RNA info attached\n"); + } return false; } if (RNA_property_array_check(but->rnaprop) != 0) { if (but->rnaindex == -1) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("ERROR: create expression failed - can't create expression for entire array\n"); + } return false; } } @@ -214,8 +219,9 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str) * don't allow drivers to be created for them */ id = (ID *)but->rnapoin.id.data; if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("ERROR: create expression failed - invalid data-block for adding drivers (%p)\n", id); + } return false; } @@ -262,8 +268,9 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) fcu = ui_but_get_fcurve(but, NULL, &action, &driven, &special); - if (fcu == NULL) + if (fcu == NULL) { return; + } if (special) { /* NLA Strip property */ diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index 5c870e6a281..b5eb6302f81 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -139,8 +139,9 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) kmi_id = kmi->id; /* copy properties, prop can be NULL for reset */ - if (prop) + if (prop) { prop = IDP_CopyProperty(prop); + } WM_keymap_properties_reset(kmi, prop); /* update and get pointers again */ @@ -407,8 +408,9 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) /* second slower test, * saved people finding keyframe items in menus when its not possible */ - if (is_anim) + if (is_anim) { is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop); + } /* determine if we can key a single component of an array */ const bool is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0; diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index da85ed2840d..4185339cc92 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -637,7 +637,9 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColors *UN #else ImBuf *ibuf = (ImBuf *)but->poin; - if (!ibuf) return; + if (!ibuf) { + return; + } float facx = 1.0f; float facy = 1.0f; @@ -732,8 +734,9 @@ static void histogram_draw_one( float color[4] = {r, g, b, alpha}; /* that can happen */ - if (res == 0) + if (res == 0) { return; + } GPU_line_smooth(true); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE); @@ -846,12 +849,15 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColors histogram_draw_one(1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_a, res, is_line, pos); } else { - if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_R) + if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_R) { histogram_draw_one(1.0, 0.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_r, res, is_line, pos); - if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_G) + } + if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_G) { histogram_draw_one(0.0, 1.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_g, res, is_line, pos); - if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_B) + } + if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_B) { histogram_draw_one(0.0, 0.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_b, res, is_line, pos); + } } immUnbindProgram(); @@ -891,7 +897,9 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColors float colors_alpha[3][3], colorsycc_alpha[3][3]; float min, max; - if (scopes == NULL) return; + if (scopes == NULL) { + return; + } rctf rect = { .xmin = (float)recti->xmin + 1, @@ -900,8 +908,9 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColors .ymax = (float)recti->ymax - 1, }; - if (scopes->wavefrm_yfac < 0.5f) + if (scopes->wavefrm_yfac < 0.5f) { scopes->wavefrm_yfac = 0.98f; + } float w = BLI_rctf_size_x(&rect) - 7; float h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac; float yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) * 0.5f; @@ -1083,10 +1092,12 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColors /* min max */ if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA ) { for (int c = 0; c < 3; c++) { - if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_RGB_PARADE, SCOPES_WAVEFRM_RGB)) + if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_RGB_PARADE, SCOPES_WAVEFRM_RGB)) { immUniformColor3f(colors[c][0] * 0.75f, colors[c][1] * 0.75f, colors[c][2] * 0.75f); - else + } + else { immUniformColor3f(colorsycc[c][0] * 0.75f, colorsycc[c][1] * 0.75f, colorsycc[c][2] * 0.75f); + } min = yofs + scopes->minmax[c][0] * h; max = yofs + scopes->minmax[c][1] * h; CLAMP(min, rect.ymin, rect.ymax); @@ -1125,11 +1136,22 @@ static void vectorscope_draw_target(uint pos, float centerx, float centery, floa float dangle, dampli, dangle2, dampli2; rgb_to_yuv(colf[0], colf[1], colf[2], &y, &u, &v, BLI_YUV_ITU_BT709); - if (u > 0 && v >= 0) tangle = atanf(v / u); - else if (u > 0 && v < 0) tangle = atanf(v / u) + 2.0f * (float)M_PI; - else if (u < 0) tangle = atanf(v / u) + (float)M_PI; - else if (u == 0 && v > 0.0f) tangle = M_PI_2; - else if (u == 0 && v < 0.0f) tangle = -M_PI_2; + + if (u > 0 && v >= 0) { + tangle = atanf(v / u); + } + else if (u > 0 && v < 0) { + tangle = atanf(v / u) + 2.0f * (float)M_PI; + } + else if (u < 0) { + tangle = atanf(v / u) + (float)M_PI; + } + else if (u == 0 && v > 0.0f) { + tangle = M_PI_2; + } + else if (u == 0 && v < 0.0f) { + tangle = -M_PI_2; + } tampli = sqrtf(u * u + v * v); /* small target vary by 2.5 degree and 2.5 IRE unit */ @@ -1249,8 +1271,9 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColo immEnd(); /* saturation points */ - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { vectorscope_draw_target(pos, centerx, centery, diam, colors[i]); + } if (scopes->ok && scopes->vecscope != NULL) { /* pixel point cloud */ @@ -1380,16 +1403,20 @@ static void ui_draw_colorband_handle( ui_draw_colorband_handle_tri(shdr_pos, x, y1 + height, half_width, half_width, true); - if (active) + if (active) { immUniformColor3ub(196, 196, 196); - else + } + else { immUniformColor3ub(96, 96, 96); + } ui_draw_colorband_handle_tri(shdr_pos, x, y1 + height, half_width, half_width, true); - if (active) + if (active) { immUniformColor3ub(255, 255, 255); - else + } + else { immUniformColor3ub(128, 128, 128); + } ui_draw_colorband_handle_tri_hlight(shdr_pos, x, y1 + height - 1, (half_width - 1), (half_width - 1)); immUniformColor3ub(0, 0, 0); @@ -1414,7 +1441,9 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const uint pos_id, col_id; ColorBand *coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin); - if (coba == NULL) return; + if (coba == NULL) { + return; + } float x1 = rect->xmin; float sizex = rect->xmax - x1; @@ -1454,8 +1483,9 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const for (int a = 0; a <= sizex; a++) { float pos = ((float)a) / sizex; BKE_colorband_evaluate(coba, pos, colf); - if (display) + if (display) { IMB_colormanagement_scene_linear_to_display_v3(colf, display); + } v1[0] = v2[0] = x1 + a; @@ -1473,8 +1503,9 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const for (int a = 0; a <= sizex; a++) { float pos = ((float)a) / sizex; BKE_colorband_evaluate(coba, pos, colf); - if (display) + if (display) { IMB_colormanagement_scene_linear_to_display_v3(colf, display); + } v1[0] = v2[0] = x1 + a; @@ -1553,10 +1584,12 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec /* transform to button */ GPU_matrix_push(); - if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect)) + if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect)) { size = 0.5f * BLI_rcti_size_x(rect); - else + } + else { size = 0.5f * BLI_rcti_size_y(rect); + } GPU_matrix_translate_2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect)); GPU_matrix_scale_1f(size); @@ -1592,11 +1625,15 @@ static void ui_draw_but_curve_grid(uint pos, const rcti *rect, float zoomx, floa { float dx = step * zoomx; float fx = rect->xmin + zoomx * (-offsx); - if (fx > rect->xmin) fx -= dx * (floorf(fx - rect->xmin)); + if (fx > rect->xmin) { + fx -= dx * (floorf(fx - rect->xmin)); + } float dy = step * zoomy; float fy = rect->ymin + zoomy * (-offsy); - if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin)); + if (fy > rect->ymin) { + fy -= dy * (floorf(fy - rect->ymin)); + } float line_count = ( floorf((rect->xmax - fx) / dx) + 1.0f + @@ -1775,12 +1812,15 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons immVertex2f(pos, rect->xmin + zoomx * (lum - offsx), rect->ymax); } else { - if (cumap->cur == 0) + if (cumap->cur == 0) { immUniformColor3ub(240, 100, 100); - else if (cumap->cur == 1) + } + else if (cumap->cur == 1) { immUniformColor3ub(100, 240, 100); - else + } + else { immUniformColor3ub(100, 100, 240); + } immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymin); immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymax); @@ -1791,8 +1831,9 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons - if (cuma->table == NULL) + if (cuma->table == NULL) { curvemapping_changed(cumap, false); + } CurveMapPoint *cmp = cuma->table; rctf line_range; @@ -1937,8 +1978,9 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, const uiWidgetCol ((!scopes->track_preview) || (scopes->track_preview->x != width || scopes->track_preview->y != height))) { - if (scopes->track_preview) + if (scopes->track_preview) { IMB_freeImBuf(scopes->track_preview); + } ImBuf *tmpibuf = BKE_tracking_sample_pattern( scopes->frame_width, scopes->frame_height, @@ -1946,13 +1988,16 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, const uiWidgetCol &scopes->undist_marker, true, scopes->use_track_mask, width, height, scopes->track_pos); if (tmpibuf) { - if (tmpibuf->rect_float) + if (tmpibuf->rect_float) { IMB_rect_from_float(tmpibuf); + } - if (tmpibuf->rect) + if (tmpibuf->rect) { scopes->track_preview = tmpibuf; - else + } + else { IMB_freeImBuf(tmpibuf); + } } } @@ -2001,10 +2046,12 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, const uiWidgetCol float x2 = pos_sel[i + 1] * (1 - axe); float y2 = pos_sel[i + 1] * axe; - if (i % 2 == 1) + if (i % 2 == 1) { immAttr4fv(col, col_sel); - else + } + else { immAttr4fv(col, col_outline); + } immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y2); @@ -2082,16 +2129,18 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, const uiWidgetColors *UNUSE GPU_blend(true); immBegin(GPU_PRIM_TRI_FAN, 16); - for (int a = 0; a < 16; a++) + for (int a = 0; a < 16; a++) { immVertex2f(pos, x + size * si[a], y + size * co[a]); + } immEnd(); immUniformColor4ub(0, 0, 0, 150); GPU_line_width(1); GPU_line_smooth(true); immBegin(GPU_PRIM_LINE_LOOP, 16); - for (int a = 0; a < 16; a++) + for (int a = 0; a < 16; a++) { immVertex2f(pos, x + size * si[a], y + size * co[a]); + } immEnd(); GPU_line_smooth(false); GPU_blend(false); @@ -2200,10 +2249,12 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha { float rad; - if (radius > (BLI_rctf_size_y(rct) - 10.0f) * 0.5f) + if (radius > (BLI_rctf_size_y(rct) - 10.0f) * 0.5f) { rad = (BLI_rctf_size_y(rct) - 10.0f) * 0.5f; - else + } + else { rad = radius; + } int a, i = 12; #if 0 diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index f47e0bc4b54..0f0d2c355e8 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -58,8 +58,9 @@ wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Eyedropper Modal Map"); /* this function is called for each spacetype, only needs to add map once */ - if (keymap && keymap->modal_items) + if (keymap && keymap->modal_items) { return NULL; + } keymap = WM_modalkeymap_add(keyconf, "Eyedropper Modal Map", modal_items); @@ -84,8 +85,9 @@ wmKeyMap *eyedropper_colorband_modal_keymap(wmKeyConfig *keyconf) }; wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Eyedropper ColorRamp PointSampling Map"); - if (keymap && keymap->modal_items) + if (keymap && keymap->modal_items) { return keymap; + } keymap = WM_modalkeymap_add(keyconf, "Eyedropper ColorRamp PointSampling Map", modal_items_point); diff --git a/source/blender/editors/interface/interface_eyedropper_driver.c b/source/blender/editors/interface/interface_eyedropper_driver.c index e1f38860721..dd2656e7fa1 100644 --- a/source/blender/editors/interface/interface_eyedropper_driver.c +++ b/source/blender/editors/interface/interface_eyedropper_driver.c @@ -134,10 +134,12 @@ static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *eve } /* cleanup */ - if (target_path) + if (target_path) { MEM_freeN(target_path); - if (dst_path) + } + if (dst_path) { MEM_freeN(dst_path); + } } } @@ -207,8 +209,12 @@ static int driverdropper_exec(bContext *C, wmOperator *op) static bool driverdropper_poll(bContext *C) { - if (!CTX_wm_window(C)) return 0; - else return 1; + if (!CTX_wm_window(C)) { + return 0; + } + else { + return 1; + } } void UI_OT_eyedropper_driver(wmOperatorType *ot) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 212a1742c70..b79bf86c03f 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -440,15 +440,18 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) lastdy += dy; if (ABS(lastdy) > (int)UI_UNIT_Y) { - if (U.uiflag2 & USER_TRACKPAD_NATURAL) + if (U.uiflag2 & USER_TRACKPAD_NATURAL) { dy = -dy; + } *val = KM_PRESS; - if (dy > 0) + if (dy > 0) { *type = WHEELUPMOUSE; - else + } + else { *type = WHEELDOWNMOUSE; + } lastdy = 0; } @@ -521,8 +524,9 @@ static void ui_mouse_scale_warp( */ static bool ui_but_dragedit_update_mval(uiHandleButtonData *data, int mx) { - if (mx == data->draglastx) + if (mx == data->draglastx) { return false; + } if (data->draglock) { if (ABS(mx - data->dragstartx) <= BUTTON_DRAGLOCK_THRESH) { @@ -646,8 +650,9 @@ static void ui_apply_but_func(bContext *C, uiBut *but) /* exception, this will crash due to removed button otherwise */ but->func(C, but->func_arg1, but->func_arg2); } - else + else { after->func = but->func; + } after->func_arg1 = but->func_arg1; after->func_arg2 = but->func_arg2; @@ -669,8 +674,9 @@ static void ui_apply_but_func(bContext *C, uiBut *but) after->a2 = but->a2; } - if (block->handle) + if (block->handle) { after->popup_op = block->handle->popup_op; + } after->optype = but->optype; after->opcontext = but->opcontext; @@ -679,8 +685,9 @@ static void ui_apply_but_func(bContext *C, uiBut *but) after->rnapoin = but->rnapoin; after->rnaprop = but->rnaprop; - if (but->context) + if (but->context) { after->context = CTX_store_copy(but->context); + } but->optype = NULL; but->opcontext = 0; @@ -697,9 +704,15 @@ static void ui_apply_but_undo(uiBut *but) const char *str = NULL; /* define which string to use for undo */ - if (but->type == UI_BTYPE_MENU) str = but->drawstr; - else if (but->drawstr[0]) str = but->drawstr; - else str = but->tip; + if (but->type == UI_BTYPE_MENU) { + str = but->drawstr; + } + else if (but->drawstr[0]) { + str = but->drawstr; + } + else { + str = but->tip; + } /* fallback, else we don't get an undo! */ if (str == NULL || str[0] == '\0') { @@ -751,11 +764,13 @@ static void ui_apply_but_funcs_after(bContext *C) after = *afterf; /* copy to avoid memleak on exit() */ BLI_freelinkN(&funcs, afterf); - if (after.context) + if (after.context) { CTX_store_set(C, after.context); + } - if (after.popup_op) + if (after.popup_op) { popup_check(C, after.popup_op); + } if (after.opptr) { /* free in advance to avoid leak on exit */ @@ -763,39 +778,50 @@ static void ui_apply_but_funcs_after(bContext *C) MEM_freeN(after.opptr); } - if (after.optype) + if (after.optype) { WM_operator_name_call_ptr(C, after.optype, after.opcontext, (after.opptr) ? &opptr : NULL); + } - if (after.opptr) + if (after.opptr) { WM_operator_properties_free(&opptr); + } - if (after.rnapoin.data) + if (after.rnapoin.data) { RNA_property_update(C, &after.rnapoin, after.rnaprop); + } if (after.context) { CTX_store_set(C, NULL); CTX_store_free(after.context); } - if (after.func) + if (after.func) { after.func(C, after.func_arg1, after.func_arg2); - if (after.funcN) + } + if (after.funcN) { after.funcN(C, after.func_argN, after.func_arg2); - if (after.func_argN) + } + if (after.func_argN) { MEM_freeN(after.func_argN); + } - if (after.handle_func) + if (after.handle_func) { after.handle_func(C, after.handle_func_arg, after.retval); - if (after.butm_func) + } + if (after.butm_func) { after.butm_func(C, after.butm_func_arg, after.a2); + } - if (after.rename_func) + if (after.rename_func) { after.rename_func(C, after.rename_arg1, after.rename_orig); - if (after.rename_orig) + } + if (after.rename_orig) { MEM_freeN(after.rename_orig); + } - if (after.undostr[0]) + if (after.undostr[0]) { ED_undo_push(C, after.undostr); + } } } @@ -818,8 +844,9 @@ static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data) { - if (but->type == UI_BTYPE_MENU) + if (but->type == UI_BTYPE_MENU) { ui_but_value_set(but, data->value); + } ui_but_update_edited(but); ui_apply_but_func(C, but); @@ -837,8 +864,12 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data) if (but->bit) { w = UI_BITBUT_TEST(lvalue, but->bitnr); - if (w) lvalue = UI_BITBUT_CLR(lvalue, but->bitnr); - else lvalue = UI_BITBUT_SET(lvalue, but->bitnr); + if (w) { + lvalue = UI_BITBUT_CLR(lvalue, but->bitnr); + } + else { + lvalue = UI_BITBUT_SET(lvalue, but->bitnr); + } ui_but_value_set(but, (double)lvalue); if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) { @@ -847,10 +878,16 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data) } else { - if (value == 0.0) push = 1; - else push = 0; + if (value == 0.0) { + push = 1; + } + else { + push = 0; + } - if (ELEM(but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N)) push = !push; + if (ELEM(but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N)) { + push = !push; + } ui_but_value_set(but, (double)push); if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) { ui_but_update_edited(but); @@ -884,8 +921,9 @@ static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleBu static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data) { - if (!data->str) + if (!data->str) { return; + } ui_but_string_set(C, but, data->str); ui_but_update_edited(but); @@ -1466,8 +1504,9 @@ static bool ui_selectcontext_begin( index = but->rnaindex; /* for now don't support whole colors */ - if (index == -1) + if (index == -1) { return false; + } /* if there is a valid property that is editable... */ if (ptr.data && prop) { @@ -1877,10 +1916,13 @@ static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButton /* if we cancel and have not applied yet, there is nothing to do, * otherwise we have to restore the original value again */ if (data->cancel) { - if (!data->applied) + if (!data->applied) { return; + } - if (data->str) MEM_freeN(data->str); + if (data->str) { + MEM_freeN(data->str); + } data->str = data->origstr; data->origstr = NULL; data->value = data->origvalue; @@ -1968,10 +2010,12 @@ static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButton ui_apply_but_BLOCK(C, but, data); break; case UI_BTYPE_COLOR: - if (data->cancel) + if (data->cancel) { ui_apply_but_VEC(C, but, data); - else + } + else { ui_apply_but_BLOCK(C, but, data); + } break; case UI_BTYPE_BUT_MENU: ui_apply_but_BUTM(C, but, data); @@ -2106,7 +2150,9 @@ static void ui_but_set_float_array(bContext *C, uiBut *but, uiHandleButtonData * for (int i = 0; i < array_length; i++) { RNA_property_float_set_index(&but->rnapoin, but->rnaprop, i, values[i]); } - if (data) data->value = values[but->rnaindex]; + if (data) { + data->value = values[but->rnaindex]; + } button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -2223,16 +2269,19 @@ static void ui_but_copy_color(uiBut *but, char *output, int output_len_max) { float rgba[4]; - if (but->rnaprop && get_but_property_array_length(but) == 4) + if (but->rnaprop && get_but_property_array_length(but) == 4) { rgba[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3); - else + } + else { rgba[3] = 1.0f; + } ui_but_v3_get(but, rgba); /* convert to linear color to do compatible copy between gamma and non-gamma */ - if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) + if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { srgb_to_linearrgb_v3_v3(rgba, rgba); + } float_array_to_string(rgba, 4, output, output_len_max); } @@ -2286,8 +2335,9 @@ static void ui_but_copy_colorband(uiBut *but) static void ui_but_paste_colorband(bContext *C, uiBut *but, uiHandleButtonData *data) { if (but_copypaste_coba.tot != 0) { - if (!but->poin) + if (!but->poin) { but->poin = MEM_callocN(sizeof(ColorBand), "colorband"); + } button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); memcpy(data->coba, &but_copypaste_coba, sizeof(ColorBand)); @@ -2307,8 +2357,9 @@ static void ui_but_copy_curvemapping(uiBut *but) static void ui_but_paste_curvemapping(bContext *C, uiBut *but) { if (but_copypaste_curve_alive) { - if (!but->poin) + if (!but->poin) { but->poin = MEM_callocN(sizeof(CurveMapping), "curvemapping"); + } button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); curvemapping_free_data((CurveMapping *) but->poin); @@ -2366,7 +2417,9 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array) switch (but->type) { case UI_BTYPE_NUM: case UI_BTYPE_NUM_SLIDER: - if (!has_required_data) break; + if (!has_required_data) { + break; + } if (copy_array && ui_but_has_array_value(but)) { ui_but_copy_numeric_array(but, buf, buf_max_len); } @@ -2377,20 +2430,26 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array) break; case UI_BTYPE_UNITVEC: - if (!has_required_data) break; + if (!has_required_data) { + break; + } ui_but_copy_numeric_array(but, buf, buf_max_len); is_buf_set = true; break; case UI_BTYPE_COLOR: - if (!has_required_data) break; + if (!has_required_data) { + break; + } ui_but_copy_color(but, buf, buf_max_len); is_buf_set = true; break; case UI_BTYPE_TEXT: case UI_BTYPE_SEARCH_MENU: - if (!has_required_data) break; + if (!has_required_data) { + break; + } ui_but_copy_text(but, buf, buf_max_len); is_buf_set = true; break; @@ -2442,7 +2501,9 @@ static void ui_but_paste(bContext *C, uiBut *but, uiHandleButtonData *data, cons switch (but->type) { case UI_BTYPE_NUM: case UI_BTYPE_NUM_SLIDER: - if (!has_required_data) break; + if (!has_required_data) { + break; + } if (paste_array && ui_but_has_array_value(but)) { ui_but_paste_numeric_array(C, but, data, buf_paste); } @@ -2452,18 +2513,24 @@ static void ui_but_paste(bContext *C, uiBut *but, uiHandleButtonData *data, cons break; case UI_BTYPE_UNITVEC: - if (!has_required_data) break; + if (!has_required_data) { + break; + } ui_but_paste_normalized_vector(C, but, buf_paste); break; case UI_BTYPE_COLOR: - if (!has_required_data) break; + if (!has_required_data) { + break; + } ui_but_paste_color(C, but, buf_paste); break; case UI_BTYPE_TEXT: case UI_BTYPE_SEARCH_MENU: - if (!has_required_data) break; + if (!has_required_data) { + break; + } ui_but_paste_text(C, but, data, buf_paste); break; @@ -2525,8 +2592,9 @@ void ui_but_text_password_hide(char password_str[UI_MAX_PASSWORD_STR], uiBut *bu { char *butstr; - if (!(but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_PASSWORD)) + if (!(but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_PASSWORD)) { return; + } butstr = (but->editstr) ? but->editstr : but->drawstr; @@ -2641,8 +2709,10 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con UI_fontstyle_set(fstyle); - if (fstyle->kerning == 1) /* for BLF_width */ + if (fstyle->kerning == 1) { + /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + } ui_but_text_password_hide(password_str, but, false); @@ -2702,7 +2772,9 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con /* done with tricky distance checks */ pos_i = but->pos; - if (but->pos <= 0) break; + if (but->pos <= 0) { + break; + } if (BLI_str_cursor_step_prev_utf8(str, but->ofs, &pos_i)) { but->pos = pos_i; str_last = &str[but->pos + but->ofs]; @@ -2712,11 +2784,14 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con } } but->pos += but->ofs; - if (but->pos < 0) but->pos = 0; + if (but->pos < 0) { + but->pos = 0; + } } - if (fstyle->kerning == 1) + if (fstyle->kerning == 1) { BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + } ui_but_text_password_hide(password_str, but, true); @@ -2725,13 +2800,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data, const float x) { - if (x > data->selstartx) data->selextend = EXTEND_RIGHT; - else if (x < data->selstartx) data->selextend = EXTEND_LEFT; + if (x > data->selstartx) { data->selextend = EXTEND_RIGHT; } + else if (x < data->selstartx) { data->selextend = EXTEND_LEFT; } ui_textedit_set_cursor_pos(but, data, x); - if (data->selextend == EXTEND_RIGHT) but->selend = but->pos; - else if (data->selextend == EXTEND_LEFT) but->selsta = but->pos; + if (data->selextend == EXTEND_RIGHT) { but->selend = but->pos; } + else if (data->selextend == EXTEND_LEFT) { but->selsta = but->pos; } ui_but_update(but); } @@ -2885,7 +2960,9 @@ static bool ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directi bool changed = false; if (jump == STRCUR_JUMP_ALL) { - if (len) changed = true; + if (len) { + changed = true; + } str[0] = '\0'; but->pos = 0; } @@ -2930,10 +3007,12 @@ static int ui_textedit_autocomplete(bContext *C, uiBut *but, uiHandleButtonData str = data->str; - if (data->searchbox) + if (data->searchbox) { changed = ui_searchbox_autocomplete(C, data->searchbox, but, data->str); - else + } + else { changed = but->autocomplete_func(C, str, but->autofunc_arg); + } but->pos = strlen(str); but->selsta = but->selend = but->pos; @@ -3171,8 +3250,9 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa uiBut *but; /* label and roundbox can overlap real buttons (backdrops...) */ - if (ELEM(actbut->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX)) + if (ELEM(actbut->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX)) { return; + } for (but = actbut->next; but; but = but->next) { if (ui_but_is_editable_as_text(but)) { @@ -3199,8 +3279,9 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa uiBut *but; /* label and roundbox can overlap real buttons (backdrops...) */ - if (ELEM(actbut->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX)) + if (ELEM(actbut->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX)) { return; + } for (but = actbut->prev; but; but = but->prev) { if (ui_but_is_editable_as_text(but)) { @@ -3276,8 +3357,9 @@ static void ui_do_but_textedit( /* exit on LMB only on RELEASE for searchbox, to mimic other popups, * and allow multiple menu levels */ - if (data->searchbox) + if (data->searchbox) { inbox = ui_searchbox_inside(data->searchbox, event->x, event->y); + } /* for double click: we do a press again for when you first click on button * (selects all text, no cursor pos) */ @@ -3298,8 +3380,9 @@ static void ui_do_but_textedit( } else if (inbox == false) { /* if searchbox, click outside will cancel */ - if (data->searchbox) + if (data->searchbox) { data->cancel = data->escapecancel = true; + } button_activate_state(C, but, BUTTON_STATE_EXIT); retval = WM_UI_HANDLER_BREAK; } @@ -3330,12 +3413,15 @@ static void ui_do_but_textedit( case XKEY: case CKEY: if (IS_EVENT_MOD(event, ctrl, oskey)) { - if (event->type == VKEY) + if (event->type == VKEY) { changed = ui_textedit_copypaste(but, data, UI_TEXTEDIT_PASTE); - else if (event->type == CKEY) + } + else if (event->type == CKEY) { changed = ui_textedit_copypaste(but, data, UI_TEXTEDIT_COPY); - else if (event->type == XKEY) + } + else if (event->type == XKEY) { changed = ui_textedit_copypaste(but, data, UI_TEXTEDIT_CUT); + } retval = WM_UI_HANDLER_BREAK; } @@ -3436,8 +3522,9 @@ static void ui_do_but_textedit( int autocomplete = ui_textedit_autocomplete(C, but, data); changed = autocomplete != AUTOCOMPLETE_NO_MATCH; - if (autocomplete == AUTOCOMPLETE_FULL_MATCH) + if (autocomplete == AUTOCOMPLETE_FULL_MATCH) { button_activate_state(C, but, BUTTON_STATE_EXIT); + } } /* the hotkey here is not well defined, was G.qual so we check all */ else if (IS_EVENT_MOD(event, shift, ctrl, alt, oskey)) { @@ -3525,12 +3612,14 @@ static void ui_do_but_textedit( } but->changed = true; - if (data->searchbox) + if (data->searchbox) { ui_searchbox_update(C, data->searchbox, but, true); /* true = reset */ + } } - if (changed || (retval == WM_UI_HANDLER_BREAK)) + if (changed || (retval == WM_UI_HANDLER_BREAK)) { ED_region_tag_redraw(data->region); + } } static void ui_do_but_textedit_select( @@ -3551,8 +3640,9 @@ static void ui_do_but_textedit_select( break; } case LEFTMOUSE: - if (event->val == KM_RELEASE) + if (event->val == KM_RELEASE) { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); + } retval = WM_UI_HANDLER_BREAK; break; } @@ -3681,18 +3771,21 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat if (func || handlefunc) { data->menu = ui_popup_block_create(C, data->region, but, func, handlefunc, arg); - if (but->block->handle) + if (but->block->handle) { data->menu->popup = but->block->handle->popup; + } } else if (menufunc) { data->menu = ui_popup_menu_create(C, data->region, but, menufunc, arg); - if (but->block->handle) + if (but->block->handle) { data->menu->popup = but->block->handle->popup; + } } else if (popoverfunc) { data->menu = ui_popover_panel_create(C, data->region, but, popoverfunc, arg); - if (but->block->handle) + if (but->block->handle) { data->menu->popup = but->block->handle->popup; + } } #ifdef USE_ALLSELECT @@ -3705,7 +3798,9 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat #endif /* this makes adjacent blocks auto open from now on */ - //if (but->block->auto_open == 0) but->block->auto_open = 1; + //if (but->block->auto_open == 0) { + // but->block->auto_open = 1; + //} } static void ui_block_open_end(bContext *C, uiBut *but, uiHandleButtonData *data) @@ -3727,8 +3822,9 @@ int ui_but_menu_direction(uiBut *but) { uiHandleButtonData *data = but->active; - if (data && data->menu) + if (data && data->menu) { return data->menu->direction; + } return 0; } @@ -3815,8 +3911,9 @@ static int ui_do_but_BUT( } else if (event->type == LEFTMOUSE && event->val == KM_RELEASE && but->block->handle) { /* regular buttons will be 'UI_SELECT', menu items 'UI_ACTIVE' */ - if (!(but->flag & (UI_SELECT | UI_ACTIVE))) + if (!(but->flag & (UI_SELECT | UI_ACTIVE))) { data->cancel = true; + } button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -3827,8 +3924,9 @@ static int ui_do_but_BUT( } else if (data->state == BUTTON_STATE_WAIT_RELEASE) { if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { - if (!(but->flag & UI_SELECT)) + if (!(but->flag & UI_SELECT)) { data->cancel = true; + } button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -3858,10 +3956,12 @@ static int ui_do_but_HOTKEYEVT( /* only cancel if click outside the button */ if (ui_but_contains_point_px(but, but->active->region, event->x, event->y) == 0) { /* data->cancel doesn't work, this button opens immediate */ - if (but->flag & UI_BUT_IMMEDIATE) + if (but->flag & UI_BUT_IMMEDIATE) { ui_but_value_set(but, 0); - else + } + else { data->cancel = true; + } button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -3869,20 +3969,30 @@ static int ui_do_but_HOTKEYEVT( /* always set */ but->modifier_key = 0; - if (event->shift) but->modifier_key |= KM_SHIFT; - if (event->alt) but->modifier_key |= KM_ALT; - if (event->ctrl) but->modifier_key |= KM_CTRL; - if (event->oskey) but->modifier_key |= KM_OSKEY; + if (event->shift) { + but->modifier_key |= KM_SHIFT; + } + if (event->alt) { + but->modifier_key |= KM_ALT; + } + if (event->ctrl) { + but->modifier_key |= KM_CTRL; + } + if (event->oskey) { + but->modifier_key |= KM_OSKEY; + } ui_but_update(but); ED_region_tag_redraw(data->region); if (event->val == KM_PRESS) { if (ISHOTKEY(event->type) && (event->type != ESCKEY)) { - if (WM_key_event_string(event->type, false)[0]) + if (WM_key_event_string(event->type, false)[0]) { ui_but_value_set(but, event->type); - else + } + else { data->cancel = true; + } button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; @@ -3917,10 +4027,12 @@ static int ui_do_but_KEYEVT( } if (event->val == KM_PRESS) { - if (WM_key_event_string(event->type, false)[0]) + if (WM_key_event_string(event->type, false)[0]) { ui_but_value_set(but, event->type); - else + } + else { data->cancel = true; + } button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -4238,21 +4350,22 @@ static float ui_numedit_apply_snapf( } if (snap == SNAP_ON) { - if (softrange < 2.10f) tempf = roundf(tempf * 10.0f) * 0.1f; - else if (softrange < 21.0f) tempf = roundf(tempf); - else tempf = roundf(tempf * 0.1f) * 10.0f; + if (softrange < 2.10f) { tempf = roundf(tempf * 10.0f) * 0.1f; } + else if (softrange < 21.0f) { tempf = roundf(tempf); } + else { tempf = roundf(tempf * 0.1f) * 10.0f; } } else if (snap == SNAP_ON_SMALL) { - if (softrange < 2.10f) tempf = roundf(tempf * 100.0f) * 0.01f; - else if (softrange < 21.0f) tempf = roundf(tempf * 10.0f) * 0.1f; - else tempf = roundf(tempf); + if (softrange < 2.10f) { tempf = roundf(tempf * 100.0f) * 0.01f; } + else if (softrange < 21.0f) { tempf = roundf(tempf * 10.0f) * 0.1f; } + else { tempf = roundf(tempf); } } else { BLI_assert(0); } - if (fac != 1.0f) + if (fac != 1.0f) { tempf *= fac; + } } return tempf; @@ -4262,8 +4375,9 @@ static float ui_numedit_apply_snap( int temp, float softmin, float softmax, const enum eSnapType snap) { - if (temp == softmin || temp == softmax) + if (temp == softmin || temp == softmax) { return temp; + } switch (snap) { case SNAP_OFF: @@ -4328,9 +4442,9 @@ static bool ui_numedit_but_NUM( } } else { - if (softrange > 256) fac = 1.0; /* 1px == 1 */ - else if (softrange > 32) fac = 1.0 / 2.0; /* 2px == 1 */ - else fac = 1.0 / 16.0; /* 16px == 1? */ + if (softrange > 256) { fac = 1.0; } /* 1px == 1 */ + else if (softrange > 32) { fac = 1.0 / 2.0; } /* 2px == 1 */ + else { fac = 1.0 / 16.0; } /* 16px == 1? */ temp = data->startvalue + (((double)mx - data->dragstartx) * (double)fac); temp = ui_numedit_apply_snap(temp, softmin, softmax, snap); @@ -4377,9 +4491,9 @@ static bool ui_numedit_but_NUM( non_linear_pixel_map = 250.0f; /* prevent large ranges from getting too out of control */ - if (softrange > 600) deler = powf(softrange, 0.75f); - else if (softrange < 25) deler = 50.0; - else if (softrange < 100) deler = 100.0; + if (softrange > 600) { deler = powf(softrange, 0.75f); } + else if (softrange < 25) { deler = 50.0; } + else if (softrange < 100) { deler = 100.0; } } deler /= fac; @@ -4583,7 +4697,9 @@ static int ui_do_but_NUM( #endif fac = 1.0f; - if (event->shift) fac /= 10.0f; + if (event->shift) { + fac /= 10.0f; + } if (ui_numedit_but_NUM(but, data, (ui_but_is_cursor_warp(but) ? screen_mx : mx), is_motion, snap, fac)) { ui_numedit_apply(C, block, but, data); @@ -4621,10 +4737,12 @@ static int ui_do_but_NUM( button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value - 1; - if (temp >= softmin && temp <= softmax) + if (temp >= softmin && temp <= softmax) { data->value = (double)temp; - else + } + else { data->cancel = true; + } button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -4632,10 +4750,12 @@ static int ui_do_but_NUM( button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value + 1; - if (temp >= softmin && temp <= softmax) + if (temp >= softmin && temp <= softmax) { data->value = (double)temp; - else + } + else { data->cancel = true; + } button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -4648,7 +4768,9 @@ static int ui_do_but_NUM( button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value - (UI_PRECISION_FLOAT_SCALE * but->a1); - if (tempf < softmin) tempf = softmin; + if (tempf < softmin) { + tempf = softmin; + } data->value = tempf; button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -4657,7 +4779,9 @@ static int ui_do_but_NUM( button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value + (UI_PRECISION_FLOAT_SCALE * but->a1); - if (tempf > softmax) tempf = softmax; + if (tempf > softmax) { + tempf = softmax; + } data->value = tempf; button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -4750,14 +4874,14 @@ static bool ui_numedit_but_SLI( if (shift) { if (tempf == softmin || tempf == softmax) {} - else if (softrange < 2.10f) tempf = roundf(tempf * 100.0f) * 0.01f; - else if (softrange < 21.0f) tempf = roundf(tempf * 10.0f) * 0.1f; - else tempf = roundf(tempf); + else if (softrange < 2.10f) { tempf = roundf(tempf * 100.0f) * 0.01f; } + else if (softrange < 21.0f) { tempf = roundf(tempf * 10.0f) * 0.1f; } + else { tempf = roundf(tempf); } } else { - if (softrange < 2.10f) tempf = roundf(tempf * 10.0f) * 0.1f; - else if (softrange < 21.0f) tempf = roundf(tempf); - else tempf = roundf(tempf * 0.1f) * 10.0f; + if (softrange < 2.10f) { tempf = roundf(tempf * 10.0f) * 0.1f; } + else if (softrange < 21.0f) { tempf = roundf(tempf); } + else { tempf = roundf(tempf * 0.1f) * 10.0f; } } } else { @@ -4832,10 +4956,12 @@ static int ui_do_but_SLI( else if (event->type == LEFTMOUSE && event->alt) { int halfpos = BLI_rctf_cent_x(&but->rect); click = 2; - if (mx < halfpos) + if (mx < halfpos) { mx = but->rect.xmin; - else + } + else { mx = but->rect.xmax; + } } #endif else if (event->type == LEFTMOUSE) { @@ -4945,22 +5071,34 @@ static int ui_do_but_SLI( f = softmin + f * softrange; if (!ui_but_is_float(but)) { - if (f < temp) temp--; - else temp++; + if (f < temp) { + temp--; + } + else { + temp++; + } - if (temp >= softmin && temp <= softmax) + if (temp >= softmin && temp <= softmax) { data->value = temp; - else + } + else { data->cancel = true; + } } else { - if (f < tempf) tempf -= 0.01f; - else tempf += 0.01f; + if (f < tempf) { + tempf -= 0.01f; + } + else { + tempf += 0.01f; + } - if (tempf >= softmin && tempf <= softmax) + if (tempf >= softmin && tempf <= softmax) { data->value = tempf; - else + } + else { data->cancel = true; + } } button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -5007,8 +5145,9 @@ static int ui_do_but_SCROLL( } /* UNUSED - otherwise code is ok, add back if needed */ #if 0 - else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) + else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) { click = 1; + } #endif } } @@ -5327,10 +5466,12 @@ static int ui_do_but_COLOR( ui_but_v3_get(but, col); rgb_to_hsv_compat_v(col, hsv); - if (event->type == WHEELDOWNMOUSE) + if (event->type == WHEELDOWNMOUSE) { hsv[2] = clamp_f(hsv[2] - 0.05f, 0.0f, 1.0f); - else if (event->type == WHEELUPMOUSE) + } + else if (event->type == WHEELUPMOUSE) { hsv[2] = clamp_f(hsv[2] + 0.05f, 0.0f, 1.0f); + } else { float fac = 0.005 * (event->y - event->prevy); hsv[2] = clamp_f(hsv[2] + fac, 0.0f, 1.0f); @@ -5444,8 +5585,9 @@ static int ui_do_but_UNITVEC( button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_UNITVEC(but, data, mx, my, snap)) + if (ui_numedit_but_UNITVEC(but, data, mx, my, snap)) { ui_numedit_apply(C, block, but, data); + } return WM_UI_HANDLER_BREAK; } @@ -5454,8 +5596,9 @@ static int ui_do_but_UNITVEC( if ((event->type == MOUSEMOVE) || ui_event_is_snap(event)) { if (mx != data->draglastx || my != data->draglasty || event->type != MOUSEMOVE) { const enum eSnapType snap = ui_event_to_snap(event); - if (ui_numedit_but_UNITVEC(but, data, mx, my, snap)) + if (ui_numedit_but_UNITVEC(but, data, mx, my, snap)) { ui_numedit_apply(C, block, but, data); + } } } else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { @@ -5475,34 +5618,46 @@ static void clamp_axis_max_v3(float v[3], const float max) const float v_max = max_fff(v[0], v[1], v[2]); if (v_max > max) { mul_v3_fl(v, max / v_max); - if (v[0] > max) v[0] = max; - if (v[1] > max) v[1] = max; - if (v[2] > max) v[2] = max; + if (v[0] > max) { + v[0] = max; + } + if (v[1] > max) { + v[1] = max; + } + if (v[2] > max) { + v[2] = max; + } } } static void ui_rgb_to_color_picker_HSVCUBE_compat_v(uiBut *but, const float rgb[3], float hsv[3]) { - if (but->a1 == UI_GRAD_L_ALT) + if (but->a1 == UI_GRAD_L_ALT) { rgb_to_hsl_compat_v(rgb, hsv); - else + } + else { rgb_to_hsv_compat_v(rgb, hsv); + } } static void ui_rgb_to_color_picker_HSVCUBE_v(uiBut *but, const float rgb[3], float hsv[3]) { - if (but->a1 == UI_GRAD_L_ALT) + if (but->a1 == UI_GRAD_L_ALT) { rgb_to_hsl_v(rgb, hsv); - else + } + else { rgb_to_hsv_v(rgb, hsv); + } } static void ui_color_picker_to_rgb_HSVCUBE_v(uiBut *but, const float hsv[3], float rgb[3]) { - if (but->a1 == UI_GRAD_L_ALT) + if (but->a1 == UI_GRAD_L_ALT) { hsl_to_rgb_v(hsv, rgb); - else + } + else { hsv_to_rgb_v(hsv, rgb); + } } static bool ui_numedit_but_HSVCUBE( @@ -5711,8 +5866,9 @@ static int ui_do_but_HSVCUBE( button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0)) + if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0)) { ui_numedit_apply(C, block, but, data); + } return WM_UI_HANDLER_BREAK; } @@ -5773,8 +5929,9 @@ static int ui_do_but_HSVCUBE( if (mx != data->draglastx || my != data->draglasty || event->type != MOUSEMOVE) { const enum eSnapType snap = ui_event_to_snap(event); - if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0)) + if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0)) { ui_numedit_apply(C, block, but, data); + } } } else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { @@ -5827,11 +5984,17 @@ static bool ui_numedit_but_HSVCIRCLE( * allow choosing a hue for black values, by giving a tiny increment */ if (cpicker->use_color_lock) { if (U.color_picker_type == USER_CP_CIRCLE_HSV) { // lock - if (hsv[2] == 0.f) hsv[2] = 0.0001f; + if (hsv[2] == 0.f) { + hsv[2] = 0.0001f; + } } else { - if (hsv[2] == 0.0f) hsv[2] = 0.0001f; - if (hsv[2] >= 0.9999f) hsv[2] = 0.9999f; + if (hsv[2] == 0.0f) { + hsv[2] = 0.0001f; + } + if (hsv[2] >= 0.9999f) { + hsv[2] = 0.9999f; + } } } @@ -5924,11 +6087,17 @@ static void ui_ndofedit_but_HSVCIRCLE( * allow choosing a hue for black values, by giving a tiny increment */ if (cpicker->use_color_lock) { if (U.color_picker_type == USER_CP_CIRCLE_HSV) { // lock - if (hsv[2] == 0.f) hsv[2] = 0.0001f; + if (hsv[2] == 0.f) { + hsv[2] = 0.0001f; + } } else { - if (hsv[2] == 0.f) hsv[2] = 0.0001f; - if (hsv[2] == 1.f) hsv[2] = 0.9999f; + if (hsv[2] == 0.f) { + hsv[2] = 0.0001f; + } + if (hsv[2] == 1.f) { + hsv[2] = 0.9999f; + } } } @@ -5972,8 +6141,9 @@ static int ui_do_but_HSVCIRCLE( button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0)) + if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0)) { ui_numedit_apply(C, block, but, data); + } return WM_UI_HANDLER_BREAK; } @@ -6064,11 +6234,13 @@ static bool ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int m float dx; bool changed = false; - if (data->draglastx == mx) + if (data->draglastx == mx) { return changed; + } - if (data->coba->tot == 0) + if (data->coba->tot == 0) { return changed; + } dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect); data->dragcbd->pos += dx; @@ -6117,7 +6289,10 @@ static int ui_do_but_COLORBAND( for (a = 0, cbd = coba->data; a < coba->tot; a++, cbd++) { xco = but->rect.xmin + (cbd->pos * BLI_rctf_size_x(&but->rect)); xco = ABS(xco - mx); - if (a == coba->cur) xco += 5; // selected one disadvantage + if (a == coba->cur) { + /* Selected one disadvantage. */ + xco += 5; + } if (xco < mindist) { coba->cur = a; mindist = xco; @@ -6135,8 +6310,9 @@ static int ui_do_but_COLORBAND( else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_COLORBAND(but, data, mx)) + if (ui_numedit_but_COLORBAND(but, data, mx)) { ui_numedit_apply(C, block, but, data); + } } } else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { @@ -6188,8 +6364,9 @@ static bool ui_numedit_but_CURVE( d[0] = mx - data->dragstartx; d[1] = my - data->dragstarty; - if (len_squared_v2(d) < (3.0f * 3.0f)) + if (len_squared_v2(d) < (3.0f * 3.0f)) { snap = false; + } } if (data->dragsel != -1) { @@ -6212,8 +6389,9 @@ static bool ui_numedit_but_CURVE( cmp[a].x = 0.125f * roundf(8.0f * cmp[a].x); cmp[a].y = 0.125f * roundf(8.0f * cmp[a].y); } - if (cmp[a].x != origx || cmp[a].y != origy) + if (cmp[a].x != origx || cmp[a].y != origy) { moved_point = true; + } cmp_last = &cmp[a]; } @@ -6247,14 +6425,18 @@ static bool ui_numedit_but_CURVE( /* clamp for clip */ if (cumap->flag & CUMA_DO_CLIP) { - if (cumap->curr.xmin - fx < cumap->clipr.xmin) + if (cumap->curr.xmin - fx < cumap->clipr.xmin) { fx = cumap->curr.xmin - cumap->clipr.xmin; - else if (cumap->curr.xmax - fx > cumap->clipr.xmax) + } + else if (cumap->curr.xmax - fx > cumap->clipr.xmax) { fx = cumap->curr.xmax - cumap->clipr.xmax; - if (cumap->curr.ymin - fy < cumap->clipr.ymin) + } + if (cumap->curr.ymin - fy < cumap->clipr.ymin) { fy = cumap->curr.ymin - cumap->clipr.ymin; - else if (cumap->curr.ymax - fy > cumap->clipr.ymax) + } + else if (cumap->curr.ymax - fy > cumap->clipr.ymax) { fy = cumap->curr.ymax - cumap->clipr.ymax; + } } cumap->curr.xmin -= fx; @@ -6388,8 +6570,9 @@ static int ui_do_but_CURVE( if (event->type == MOUSEMOVE) { if (event->x != data->draglastx || event->y != data->draglasty) { - if (ui_numedit_but_CURVE(block, but, data, event->x, event->y, event->ctrl != 0, event->shift != 0)) + if (ui_numedit_but_CURVE(block, but, data, event->x, event->y, event->ctrl != 0, event->shift != 0)) { ui_numedit_apply(C, block, but, data); + } } } else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { @@ -6401,8 +6584,9 @@ static int ui_do_but_CURVE( if (data->dragchange == false) { /* deselect all, select one */ if (!event->shift) { - for (a = 0; a < cuma->totpoint; a++) + for (a = 0; a < cuma->totpoint; a++) { cmp[a].flag &= ~CUMA_SELECT; + } cmp[data->dragsel].flag |= CUMA_SELECT; } } @@ -6462,8 +6646,9 @@ static int ui_do_but_HISTOGRAM( button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_HISTOGRAM(but, data, mx, my)) + if (ui_numedit_but_HISTOGRAM(but, data, mx, my)) { ui_numedit_apply(C, block, but, data); + } return WM_UI_HANDLER_BREAK; } @@ -6486,8 +6671,9 @@ static int ui_do_but_HISTOGRAM( } else if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_HISTOGRAM(but, data, mx, my)) + if (ui_numedit_but_HISTOGRAM(but, data, mx, my)) { ui_numedit_apply(C, block, but, data); + } } } else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { @@ -6537,8 +6723,9 @@ static int ui_do_but_WAVEFORM( button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_WAVEFORM(but, data, mx, my)) + if (ui_numedit_but_WAVEFORM(but, data, mx, my)) { ui_numedit_apply(C, block, but, data); + } return WM_UI_HANDLER_BREAK; } @@ -6561,8 +6748,9 @@ static int ui_do_but_WAVEFORM( } else if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_WAVEFORM(but, data, mx, my)) + if (ui_numedit_but_WAVEFORM(but, data, mx, my)) { ui_numedit_apply(C, block, but, data); + } } } else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { @@ -6592,8 +6780,9 @@ static bool ui_numedit_but_TRACKPREVIEW( } if (!scopes->track_locked) { - if (scopes->marker->framenr != scopes->framenr) + if (scopes->marker->framenr != scopes->framenr) { scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr); + } scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED); scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_rctf_size_x(&but->block->rect); @@ -6629,8 +6818,9 @@ static int ui_do_but_TRACKPREVIEW( button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0)) + if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0)) { ui_numedit_apply(C, block, but, data); + } return WM_UI_HANDLER_BREAK; } @@ -6645,8 +6835,9 @@ static int ui_do_but_TRACKPREVIEW( } else if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0)) + if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0)) { ui_numedit_apply(C, block, but, data); + } } } else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { @@ -6805,10 +6996,13 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * retval = ui_do_but_BUT(C, but, data, event); break; case UI_BTYPE_COLOR: - if (but->a1 == -1) /* signal to prevent calling up color picker */ + if (but->a1 == -1) { + /* signal to prevent calling up color picker */ retval = ui_do_but_EXIT(C, but, data, event); - else + } + else { retval = ui_do_but_COLOR(C, but, data, event); + } break; case UI_BTYPE_UNITVEC: retval = ui_do_but_UNITVEC(C, block, but, data, event); @@ -6925,13 +7119,15 @@ static void ui_blocks_set_tooltips(ARegion *ar, const bool enable) { uiBlock *block; - if (!ar) + if (!ar) { return; + } /* we disabled buttons when when they were already shown, and * re-enable them on mouse move */ - for (block = ar->uiblocks.first; block; block = block->next) + for (block = ar->uiblocks.first; block; block = block->next) { block->tooltipdisabled = !enable; + } } /** @@ -7032,8 +7228,9 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s uiHandleButtonData *data; data = but->active; - if (data->state == state) + if (data->state == state) { return; + } /* highlight has timers for tooltips and auto open */ if (state == BUTTON_STATE_HIGHLIGHT) { @@ -7073,17 +7270,21 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s } /* text editing */ - if (state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING) + if (state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING) { ui_textedit_begin(C, but, data); - else if (data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING) + } + else if (data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING) { ui_textedit_end(C, but, data); - else if (data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING) + } + else if (data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING) { ui_textedit_end(C, but, data); + } /* number editing */ if (state == BUTTON_STATE_NUM_EDITING) { - if (ui_but_is_cursor_warp(but)) + if (ui_but_is_cursor_warp(but)) { WM_cursor_grab_enable(CTX_wm_window(C), true, true, NULL); + } ui_numedit_begin(but, data); } else if (data->state == BUTTON_STATE_NUM_EDITING) { @@ -7119,10 +7320,12 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s } } /* menu open */ - if (state == BUTTON_STATE_MENU_OPEN) + if (state == BUTTON_STATE_MENU_OPEN) { ui_block_open_begin(C, but, data); - else if (data->state == BUTTON_STATE_MENU_OPEN) + } + else if (data->state == BUTTON_STATE_MENU_OPEN) { ui_block_open_end(C, but, data); + } /* add a short delay before exiting, to ensure there is some feedback */ if (state == BUTTON_STATE_WAIT_FLASH) { @@ -7146,8 +7349,9 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s * but not for popups, because we already have a window level handler*/ if (!(but->block->handle && but->block->handle->popup)) { if (button_modal_state(state)) { - if (!button_modal_state(data->state)) + if (!button_modal_state(data->state)) { WM_event_add_ui_handler(C, &data->window->modalhandlers, ui_handler_region_menu, NULL, data, 0); + } } else { if (button_modal_state(data->state)) { @@ -7170,8 +7374,9 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s * highlight when not in a popup menu, we remove because data used in * button below popup might have been removed by action of popup. Needs * a more reliable solution... */ - if (state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP)) + if (state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP)) { ui_but_update(but); + } } /* redraw */ @@ -7211,9 +7416,11 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA /* we disable auto_open in the block after a threshold, because we still * want to allow auto opening adjacent menus even if no button is activated * in between going over to the other button, but only for a short while */ - if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open == true) - if (but->block->auto_open_last + BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer()) + if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open == true) { + if (but->block->auto_open_last + BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer()) { but->block->auto_open = false; + } + } if (type == BUTTON_ACTIVATE_OVER) { data->used_mouse = true; @@ -7222,8 +7429,9 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA /* activate right away */ if (but->flag & UI_BUT_IMMEDIATE) { - if (but->type == UI_BTYPE_HOTKEY_EVENT) + if (but->type == UI_BTYPE_HOTKEY_EVENT) { button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); + } /* .. more to be added here */ } @@ -7239,15 +7447,18 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA if (subblock) { subbut = ui_but_first(subblock); - if (subbut) + if (subbut) { ui_handle_button_activate(C, subar, subbut, BUTTON_ACTIVATE); + } } } } - else if (type == BUTTON_ACTIVATE_TEXT_EDITING) + else if (type == BUTTON_ACTIVATE_TEXT_EDITING) { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); - else if (type == BUTTON_ACTIVATE_APPLY) + } + else if (type == BUTTON_ACTIVATE_APPLY) { button_activate_state(C, but, BUTTON_STATE_WAIT_FLASH); + } if (but->type == UI_BTYPE_GRIP) { const bool horizontal = (BLI_rctf_size_x(&but->rect) < BLI_rctf_size_y(&but->rect)); @@ -7283,12 +7494,14 @@ static void button_activate_exit( } /* ensure we are in the exit state */ - if (data->state != BUTTON_STATE_EXIT) + if (data->state != BUTTON_STATE_EXIT) { button_activate_state(C, but, BUTTON_STATE_EXIT); + } /* apply the button action or value */ - if (!onfree) + if (!onfree) { ui_apply_but(C, block, but, data, false); + } #ifdef USE_DRAG_MULTINUM if (data->multi_data.has_mbuts) { @@ -7338,14 +7551,16 @@ static void button_activate_exit( #endif /* popup menu memory */ - if (block->flag & UI_BLOCK_POPUP_MEMORY) + if (block->flag & UI_BLOCK_POPUP_MEMORY) { ui_popup_menu_memory_set(block, but); + } } /* disable tooltips until mousemove + last active flag */ for (block = data->region->uiblocks.first; block; block = block->next) { - for (bt = block->buttons.first; bt; bt = bt->next) + for (bt = block->buttons.first; bt; bt = bt->next) { bt->flag &= ~UI_BUT_LAST_ACTIVE; + } block->tooltipdisabled = 1; } @@ -7353,10 +7568,12 @@ static void button_activate_exit( ui_blocks_set_tooltips(data->region, false); /* clean up */ - if (data->str) + if (data->str) { MEM_freeN(data->str); - if (data->origstr) + } + if (data->origstr) { MEM_freeN(data->origstr); + } #ifdef USE_ALLSELECT ui_selectcontext_end(but, &data->select_others); @@ -7378,14 +7595,16 @@ static void button_activate_exit( but->flag &= ~(UI_ACTIVE | UI_SELECT); but->flag |= UI_BUT_LAST_ACTIVE; - if (!onfree) + if (!onfree) { ui_but_update(but); + } /* adds empty mousemove in queue for re-init handler, in case mouse is * still over a button. We cannot just check for this ourselves because * at this point the mouse may be over a button in another region */ - if (mousemove) + if (mousemove) { WM_event_add_mousemove(C); + } } void ui_but_active_free(const bContext *C, uiBut *but) @@ -7414,10 +7633,12 @@ static uiBut *ui_context_button_active(ARegion *ar, bool (*but_check_cb)(uiBut * /* find active button */ for (block = ar->uiblocks.first; block; block = block->next) { for (but = block->buttons.first; but; but = but->next) { - if (but->active) + if (but->active) { activebut = but; - else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) + } + else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) { activebut = but; + } } } @@ -7599,9 +7820,11 @@ static uiBut *ui_but_find_open_event(ARegion *ar, const wmEvent *event) uiBut *but; for (block = ar->uiblocks.first; block; block = block->next) { - for (but = block->buttons.first; but; but = but->next) - if (but == event->customdata) + for (but = block->buttons.first; but; but = but->next) { + if (but == event->customdata) { return but; + } + } } return NULL; } @@ -8037,8 +8260,9 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar, /* if type still is mousepan, we call it handled, since delta-y accumulate */ /* also see wm_event_system.c do_wheel_ui hack */ - if (type == MOUSEPAN) + if (type == MOUSEPAN) { retval = WM_UI_HANDLER_BREAK; + } } if (val == KM_PRESS) { @@ -8154,10 +8378,12 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u /* copy over return values from the closing menu */ if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_UPDATE)) { - if (but->type == UI_BTYPE_COLOR) + if (but->type == UI_BTYPE_COLOR) { copy_v3_v3(data->vec, menu->retvec); - else if (but->type == UI_BTYPE_MENU) + } + else if (but->type == UI_BTYPE_MENU) { data->value = menu->retvalue; + } } if (menu->menuretval & UI_RETURN_UPDATE) { @@ -8173,8 +8399,9 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u /* now change button state or exit, which will close the submenu */ if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) { - if (menu->menuretval != UI_RETURN_OK) + if (menu->menuretval != UI_RETURN_OK) { data->cancel = true; + } button_activate_exit(C, but, data, true, false); } @@ -8221,10 +8448,12 @@ static void ui_mouse_motion_towards_init_ex(uiPopupBlockHandle *menu, const int menu->towards_xy[0] = xy[0]; menu->towards_xy[1] = xy[1]; - if (force) + if (force) { menu->towardstime = DBL_MAX; /* unlimited time */ - else + } + else { menu->towardstime = PIL_check_seconds_timer(); + } } } @@ -8272,8 +8501,9 @@ static bool ui_mouse_motion_towards_check( return false; } - if (len_squared_v2v2(oldp, newp) < (4.0f * 4.0f)) + if (len_squared_v2v2(oldp, newp) < (4.0f * 4.0f)) { return menu->dotowards; + } /* verify that we are moving towards one of the edges of the * menu block, in other words, in the triangle formed by the @@ -8310,12 +8540,14 @@ static bool ui_mouse_motion_towards_check( isect_point_tri_v2(newp, oldp, p3, p4) || isect_point_tri_v2(newp, oldp, p4, p1)); - if (!closer) + if (!closer) { menu->dotowards = false; + } /* 1 second timer */ - if (PIL_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH) + if (PIL_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH) { menu->dotowards = false; + } return menu->dotowards; } @@ -8349,12 +8581,16 @@ static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEve static char ui_menu_scroll_test(uiBlock *block, int my) { if (block->flag & (UI_BLOCK_CLIPTOP | UI_BLOCK_CLIPBOTTOM)) { - if (block->flag & UI_BLOCK_CLIPTOP) - if (my > block->rect.ymax - UI_MENU_SCROLL_MOUSE) + if (block->flag & UI_BLOCK_CLIPTOP) { + if (my > block->rect.ymax - UI_MENU_SCROLL_MOUSE) { return 't'; - if (block->flag & UI_BLOCK_CLIPBOTTOM) - if (my < block->rect.ymin + UI_MENU_SCROLL_MOUSE) + } + } + if (block->flag & UI_BLOCK_CLIPBOTTOM) { + if (my < block->rect.ymin + UI_MENU_SCROLL_MOUSE) { return 'b'; + } + } } return 0; } @@ -8519,13 +8755,21 @@ static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlock ScrArea *ctx_area = CTX_wm_area(C); ARegion *ctx_region = CTX_wm_region(C); - if (menu->ctx_area) CTX_wm_area_set(C, menu->ctx_area); - if (menu->ctx_region) CTX_wm_region_set(C, menu->ctx_region); + if (menu->ctx_area) { + CTX_wm_area_set(C, menu->ctx_area); + } + if (menu->ctx_region) { + CTX_wm_region_set(C, menu->ctx_region); + } retval = ui_handle_button_event(C, event, but); - if (menu->ctx_area) CTX_wm_area_set(C, ctx_area); - if (menu->ctx_region) CTX_wm_region_set(C, ctx_region); + if (menu->ctx_area) { + CTX_wm_area_set(C, ctx_area); + } + if (menu->ctx_region) { + CTX_wm_region_set(C, ctx_region); + } } else { retval = ui_handle_button_over(C, event, ar); @@ -8551,10 +8795,12 @@ float ui_block_calc_pie_segment(uiBlock *block, const float event_xy[2]) len = normalize_v2_v2(block->pie_data.pie_dir, seg2); - if (len < U.pie_menu_threshold * U.dpi_fac) + if (len < U.pie_menu_threshold * U.dpi_fac) { block->pie_data.flags |= UI_PIE_INVALID_DIR; - else + } + else { block->pie_data.flags &= ~UI_PIE_INVALID_DIR; + } return len; } @@ -8618,8 +8864,9 @@ static int ui_handle_menu_event( } } else if (event->type == TIMER) { - if (event->customdata == menu->scrolltimer) + if (event->customdata == menu->scrolltimer) { ui_menu_scroll_to_y(ar, block, my); + } } else { /* for ui_mouse_motion_towards_block */ @@ -8629,10 +8876,12 @@ static int ui_handle_menu_event( } /* add menu scroll timer, if needed */ - if (ui_menu_scroll_test(block, my)) - if (menu->scrolltimer == NULL) + if (ui_menu_scroll_test(block, my)) { + if (menu->scrolltimer == NULL) { menu->scrolltimer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, MENU_SCROLL_INTERVAL); + } + } } /* first block own event func */ @@ -8668,9 +8917,11 @@ static int ui_handle_menu_event( /* Closing sub-levels of pull-downs. */ case LEFTARROWKEY: - if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) - if (block->saferct.first) + if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) { + if (block->saferct.first) { menu->menuretval = UI_RETURN_OUT; + } + } retval = WM_UI_HANDLER_BREAK; break; @@ -8679,19 +8930,25 @@ static int ui_handle_menu_event( case RIGHTARROWKEY: if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) { - if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) + if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) { break; + } but = ui_region_find_active_but(ar); if (!but) { /* no item active, we make first active */ - if (block->direction & UI_DIR_UP) but = ui_but_last(block); - else but = ui_but_first(block); + if (block->direction & UI_DIR_UP) { + but = ui_but_last(block); + } + else { + but = ui_but_first(block); + } } - if (but && ELEM(but->type, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN)) + if (but && ELEM(but->type, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN)) { ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN); + } } retval = WM_UI_HANDLER_BREAK; @@ -8728,16 +8985,18 @@ static int ui_handle_menu_event( int val = event->val; /* convert pan to scrollwheel */ - if (type == MOUSEPAN) + if (type == MOUSEPAN) { ui_pan_to_scroll(event, &type, &val); + } if (val == KM_PRESS) { const bool is_next = (ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE) == ((block->flag & UI_BLOCK_IS_FLIP) != 0)); - if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) + if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) { break; + } #ifdef USE_KEYNAV_LIMIT ui_mouse_motion_keynav_init(&menu->keynav_state, event); @@ -8770,40 +9029,71 @@ static int ui_handle_menu_event( break; case ONEKEY: case PAD1: - act = 1; ATTR_FALLTHROUGH; + act = 1; + ATTR_FALLTHROUGH; case TWOKEY: case PAD2: - if (act == 0) act = 2; ATTR_FALLTHROUGH; + if (act == 0) { + act = 2; + } + ATTR_FALLTHROUGH; case THREEKEY: case PAD3: - if (act == 0) act = 3; ATTR_FALLTHROUGH; + if (act == 0) { + act = 3; + } + ATTR_FALLTHROUGH; case FOURKEY: case PAD4: - if (act == 0) act = 4; ATTR_FALLTHROUGH; + if (act == 0) { + act = 4; + } + ATTR_FALLTHROUGH; case FIVEKEY: case PAD5: - if (act == 0) act = 5; ATTR_FALLTHROUGH; + if (act == 0) { + act = 5; + } + ATTR_FALLTHROUGH; case SIXKEY: case PAD6: - if (act == 0) act = 6; ATTR_FALLTHROUGH; + if (act == 0) { + act = 6; + } + ATTR_FALLTHROUGH; case SEVENKEY: case PAD7: - if (act == 0) act = 7; ATTR_FALLTHROUGH; + if (act == 0) { + act = 7; + } + ATTR_FALLTHROUGH; case EIGHTKEY: case PAD8: - if (act == 0) act = 8; ATTR_FALLTHROUGH; + if (act == 0) { + act = 8; + } + ATTR_FALLTHROUGH; case NINEKEY: case PAD9: - if (act == 0) act = 9; ATTR_FALLTHROUGH; + if (act == 0) { + act = 9; + } + ATTR_FALLTHROUGH; case ZEROKEY: case PAD0: - if (act == 0) act = 10; + if (act == 0) { + act = 10; + } if ((block->flag & UI_BLOCK_NUMSELECT) && event->val == KM_PRESS) { int count; - if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) + if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) { break; + } - if (event->alt) act += 10; + if (event->alt) { + act += 10; + } count = 0; for (but = block->buttons.first; but; but = but->next) { bool doit = false; - if (!ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) + if (!ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) { count++; + } /* exception for rna layer buts */ if (but->rnapoin.data && but->rnaprop && @@ -8873,8 +9163,9 @@ static int ui_handle_menu_event( if ((event->val == KM_PRESS || event->val == KM_DBL_CLICK) && !IS_EVENT_MOD(event, shift, ctrl, oskey)) { - if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) + if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) { break; + } for (but = block->buttons.first; but; but = but->next) { if (!(but->flag & UI_BUT_DISABLED) && but->menu_key == event->type) { @@ -8923,16 +9214,20 @@ static int ui_handle_menu_event( if (ELEM(event->val, KM_PRESS, KM_DBL_CLICK)) { if ((is_parent_menu == false) && (U.uiflag & USER_MENUOPENAUTO) == 0) { /* for root menus, allow clicking to close */ - if (block->flag & (UI_BLOCK_OUT_1)) + if (block->flag & (UI_BLOCK_OUT_1)) { menu->menuretval = UI_RETURN_OK; - else + } + else { menu->menuretval = UI_RETURN_OUT; + } } else if (saferct && !BLI_rctf_isect_pt(&saferct->parent, event->x, event->y)) { - if (block->flag & (UI_BLOCK_OUT_1)) + if (block->flag & (UI_BLOCK_OUT_1)) { menu->menuretval = UI_RETURN_OK; - else + } + else { menu->menuretval = UI_RETURN_OUT; + } } } else if (ELEM(event->val, KM_RELEASE, KM_CLICK)) { @@ -8963,8 +9258,9 @@ static int ui_handle_menu_event( else if (ELEM(event->type, RETKEY, PADENTER) && event->val == KM_PRESS) { /* enter will always close this block, we let the event * get handled by the button if it is activated, otherwise we cancel */ - if (!ui_region_find_active_but(ar)) + if (!ui_region_find_active_but(ar)) { menu->menuretval = UI_RETURN_CANCEL | UI_RETURN_POPUP_OK; + } } #ifdef USE_DRAG_POPUP else if ((event->type == LEFTMOUSE) && (event->val == KM_PRESS) && @@ -8995,22 +9291,27 @@ static int ui_handle_menu_event( * events we check all preceding block rects too to make * arrow keys navigation work */ if (event->type != MOUSEMOVE || saferct == block->saferct.first) { - if (BLI_rctf_isect_pt(&saferct->parent, (float)event->x, (float)event->y)) + if (BLI_rctf_isect_pt(&saferct->parent, (float)event->x, (float)event->y)) { break; - if (BLI_rctf_isect_pt(&saferct->safety, (float)event->x, (float)event->y)) + } + if (BLI_rctf_isect_pt(&saferct->safety, (float)event->x, (float)event->y)) { break; + } } } /* strict check, and include the parent rect */ if (!menu->dotowards && !saferct) { - if (block->flag & (UI_BLOCK_OUT_1)) + if (block->flag & (UI_BLOCK_OUT_1)) { menu->menuretval = UI_RETURN_OK; - else + } + else { menu->menuretval = UI_RETURN_OUT; + } } - else if (menu->dotowards && event->type == MOUSEMOVE) + else if (menu->dotowards && event->type == MOUSEMOVE) { retval = WM_UI_HANDLER_BREAK; + } } } @@ -9045,12 +9346,15 @@ static int ui_handle_menu_event( /* if we set a menu return value, ensure we continue passing this on to * lower menus and buttons, so always set continue then, and if we are * inside the region otherwise, ensure we swallow the event */ - if (menu->menuretval) + if (menu->menuretval) { return WM_UI_HANDLER_CONTINUE; - else if (inside) + } + else if (inside) { return WM_UI_HANDLER_BREAK; - else + } + else { return retval; + } } static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu) @@ -9089,8 +9393,9 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo * will actually close the submenu too */ ui_handle_button_return_submenu(C, event, but); - if (update) + if (update) { submenu->menuretval = 0; + } } if (block->flag & (UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_POPOVER)) { @@ -9168,13 +9473,15 @@ static int ui_but_pie_button_activate(bContext *C, uiBut *but, uiPopupBlockHandl { uiBut *active_but; - if (but == NULL) + if (but == NULL) { return WM_UI_HANDLER_BREAK; + } active_but = ui_region_find_active_but(menu->region); - if (active_but) + if (active_but) { button_activate_exit(C, active_but, active_but->active, false, false); + } button_activate_init(C, menu->region, but, BUTTON_ACTIVATE_OVER); return ui_but_pie_menu_apply(C, menu, but, false); @@ -9317,8 +9624,9 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle if (but && (U.pie_menu_confirm > 0) && (dist >= U.dpi_fac * (U.pie_menu_threshold + U.pie_menu_confirm))) { - if (but) + if (but) { return ui_but_pie_menu_apply(C, menu, but, true); + } } retval = ui_but_pie_menu_apply(C, menu, but, true); @@ -9589,15 +9897,18 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(use } if (retval == WM_UI_HANDLER_CONTINUE) { - if (but) + if (but) { retval = ui_handle_button_event(C, event, but); - else + } + else { retval = ui_handle_button_over(C, event, ar); + } } /* re-enable tooltips */ - if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) + if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) { ui_blocks_set_tooltips(ar, true); + } /* delayed apply callbacks */ ui_apply_but_funcs_after(C); @@ -9611,18 +9922,23 @@ static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata)) ARegion *ar; ar = CTX_wm_region(C); - if (ar == NULL) return; + if (ar == NULL) { + return; + } UI_blocklist_free(C, &ar->uiblocks); sc = CTX_wm_screen(C); - if (sc == NULL) return; + if (sc == NULL) { + return; + } /* delayed apply callbacks, but not for screen level regions, those * we rather do at the very end after closing them all, which will * be done in ui_region_handler/window */ - if (BLI_findindex(&sc->regionbase, ar) == -1) + if (BLI_findindex(&sc->regionbase, ar) == -1) { ui_apply_but_funcs_after(C); + } } /* handle buttons at the window level, modal, for example while @@ -9634,8 +9950,9 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE int retval = WM_UI_HANDLER_CONTINUE; ar = CTX_wm_menu(C); - if (!ar) + if (!ar) { ar = CTX_wm_region(C); + } but = ui_region_find_active_but(ar); @@ -9706,8 +10023,9 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE } /* re-enable tooltips */ - if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) + if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) { ui_blocks_set_tooltips(ar, true); + } /* delayed apply callbacks */ ui_apply_but_funcs_after(C); @@ -9778,20 +10096,24 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata) #endif if ((temp.menuretval & UI_RETURN_OK) || (temp.menuretval & UI_RETURN_POPUP_OK)) { - if (temp.popup_func) + if (temp.popup_func) { temp.popup_func(C, temp.popup_arg, temp.retvalue); - if (temp.optype) + } + if (temp.optype) { WM_operator_name_call_ptr(C, temp.optype, temp.opcontext, NULL); + } } - else if (temp.cancel_func) + else if (temp.cancel_func) { temp.cancel_func(C, temp.popup_arg); + } WM_event_add_mousemove(C); } else { /* re-enable tooltips */ - if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) + if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) { ui_blocks_set_tooltips(menu->region, true); + } } /* delayed apply callbacks */ @@ -9801,8 +10123,9 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata) /* reaqcuire window in case pie invalidates it somehow */ wmWindow *win = CTX_wm_window(C); - if (win) + if (win) { win->last_pie_event = EVENT_NONE; + } } CTX_wm_region_set(C, menu_region); @@ -9890,8 +10213,9 @@ bool UI_textbutton_activate_rna( } } } - if (but) + if (but) { break; + } } if (but) { @@ -9910,12 +10234,15 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut) uiBut *but = NULL; for (block = ar->uiblocks.first; block; block = block->next) { - for (but = block->buttons.first; but; but = but->next) - if (but == actbut && but->type == UI_BTYPE_TEXT) + for (but = block->buttons.first; but; but = but->next) { + if (but == actbut && but->type == UI_BTYPE_TEXT) { break; + } + } - if (but) + if (but) { break; + } } if (but) { @@ -9944,9 +10271,11 @@ void UI_screen_free_active_but(const bContext *C, bScreen *screen) if (but) { uiHandleButtonData *data = but->active; - if (data->menu == NULL && data->searchbox == NULL) - if (data->state == BUTTON_STATE_HIGHLIGHT) + if (data->menu == NULL && data->searchbox == NULL) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { ui_but_active_free(C, but); + } + } } } } @@ -9961,8 +10290,9 @@ bool UI_but_active_drop_name(bContext *C) uiBut *but = ui_region_find_active_but(ar); if (but) { - if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) + if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { return 1; + } } return 0; @@ -9975,8 +10305,9 @@ bool UI_but_active_drop_color(bContext *C) if (ar) { uiBut *but = ui_region_find_active_but(ar); - if (but && but->type == UI_BTYPE_COLOR) + if (but && but->type == UI_BTYPE_COLOR) { return true; + } } return false; diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 8606779d5fd..96086b21ab2 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -206,8 +206,9 @@ static DrawInfo *def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, iimg->rect = MEM_mallocN(size * size * sizeof(uint), "icon_rect"); /* Here we store the rect in the icon - same as before */ - if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0) + if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0) { memcpy(iimg->rect, bbuf->rect, size * size * sizeof(int)); + } else { /* this code assumes square images */ imgsize = bbuf->x; @@ -674,15 +675,17 @@ static void init_event_icons(void) static void icon_verify_datatoc(IconImage *iimg) { /* if it has own rect, things are all OK */ - if (iimg->rect) + if (iimg->rect) { return; + } if (iimg->datatoc_rect) { ImBuf *bbuf = IMB_ibImageFromMemory(iimg->datatoc_rect, iimg->datatoc_size, IB_rect, NULL, ""); /* w and h were set on initialize */ - if (bbuf->x != iimg->h && bbuf->y != iimg->w) + if (bbuf->x != iimg->h && bbuf->y != iimg->w) { IMB_scaleImBuf(bbuf, iimg->w, iimg->h); + } iimg->rect = bbuf->rect; bbuf->rect = NULL; @@ -718,17 +721,21 @@ static void init_internal_icons(void) } } #endif - if (b16buf == NULL) + if (b16buf == NULL) { b16buf = IMB_ibImageFromMemory((const uchar *)datatoc_blender_icons16_png, datatoc_blender_icons16_png_size, IB_rect, NULL, ""); - if (b16buf) + } + if (b16buf) { IMB_premultiply_alpha(b16buf); + } - if (b32buf == NULL) + if (b32buf == NULL) { b32buf = IMB_ibImageFromMemory((const uchar *)datatoc_blender_icons32_png, datatoc_blender_icons32_png_size, IB_rect, NULL, ""); - if (b32buf) + } + if (b32buf) { IMB_premultiply_alpha(b32buf); + } if (b16buf && b32buf) { /* Free existing texture if any. */ @@ -835,8 +842,9 @@ static void init_iconfile_list(struct ListBase *list) BLI_listbase_clear(list); icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons"); - if (icondir == NULL) + if (icondir == NULL) { return; + } totfile = BLI_filelist_dir_contents(icondir, &dir); @@ -944,8 +952,9 @@ void UI_icons_free_drawinfo(void *drawinfo) if (di) { if (di->type == ICON_TYPE_BUFFER) { if (di->data.buffer.image) { - if (di->data.buffer.image->rect) + if (di->data.buffer.image->rect) { MEM_freeN(di->data.buffer.image->rect); + } MEM_freeN(di->data.buffer.image); } } @@ -1008,8 +1017,9 @@ int UI_icon_get_width(int icon_id) icon = BKE_icon_get(icon_id); if (icon == NULL) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id); + } return 0; } @@ -1025,8 +1035,9 @@ int UI_icon_get_height(int icon_id) { Icon *icon = BKE_icon_get(icon_id); if (icon == NULL) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id); + } return 0; } @@ -1069,8 +1080,9 @@ static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size) uint render_size = UI_preview_render_size(size); if (!prv_img) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("%s, error: requested preview image does not exist", __func__); + } } else if (!prv_img->rect[size]) { prv_img->w[size] = render_size; @@ -1105,8 +1117,9 @@ static void ui_studiolight_free_function(StudioLight *sl, void *data) wmWindowManager *wm = data; /* Happens if job was canceled or already finished. */ - if (wm == NULL) + if (wm == NULL) { return; + } // get icons_id, get icons and kill wm jobs if (sl->icon_id_radiance) { @@ -1195,8 +1208,9 @@ static void icon_set_image( const bContext *C, Scene *scene, ID *id, PreviewImage *prv_img, enum eIconSizes size, const bool use_job) { if (!prv_img) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("%s: no preview image for this ID: %s\n", __func__, id->name); + } return; } @@ -1321,8 +1335,9 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), immDrawPixelsTex(&state, draw_x, draw_y, draw_w, draw_h, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, 1.0f, 1.0f, col); - if (ima) + if (ima) { IMB_freeImBuf(ima); + } } /* High enough to make a difference, low enough so that @@ -1353,8 +1368,9 @@ void UI_icon_draw_cache_begin(void) static void icon_draw_cache_flush_ex(void) { - if (g_icon_draw_cache.calls == 0) + if (g_icon_draw_cache.calls == 0) { return; + } /* We need to flush widget base first to ensure correct ordering. */ UI_widgetbase_draw_cache_flush(); @@ -1388,8 +1404,9 @@ void UI_icon_draw_cache_end(void) g_icon_draw_cache.enabled = false; /* Don't change blend state if it's not needed. */ - if (g_icon_draw_cache.calls == 0) + if (g_icon_draw_cache.calls == 0) { return; + } GPU_blend(true); icon_draw_cache_flush_ex(); @@ -1418,8 +1435,12 @@ static void icon_draw_texture_cached( call->tex.ymin = iy * icongltex.invh; call->tex.ymax = (iy + ih) * icongltex.invh; - if (rgb) copy_v4_fl4(call->color, rgb[0], rgb[1], rgb[2], alpha); - else copy_v4_fl(call->color, alpha); + if (rgb) { + copy_v4_fl4(call->color, rgb[0], rgb[1], rgb[2], alpha); + } + else { + copy_v4_fl(call->color, alpha); + } if (g_icon_draw_cache.calls == ICON_DRAW_CACHE_SIZE) { icon_draw_cache_flush_ex(); @@ -1453,8 +1474,12 @@ static void icon_draw_texture( GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR); GPU_shader_bind(shader); - if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha); - else glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha); + if (rgb) { + glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha); + } + else { + glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha); + } glUniform1i(GPU_shader_get_uniform_ensure(shader, "image"), 0); glUniform4f(GPU_shader_get_uniform_ensure(shader, "rect_icon"), x1, y1, x2, y2); @@ -1496,8 +1521,9 @@ static void icon_draw_size( alpha *= btheme->tui.icon_alpha; if (icon == NULL) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id); + } return; } @@ -1583,7 +1609,10 @@ static void icon_draw_size( #ifndef WITH_HEADLESS icon_verify_datatoc(iimg); #endif - if (!iimg->rect) return; /* something has gone wrong! */ + if (!iimg->rect) { + /* something has gone wrong! */ + return; + } icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, desaturate); } @@ -1592,7 +1621,10 @@ static void icon_draw_size( if (pi) { /* no create icon on this level in code */ - if (!pi->rect[size]) return; /* something has gone wrong! */ + if (!pi->rect[size]) { + /* Something has gone wrong! */ + return; + } /* Preview images use premultiplied alpha. */ GPU_blend_set_func_separate(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); @@ -1643,8 +1675,9 @@ static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs) PreviewImage *pi = BKE_previewimg_id_ensure(id); enum eIconSizes i; - if (!pi) + if (!pi) { return; + } for (i = 0; i < NUM_ICON_SIZES; i++) { /* check if rect needs to be created; changed @@ -1809,8 +1842,9 @@ int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big { ID *id = NULL; - if (!ptr->data) + if (!ptr->data) { return rnaicon; + } /* try ID, material, texture or dynapaint slot */ if (RNA_struct_is_ID(ptr->type)) { @@ -1825,12 +1859,15 @@ int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big else if (RNA_struct_is_a(ptr->type, &RNA_DynamicPaintSurface)) { DynamicPaintSurface *surface = ptr->data; - if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) + if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) { return ICON_SHADING_TEXTURE; - else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) + } + else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) { return ICON_OUTLINER_DATA_MESH; - else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) + } + else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) { return ICON_FILE_IMAGE; + } } else if (RNA_struct_is_a(ptr->type, &RNA_StudioLight)) { StudioLight *sl = ptr->data; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b02b32766b9..bb3172d7174 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -236,8 +236,9 @@ static int ui_item_fit(int item, int pos, int all, int available, bool is_last, if (all > available) { /* contents is bigger than available space */ - if (is_last) + if (is_last) { return available - pos; + } else { float width = *extra_pixel + (item * available) / (float)all; *extra_pixel = width - (int)width; @@ -247,8 +248,9 @@ static int ui_item_fit(int item, int pos, int all, int available, bool is_last, else { /* contents is smaller or equal to available space */ if (alignment == UI_LAYOUT_ALIGN_EXPAND) { - if (is_last) + if (is_last) { return available - pos; + } else { float width = *extra_pixel + (item * available) / (float)all; *extra_pixel = width - (int)width; @@ -286,8 +288,9 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool bool variable; const int unit_x = UI_UNIT_X * (layout->scale[0] ? layout->scale[0] : 1.0f); - if (icon && !name[0]) + if (icon && !name[0]) { return unit_x; /* icon only */ + } variable = ui_layout_variable_size(layout); @@ -315,14 +318,22 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - if (r_w) *r_w = BLI_rctf_size_x(&bitem->but->rect); - if (r_h) *r_h = BLI_rctf_size_y(&bitem->but->rect); + if (r_w) { + *r_w = BLI_rctf_size_x(&bitem->but->rect); + } + if (r_h) { + *r_h = BLI_rctf_size_y(&bitem->but->rect); + } } else { uiLayout *litem = (uiLayout *)item; - if (r_w) *r_w = litem->w; - if (r_h) *r_h = litem->h; + if (r_w) { + *r_w = litem->w; + } + if (r_h) { + *r_h = litem->h; + } } } @@ -331,12 +342,20 @@ static void ui_item_offset(uiItem *item, int *r_x, int *r_y) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - if (r_x) *r_x = bitem->but->rect.xmin; - if (r_y) *r_y = bitem->but->rect.ymin; + if (r_x) { + *r_x = bitem->but->rect.xmin; + } + if (r_y) { + *r_y = bitem->but->rect.ymin; + } } else { - if (r_x) *r_x = 0; - if (r_y) *r_y = 0; + if (r_x) { + *r_x = 0; + } + if (r_y) { + *r_y = 0; + } } } @@ -375,10 +394,12 @@ static void ui_item_move(uiItem *item, int delta_xmin, int delta_xmax) else { uiLayout *litem = (uiLayout *)item; - if (delta_xmin > 0) + if (delta_xmin > 0) { litem->x += delta_xmin; - else + } + else { litem->w += delta_xmax; + } } } @@ -406,10 +427,12 @@ static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, bool { uiLayout *sub; - if (uiLayoutGetLocalDir(test) == UI_LAYOUT_HORIZONTAL) + if (uiLayoutGetLocalDir(test) == UI_LAYOUT_HORIZONTAL) { sub = uiLayoutRow(layout, align); - else + } + else { sub = uiLayoutColumn(layout, align); + } sub->space = 0; return sub; @@ -428,14 +451,17 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index) if (!shift) { RNA_property_boolean_set_index(ptr, prop, index, true); - for (i = 0; i < len; i++) - if (i != index) + for (i = 0; i < len; i++) { + if (i != index) { RNA_property_boolean_set_index(ptr, prop, i, 0); + } + } RNA_property_update(C, ptr, prop); - for (cbut = but->block->buttons.first; cbut; cbut = cbut->next) + for (cbut = but->block->buttons.first; cbut; cbut = cbut->next) { ui_but_update(cbut); + } } } @@ -504,36 +530,42 @@ static void ui_item_array( const uint layer_flag = (1u << layer_num); if (layer_used & layer_flag) { - if (layer_active & layer_flag) + if (layer_active & layer_flag) { icon = ICON_LAYER_ACTIVE; - else + } + else { icon = ICON_LAYER_USED; + } } else { icon = ICON_BLANK1; } but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth); - if (subtype == PROP_LAYER_MEMBER) + if (subtype == PROP_LAYER_MEMBER) { UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num)); + } } for (a = 0; a < colbuts; a++) { const int layer_num = a + len / 2 + b * colbuts; const uint layer_flag = (1u << layer_num); if (layer_used & layer_flag) { - if (layer_active & layer_flag) + if (layer_active & layer_flag) { icon = ICON_LAYER_ACTIVE; - else + } + else { icon = ICON_LAYER_USED; + } } else { icon = ICON_BLANK1; } but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth); - if (subtype == PROP_LAYER_MEMBER) + if (subtype == PROP_LAYER_MEMBER) { UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num)); + } } UI_block_align_end(block); @@ -547,7 +579,10 @@ static void ui_item_array( UI_block_layout_set_current(block, uiLayoutAbsolute(layout, true)); totdim = RNA_property_array_dimension(ptr, prop, dim_size); - if (totdim != 2) return; /* only 2D matrices supported in UI so far */ + if (totdim != 2) { + /* Only 2D matrices supported in UI so far. */ + return; + } w /= dim_size[0]; /* h /= dim_size[1]; */ /* UNUSED */ @@ -557,8 +592,9 @@ static void ui_item_array( row = a / dim_size[0]; but = uiDefAutoButR(block, ptr, prop, a, "", ICON_NONE, x + w * col, y + (dim_size[1] * UI_UNIT_Y) - (row * UI_UNIT_Y), w, UI_UNIT_Y); - if (slider && but->type == UI_BTYPE_NUM) + if (slider && but->type == UI_BTYPE_NUM) { but->type = UI_BTYPE_NUM_SLIDER; + } } } else if (subtype == PROP_DIRECTION && !expand) { @@ -608,12 +644,15 @@ static void ui_item_array( min_ii(w, ui_text_icon_width(layout, str_buf, icon, false)) : w); but = uiDefAutoButR(block, ptr, prop, a, str_buf, icon, 0, 0, width_item, UI_UNIT_Y); - if (slider && but->type == UI_BTYPE_NUM) + if (slider && but->type == UI_BTYPE_NUM) { but->type = UI_BTYPE_NUM_SLIDER; - if (toggle && but->type == UI_BTYPE_CHECKBOX) + } + if (toggle && but->type == UI_BTYPE_CHECKBOX) { but->type = UI_BTYPE_TOGGLE; - if ((a == 0) && (subtype == PROP_AXISANGLE)) + } + if ((a == 0) && (subtype == PROP_AXISANGLE)) { UI_but_unit_type_set(but, PROP_UNIT_ROTATION); + } } if (boolarr) { @@ -665,10 +704,12 @@ static void ui_item_enum_expand_exec( BLI_assert(RNA_property_type(prop) == PROP_ENUM); - if (radial) + if (radial) { RNA_property_enum_items_gettexted_all(block->evil_C, ptr, prop, &item_array, NULL, &free); - else + } + else { RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item_array, NULL, &free); + } /* we dont want nested rows, cols in menus */ if (radial) { @@ -721,12 +762,15 @@ static void ui_item_enum_expand_exec( value = item->value; itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0); - if (icon && name[0] && !icon_only) + if (icon && name[0] && !icon_only) { but = uiDefIconTextButR_prop(block, but_type, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); - else if (icon) + } + else if (icon) { but = uiDefIconButR_prop(block, but_type, 0, icon, 0, 0, (is_first) ? itemw : ceilf(itemw - U.pixelsize), h, ptr, prop, -1, 0, value, -1, -1, NULL); - else + } + else { but = uiDefButR_prop(block, but_type, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); + } if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { /* If this is set, assert since we're clobbering someone elses callback. */ @@ -734,8 +778,9 @@ static void ui_item_enum_expand_exec( UI_but_func_set(but, ui_item_enum_expand_handle, but, POINTER_FROM_INT(value)); } - if (uiLayoutGetLocalDir(layout) != UI_LAYOUT_HORIZONTAL) + if (uiLayoutGetLocalDir(layout) != UI_LAYOUT_HORIZONTAL) { but->drawflag |= UI_BUT_TEXT_LEFT; + } /* Allow quick, inaccurate swipe motions to switch tabs * (no need to keep cursor over them). */ @@ -849,8 +894,9 @@ static uiBut *ui_item_with_label( but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, prop_but_width, h, ptr, prop, 0, 0, 0, -1, -1, NULL); UI_but_func_set(but, ui_keymap_but_cb, but, NULL); - if (flag & UI_ITEM_R_IMMEDIATE) + if (flag & UI_ITEM_R_IMMEDIATE) { UI_but_flag_enable(but, UI_BUT_IMMEDIATE); + } } } else { @@ -887,8 +933,9 @@ void UI_context_active_but_prop_get_filebrowser( *r_prop = NULL; *r_is_undo = false; - if (!ar) + if (!ar) { return; + } for (block = ar->uiblocks.first; block; block = block->next) { for (but = block->buttons.first; but; but = but->next) { @@ -932,8 +979,9 @@ static void ui_item_disabled(uiLayout *layout, const char *name) UI_block_layout_set_current(block, layout); - if (!name) + if (!name) { name = ""; + } w = ui_text_icon_width(layout, name, 0, 0); @@ -958,14 +1006,17 @@ static uiBut *uiItemFullO_ptr_ex( int w; if (!name) { - if (ot && ot->srna && (flag & UI_ITEM_R_ICON_ONLY) == 0) + if (ot && ot->srna && (flag & UI_ITEM_R_ICON_ONLY) == 0) { name = RNA_struct_ui_name(ot->srna); - else + } + else { name = ""; + } } - if (layout->root->type == UI_LAYOUT_MENU && !icon) + if (layout->root->type == UI_LAYOUT_MENU && !icon) { icon = ICON_BLANK1; + } /* create button */ UI_block_layout_set_current(block, layout); @@ -993,8 +1044,9 @@ static uiBut *uiItemFullO_ptr_ex( assert(but->optype != NULL); /* text alignment for toolbar buttons */ - if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon) + if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon) { but->drawflag |= UI_BUT_TEXT_LEFT; + } if (flag & UI_ITEM_R_NO_BG) { layout->emboss = prev_emboss; @@ -1004,8 +1056,9 @@ static uiBut *uiItemFullO_ptr_ex( but->flag |= UI_SELECT_DRAW; } - if (layout->redalert) + if (layout->redalert) { UI_but_flag_enable(but, UI_BUT_REDALERT); + } /* assign properties */ if (properties || r_opptr) { @@ -1139,8 +1192,9 @@ void uiItemEnumO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int RNA_property_enum_set(&ptr, prop, value); - if (!name) + if (!name) { name = ui_menu_enumpropname(layout, &ptr, prop, value); + } uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL); } @@ -1205,9 +1259,11 @@ void uiItemsFullEnumO_items( /* Check if there are more visible items for the next level. If not, we don't * add a new level and add the remaining item instead of the 'more' button. */ - for (tmp = item + 1; tmp->identifier; tmp++) - if (tmp->name) + for (tmp = item + 1; tmp->identifier; tmp++) { + if (tmp->name) { break; + } + } if (tmp->identifier) { /* only true if loop above found item and did early-exit */ ui_pie_menu_level_create(block, ot, propname, properties, item_array, totitem, context, flag); @@ -1374,8 +1430,9 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char RNA_property_enum_set(&ptr, prop, value); /* same as uiItemEnumO */ - if (!name) + if (!name) { name = ui_menu_enumpropname(layout, &ptr, prop, value); + } uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL); } @@ -1418,8 +1475,9 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char RNA_property_enum_set(&ptr, prop, value); /* same as uiItemEnumO */ - if (!name) + if (!name) { name = ui_menu_enumpropname(layout, &ptr, prop, value); + } uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL); } @@ -1525,8 +1583,9 @@ static void ui_item_rna_size( if (!w) { if (type == PROP_ENUM && icon_only) { w = ui_text_icon_width(layout, "", ICON_BLANK1, compact); - if (index != RNA_ENUM_VALUE) + if (index != RNA_ENUM_VALUE) { w += 0.6f * UI_UNIT_X; + } } else { /* not compact for float/int buttons, looks too squashed */ @@ -1537,24 +1596,32 @@ static void ui_item_rna_size( /* increase height for arrays */ if (index == RNA_NO_INDEX && len > 0) { - if (!name[0] && icon == ICON_NONE) + if (!name[0] && icon == ICON_NONE) { h = 0; - if (layout->item.flag & UI_ITEM_PROP_SEP) + } + if (layout->item.flag & UI_ITEM_PROP_SEP) { h = 0; - if (ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) + } + if (ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) { h += 2 * UI_UNIT_Y; - else if (subtype == PROP_MATRIX) + } + else if (subtype == PROP_MATRIX) { h += ceilf(sqrtf(len)) * UI_UNIT_Y; - else + } + else { h += len * UI_UNIT_Y; + } } else if (ui_layout_variable_size(layout)) { - if (type == PROP_BOOLEAN && name[0]) + if (type == PROP_BOOLEAN && name[0]) { w += UI_UNIT_X / 5; - else if (type == PROP_ENUM && !icon_only) + } + else if (type == PROP_ENUM && !icon_only) { w += UI_UNIT_X / 4; - else if (type == PROP_FLOAT || type == PROP_INT) + } + else if (type == PROP_FLOAT || type == PROP_INT) { w += UI_UNIT_X * 3; + } } *r_w = w; @@ -1611,8 +1678,9 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index } } - if (icon == ICON_NONE) + if (icon == ICON_NONE) { icon = RNA_property_ui_icon(prop); + } if (flag & UI_ITEM_R_ICON_ONLY) { /* pass */ @@ -1802,12 +1870,15 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index } /* enum item */ else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) { - if (icon && name[0] && !icon_only) + if (icon && name[0] && !icon_only) { uiDefIconTextButR_prop(block, UI_BTYPE_ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); - else if (icon) + } + else if (icon) { uiDefIconButR_prop(block, UI_BTYPE_ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); - else + } + else { uiDefButR_prop(block, UI_BTYPE_ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); + } } /* expanded enum */ else if (type == PROP_ENUM && expand) { @@ -1818,27 +1889,33 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag); ui_but_add_search(but, ptr, prop, NULL, NULL); - if (layout->redalert) + if (layout->redalert) { UI_but_flag_enable(but, UI_BUT_REDALERT); + } - if (layout->activate_init) + if (layout->activate_init) { UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT); + } } /* single button */ else { but = uiDefAutoButR(block, ptr, prop, index, name, icon, 0, 0, w, h); - if (slider && but->type == UI_BTYPE_NUM) + if (slider && but->type == UI_BTYPE_NUM) { but->type = UI_BTYPE_NUM_SLIDER; + } - if (toggle && but->type == UI_BTYPE_CHECKBOX) + if (toggle && but->type == UI_BTYPE_CHECKBOX) { but->type = UI_BTYPE_TOGGLE; + } - if (layout->redalert) + if (layout->redalert) { UI_but_flag_enable(but, UI_BUT_REDALERT); + } - if (layout->activate_init) + if (layout->activate_init) { UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT); + } if (use_prop_sep && (use_prop_sep_split_label == false)) { /* When the button uses it's own text right align it. */ @@ -2040,8 +2117,9 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname ui_but_tip_from_enum_item(bt, &item[i]); } - else + else { uiItemS(column); + } } } @@ -2160,15 +2238,18 @@ void uiItemPointerR_prop( /* get icon & name */ if (icon == ICON_NONE) { - if (type == PROP_POINTER) + if (type == PROP_POINTER) { icontype = RNA_property_pointer_type(ptr, prop); - else + } + else { icontype = RNA_property_pointer_type(searchptr, searchprop); + } icon = RNA_struct_ui_icon(icontype); } - if (!name) + if (!name) { name = RNA_property_ui_name(prop); + } if (use_prop_sep == false) { name = ui_item_name_add_colon(name, namestr); @@ -2239,10 +2320,12 @@ static uiBut *ui_item_menu( UI_block_layout_set_current(block, layout); - if (!name) + if (!name) { name = ""; - if (layout->root->type == UI_LAYOUT_MENU && !icon) + } + if (layout->root->type == UI_LAYOUT_MENU && !icon) { icon = ICON_BLANK1; + } w = ui_text_icon_width(layout, name, icon, 1); h = UI_UNIT_Y; @@ -2304,8 +2387,9 @@ void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon) name = CTX_IFACE_(mt->translation_context, mt->label); } - if (layout->root->type == UI_LAYOUT_MENU && !icon) + if (layout->root->type == UI_LAYOUT_MENU && !icon) { icon = ICON_BLANK1; + } ui_item_menu( layout, name, icon, ui_item_menutype_func, mt, NULL, @@ -2404,10 +2488,12 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) UI_block_layout_set_current(block, layout); - if (!name) + if (!name) { name = ""; - if (layout->root->type == UI_LAYOUT_MENU && !icon) + } + if (layout->root->type == UI_LAYOUT_MENU && !icon) { icon = ICON_BLANK1; + } w = ui_text_icon_width(layout, name, icon, 0); @@ -2450,9 +2536,11 @@ void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, const char *name, int icon) { uiBut *but = uiItemL_(layout, name, icon); - if (ptr && ptr->type) - if (RNA_struct_is_ID(ptr->type)) + if (ptr && ptr->type) { + if (RNA_struct_is_ID(ptr->type)) { UI_but_drag_set_id(but, ptr->id.data); + } + } } @@ -2466,19 +2554,24 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval) UI_block_layout_set_current(block, layout); - if (!name) + if (!name) { name = ""; - if (layout->root->type == UI_LAYOUT_MENU && !icon) + } + if (layout->root->type == UI_LAYOUT_MENU && !icon) { icon = ICON_BLANK1; + } w = ui_text_icon_width(layout, name, icon, 0); - if (icon && name[0]) + if (icon && name[0]) { uiDefIconTextButI(block, UI_BTYPE_BUT, argval, icon, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, ""); - else if (icon) + } + else if (icon) { uiDefIconButI(block, UI_BTYPE_BUT, argval, icon, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, ""); - else + } + else { uiDefButI(block, UI_BTYPE_BUT, argval, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, ""); + } } /* separator item */ @@ -2522,8 +2615,9 @@ void uiItemSpacer(uiLayout *layout) /* level items */ void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg) { - if (!func) + if (!func) { return; + } ui_item_menu(layout, name, icon, func, arg, NULL, "", false); } @@ -2533,8 +2627,9 @@ void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc */ void uiItemMenuFN(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *argN) { - if (!func) + if (!func) { return; + } /* Second 'argN' only ensures it gets freed. */ ui_item_menu(layout, name, icon, func, argN, argN, "", false); @@ -2576,8 +2671,9 @@ void uiItemMenuEnumO_ptr( name = RNA_struct_ui_name(ot->srna); } - if (layout->root->type == UI_LAYOUT_MENU && !icon) + if (layout->root->type == UI_LAYOUT_MENU && !icon) { icon = ICON_BLANK1; + } lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel"); BLI_strncpy(lvl->opname, ot->idname, sizeof(lvl->opname)); @@ -2632,10 +2728,12 @@ void uiItemMenuEnumR_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA { MenuItemLevel *lvl; - if (!name) + if (!name) { name = RNA_property_ui_name(prop); - if (layout->root->type == UI_LAYOUT_MENU && !icon) + } + if (layout->root->type == UI_LAYOUT_MENU && !icon) { icon = ICON_BLANK1; + } lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel"); lvl->rnapoin = *ptr; @@ -2687,8 +2785,9 @@ static void ui_litem_estimate_row(uiLayout *litem) litem->w += itemw; litem->h = MAX2(itemh, litem->h); - if (item->next) + if (item->next) { litem->w += litem->space; + } } if (min_size_flag) { @@ -2720,11 +2819,13 @@ static void ui_litem_layout_row(uiLayout *litem) tot++; } - if (totw == 0) + if (totw == 0) { return; + } - if (w != 0) + if (w != 0) { w -= (tot - 1) * litem->space; + } fixedw = 0; /* keep clamping items to fixed minimum size until all are done */ @@ -2736,16 +2837,19 @@ static void ui_litem_layout_row(uiLayout *litem) extra_pixel = 0.0f; for (item = litem->items.first; item; item = item->next) { - if (item->flag & UI_ITEM_FIXED) + if (item->flag & UI_ITEM_FIXED) { continue; + } ui_item_size(item, &itemw, &itemh); minw = ui_litem_min_width(itemw); - if (w - lastw > 0) + if (w - lastw > 0) { neww = ui_item_fit(itemw, x, totw, w - lastw, !item->next, litem->alignment, &extra_pixel); - else + } + else { neww = 0; /* no space left, all will need clamping to minimum size */ + } x += neww; @@ -2807,20 +2911,23 @@ static void ui_litem_layout_row(uiLayout *litem) /* align right/center */ offset = 0; if (litem->alignment == UI_LAYOUT_ALIGN_RIGHT) { - if (freew + fixedw > 0 && freew + fixedw < w) + if (freew + fixedw > 0 && freew + fixedw < w) { offset = w - (fixedw + freew); + } } else if (litem->alignment == UI_LAYOUT_ALIGN_CENTER) { - if (freew + fixedw > 0 && freew + fixedw < w) + if (freew + fixedw > 0 && freew + fixedw < w) { offset = (w - (fixedw + freew)) / 2; + } } /* position item */ ui_item_position(item, x + offset, y - itemh, itemw, itemh); x += itemw; - if (item->next) + if (item->next) { x += litem->space; + } } /* add extra pixel */ @@ -2830,8 +2937,9 @@ static void ui_litem_layout_row(uiLayout *litem) last_free_item && last_item && last_item->flag & UI_ITEM_FIXED) { ui_item_move(last_free_item, 0, extra_pixel); - for (item = last_free_item->next; item; item = item->next) + for (item = last_free_item->next; item; item = item->next) { ui_item_move(item, extra_pixel, extra_pixel); + } } litem->w = x - litem->x; @@ -2858,8 +2966,9 @@ static void ui_litem_estimate_column(uiLayout *litem, bool is_box) litem->w = MAX2(litem->w, itemw); litem->h += itemh; - if (item->next && (!is_box || item != litem->items.first)) + if (item->next && (!is_box || item != litem->items.first)) { litem->h += litem->space; + } } if (min_size_flag) { @@ -2881,8 +2990,9 @@ static void ui_litem_layout_column(uiLayout *litem, bool is_box) y -= itemh; ui_item_position(item, x, y, litem->w, itemh); - if (item->next && (!is_box || item != litem->items.first)) + if (item->next && (!is_box || item != litem->items.first)) { y -= litem->space; + } if (is_box) { item->flag |= UI_ITEM_BOX_ITEM; @@ -2914,8 +3024,9 @@ static RadialDirection ui_get_radialbut_vec(float vec[2], short itemnum) static bool ui_item_is_radial_displayable(uiItem *item) { - if ((item->type == ITEM_BUTTON) && (((uiButtonItem *)item)->but->type == UI_BTYPE_LABEL)) + if ((item->type == ITEM_BUTTON) && (((uiButtonItem *)item)->but->type == UI_BTYPE_LABEL)) { return false; + } return true; } @@ -2923,8 +3034,9 @@ static bool ui_item_is_radial_displayable(uiItem *item) static bool ui_item_is_radial_drawable(uiButtonItem *bitem) { - if (ELEM(bitem->but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER)) + if (ELEM(bitem->but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER)) { return false; + } return true; } @@ -2949,11 +3061,13 @@ static void ui_litem_layout_radial(uiLayout *litem) int minx = x, miny = y, maxx = x, maxy = y; /* first count total items */ - for (item = litem->items.first; item; item = item->next) + for (item = litem->items.first; item; item = item->next) { totitems++; + } - if (totitems < 5) + if (totitems < 5) { litem->root->block->pie_data.flags |= UI_PIE_DEGREES_RANGE_LARGE; + } for (item = litem->items.first; item; item = item->next) { /* not all button types are drawn in a radial menu, do filtering here */ @@ -3024,12 +3138,15 @@ static void ui_litem_layout_root_radial(uiLayout *litem) static void ui_litem_layout_root(uiLayout *litem) { - if (litem->root->type == UI_LAYOUT_HEADER) + if (litem->root->type == UI_LAYOUT_HEADER) { ui_litem_layout_row(litem); - else if (litem->root->type == UI_LAYOUT_PIEMENU) + } + else if (litem->root->type == UI_LAYOUT_PIEMENU) { ui_litem_layout_root_radial(litem); - else + } + else { ui_litem_layout_column(litem, false); + } } /* box layout */ @@ -3055,16 +3172,24 @@ static void ui_litem_layout_box(uiLayout *litem) litem->x += style->boxspace; litem->y -= style->boxspace; - if (w != 0) litem->w -= 2 * style->boxspace; - if (h != 0) litem->h -= 2 * style->boxspace; + if (w != 0) { + litem->w -= 2 * style->boxspace; + } + if (h != 0) { + litem->h -= 2 * style->boxspace; + } ui_litem_layout_column(litem, true); litem->x -= style->boxspace; litem->y -= style->boxspace; - if (w != 0) litem->w += 2 * style->boxspace; - if (h != 0) litem->h += 2 * style->boxspace; + if (w != 0) { + litem->w += 2 * style->boxspace; + } + if (h != 0) { + litem->h += 2 * style->boxspace; + } /* roundbox around the sublayout */ but = box->roundbox; @@ -3607,10 +3732,12 @@ static void ui_litem_layout_absolute(uiLayout *litem) totw -= minx; toth -= miny; - if (litem->w && totw > 0) + if (litem->w && totw > 0) { scalex = (float)litem->w / (float)totw; - if (litem->h && toth > 0) + } + if (litem->h && toth > 0) { scaley = (float)litem->h / (float)toth; + } x = litem->x; y = litem->y - scaley * toth; @@ -3655,8 +3782,9 @@ static void ui_litem_layout_split(uiLayout *litem) const int tot = BLI_listbase_count(&litem->items); int itemh, x, y, w, colw = 0; - if (tot == 0) + if (tot == 0) { return; + } x = litem->x; y = litem->y; @@ -3837,8 +3965,9 @@ uiLayout *uiLayoutRadial(uiLayout *layout) uiItem *item; /* radial layouts are only valid for radial menus */ - if (layout->root->type != UI_LAYOUT_PIEMENU) + if (layout->root->type != UI_LAYOUT_PIEMENU) { return ui_item_local_sublayout(layout, layout, 0); + } /* only one radial wheel per root layout is allowed, so check and return that, if it exists */ for (item = layout->root->layout->items.first; item; item = item->next) { @@ -4135,8 +4264,9 @@ static void ui_item_estimate(uiItem *item) if (item->type != ITEM_BUTTON) { uiLayout *litem = (uiLayout *)item; - for (subitem = litem->items.first; subitem; subitem = subitem->next) + for (subitem = litem->items.first; subitem; subitem = subitem->next) { ui_item_estimate(subitem); + } if (BLI_listbase_is_empty(&litem->items)) { litem->w = 0; @@ -4144,8 +4274,9 @@ static void ui_item_estimate(uiItem *item) return; } - if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f) + if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f) { ui_item_scale(litem, litem->scale); + } switch (litem->item.type) { case ITEM_LAYOUT_COLUMN: @@ -4247,15 +4378,19 @@ static void ui_item_layout(uiItem *item) if (item->type != ITEM_BUTTON) { uiLayout *litem = (uiLayout *)item; - if (BLI_listbase_is_empty(&litem->items)) + if (BLI_listbase_is_empty(&litem->items)) { return; + } - if (litem->align) + if (litem->align) { ui_item_align(litem, ++litem->root->block->alignnr); - if (!litem->active) + } + if (!litem->active) { ui_item_flag(litem, UI_BUT_INACTIVE); - if (!litem->enabled) + } + if (!litem->enabled) { ui_item_flag(litem, UI_BUT_DISABLED); + } switch (litem->item.type) { case ITEM_LAYOUT_COLUMN: @@ -4309,14 +4444,19 @@ static void ui_item_layout(uiItem *item) static void ui_layout_end(uiBlock *block, uiLayout *layout, int *x, int *y) { - if (layout->root->handlefunc) + if (layout->root->handlefunc) { UI_block_func_handle_set(block, layout->root->handlefunc, layout->root->argv); + } ui_item_estimate(&layout->item); ui_item_layout(&layout->item); - if (x) *x = layout->x; - if (y) *y = layout->y; + if (x) { + *x = layout->x; + } + if (y) { + *y = layout->y; + } } static void ui_layout_free(uiLayout *layout) @@ -4326,10 +4466,12 @@ static void ui_layout_free(uiLayout *layout) for (item = layout->items.first; item; item = next) { next = item->next; - if (item->type == ITEM_BUTTON) + if (item->type == ITEM_BUTTON) { MEM_freeN(item); - else + } + else { ui_layout_free((uiLayout *)item); + } } MEM_freeN(layout); @@ -4375,8 +4517,9 @@ uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int s layout->context = NULL; layout->emboss = UI_EMBOSS_UNDEFINED; - if (type == UI_LAYOUT_MENU || type == UI_LAYOUT_PIEMENU) + if (type == UI_LAYOUT_MENU || type == UI_LAYOUT_PIEMENU) { layout->space = 0; + } if (dir == UI_LAYOUT_HORIZONTAL) { layout->h = size; @@ -4462,8 +4605,12 @@ void UI_block_layout_resolve(uiBlock *block, int *x, int *y) BLI_assert(block->active); - if (x) *x = 0; - if (y) *y = 0; + if (x) { + *x = 0; + } + if (y) { + *y = 0; + } block->curlayout = NULL; diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index c7c039bf8f9..97dd79864e1 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -257,8 +257,9 @@ static int reset_default_button_exec(bContext *C, wmOperator *op) /* if there is a valid property that is editable... */ if (ptr.data && prop && RNA_property_editable(&ptr, prop)) { - if (RNA_property_reset(&ptr, prop, (all) ? -1 : index)) + if (RNA_property_reset(&ptr, prop, (all) ? -1 : index)) { return operator_button_property_finish(C, &ptr, prop); + } } return OPERATOR_CANCELLED; @@ -316,8 +317,9 @@ static int assign_default_button_exec(bContext *C, wmOperator *UNUSED(op)) /* if there is a valid property that is editable... */ if (ptr.data && prop && RNA_property_editable(&ptr, prop)) { - if (RNA_property_assign_default(&ptr, prop)) + if (RNA_property_assign_default(&ptr, prop)) { return operator_button_property_finish(C, &ptr, prop); + } } return OPERATOR_CANCELLED; @@ -1298,8 +1300,9 @@ static void edittranslation_find_po_file(const char *root, const char *uilng, ch BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng); BLI_join_dirfile(path, maxlen, root, uilng); BLI_path_append(path, maxlen, tstr); - if (BLI_is_file(path)) + if (BLI_is_file(path)) { return; + } /* Now try without the second iso code part (_ES in es_ES). */ { @@ -1316,14 +1319,16 @@ static void edittranslation_find_po_file(const char *root, const char *uilng, ch if (tstr[0]) { /* Because of some codes like sr_SR@latin... */ tc = strchr(uilng, '@'); - if (tc) + if (tc) { BLI_strncpy(tstr + szt, tc, sizeof(tstr) - szt); + } BLI_join_dirfile(path, maxlen, root, tstr); strcat(tstr, ".po"); BLI_path_append(path, maxlen, tstr); - if (BLI_is_file(path)) + if (BLI_is_file(path)) { return; + } } } @@ -1397,26 +1402,36 @@ static int edittranslation_exec(bContext *C, wmOperator *op) ret = WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr); /* Clean up */ - if (but_label.strinfo) + if (but_label.strinfo) { MEM_freeN(but_label.strinfo); - if (rna_label.strinfo) + } + if (rna_label.strinfo) { MEM_freeN(rna_label.strinfo); - if (enum_label.strinfo) + } + if (enum_label.strinfo) { MEM_freeN(enum_label.strinfo); - if (but_tip.strinfo) + } + if (but_tip.strinfo) { MEM_freeN(but_tip.strinfo); - if (rna_tip.strinfo) + } + if (rna_tip.strinfo) { MEM_freeN(rna_tip.strinfo); - if (enum_tip.strinfo) + } + if (enum_tip.strinfo) { MEM_freeN(enum_tip.strinfo); - if (rna_struct.strinfo) + } + if (rna_struct.strinfo) { MEM_freeN(rna_struct.strinfo); - if (rna_prop.strinfo) + } + if (rna_prop.strinfo) { MEM_freeN(rna_prop.strinfo); - if (rna_enum.strinfo) + } + if (rna_enum.strinfo) { MEM_freeN(rna_enum.strinfo); - if (rna_ctxt.strinfo) + } + if (rna_ctxt.strinfo) { MEM_freeN(rna_ctxt.strinfo); + } return ret; } @@ -1544,8 +1559,9 @@ bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED( SpaceImage *sima = CTX_wm_space_image(C); ARegion *ar = CTX_wm_region(C); - if (UI_but_active_drop_color(C)) + if (UI_but_active_drop_color(C)) { return 1; + } if (sima && (sima->mode == SI_MODE_PAINT) && sima->image && (ar && ar->regiontype == RGN_TYPE_WINDOW)) @@ -1589,14 +1605,16 @@ static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( } if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { - if (!gamma) + if (!gamma) { IMB_colormanagement_scene_linear_to_srgb_v3(color); + } RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color); RNA_property_update(C, &but->rnapoin, but->rnaprop); } else if (RNA_property_subtype(but->rnaprop) == PROP_COLOR) { - if (gamma) + if (gamma) { IMB_colormanagement_srgb_to_scene_linear_v3(color); + } RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color); RNA_property_update(C, &but->rnapoin, but->rnaprop); } diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index dfcae82fd51..9146e537dd5 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -134,16 +134,21 @@ typedef enum eSpaceButtons_Align { static int panel_aligned(ScrArea *sa, ARegion *ar) { - if (sa->spacetype == SPACE_PROPERTIES && ar->regiontype == RGN_TYPE_WINDOW) + if (sa->spacetype == SPACE_PROPERTIES && ar->regiontype == RGN_TYPE_WINDOW) { return BUT_VERTICAL; - else if (sa->spacetype == SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW) + } + else if (sa->spacetype == SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW) { return BUT_VERTICAL; - else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) + } + else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) { return BUT_VERTICAL; - else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) + } + else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) { return BUT_VERTICAL; - else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS, RGN_TYPE_HUD, RGN_TYPE_NAV_BAR, RGN_TYPE_EXECUTE)) + } + else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS, RGN_TYPE_HUD, RGN_TYPE_NAV_BAR, RGN_TYPE_EXECUTE)) { return BUT_VERTICAL; + } return 0; } @@ -313,10 +318,12 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, ListBase *lb, uiBlock *block, Pa BLI_strncpy(pa->panelname, idname, sizeof(pa->panelname)); if (pt->flag & PNL_DEFAULT_CLOSED) { - if (align == BUT_VERTICAL) + if (align == BUT_VERTICAL) { pa->flag |= PNL_CLOSEDY; - else + } + else { pa->flag |= PNL_CLOSEDX; + } } pa->ofsx = 0; @@ -378,13 +385,16 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, ListBase *lb, uiBlock *block, Pa if (newpanel) { pa->sortorder = (palast) ? palast->sortorder + 1 : 0; - for (panext = lb->first; panext; panext = panext->next) - if (panext != pa && panext->sortorder >= pa->sortorder) + for (panext = lb->first; panext; panext = panext->next) { + if (panext != pa && panext->sortorder >= pa->sortorder) { panext->sortorder++; + } + } } - if (palast) + if (palast) { palast->runtime_flag &= ~PNL_LAST_ADDED; + } /* assign to block */ block->panel = pa; @@ -395,8 +405,12 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, ListBase *lb, uiBlock *block, Pa *r_open = false; - if (pa->paneltab) return pa; - if (pa->flag & PNL_CLOSED) return pa; + if (pa->paneltab) { + return pa; + } + if (pa->flag & PNL_CLOSED) { + return pa; + } *r_open = true; @@ -429,15 +443,18 @@ void UI_panel_end(uiBlock *block, int width, int height) /* check if we need to do an animation */ if (!ELEM(width, 0, pa->sizex) || !ELEM(height, 0, pa->sizey)) { pa->runtime_flag |= PNL_ANIM_ALIGN; - if (height != 0) + if (height != 0) { pa->ofsy += pa->sizey - height; + } } /* update width/height if non-zero */ - if (width != 0) + if (width != 0) { pa->sizex = width; - if (height != 0) + } + if (height != 0) { pa->sizey = height; + } } } @@ -639,10 +656,12 @@ static void ui_draw_aligned_panel_header( uchar col_title[4]; /* + 0.001f to avoid flirting with float inaccuracy */ - if (panel->control & UI_PNL_CLOSE) + if (panel->control & UI_PNL_CLOSE) { pnl_icons = (panel->labelofs + (2.0f * PNL_ICON)) / block->aspect + 0.001f; - else + } + else { pnl_icons = (panel->labelofs + (1.1f * PNL_ICON)) / block->aspect + 0.001f; + } /* draw text label */ panel_title_color_get(show_background, col_title); @@ -683,8 +702,12 @@ void ui_draw_aligned_panel( * This may be changed in future. */ show_background); - if (panel->paneltab) return; - if (panel->type && (panel->type->flag & PNL_NO_HEADER)) return; + if (panel->paneltab) { + return; + } + if (panel->type && (panel->type->flag & PNL_NO_HEADER)) { + return; + } /* calculate header rect */ /* + 0.001f to prevent flicker due to float inaccuracy */ @@ -787,8 +810,12 @@ void ui_draw_aligned_panel( else { /* in some occasions, draw a border */ if (panel->flag & PNL_SELECT) { - if (panel->control & UI_PNL_SOLID) UI_draw_roundbox_corner_set(UI_CNR_ALL); - else UI_draw_roundbox_corner_set(UI_CNR_NONE); + if (panel->control & UI_PNL_SOLID) { + UI_draw_roundbox_corner_set(UI_CNR_ALL); + } + else { + UI_draw_roundbox_corner_set(UI_CNR_NONE); + } UI_GetThemeColorShade4fv(TH_BACK, -120, color); UI_draw_roundbox_aa(false, 0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax + 1, 8, color); @@ -806,8 +833,9 @@ void ui_draw_aligned_panel( immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); } - if (panel->control & UI_PNL_SCALE) + if (panel->control & UI_PNL_SCALE) { ui_draw_panel_scalewidget(pos, rect); + } immUnbindProgram(); } @@ -841,12 +869,15 @@ void ui_draw_aligned_panel( rgb_uchar_to_float(tria_color, col_title); tria_color[3] = 1.0f; - if (is_closed_y) + if (is_closed_y) { ui_draw_anti_tria_rect(&itemrect, 'h', tria_color); - else if (is_closed_x) + } + else if (is_closed_x) { ui_draw_anti_tria_rect(&itemrect, 'h', tria_color); - else + } + else { ui_draw_anti_tria_rect(&itemrect, 'v', tria_color); + } } } @@ -854,16 +885,18 @@ void ui_draw_aligned_panel( static int get_panel_header(const Panel *pa) { - if (pa->type && (pa->type->flag & PNL_NO_HEADER)) + if (pa->type && (pa->type->flag & PNL_NO_HEADER)) { return 0; + } return PNL_HEADER; } static int get_panel_size_y(const Panel *pa) { - if (pa->type && (pa->type->flag & PNL_NO_HEADER)) + if (pa->type && (pa->type->flag & PNL_NO_HEADER)) { return pa->sizey; + } return PNL_HEADER + pa->sizey; } @@ -872,8 +905,9 @@ static int get_panel_real_size_y(const Panel *pa) { int sizey = (pa->flag & PNL_CLOSED) ? 0 : pa->sizey; - if (pa->type && (pa->type->flag & PNL_NO_HEADER)) + if (pa->type && (pa->type->flag & PNL_NO_HEADER)) { return sizey; + } return PNL_HEADER + sizey; } @@ -887,17 +921,31 @@ int UI_panel_size_y(const Panel *pa) * change sizey or location when closed */ static int get_panel_real_ofsy(Panel *pa) { - if (pa->flag & PNL_CLOSEDY) return pa->ofsy + pa->sizey; - else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) return pa->ofsy + pa->sizey; - else if (pa->paneltab) return pa->paneltab->ofsy; - else return pa->ofsy; + if (pa->flag & PNL_CLOSEDY) { + return pa->ofsy + pa->sizey; + } + else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) { + return pa->ofsy + pa->sizey; + } + else if (pa->paneltab) { + return pa->paneltab->ofsy; + } + else { + return pa->ofsy; + } } static int get_panel_real_ofsx(Panel *pa) { - if (pa->flag & PNL_CLOSEDX) return pa->ofsx + get_panel_header(pa); - else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDX)) return pa->ofsx + get_panel_header(pa); - else return pa->ofsx + pa->sizex; + if (pa->flag & PNL_CLOSEDX) { + return pa->ofsx + get_panel_header(pa); + } + else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDX)) { + return pa->ofsx + get_panel_header(pa); + } + else { + return pa->ofsx + pa->sizex; + } } typedef struct PanelSort { @@ -916,10 +964,18 @@ static int find_leftmost_panel(const void *a1, const void *a2) { const PanelSort *ps1 = a1, *ps2 = a2; - if (ps1->pa->ofsx > ps2->pa->ofsx) return 1; - else if (ps1->pa->ofsx < ps2->pa->ofsx) return -1; - else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1; - else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1; + if (ps1->pa->ofsx > ps2->pa->ofsx) { + return 1; + } + else if (ps1->pa->ofsx < ps2->pa->ofsx) { + return -1; + } + else if (ps1->pa->sortorder > ps2->pa->sortorder) { + return 1; + } + else if (ps1->pa->sortorder < ps2->pa->sortorder) { + return -1; + } return 0; } @@ -934,13 +990,25 @@ static int find_highest_panel(const void *a1, const void *a2) if (ps1->pa->type->flag & PNL_NO_HEADER && ps2->pa->type->flag & PNL_NO_HEADER) { /* skip and check for ofs and sortorder below */ } - else if (ps1->pa->type->flag & PNL_NO_HEADER) return -1; - else if (ps2->pa->type->flag & PNL_NO_HEADER) return 1; + else if (ps1->pa->type->flag & PNL_NO_HEADER) { + return -1; + } + else if (ps2->pa->type->flag & PNL_NO_HEADER) { + return 1; + } - if (ps1->pa->ofsy + ps1->pa->sizey < ps2->pa->ofsy + ps2->pa->sizey) return 1; - else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) return -1; - else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1; - else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1; + if (ps1->pa->ofsy + ps1->pa->sizey < ps2->pa->ofsy + ps2->pa->sizey) { + return 1; + } + else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) { + return -1; + } + else if (ps1->pa->sortorder > ps2->pa->sortorder) { + return 1; + } + else if (ps1->pa->sortorder < ps2->pa->sortorder) { + return -1; + } return 0; } @@ -949,8 +1017,12 @@ static int compare_panel(const void *a1, const void *a2) { const PanelSort *ps1 = a1, *ps2 = a2; - if (ps1->pa->sortorder > ps2->pa->sortorder) return 1; - else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1; + if (ps1->pa->sortorder > ps2->pa->sortorder) { + return 1; + } + else if (ps1->pa->sortorder < ps2->pa->sortorder) { + return -1; + } return 0; } @@ -985,19 +1057,25 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo bool has_category_tabs = UI_panel_category_is_visible(ar); /* count active, not tabbed panels */ - for (pa = ar->panels.first; pa; pa = pa->next) - if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) + for (pa = ar->panels.first; pa; pa = pa->next) { + if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) { tot++; + } + } - if (tot == 0) return 0; + if (tot == 0) { + return 0; + } /* extra; change close direction? */ for (pa = ar->panels.first; pa; pa = pa->next) { if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) { - if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL)) + if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL)) { pa->flag ^= PNL_CLOSED; - else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL)) + } + else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL)) { pa->flag ^= PNL_CLOSED; + } } } @@ -1015,17 +1093,21 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo if (drag) { /* while we are dragging, we sort on location and update sortorder */ - if (align == BUT_VERTICAL) + if (align == BUT_VERTICAL) { qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel); - else + } + else { qsort(panelsort, tot, sizeof(PanelSort), find_leftmost_panel); + } - for (ps = panelsort, a = 0; a < tot; a++, ps++) + for (ps = panelsort, a = 0; a < tot; a++, ps++) { ps->orig->sortorder = a; + } } - else + else { /* otherwise use sortorder */ qsort(panelsort, tot, sizeof(PanelSort), compare_panel); + } /* no smart other default start loc! this keeps switching f5/f6/etc compatible */ ps = panelsort; @@ -1111,10 +1193,12 @@ static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y) } } - if (sizex == 0) + if (sizex == 0) { sizex = UI_PANEL_WIDTH; - if (sizey == 0) + } + if (sizey == 0) { sizey = -UI_PANEL_WIDTH; + } *x = sizex; *y = sizey; @@ -1173,9 +1257,11 @@ void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y) Panel *panot, *panew, *patest, *pa, *firstpa; /* offset contents */ - for (block = ar->uiblocks.first; block; block = block->next) - if (block->active && block->panel) + for (block = ar->uiblocks.first; block; block = block->next) { + if (block->active && block->panel) { ui_offset_panel_block(block); + } + } /* consistency; are panels not made, whilst they have tabs */ for (panot = ar->panels.first; panot; panot = panot->next) { @@ -1204,21 +1290,27 @@ void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y) /* re-align, possibly with animation */ if (panels_need_realign(sa, ar, &pa)) { - if (pa) + if (pa) { panel_activate_state(C, pa, PANEL_STATE_ANIMATION); - else + } + else { uiAlignPanelStep(sa, ar, 1.0, false); + } } /* tag first panel */ firstpa = NULL; - for (block = ar->uiblocks.first; block; block = block->next) - if (block->active && block->panel) - if (!firstpa || block->panel->sortorder < firstpa->sortorder) + for (block = ar->uiblocks.first; block; block = block->next) { + if (block->active && block->panel) { + if (!firstpa || block->panel->sortorder < firstpa->sortorder) { firstpa = block->panel; + } + } + } - if (firstpa) + if (firstpa) { firstpa->runtime_flag |= PNL_FIRST; + } /* compute size taken up by panel */ ui_panels_size(sa, ar, x, y); @@ -1280,16 +1372,28 @@ static void check_panel_overlap(ARegion *ar, Panel *panel) if (pa->paneltab == NULL && (pa->runtime_flag & PNL_ACTIVE)) { float safex = 0.2, safey = 0.2; - if (pa->flag & PNL_CLOSEDX) safex = 0.05; - else if (pa->flag & PNL_CLOSEDY) safey = 0.05; - else if (panel->flag & PNL_CLOSEDX) safex = 0.05; - else if (panel->flag & PNL_CLOSEDY) safey = 0.05; + if (pa->flag & PNL_CLOSEDX) { + safex = 0.05; + } + else if (pa->flag & PNL_CLOSEDY) { + safey = 0.05; + } + else if (panel->flag & PNL_CLOSEDX) { + safex = 0.05; + } + else if (panel->flag & PNL_CLOSEDY) { + safey = 0.05; + } - if (pa->ofsx > panel->ofsx - safex * panel->sizex) - if (pa->ofsx + pa->sizex < panel->ofsx + (1.0f + safex) * panel->sizex) - if (pa->ofsy > panel->ofsy - safey * panel->sizey) - if (pa->ofsy + pa->sizey < panel->ofsy + (1.0f + safey) * panel->sizey) + if (pa->ofsx > panel->ofsx - safex * panel->sizex) { + if (pa->ofsx + pa->sizex < panel->ofsx + (1.0f + safex) * panel->sizex) { + if (pa->ofsy > panel->ofsy - safey * panel->sizey) { + if (pa->ofsy + pa->sizey < panel->ofsy + (1.0f + safey) * panel->sizey) { pa->flag |= PNL_OVERLAP; + } + } + } + } } } } @@ -1305,8 +1409,9 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel) short align = panel_aligned(sa, ar), dx = 0, dy = 0; /* first clip for window, no dragging outside */ - if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) + if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) { return; + } dx = (event->x - data->startx) & ~(PNL_GRID - 1); dy = (event->y - data->starty) & ~(PNL_GRID - 1); @@ -1317,8 +1422,9 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel) if (data->state == PANEL_STATE_DRAG_SCALE) { panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX); - if (data->startsizey - dy < UI_PANEL_MINY) + if (data->startsizey - dy < UI_PANEL_MINY) { dy = -UI_PANEL_MINY + data->startsizey; + } panel->sizey = data->startsizey - dy; panel->ofsy = data->startofsy + dy; @@ -1331,7 +1437,9 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel) panel->ofsy = data->startofsy + dy; check_panel_overlap(ar, panel); - if (align) uiAlignPanelStep(sa, ar, 0.2, true); + if (align) { + uiAlignPanelStep(sa, ar, 0.2, true); + } } ED_region_tag_redraw(ar); @@ -1526,21 +1634,29 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in /* XXX weak code, currently it assumes layout style for location of widgets */ /* check open/collapsed button */ - if (event == RETKEY) + if (event == RETKEY) { button = 1; - else if (event == AKEY) + } + else if (event == AKEY) { button = 1; + } else if (ELEM(event, 0, RETKEY, LEFTMOUSE) && shift) { block->panel->flag ^= PNL_PIN; button = 2; } else if (block->panel->flag & PNL_CLOSEDX) { - if (my >= block->rect.ymax) button = 1; + if (my >= block->rect.ymax) { + button = 1; + } } else if (block->panel->control & UI_PNL_CLOSE) { /* whole of header can be used to collapse panel (except top-right corner) */ - if (mx <= block->rect.xmax - 8 - PNL_ICON) button = 2; - //else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) button = 1; + if (mx <= block->rect.xmax - 8 - PNL_ICON) { + button = 2; + } + //else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) { + // button = 1; + //} } else if (mx < rect_leftmost) { button = 1; @@ -1561,8 +1677,9 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in if (block->panel->flag & PNL_CLOSED) { block->panel->flag &= ~PNL_CLOSED; /* snap back up so full panel aligns with screen edge */ - if (block->panel->snap & PNL_SNAP_BOTTOM) + if (block->panel->snap & PNL_SNAP_BOTTOM) { block->panel->ofsy = 0; + } if (event == LEFTMOUSE) { ui_panel_drag_collapse_handler_add(C, false); @@ -1578,8 +1695,9 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in else { /* snap down to bottom screen edge */ block->panel->flag |= PNL_CLOSEDY; - if (block->panel->snap & PNL_SNAP_BOTTOM) + if (block->panel->snap & PNL_SNAP_BOTTOM) { block->panel->ofsy = -block->panel->sizey; + } if (event == LEFTMOUSE) { ui_panel_drag_collapse_handler_add(C, true); @@ -1588,8 +1706,12 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in for (pa = ar->panels.first; pa; pa = pa->next) { if (pa->paneltab == block->panel) { - if (block->panel->flag & PNL_CLOSED) pa->flag |= PNL_CLOSED; - else pa->flag &= ~PNL_CLOSED; + if (block->panel->flag & PNL_CLOSED) { + pa->flag |= PNL_CLOSED; + } + else { + pa->flag &= ~PNL_CLOSED; + } } } } @@ -2129,8 +2251,9 @@ static int ui_handle_panel_category_cycling(const wmEvent *event, ARegion *ar, c (event->mval[0] > ((PanelCategoryDyn *)ar->panels_category.first)->rect.xmin)); /* if mouse is inside non-tab region, ctrl key is required */ - if (is_mousewheel && !event->ctrl && !inside_tabregion) + if (is_mousewheel && !event->ctrl && !inside_tabregion) { return WM_UI_HANDLER_CONTINUE; + } if (active_but && ui_but_supports_cycling(active_but)) { @@ -2238,11 +2361,13 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons if (event->type == AKEY && ((event->ctrl + event->oskey + event->shift + event->alt) == 0)) { if (pa->flag & PNL_CLOSEDY) { - if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) + if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) { ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); + } } - else + else { ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); + } retval = WM_UI_HANDLER_BREAK; continue; @@ -2305,11 +2430,13 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons /* if panel is closed, only zoom if mouse is over the header */ if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) { - if (inside_header) + if (inside_header) { zoom = 1; + } } - else + else { zoom = 1; + } if (zoom) { ScrArea *sa = CTX_wm_area(C); @@ -2317,8 +2444,12 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons if (sa->spacetype != SPACE_PROPERTIES) { if (!(pa->control & UI_PNL_SCALE)) { - if (event->type == PADPLUSKEY) sl->blockscale += 0.1; - else sl->blockscale -= 0.1; + if (event->type == PADPLUSKEY) { + sl->blockscale += 0.1; + } + else { + sl->blockscale -= 0.1; + } CLAMP(sl->blockscale, 0.6, 1.0); ED_region_tag_redraw(ar); @@ -2349,28 +2480,35 @@ static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata) ARegion *ar = CTX_wm_region(C); int align = panel_aligned(sa, ar); - if (align) + if (align) { panel_activate_state(C, panel, PANEL_STATE_ANIMATION); - else + } + else { panel_activate_state(C, panel, PANEL_STATE_EXIT); + } } else if (event->type == MOUSEMOVE) { - if (data->state == PANEL_STATE_DRAG) + if (data->state == PANEL_STATE_DRAG) { ui_do_drag(C, event, panel); + } } else if (event->type == TIMER && event->customdata == data->animtimer) { - if (data->state == PANEL_STATE_ANIMATION) + if (data->state == PANEL_STATE_ANIMATION) { ui_do_animate(C, panel); - else if (data->state == PANEL_STATE_DRAG) + } + else if (data->state == PANEL_STATE_DRAG) { ui_do_drag(C, event, panel); + } } data = panel->activedata; - if (data && data->state == PANEL_STATE_ANIMATION) + if (data && data->state == PANEL_STATE_ANIMATION) { return WM_UI_HANDLER_CONTINUE; - else + } + else { return WM_UI_HANDLER_BREAK; + } } static void ui_handler_remove_panel(bContext *C, void *userdata) @@ -2386,8 +2524,9 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat wmWindow *win = CTX_wm_window(C); ARegion *ar = CTX_wm_region(C); - if (data && data->state == state) + if (data && data->state == state) { return; + } if (state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) { if (data && data->state != PANEL_STATE_ANIMATION) { @@ -2403,8 +2542,9 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat pa->flag &= ~PNL_SELECT; } - else + else { pa->flag |= PNL_SELECT; + } if (data && data->animtimer) { WM_event_remove_timer(CTX_wm_manager(C), win, data->animtimer); @@ -2425,8 +2565,9 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat WM_event_add_ui_handler(C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, 0); } - if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG)) + if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG)) { data->animtimer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL); + } data->state = state; data->startx = win->eventstate->x; diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index 1d50fa0d804..8300ee71c50 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -81,18 +81,24 @@ bool ui_but_is_toggle(const uiBut *but) bool ui_but_is_interactive(const uiBut *but, const bool labeledit) { /* note, UI_BTYPE_LABEL is included for highlights, this allows drags */ - if ((but->type == UI_BTYPE_LABEL) && but->dragpoin == NULL) + if ((but->type == UI_BTYPE_LABEL) && but->dragpoin == NULL) { return false; - if (ELEM(but->type, UI_BTYPE_ROUNDBOX, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_LISTBOX)) + } + if (ELEM(but->type, UI_BTYPE_ROUNDBOX, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_LISTBOX)) { return false; - if (but->flag & UI_HIDDEN) + } + if (but->flag & UI_HIDDEN) { return false; - if (but->flag & UI_SCROLLED) + } + if (but->flag & UI_SCROLLED) { return false; - if ((but->type == UI_BTYPE_TEXT) && (but->dt == UI_EMBOSS_NONE) && !labeledit) + } + if ((but->type == UI_BTYPE_TEXT) && (but->dt == UI_EMBOSS_NONE) && !labeledit) { return false; - if ((but->type == UI_BTYPE_LISTROW) && labeledit) + } + if ((but->type == UI_BTYPE_LISTROW) && labeledit) { return false; + } return true; } @@ -175,13 +181,15 @@ static bool ui_but_isect_pie_seg(const uiBlock *block, const uiBut *but) const float angle_range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_4 : M_PI_4 / 2.0; float vec[2]; - if (block->pie_data.flags & UI_PIE_INVALID_DIR) + if (block->pie_data.flags & UI_PIE_INVALID_DIR) { return false; + } ui_but_pie_dir(but->pie_dir, vec); - if (saacos(dot_v2v2(vec, block->pie_data.pie_dir)) < angle_range) + if (saacos(dot_v2v2(vec, block->pie_data.pie_dir)) < angle_range) { return true; + } return false; } @@ -195,8 +203,9 @@ bool ui_but_contains_point_px(const uiBut *but, const ARegion *ar, int x, int y) { uiBlock *block = but->block; float mx, my; - if (!ui_region_contains_point_px(ar, x, y)) + if (!ui_region_contains_point_px(ar, x, y)) { return false; + } mx = x; my = y; @@ -246,10 +255,12 @@ uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, const bo uiBut *but, *butover = NULL; float mx, my; -// if (!win->active) +// if (!win->active) { // return NULL; - if (!ui_region_contains_point_px(ar, x, y)) +// } + if (!ui_region_contains_point_px(ar, x, y)) { return NULL; + } for (block = ar->uiblocks.first; block; block = block->next) { mx = x; @@ -294,8 +305,9 @@ uiBut *ui_list_find_mouse_over_ex(ARegion *ar, int x, int y) uiBut *but; float mx, my; - if (!ui_region_contains_point_px(ar, x, y)) + if (!ui_region_contains_point_px(ar, x, y)) { return NULL; + } for (block = ar->uiblocks.first; block; block = block->next) { mx = x; @@ -328,7 +340,9 @@ uiBut *ui_but_prev(uiBut *but) { while (but->prev) { but = but->prev; - if (ui_but_is_editable(but)) return but; + if (ui_but_is_editable(but)) { + return but; + } } return NULL; } @@ -337,7 +351,9 @@ uiBut *ui_but_next(uiBut *but) { while (but->next) { but = but->next; - if (ui_but_is_editable(but)) return but; + if (ui_but_is_editable(but)) { + return but; + } } return NULL; } @@ -348,7 +364,9 @@ uiBut *ui_but_first(uiBlock *block) but = block->buttons.first; while (but) { - if (ui_but_is_editable(but)) return but; + if (ui_but_is_editable(but)) { + return but; + } but = but->next; } return NULL; @@ -360,7 +378,9 @@ uiBut *ui_but_last(uiBlock *block) but = block->buttons.last; while (but) { - if (ui_but_is_editable(but)) return but; + if (ui_but_is_editable(but)) { + return but; + } but = but->prev; } return NULL; @@ -438,10 +458,13 @@ uiBut *ui_region_find_active_but(ARegion *ar) uiBlock *block; uiBut *but; - for (block = ar->uiblocks.first; block; block = block->next) - for (but = block->buttons.first; but; but = but->next) - if (but->active) + for (block = ar->uiblocks.first; block; block = block->next) { + for (but = block->buttons.first; but; but = but->next) { + if (but->active) { return but; + } + } + } return NULL; } @@ -461,8 +484,9 @@ bool ui_region_contains_point_px(const ARegion *ar, int x, int y) /* check if the mouse is in the region */ if (!BLI_rcti_isect_pt(&winrct, x, y)) { - for (uiBlock *block = ar->uiblocks.first; block; block = block->next) + for (uiBlock *block = ar->uiblocks.first; block; block = block->next) { block->auto_open = false; + } return false; } diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.c index f96210b46d4..52136cee9ea 100644 --- a/source/blender/editors/interface/interface_region_color_picker.c +++ b/source/blender/editors/interface/interface_region_color_picker.c @@ -178,8 +178,9 @@ static void ui_update_color_picker_buts_rgb( /* this updates button strings, * is hackish... but button pointers are on stack of caller function */ for (bt = block->buttons.first; bt; bt = bt->next) { - if (bt->custom_data != cpicker) + if (bt->custom_data != cpicker) { continue; + } if (bt->rnaprop) { ui_but_v3_set(bt, rgb); @@ -201,9 +202,15 @@ static void ui_update_color_picker_buts_rgb( IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex); } - if (rgb_hex[0] > 1.0f) rgb_hex[0] = modf(rgb_hex[0], &intpart); - if (rgb_hex[1] > 1.0f) rgb_hex[1] = modf(rgb_hex[1], &intpart); - if (rgb_hex[2] > 1.0f) rgb_hex[2] = modf(rgb_hex[2], &intpart); + if (rgb_hex[0] > 1.0f) { + rgb_hex[0] = modf(rgb_hex[0], &intpart); + } + if (rgb_hex[1] > 1.0f) { + rgb_hex[1] = modf(rgb_hex[1], &intpart); + } + if (rgb_hex[2] > 1.0f) { + rgb_hex[2] = modf(rgb_hex[2], &intpart); + } rgb_float_to_uchar(rgb_hex_uchar, rgb_hex); BLI_snprintf(col, sizeof(col), "%02X%02X%02X", UNPACK3_EX((uint), rgb_hex_uchar, )); @@ -252,8 +259,9 @@ static void ui_colorpicker_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a but, but->block, but->custom_data, rgb); } - if (popup) + if (popup) { popup->menuretval = UI_RETURN_UPDATE; + } } static void ui_color_wheel_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg)) @@ -271,8 +279,9 @@ static void ui_color_wheel_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a ui_update_color_picker_buts_rgb(but, but->block, cpicker, rgb); - if (popup) + if (popup) { popup->menuretval = UI_RETURN_UPDATE; + } } static void ui_colorpicker_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl) @@ -292,8 +301,9 @@ static void ui_colorpicker_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexc ui_update_color_picker_buts_rgb(but, but->block, cpicker, rgb); - if (popup) + if (popup) { popup->menuretval = UI_RETURN_UPDATE; + } } static void ui_popup_close_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg)) @@ -589,10 +599,12 @@ static int ui_colorpicker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *blo { float add = 0.0f; - if (event->type == WHEELUPMOUSE) + if (event->type == WHEELUPMOUSE) { add = 0.05f; - else if (event->type == WHEELDOWNMOUSE) + } + else if (event->type == WHEELDOWNMOUSE) { add = -0.05f; + } if (add != 0.0f) { uiBut *but; @@ -615,8 +627,9 @@ static int ui_colorpicker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *blo ui_but_v3_set(but, rgb); ui_update_color_picker_buts_rgb(but, block, cpicker, rgb); - if (popup) + if (popup) { popup->menuretval = UI_RETURN_UPDATE; + } return 1; } diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c index 06ea9a7a927..b2fcfc0b23b 100644 --- a/source/blender/editors/interface/interface_region_menu_pie.c +++ b/source/blender/editors/interface/interface_region_menu_pie.c @@ -75,8 +75,9 @@ static uiBlock *ui_block_func_PIE(bContext *UNUSED(C), uiPopupBlockHandle *handl /* in some cases we create the block before the region, * so we set it delayed here if necessary */ - if (BLI_findindex(&handle->region->uiblocks, block) == -1) + if (BLI_findindex(&handle->region->uiblocks, block) == -1) { UI_block_region_set(block, handle->region); + } UI_block_layout_resolve(block, &width, &height); @@ -134,8 +135,9 @@ uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, co event_type = EVENT_NONE; pie->block_radial->pie_data.flags |= UI_PIE_CLICK_STYLE; } - else + else { event_type = win->last_pie_event; + } } else { event_type = event->type; diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c index bda19b712a1..a20c4fe9379 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.c +++ b/source/blender/editors/interface/interface_region_menu_popup.c @@ -480,8 +480,9 @@ void UI_popup_menu_reports(bContext *C, ReportList *reports) uiPopupMenu *pup = NULL; uiLayout *layout; - if (!CTX_wm_window(C)) + if (!CTX_wm_window(C)) { return; + } for (report = reports->list.first; report; report = report->next) { int icon; diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c index 3176c7a454a..0b1d3f19919 100644 --- a/source/blender/editors/interface/interface_region_popover.c +++ b/source/blender/editors/interface/interface_region_popover.c @@ -153,8 +153,9 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v /* If menu slides out of other menu, override direction. */ bool slideout = ui_block_is_menu(pup->but->block); - if (slideout) + if (slideout) { UI_block_direction_set(block, UI_DIR_RIGHT); + } /* Store the button location for positioning the popover arrow hint. */ if (!handle->refresh) { diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index 2275ee9ebf5..59223970af8 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -95,10 +95,12 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut /* widget_roundbox_set has this correction too, keep in sync */ if (but->type != UI_BTYPE_PULLDOWN) { - if (but->drawflag & UI_BUT_ALIGN_TOP) + if (but->drawflag & UI_BUT_ALIGN_TOP) { butrct.ymax += U.pixelsize; - if (but->drawflag & UI_BUT_ALIGN_LEFT) + } + if (but->drawflag & UI_BUT_ALIGN_LEFT) { butrct.xmin -= U.pixelsize; + } } handle->prev_butrct = butrct; @@ -148,44 +150,46 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut const float max_size_y = max_ff(size_y, handle->max_size_y); /* check if there's space at all */ - if (butrct.xmin - max_size_x + center_x > 0.0f) left = 1; - if (butrct.xmax + max_size_x - center_x < win_x) right = 1; - if (butrct.ymin - max_size_y + center_y > 0.0f) down = 1; - if (butrct.ymax + max_size_y - center_y < win_y) top = 1; + if (butrct.xmin - max_size_x + center_x > 0.0f) { left = 1; } + if (butrct.xmax + max_size_x - center_x < win_x) { right = 1; } + if (butrct.ymin - max_size_y + center_y > 0.0f) { down = 1; } + if (butrct.ymax + max_size_y - center_y < win_y) { top = 1; } if (top == 0 && down == 0) { - if (butrct.ymin - max_size_y < win_y - butrct.ymax - max_size_y) + if (butrct.ymin - max_size_y < win_y - butrct.ymax - max_size_y) { top = 1; - else + } + else { down = 1; + } } dir1 = (block->direction & UI_DIR_ALL); /* Secondary directions. */ if (dir1 & (UI_DIR_UP | UI_DIR_DOWN)) { - if (dir1 & UI_DIR_LEFT) dir2 = UI_DIR_LEFT; - else if (dir1 & UI_DIR_RIGHT) dir2 = UI_DIR_RIGHT; + if (dir1 & UI_DIR_LEFT) { dir2 = UI_DIR_LEFT; } + else if (dir1 & UI_DIR_RIGHT) { dir2 = UI_DIR_RIGHT; } dir1 &= (UI_DIR_UP | UI_DIR_DOWN); } - if ((dir2 == 0) && (dir1 == UI_DIR_LEFT || dir1 == UI_DIR_RIGHT)) dir2 = UI_DIR_DOWN; - if ((dir2 == 0) && (dir1 == UI_DIR_UP || dir1 == UI_DIR_DOWN)) dir2 = UI_DIR_LEFT; + if ((dir2 == 0) && (dir1 == UI_DIR_LEFT || dir1 == UI_DIR_RIGHT)) { dir2 = UI_DIR_DOWN; } + if ((dir2 == 0) && (dir1 == UI_DIR_UP || dir1 == UI_DIR_DOWN)) { dir2 = UI_DIR_LEFT; } /* no space at all? don't change */ if (left || right) { - if (dir1 == UI_DIR_LEFT && left == 0) dir1 = UI_DIR_RIGHT; - if (dir1 == UI_DIR_RIGHT && right == 0) dir1 = UI_DIR_LEFT; + if (dir1 == UI_DIR_LEFT && left == 0) { dir1 = UI_DIR_RIGHT; } + if (dir1 == UI_DIR_RIGHT && right == 0) { dir1 = UI_DIR_LEFT; } /* this is aligning, not append! */ - if (dir2 == UI_DIR_LEFT && right == 0) dir2 = UI_DIR_RIGHT; - if (dir2 == UI_DIR_RIGHT && left == 0) dir2 = UI_DIR_LEFT; + if (dir2 == UI_DIR_LEFT && right == 0) { dir2 = UI_DIR_RIGHT; } + if (dir2 == UI_DIR_RIGHT && left == 0) { dir2 = UI_DIR_LEFT; } } if (down || top) { - if (dir1 == UI_DIR_UP && top == 0) dir1 = UI_DIR_DOWN; - if (dir1 == UI_DIR_DOWN && down == 0) dir1 = UI_DIR_UP; + if (dir1 == UI_DIR_UP && top == 0) { dir1 = UI_DIR_DOWN; } + if (dir1 == UI_DIR_DOWN && down == 0) { dir1 = UI_DIR_UP; } BLI_assert(dir2 != UI_DIR_UP); -// if (dir2 == UI_DIR_UP && top == 0) dir2 = UI_DIR_DOWN; - if (dir2 == UI_DIR_DOWN && down == 0) dir2 = UI_DIR_UP; +// if (dir2 == UI_DIR_UP && top == 0) { dir2 = UI_DIR_DOWN; } + if (dir2 == UI_DIR_DOWN && down == 0) { dir2 = UI_DIR_UP; } } handle->prev_dir1 = dir1; @@ -203,18 +207,18 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut if (dir1 == UI_DIR_LEFT) { offset_x = butrct.xmin - block->rect.xmax; - if (dir2 == UI_DIR_UP) offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; - else offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING; + if (dir2 == UI_DIR_UP) { offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; } + else { offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING; } } else if (dir1 == UI_DIR_RIGHT) { offset_x = butrct.xmax - block->rect.xmin; - if (dir2 == UI_DIR_UP) offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; - else offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING; + if (dir2 == UI_DIR_UP) { offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; } + else { offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING; } } else if (dir1 == UI_DIR_UP) { offset_y = butrct.ymax - block->rect.ymin; - if (dir2 == UI_DIR_RIGHT) offset_x = butrct.xmax - block->rect.xmax + center_x; - else offset_x = butrct.xmin - block->rect.xmin - center_x; + if (dir2 == UI_DIR_RIGHT) { offset_x = butrct.xmax - block->rect.xmax + center_x; } + else { offset_x = butrct.xmin - block->rect.xmin - center_x; } /* changed direction? */ if ((dir1 & block->direction) == 0) { /* TODO: still do */ @@ -223,8 +227,8 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut } else if (dir1 == UI_DIR_DOWN) { offset_y = butrct.ymin - block->rect.ymax; - if (dir2 == UI_DIR_RIGHT) offset_x = butrct.xmax - block->rect.xmax + center_x; - else offset_x = butrct.xmin - block->rect.xmin - center_x; + if (dir2 == UI_DIR_RIGHT) { offset_x = butrct.xmax - block->rect.xmax + center_x; } + else { offset_x = butrct.xmin - block->rect.xmin - center_x; } /* changed direction? */ if ((dir1 & block->direction) == 0) { /* TODO: still do */ @@ -257,23 +261,43 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut /* when you are outside parent button, safety there should be smaller */ /* parent button to left */ - if (midx < block->rect.xmin) block->safety.xmin = block->rect.xmin - 3; - else block->safety.xmin = block->rect.xmin - 40; + if (midx < block->rect.xmin) { + block->safety.xmin = block->rect.xmin - 3; + } + else { + block->safety.xmin = block->rect.xmin - 40; + } /* parent button to right */ - if (midx > block->rect.xmax) block->safety.xmax = block->rect.xmax + 3; - else block->safety.xmax = block->rect.xmax + 40; + if (midx > block->rect.xmax) { + block->safety.xmax = block->rect.xmax + 3; + } + else { + block->safety.xmax = block->rect.xmax + 40; + } /* parent button on bottom */ - if (midy < block->rect.ymin) block->safety.ymin = block->rect.ymin - 3; - else block->safety.ymin = block->rect.ymin - 40; + if (midy < block->rect.ymin) { + block->safety.ymin = block->rect.ymin - 3; + } + else { + block->safety.ymin = block->rect.ymin - 40; + } /* parent button on top */ - if (midy > block->rect.ymax) block->safety.ymax = block->rect.ymax + 3; - else block->safety.ymax = block->rect.ymax + 40; + if (midy > block->rect.ymax) { + block->safety.ymax = block->rect.ymax + 3; + } + else { + block->safety.ymax = block->rect.ymax + 40; + } /* exception for switched pulldowns... */ if (dir1 && (dir1 & block->direction) == 0) { - if (dir2 == UI_DIR_RIGHT) block->safety.xmax = block->rect.xmax + 3; - if (dir2 == UI_DIR_LEFT) block->safety.xmin = block->rect.xmin - 3; + if (dir2 == UI_DIR_RIGHT) { + block->safety.xmax = block->rect.xmax + 3; + } + if (dir2 == UI_DIR_LEFT) { + block->safety.xmin = block->rect.xmin - 3; + } } block->direction = dir1; } @@ -335,8 +359,9 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar) { uiBlock *block; - for (block = ar->uiblocks.first; block; block = block->next) + for (block = ar->uiblocks.first; block; block = block->next) { UI_block_draw(C, block); + } } /** @@ -409,11 +434,13 @@ void ui_popup_block_scrolltest(uiBlock *block) block->flag &= ~(UI_BLOCK_CLIPBOTTOM | UI_BLOCK_CLIPTOP); - for (bt = block->buttons.first; bt; bt = bt->next) + for (bt = block->buttons.first; bt; bt = bt->next) { bt->flag &= ~UI_SCROLLED; + } - if (block->buttons.first == block->buttons.last) + if (block->buttons.first == block->buttons.last) { return; + } /* mark buttons that are outside boundary */ for (bt = block->buttons.first; bt; bt = bt->next) { @@ -430,12 +457,14 @@ void ui_popup_block_scrolltest(uiBlock *block) /* mark buttons overlapping arrows, if we have them */ for (bt = block->buttons.first; bt; bt = bt->next) { if (block->flag & UI_BLOCK_CLIPBOTTOM) { - if (bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW) + if (bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW) { bt->flag |= UI_SCROLLED; + } } if (block->flag & UI_BLOCK_CLIPTOP) { - if (bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW) + if (bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW) { bt->flag |= UI_SCROLLED; + } } } } @@ -454,8 +483,9 @@ static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle) WM_event_add_mousemove(C); } - if (handle->scrolltimer) + if (handle->scrolltimer) { WM_event_remove_timer(CTX_wm_manager(C), win, handle->scrolltimer); + } } /** @@ -485,10 +515,12 @@ uiBlock *ui_popup_block_refresh( #endif /* create ui block */ - if (create_func) + if (create_func) { block = create_func(C, ar, arg); - else + } + else { block = handle_create_func(C, handle, arg); + } /* callbacks _must_ leave this for us, otherwise we can't call UI_block_update_from_old */ BLI_assert(!block->endblock); @@ -503,8 +535,9 @@ uiBlock *ui_popup_block_refresh( MEM_freeN(handle); handle = block->handle; } - else + else { block->handle = handle; + } ar->regiondata = handle; @@ -550,13 +583,21 @@ uiBlock *ui_popup_block_refresh( /* only try translation if area is large enough */ if (BLI_rctf_size_x(&block->rect) < winx - (2.0f * win_width)) { - if (block->rect.xmin < win_width ) x_offset += win_width - block->rect.xmin; - if (block->rect.xmax > winx - win_width) x_offset += winx - win_width - block->rect.xmax; + if (block->rect.xmin < win_width ) { + x_offset += win_width - block->rect.xmin; + } + if (block->rect.xmax > winx - win_width) { + x_offset += winx - win_width - block->rect.xmax; + } } if (BLI_rctf_size_y(&block->rect) < winy - (2.0f * win_width)) { - if (block->rect.ymin < win_width ) y_offset += win_width - block->rect.ymin; - if (block->rect.ymax > winy - win_width) y_offset += winy - win_width - block->rect.ymax; + if (block->rect.ymin < win_width ) { + y_offset += win_width - block->rect.ymin; + } + if (block->rect.ymax > winy - win_width) { + y_offset += winy - win_width - block->rect.ymax; + } } /* if we are offsetting set up initial data for timeout functionality */ @@ -566,8 +607,9 @@ uiBlock *ui_popup_block_refresh( UI_block_translate(block, x_offset, y_offset); - if (U.pie_initial_timeout > 0) + if (U.pie_initial_timeout > 0) { block->pie_data.flags |= UI_PIE_INITIAL_DIRECTION; + } } ar->winrct.xmin = 0; diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c index a4852ff4789..9aebf1183e0 100644 --- a/source/blender/editors/interface/interface_region_search.c +++ b/source/blender/editors/interface/interface_region_search.c @@ -108,8 +108,9 @@ bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int /* hijack for finding active item */ if (items->active) { - if (poin == items->active) + if (poin == items->active) { items->offset_i = items->totitem; + } items->totitem++; return true; } @@ -125,12 +126,15 @@ bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int return true; } - if (items->names) + if (items->names) { BLI_strncpy(items->names[items->totitem], name, items->maxstrlen); - if (items->pointers) + } + if (items->pointers) { items->pointers[items->totitem] = poin; - if (items->icons) + } + if (items->icons) { items->icons[items->totitem] = iconid; + } items->totitem++; @@ -275,8 +279,9 @@ void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, const wmEvent *eve uiSearchboxData *data = ar->regiondata; int type = event->type, val = event->val; - if (type == MOUSEPAN) + if (type == MOUSEPAN) { ui_pan_to_scroll(event, &type, &val); + } switch (type) { case WHEELUPMOUSE: @@ -354,8 +359,9 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset) } /* callback */ - if (but->search_func) + if (but->search_func) { but->search_func(C, but->search_arg, but->editstr, &data->items); + } /* handle case where editstr is equal to one of items */ if (reset && data->active == -1) { @@ -369,8 +375,9 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset) break; } } - if (data->items.totitem == 1 && but->editstr[0]) + if (data->items.totitem == 1 && but->editstr[0]) { data->active = 0; + } } /* validate selected item */ @@ -521,8 +528,9 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but /* special case, hardcoded feature, not draw backdrop when called from menus, * assume for design that popup already added it */ - if (but->block->flag & UI_BLOCK_SEARCH_MENU) + if (but->block->flag & UI_BLOCK_SEARCH_MENU) { data->noback = true; + } if (but->a1 > 0 && but->a2 > 0) { data->preview = true; @@ -605,8 +613,9 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but if (rect_i.ymin < 0) { int newy1 = but->rect.ymax + ofsy; - if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) + if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { newy1 = UI_view2d_view_to_region_y(&butregion->v2d, newy1); + } newy1 += butregion->winrct.ymin; @@ -645,8 +654,9 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but data->items.names = MEM_callocN(data->items.maxitem * sizeof(void *), "search names"); data->items.pointers = MEM_callocN(data->items.maxitem * sizeof(void *), "search pointers"); data->items.icons = MEM_callocN(data->items.maxitem * sizeof(int), "search icons"); - for (i = 0; i < data->items.maxitem; i++) + for (i = 0; i < data->items.maxitem; i++) { data->items.names[i] = MEM_callocN(but->hardmax + 1, "search pointers"); + } return ar; } @@ -784,8 +794,9 @@ void ui_but_search_refresh(uiBut *but) items->maxitem = 10; items->maxstrlen = 256; items->names = MEM_callocN(items->maxitem * sizeof(void *), "search names"); - for (x1 = 0; x1 < items->maxitem; x1++) + for (x1 = 0; x1 < items->maxitem; x1++) { items->names[x1] = MEM_callocN(but->hardmax + 1, "search names"); + } but->search_func(but->block->evil_C, but->search_arg, but->drawstr, items); diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 629de557a2d..4bde694b5da 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -839,20 +839,27 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but) } /* Free strinfo's... */ - if (but_tip.strinfo) + if (but_tip.strinfo) { MEM_freeN(but_tip.strinfo); - if (enum_label.strinfo) + } + if (enum_label.strinfo) { MEM_freeN(enum_label.strinfo); - if (enum_tip.strinfo) + } + if (enum_tip.strinfo) { MEM_freeN(enum_tip.strinfo); - if (op_keymap.strinfo) + } + if (op_keymap.strinfo) { MEM_freeN(op_keymap.strinfo); - if (prop_keymap.strinfo) + } + if (prop_keymap.strinfo) { MEM_freeN(prop_keymap.strinfo); - if (rna_struct.strinfo) + } + if (rna_struct.strinfo) { MEM_freeN(rna_struct.strinfo); - if (rna_prop.strinfo) + } + if (rna_prop.strinfo) { MEM_freeN(rna_prop.strinfo); + } if (data->fields_len == 0) { MEM_freeN(data); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 8e3e99940a6..933864c1cb4 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -58,8 +58,9 @@ void ui_region_temp_remove(bContext *C, bScreen *sc, ARegion *ar) BLI_assert(ar->regiontype == RGN_TYPE_TEMPORARY); BLI_assert(BLI_findindex(&sc->regionbase, ar) != -1); - if (win) + if (win) { wm_draw_region_clear(win, ar); + } ED_region_exit(C, ar); BKE_area_region_free(NULL, ar); /* NULL: no spacetype */ diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index f59bc5759e1..eecd5885c74 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -257,16 +257,19 @@ void UI_fontstyle_draw_rotated(const uiFontStyle *fs, const rcti *rect, const ch BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady); } - if (fs->kerning == 1) + if (fs->kerning == 1) { BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); + } BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); BLF_disable(fs->uifont_id, BLF_ROTATION); BLF_disable(fs->uifont_id, BLF_CLIPPING); - if (fs->shadow) + if (fs->shadow) { BLF_disable(fs->uifont_id, BLF_SHADOW); - if (fs->kerning == 1) + } + if (fs->kerning == 1) { BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT); + } } /** @@ -277,16 +280,18 @@ void UI_fontstyle_draw_rotated(const uiFontStyle *fs, const rcti *rect, const ch */ void UI_fontstyle_draw_simple(const uiFontStyle *fs, float x, float y, const char *str, const uchar col[4]) { - if (fs->kerning == 1) + if (fs->kerning == 1) { BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); + } UI_fontstyle_set(fs); BLF_position(fs->uifont_id, x, y, 0.0f); BLF_color4ubv(fs->uifont_id, col); BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); - if (fs->kerning == 1) + if (fs->kerning == 1) { BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT); + } } /** @@ -296,8 +301,9 @@ void UI_fontstyle_draw_simple_backdrop( const uiFontStyle *fs, float x, float y, const char *str, const float col_fg[4], const float col_bg[4]) { - if (fs->kerning == 1) + if (fs->kerning == 1) { BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); + } UI_fontstyle_set(fs); @@ -324,8 +330,9 @@ void UI_fontstyle_draw_simple_backdrop( BLF_color4fv(fs->uifont_id, col_fg); BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); - if (fs->kerning == 1) + if (fs->kerning == 1) { BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT); + } } @@ -373,14 +380,17 @@ int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str) { int width; - if (fs->kerning == 1) /* for BLF_width */ + if (fs->kerning == 1) { + /* for BLF_width */ BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); + } UI_fontstyle_set(fs); width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); - if (fs->kerning == 1) + if (fs->kerning == 1) { BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT); + } return width; } @@ -404,8 +414,9 @@ void uiStyleInit(void) uchar *monofont_ttf = (uchar *)datatoc_bmonofont_ttf; /* recover from uninitialized dpi */ - if (U.dpi == 0) + if (U.dpi == 0) { U.dpi = 72; + } CLAMP(U.dpi, 48, 144); for (font = U.uifonts.first; font; font = font->next) { @@ -479,8 +490,9 @@ void uiStyleInit(void) BLF_default_set(font->blf_id); if (font->blf_id == -1) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("%s: error, no fonts available\n", __func__); + } } else { /* ? just for speed to initialize? @@ -563,8 +575,9 @@ void uiStyleInit(void) * \note This isn't good that the render font depends on the preferences, * keep for now though, since without this there is no way to display many unicode chars. */ - if (blf_mono_font_render == -1) + if (blf_mono_font_render == -1) { blf_mono_font_render = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size); + } BLF_size(blf_mono_font_render, 12 * U.pixelsize, 72); } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 2a22e946923..3b52984df3e 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -143,8 +143,9 @@ static void template_add_button_search_menu( UI_but_drawflag_enable(but, UI_BUT_ICON_LEFT); } - if ((idfrom && idfrom->lib) || !editable) + if ((idfrom && idfrom->lib) || !editable) { UI_but_flag_enable(but, UI_BUT_DISABLED); + } if (use_big_size) { uiLayoutRow(layout, true); } @@ -165,8 +166,9 @@ static void template_add_button_search_menu( } UI_but_drawflag_enable(but, UI_BUT_ICON_LEFT); - if ((idfrom && idfrom->lib) || !editable) + if ((idfrom && idfrom->lib) || !editable) { UI_but_flag_enable(but, UI_BUT_DISABLED); + } } } @@ -451,8 +453,12 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) break; case UI_ID_FAKE_USER: if (id) { - if (id->flag & LIB_FAKEUSER) id_us_plus(id); - else id_us_min(id); + if (id->flag & LIB_FAKEUSER) { + id_us_plus(id); + } + else { + id_us_min(id); + } } else { return; @@ -665,8 +671,9 @@ static void template_ID( block = uiLayoutGetBlock(layout); UI_block_align_begin(block); - if (idptr.type) + if (idptr.type) { type = idptr.type; + } if (flag & UI_ID_BROWSE) { template_add_button_search_menu( @@ -686,7 +693,9 @@ static void template_ID( block, UI_BTYPE_TEXT, 0, name, 0, 0, TEMPLATE_SEARCH_TEXTBUT_WIDTH, TEMPLATE_SEARCH_TEXTBUT_HEIGHT, &idptr, "name", -1, 0, 0, -1, -1, RNA_struct_ui_description(type)); UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_RENAME)); - if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT); + if (user_alert) { + UI_but_flag_enable(but, UI_BUT_REDALERT); + } if (id->lib) { if (id->tag & LIB_TAG_INDIRECT) { @@ -788,8 +797,9 @@ static void template_ID( UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN)); } - if ((idfrom && idfrom->lib) || !editable) + if ((idfrom && idfrom->lib) || !editable) { UI_but_flag_enable(but, UI_BUT_DISABLED); + } } /* delete button */ @@ -925,10 +935,12 @@ static void ui_template_id( template_ui->filter = 0; } - if (newop) + if (newop) { flag |= UI_ID_ADD_NEW; - if (openop) + } + if (openop) { flag |= UI_ID_OPEN; + } type = RNA_property_pointer_type(ptr, prop); idcode = RNA_type_to_ID_code(type); @@ -1054,8 +1066,9 @@ void uiTemplateAnyID( /* Label - either use the provided text, or will become "ID-Block:" */ if (text) { - if (text[0]) + if (text[0]) { uiItemL(row, text, ICON_NONE); + } } else { uiItemL(row, IFACE_("ID-Block:"), ICON_NONE); @@ -1349,9 +1362,11 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v) static int modifier_can_delete(ModifierData *md) { /* fluid particle modifier can't be deleted here */ - if (md->type == eModifierType_ParticleSystem) - if (((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID) + if (md->type == eModifierType_ParticleSystem) { + if (((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID) { return 0; + } + } return 1; } @@ -1597,10 +1612,12 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) vmd = modifiers_getVirtualModifierList(ob, &virtualModifierData); for (i = 0; vmd; i++, vmd = vmd->next) { - if (md == vmd) + if (md == vmd) { return draw_modifier(layout, scene, ob, md, i, cageIndex, lastCageIndex); - else if (vmd->mode & eModifierMode_Virtual) + } + else if (vmd->mode & eModifierMode_Virtual) { i--; + } } return NULL; @@ -1729,8 +1746,9 @@ uiLayout *uiTemplateGpencilModifier(uiLayout *layout, bContext *UNUSED(C), Point /* find modifier and draw it */ vmd = ob->greasepencil_modifiers.first; for (i = 0; vmd; i++, vmd = vmd->next) { - if (md == vmd) + if (md == vmd) { return gpencil_draw_modifier(layout, ob, md); + } } return NULL; @@ -1848,8 +1866,9 @@ uiLayout *uiTemplateShaderFx(uiLayout *layout, bContext *UNUSED(C), PointerRNA * /* find modifier and draw it */ vfx = ob->shader_fx.first; for (i = 0; vfx; i++, vfx = vfx->next) { - if (fx == vfx) + if (fx == vfx) { return gpencil_draw_shaderfx(layout, ob, fx); + } } return NULL; @@ -1939,8 +1958,9 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event) case B_CONSTRAINT_CHANGETARGET: { Main *bmain = CTX_data_main(C); - if (ob->pose) + if (ob->pose) { BKE_pose_tag_recalc(bmain, ob->pose); /* checks & sorts pose channels */ + } DEG_relations_tag_update(bmain); break; } @@ -1950,13 +1970,20 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event) } /* note: RNA updates now call this, commenting else it gets called twice. - * if there are problems because of this, then rna needs changed update functions. - * - * object_test_constraints(ob); - * if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); */ + * if there are problems because of this, then rna needs changed update functions. */ +#if 0 + object_test_constraints(ob); + if (ob->pose) { + BKE_pose_update_constraint_flags(ob->pose); + } +#endif - if (ob->type == OB_ARMATURE) DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM); - else DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); + if (ob->type == OB_ARMATURE) { + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM); + } + else { + DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); + } WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); } @@ -1984,14 +2011,17 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) /* exception for 'Null' constraint - it doesn't have constraint typeinfo! */ BLI_strncpy(typestr, (con->type == CONSTRAINT_TYPE_NULL) ? IFACE_("Null") : IFACE_("Unknown"), sizeof(typestr)); } - else + else { BLI_strncpy(typestr, IFACE_(cti->name), sizeof(typestr)); + } /* determine whether constraint is proxy protected or not */ - if (BKE_constraints_proxylocked_owner(ob, pchan)) + if (BKE_constraints_proxylocked_owner(ob, pchan)) { proxy_protected = (con->flag & CONSTRAINT_PROXY_LOCAL) == 0; - else + } + else { proxy_protected = 0; + } /* unless button has own callback, it adds this callback to button */ block = uiLayoutGetBlock(layout); @@ -2018,14 +2048,16 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) uiDefBut(block, UI_BTYPE_LABEL, B_CONSTRAINT_TEST, typestr, xco + 0.5f * UI_UNIT_X, yco, 5 * UI_UNIT_X, 0.9f * UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, ""); - if (con->flag & CONSTRAINT_DISABLE) + if (con->flag & CONSTRAINT_DISABLE) { uiLayoutSetRedAlert(row, true); + } if (proxy_protected == 0) { uiItemR(row, &ptr, "name", 0, "", ICON_NONE); } - else + else { uiItemL(row, con->name, ICON_NONE); + } uiLayoutSetRedAlert(row, false); @@ -2056,11 +2088,13 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) if (con->prev) { prev_proxylock = (con->prev->flag & CONSTRAINT_PROXY_LOCAL) ? 0 : 1; } - else + else { prev_proxylock = 0; + } } - else + else { prev_proxylock = 0; + } show_upbut = ((prev_proxylock == 0) && (con->prev)); show_downbut = (con->next) ? 1 : 0; @@ -2076,11 +2110,13 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) /* up/down */ if (show_upbut || show_downbut) { UI_block_align_begin(block); - if (show_upbut) + if (show_upbut) { uiItemO(row, "", ICON_TRIA_UP, "CONSTRAINT_OT_move_up"); + } - if (show_downbut) + if (show_downbut) { uiItemO(row, "", ICON_TRIA_DOWN, "CONSTRAINT_OT_move_down"); + } UI_block_align_end(block); } @@ -2091,8 +2127,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) } /* Set but-locks for protected settings (magic numbers are used here!) */ - if (proxy_protected) + if (proxy_protected) { UI_block_lock_set(block, true, IFACE_("Cannot edit Proxy-Protected Constraint")); + } /* Draw constraint data */ if ((con->flag & CONSTRAINT_EXPAND) == 0) { @@ -2134,8 +2171,9 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) /* hrms, the temporal constraint should not draw! */ if (con->type == CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data = con->data; - if (data->flag & CONSTRAINT_IK_TEMP) + if (data->flag & CONSTRAINT_IK_TEMP) { return NULL; + } } return draw_constraint(layout, ob, con); @@ -2187,20 +2225,26 @@ void uiTemplatePreview( pparent = NULL; if (id && (GS(id->name) == ID_TE)) { - if (parent && (GS(parent->name) == ID_MA)) + if (parent && (GS(parent->name) == ID_MA)) { pr_texture = &((Material *)parent)->pr_texture; - else if (parent && (GS(parent->name) == ID_WO)) + } + else if (parent && (GS(parent->name) == ID_WO)) { pr_texture = &((World *)parent)->pr_texture; - else if (parent && (GS(parent->name) == ID_LA)) + } + else if (parent && (GS(parent->name) == ID_LA)) { pr_texture = &((Light *)parent)->pr_texture; - else if (parent && (GS(parent->name) == ID_LS)) + } + else if (parent && (GS(parent->name) == ID_LS)) { pr_texture = &((FreestyleLineStyle *)parent)->pr_texture; + } if (pr_texture) { - if (*pr_texture == TEX_PR_OTHER) + if (*pr_texture == TEX_PR_OTHER) { pid = parent; - else if (*pr_texture == TEX_PR_BOTH) + } + else if (*pr_texture == TEX_PR_BOTH) { pparent = parent; + } } } @@ -2246,8 +2290,12 @@ void uiTemplatePreview( /* add buttons */ if (pid && show_buttons) { if (GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) { - if (GS(pid->name) == ID_MA) ma = (Material *)pid; - else ma = (Material *)pparent; + if (GS(pid->name) == ID_MA) { + ma = (Material *)pid; + } + else { + ma = (Material *)pparent; + } /* Create RNA Pointer */ RNA_pointer_create(&ma->id, &RNA_Material, ma, &material_ptr); @@ -2430,8 +2478,12 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v) float pos = 0.5f; if (coba->tot > 1) { - if (coba->cur > 0) pos = (coba->data[coba->cur - 1].pos + coba->data[coba->cur].pos) * 0.5f; - else pos = (coba->data[coba->cur + 1].pos + coba->data[coba->cur].pos) * 0.5f; + if (coba->cur > 0) { + pos = (coba->data[coba->cur - 1].pos + coba->data[coba->cur].pos) * 0.5f; + } + else { + pos = (coba->data[coba->cur + 1].pos + coba->data[coba->cur].pos) * 0.5f; + } } if (BKE_colorband_element_add(coba, pos)) { @@ -2569,12 +2621,14 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname ID *id; rctf rect; - if (!prop || RNA_property_type(prop) != PROP_POINTER) + if (!prop || RNA_property_type(prop) != PROP_POINTER) { return; + } cptr = RNA_property_pointer_get(ptr, prop); - if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp)) { return; + } cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); cb->ptr = *ptr; @@ -2733,12 +2787,14 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname uiLayout *col; Histogram *hist; - if (!prop || RNA_property_type(prop) != PROP_POINTER) + if (!prop || RNA_property_type(prop) != PROP_POINTER) { return; + } cptr = RNA_property_pointer_get(ptr, prop); - if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram)) { return; + } hist = (Histogram *)cptr.data; if (hist->height < UI_UNIT_Y) { @@ -2768,12 +2824,14 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) uiLayout *col; Scopes *scopes; - if (!prop || RNA_property_type(prop) != PROP_POINTER) + if (!prop || RNA_property_type(prop) != PROP_POINTER) { return; + } cptr = RNA_property_pointer_get(ptr, prop); - if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) { return; + } scopes = (Scopes *)cptr.data; col = uiLayoutColumn(layout, true); @@ -2803,12 +2861,14 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna uiLayout *col; Scopes *scopes; - if (!prop || RNA_property_type(prop) != PROP_POINTER) + if (!prop || RNA_property_type(prop) != PROP_POINTER) { return; + } cptr = RNA_property_pointer_get(ptr, prop); - if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) { return; + } scopes = (Scopes *)cptr.data; if (scopes->vecscope_height < UI_UNIT_Y) { @@ -2858,28 +2918,36 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u if (BLI_rctf_size_x(&cumap->curr) < 20.0f * BLI_rctf_size_x(&cumap->clipr)) { d = d1 = 0.15f * BLI_rctf_size_x(&cumap->curr); - if (cumap->flag & CUMA_DO_CLIP) - if (cumap->curr.xmin - d < cumap->clipr.xmin) + if (cumap->flag & CUMA_DO_CLIP) { + if (cumap->curr.xmin - d < cumap->clipr.xmin) { d1 = cumap->curr.xmin - cumap->clipr.xmin; + } + } cumap->curr.xmin -= d1; d1 = d; - if (cumap->flag & CUMA_DO_CLIP) - if (cumap->curr.xmax + d > cumap->clipr.xmax) + if (cumap->flag & CUMA_DO_CLIP) { + if (cumap->curr.xmax + d > cumap->clipr.xmax) { d1 = -cumap->curr.xmax + cumap->clipr.xmax; + } + } cumap->curr.xmax += d1; d = d1 = 0.15f * BLI_rctf_size_y(&cumap->curr); - if (cumap->flag & CUMA_DO_CLIP) - if (cumap->curr.ymin - d < cumap->clipr.ymin) + if (cumap->flag & CUMA_DO_CLIP) { + if (cumap->curr.ymin - d < cumap->clipr.ymin) { d1 = cumap->curr.ymin - cumap->clipr.ymin; + } + } cumap->curr.ymin -= d1; d1 = d; - if (cumap->flag & CUMA_DO_CLIP) - if (cumap->curr.ymax + d > cumap->clipr.ymax) + if (cumap->flag & CUMA_DO_CLIP) { + if (cumap->curr.ymax + d > cumap->clipr.ymax) { d1 = -cumap->curr.ymax + cumap->clipr.ymax; + } + } cumap->curr.ymax += d1; } @@ -3067,8 +3135,9 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) int a; cumap->preset = CURVE_PRESET_LINE; - for (a = 0; a < CM_TOT; a++) + for (a = 0; a < CM_TOT; a++) { curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); + } cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f; cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; @@ -3163,11 +3232,13 @@ static void curvemap_buttons_layout( UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); } } - else + else { uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); + } - if (labeltype == 'h') + if (labeltype == 'h') { bg = UI_GRAD_H; + } /* operation buttons */ sub = uiLayoutRow(row, true); @@ -3180,16 +3251,19 @@ static void curvemap_buttons_layout( bt = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_ZOOM_OUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom out")); UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, NULL); - if (brush) + if (brush) { bt = uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_DOWNARROW_HLT, 0, 0, dx, dx, TIP_("Tools")); - else if (neg_slope) + } + else if (neg_slope) { bt = uiDefIconBlockBut( block, curvemap_tools_negslope_func, cumap, 0, ICON_DOWNARROW_HLT, 0, 0, dx, dx, TIP_("Tools")); - else + } + else { bt = uiDefIconBlockBut( block, curvemap_tools_posslope_func, cumap, 0, ICON_DOWNARROW_HLT, 0, 0, dx, dx, TIP_("Tools")); + } UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); @@ -3274,8 +3348,9 @@ void uiTemplateCurveMapping( } cptr = RNA_property_pointer_get(ptr, prop); - if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping)) { return; + } cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); cb->ptr = *ptr; @@ -3417,8 +3492,9 @@ void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, } cptr = RNA_property_pointer_get(ptr, prop); - if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette)) { return; + } block = uiLayoutGetBlock(layout); @@ -3489,8 +3565,9 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2) /* Normally clicking only selects one layer */ RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, cur, true); for (i = 0; i < tot; ++i) { - if (i != cur) + if (i != cur) { RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, i, false); + } } } @@ -3535,8 +3612,9 @@ void uiTemplateLayers( return; } - if (RNA_property_array_length(used_ptr, used_prop) < layers) + if (RNA_property_array_length(used_ptr, used_prop) < layers) { used_prop = NULL; + } } /* layers are laid out going across rows, with the columns being divided into groups */ @@ -3557,10 +3635,12 @@ void uiTemplateLayers( int icon = 0; int butlay = 1 << layer; - if (active_layer & butlay) + if (active_layer & butlay) { icon = ICON_LAYER_ACTIVE; - else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer)) + } + else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer)) { icon = ICON_LAYER_USED; + } but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2); UI_but_func_set(but, handle_layer_buttons, but, POINTER_FROM_INT(layer)); @@ -3754,13 +3834,16 @@ static void uilist_prepare( const bool use_auto_size = (ui_list->list_grip < (rows - UI_LIST_AUTO_SIZE_THRESHOLD)); /* default rows */ - if (rows <= 0) + if (rows <= 0) { rows = 5; + } dyn_data->visual_height_min = rows; - if (maxrows < rows) + if (maxrows < rows) { maxrows = max_ii(rows, 5); - if (columns <= 0) + } + if (columns <= 0) { columns = 9; + } if (columns > 1) { dyn_data->height = (int)ceil((double)len / (double)columns); @@ -4093,8 +4176,9 @@ void uiTemplateList( sub = uiLayoutRow(overlap, false); icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false); - if (icon == ICON_DOT) + if (icon == ICON_DOT) { icon = ICON_NONE; + } draw_item(ui_list, C, sub, dataptr, itemptr, icon, active_dataptr, active_propname, org_i, flt_flag); @@ -4130,8 +4214,9 @@ void uiTemplateList( int org_i = items_ptr[activei].org_idx; icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false); - if (icon == ICON_DOT) + if (icon == ICON_DOT) { icon = ICON_NONE; + } draw_item(ui_list, C, row, dataptr, itemptr, icon, active_dataptr, active_propname, org_i, 0); } /* if list is empty, add in dummy button */ @@ -4144,8 +4229,9 @@ void uiTemplateList( but = uiDefIconTextButR_prop( block, UI_BTYPE_NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, active_dataptr, activeprop, 0, 0, 0, 0, 0, ""); - if (dyn_data->items_shown == 0) + if (dyn_data->items_shown == 0) { UI_but_flag_enable(but, UI_BUT_DISABLED); + } break; case UILST_LAYOUT_GRID: box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop); @@ -4164,8 +4250,9 @@ void uiTemplateList( int flt_flag = items_ptr[i].flt_flag; /* create button */ - if (!(i % columns)) + if (!(i % columns)) { subrow = uiLayoutRow(col, false); + } subblock = uiLayoutGetBlock(subrow); overlap = uiLayoutOverlap(subrow); @@ -4272,8 +4359,9 @@ static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2) { wmOperatorType *ot = arg2; - if (ot) + if (ot) { WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, NULL); + } } static bool has_word_prefix(const char *haystack, const char *needle, size_t needle_len) @@ -4306,8 +4394,9 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char const char *ot_ui_name = CTX_IFACE_(ot->translation_context, ot->name); int index; - if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) + if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) { continue; + } /* match name against all search words */ for (index = 0; index < words_len; index++) { @@ -4334,8 +4423,9 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char } } - if (false == UI_search_item_add(items, name, ot, 0)) + if (false == UI_search_item_add(items, name, ot, 0)) { break; + } } } } @@ -4600,14 +4690,16 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) UI_block_func_handle_set(block, do_running_jobs, NULL); if (sa->spacetype == SPACE_SEQ) { - if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) + if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) { owner = sa; + } handle_event = B_STOPSEQ; icon = ICON_SEQUENCE; } else if (sa->spacetype == SPACE_CLIP) { - if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) + if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) { owner = sa; + } handle_event = B_STOPCLIP; icon = ICON_TRACKER; } @@ -4716,9 +4808,10 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) } } - if (screen->animtimer) + if (screen->animtimer) { uiDefIconTextBut(block, UI_BTYPE_BUT, B_STOPANIM, ICON_CANCEL, IFACE_("Anim Player"), 0, 0, UI_UNIT_X * 5.0f, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop animation playback")); + } } /************************* Reports for Last Operator Template **************************/ @@ -4737,11 +4830,15 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) int icon; /* if the report display has timed out, don't show */ - if (!reports->reporttimer) return; + if (!reports->reporttimer) { + return; + } rti = (ReportTimerInfo *)reports->reporttimer->customdata; - if (!rti || rti->widthfac == 0.0f || !report) return; + if (!rti || rti->widthfac == 0.0f || !report) { + return; + } ui_abs = uiLayoutAbsolute(layout, false); block = uiLayoutGetBlock(ui_abs); @@ -4771,11 +4868,13 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) */ UI_block_emboss_set(block, UI_EMBOSS_NONE); - if (reports->list.first != reports->list.last) + if (reports->list.first != reports->list.last) { uiDefIconButO(block, UI_BTYPE_BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, TIP_("Click to see the remaining reports in text block: 'Recent Reports'")); - else + } + else { uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); + } UI_block_emboss_set(block, UI_EMBOSS); @@ -4837,8 +4936,9 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title, uiItemS(layout); - if (title) + if (title) { uiItemL(layout, title, ICON_NONE); + } flow = uiLayoutColumnFlow(layout, 2, false); @@ -4954,8 +5054,9 @@ void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *UNUSED(C), P col = uiLayoutColumn(layout, false); uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, NULL, ICON_NONE); - if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) + if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) { uiTemplateCurveMapping(col, &view_transform_ptr, "curve_mapping", 'c', true, false, false, false); + } } /********************************* Component Menu *************************************/ 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 */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index dce418ab25a..f99cf389935 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -439,16 +439,20 @@ GPUBatch *ui_batch_roundbox_get(bool filled, bool antialiased) GPUBatch **batch = NULL; if (filled) { - if (antialiased) + if (antialiased) { batch = &g_ui_batch_cache.roundbox_simple_aa; - else + } + else { batch = &g_ui_batch_cache.roundbox_simple; + } } else { - if (antialiased) + if (antialiased) { BLI_assert(0); /* Use GL_LINE_SMOOTH instead!!: */ - else + } + else { batch = &g_ui_batch_cache.roundbox_simple_outline; + } } if (*batch == NULL) { @@ -653,8 +657,9 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad, rad += step; - if (2.0f * rad > BLI_rcti_size_y(rect)) + if (2.0f * rad > BLI_rcti_size_y(rect)) { rad = 0.5f * BLI_rcti_size_y(rect); + } minx = rect->xmin - step; miny = rect->ymin - step; @@ -746,11 +751,13 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re BLI_rcti_size_x(rect) * hnum, BLI_rcti_size_y(rect) * vnum); - if (2.0f * rad > minsize) + if (2.0f * rad > minsize) { rad = 0.5f * minsize; + } - if (2.0f * (radi + 1.0f) > minsize) + if (2.0f * (radi + 1.0f) > minsize) { radi = 0.5f * minsize - U.pixelsize; + } wt->uniform_params.rad = rad; wt->uniform_params.radi = radi; @@ -986,8 +993,9 @@ static void widget_draw_vertex_buffer(uint pos, uint col, int mode, { immBegin(mode, totvert); for (int i = 0; i < totvert; ++i) { - if (quads_col) + if (quads_col) { immAttr4ubv(col, quads_col[i]); + } immVertex2fv(pos, quads_pos[i]); } immEnd(); @@ -1147,8 +1155,9 @@ void UI_widgetbase_draw_cache_flush(void) { float checker_params[3] = {UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 8.0f}; - if (g_widget_base_batch.count == 0) + if (g_widget_base_batch.count == 0) { return; + } GPUBatch *batch = g_widget_base_batch.batch; if (g_widget_base_batch.count == 1) { @@ -1307,8 +1316,9 @@ static void widget_draw_preview(BIFIconID icon, float alpha, const rcti *rect) { int w, h, size; - if (icon == ICON_NONE) + if (icon == ICON_NONE) { return; + } w = BLI_rcti_size_x(rect); h = BLI_rcti_size_y(rect); @@ -1346,16 +1356,24 @@ static void widget_draw_icon( } /* this icon doesn't need draw... */ - if (icon == ICON_BLANK1 && (but->flag & UI_BUT_ICON_SUBMENU) == 0) return; + if (icon == ICON_BLANK1 && (but->flag & UI_BUT_ICON_SUBMENU) == 0) { + return; + } aspect = but->block->aspect / UI_DPI_FAC; height = ICON_DEFAULT_HEIGHT / aspect; /* calculate blend color */ if (ELEM(but->type, UI_BTYPE_TOGGLE, UI_BTYPE_ROW, UI_BTYPE_TOGGLE_N, UI_BTYPE_LISTROW)) { - if (but->flag & UI_SELECT) {} - else if (but->flag & UI_ACTIVE) {} - else alpha = 0.75f; + if (but->flag & UI_SELECT) { + /* pass */ + } + else if (but->flag & UI_ACTIVE) { + /* pass */ + } + else { + alpha = 0.75f; + } } else if ((but->type == UI_BTYPE_LABEL)) { /* extra feature allows more alpha blending */ @@ -1376,12 +1394,15 @@ static void widget_draw_icon( if (but->drawflag & UI_BUT_ICON_LEFT) { /* special case - icon_only pie buttons */ - if (ui_block_is_pie_menu(but->block) && !ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && but->str && but->str[0] == '\0') + if (ui_block_is_pie_menu(but->block) && !ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && but->str && but->str[0] == '\0') { xs = rect->xmin + 2.0f * ofs; - else if (but->dt == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL) + } + else if (but->dt == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL) { xs = rect->xmin + 2.0f * ofs; - else + } + else { xs = rect->xmin + 4.0f * ofs; + } } else { xs = (rect->xmin + rect->xmax - height) / 2.0f; @@ -1504,7 +1525,8 @@ float UI_text_clip_middle_ex( /* need to set this first */ UI_fontstyle_set(fstyle); - if (fstyle->kerning == 1) { /* for BLF_width */ + if (fstyle->kerning == 1) { + /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); } @@ -1653,15 +1675,19 @@ static void ui_text_clip_cursor(const uiFontStyle *fstyle, uiBut *but, const rct /* need to set this first */ UI_fontstyle_set(fstyle); - if (fstyle->kerning == 1) /* for BLF_width */ + if (fstyle->kerning == 1) { + /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + } /* define ofs dynamically */ - if (but->ofs > but->pos) + if (but->ofs > but->pos) { but->ofs = but->pos; + } - if (BLF_width(fstyle->uifont_id, but->editstr, INT_MAX) <= okwidth) + if (BLF_width(fstyle->uifont_id, but->editstr, INT_MAX) <= okwidth) { but->ofs = 0; + } but->strwidth = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, INT_MAX); @@ -1681,17 +1707,21 @@ static void ui_text_clip_cursor(const uiFontStyle *fstyle, uiBut *but, const rct else { int bytes; /* shift string to the left */ - if (width < 20 && but->ofs > 0) + if (width < 20 && but->ofs > 0) { ui_text_clip_give_prev_off(but, but->editstr); + } bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->editstr, but->editstr + len)); - if (bytes == -1) + if (bytes == -1) { bytes = 1; + } len -= bytes; } but->strwidth = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, len - but->ofs); - if (but->strwidth < 10) break; + if (but->strwidth < 10) { + break; + } } } @@ -1716,8 +1746,10 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons /* need to set this first */ UI_fontstyle_set(fstyle); - if (fstyle->kerning == 1) /* for BLF_width */ + if (fstyle->kerning == 1) { + /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + } but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr)); but->ofs = 0; @@ -1749,7 +1781,9 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons // BLI_assert(strlen(but->drawstr) == drawstr_len); but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs); - if (but->strwidth < 10) break; + if (but->strwidth < 10) { + break; + } } @@ -1757,7 +1791,9 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons while ((but->strwidth > okwidth) && (but->ofs < 2)) { ui_text_clip_give_next_off(but, but->drawstr); but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs); - if (but->strwidth < 10) break; + if (but->strwidth < 10) { + break; + } } } @@ -1773,8 +1809,9 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons but->drawstr[drawstr_len] = 0; } - if (fstyle->kerning == 1) + if (fstyle->kerning == 1) { BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + } } #ifdef WITH_INPUT_IME @@ -1848,9 +1885,10 @@ static void widget_draw_text(const uiFontStyle *fstyle, const uiWidgetColors *wc align = UI_STYLE_TEXT_CENTER; } - if (fstyle->kerning == 1) /* for BLF_width */ + if (fstyle->kerning == 1) { + /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); - + } /* Special case: when we're entering text for multiple buttons, * don't draw the text for any of the multi-editing buttons */ @@ -1974,8 +2012,9 @@ static void widget_draw_text(const uiFontStyle *fstyle, const uiWidgetColors *wc #endif } - if (fstyle->kerning == 1) + if (fstyle->kerning == 1) { BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + } #if 0 ui_rasterpos_safe(x, y, but->aspect); @@ -2038,8 +2077,9 @@ static void widget_draw_text(const uiFontStyle *fstyle, const uiWidgetColors *wc BLI_strncpy(fixedbuf, drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawlen)); str = strchr(fixedbuf, but->menu_key - 32); /* upper case */ - if (str == NULL) + if (str == NULL) { str = strchr(fixedbuf, but->menu_key); + } if (str) { int ul_index = -1; @@ -2175,11 +2215,13 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, const uiWidgetColor /* pass (even if its a menu toolbar) */ } else if (ui_block_is_pie_menu(but->block)) { - if (but->dt == UI_EMBOSS_RADIAL) + if (but->dt == UI_EMBOSS_RADIAL) { rect->xmin += 0.3f * U.widget_unit; + } } - else if (ui_block_is_menu(but->block)) + else if (ui_block_is_menu(but->block)) { rect->xmin += 0.2f * U.widget_unit; + } widget_draw_icon(but, icon, alpha, rect, wcol->text); if (show_menu_icon) { @@ -2324,33 +2366,44 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) if (state & UI_SELECT) { copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); - if (drawflag & UI_BUT_ANIMATED_CHANGED) + if (drawflag & UI_BUT_ANIMATED_CHANGED) { widget_state_blend(wt->wcol.inner, wcol_state->inner_changed_sel, wcol_state->blend); - else if (state & UI_BUT_ANIMATED_KEY) + } + else if (state & UI_BUT_ANIMATED_KEY) { widget_state_blend(wt->wcol.inner, wcol_state->inner_key_sel, wcol_state->blend); - else if (state & UI_BUT_ANIMATED) + } + else if (state & UI_BUT_ANIMATED) { widget_state_blend(wt->wcol.inner, wcol_state->inner_anim_sel, wcol_state->blend); - else if (state & UI_BUT_DRIVEN) + } + else if (state & UI_BUT_DRIVEN) { widget_state_blend(wt->wcol.inner, wcol_state->inner_driven_sel, wcol_state->blend); - else if (state & UI_BUT_OVERRIDEN) + } + else if (state & UI_BUT_OVERRIDEN) { widget_state_blend(wt->wcol.inner, wcol_state->inner_overridden_sel, wcol_state->blend); + } copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); - if (state & UI_SELECT) + if (state & UI_SELECT) { SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); + } } else { - if (drawflag & UI_BUT_ANIMATED_CHANGED) + if (drawflag & UI_BUT_ANIMATED_CHANGED) { widget_state_blend(wt->wcol.inner, wcol_state->inner_changed, wcol_state->blend); - else if (state & UI_BUT_ANIMATED_KEY) + } + else if (state & UI_BUT_ANIMATED_KEY) { widget_state_blend(wt->wcol.inner, wcol_state->inner_key, wcol_state->blend); - else if (state & UI_BUT_ANIMATED) + } + else if (state & UI_BUT_ANIMATED) { widget_state_blend(wt->wcol.inner, wcol_state->inner_anim, wcol_state->blend); - else if (state & UI_BUT_DRIVEN) + } + else if (state & UI_BUT_DRIVEN) { widget_state_blend(wt->wcol.inner, wcol_state->inner_driven, wcol_state->blend); - else if (state & UI_BUT_OVERRIDEN) + } + else if (state & UI_BUT_OVERRIDEN) { widget_state_blend(wt->wcol.inner, wcol_state->inner_overridden, wcol_state->blend); + } if (state & UI_ACTIVE) { /* mouse over? */ widget_active_color(wt->wcol.inner); @@ -2394,31 +2447,42 @@ static void widget_state_numslider(uiWidgetType *wt, int state, int drawflag) /* TODO: maybe we should have separate settings for the blending colors used for this case? */ if (state & UI_SELECT) { - if (drawflag & UI_BUT_ANIMATED_CHANGED) + if (drawflag & UI_BUT_ANIMATED_CHANGED) { widget_state_blend(wt->wcol.item, wcol_state->inner_changed_sel, blend); - else if (state & UI_BUT_ANIMATED_KEY) + } + else if (state & UI_BUT_ANIMATED_KEY) { widget_state_blend(wt->wcol.item, wcol_state->inner_key_sel, blend); - else if (state & UI_BUT_ANIMATED) + } + else if (state & UI_BUT_ANIMATED) { widget_state_blend(wt->wcol.item, wcol_state->inner_anim_sel, blend); - else if (state & UI_BUT_DRIVEN) + } + else if (state & UI_BUT_DRIVEN) { widget_state_blend(wt->wcol.item, wcol_state->inner_driven_sel, blend); - else if (state & UI_BUT_OVERRIDEN) + } + else if (state & UI_BUT_OVERRIDEN) { widget_state_blend(wt->wcol.item, wcol_state->inner_overridden_sel, blend); + } - if (state & UI_SELECT) + if (state & UI_SELECT) { SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); + } } else { - if (drawflag & UI_BUT_ANIMATED_CHANGED) + if (drawflag & UI_BUT_ANIMATED_CHANGED) { widget_state_blend(wt->wcol.item, wcol_state->inner_changed, blend); - else if (state & UI_BUT_ANIMATED_KEY) + } + else if (state & UI_BUT_ANIMATED_KEY) { widget_state_blend(wt->wcol.item, wcol_state->inner_key, blend); - else if (state & UI_BUT_ANIMATED) + } + else if (state & UI_BUT_ANIMATED) { widget_state_blend(wt->wcol.item, wcol_state->inner_anim, blend); - else if (state & UI_BUT_DRIVEN) + } + else if (state & UI_BUT_DRIVEN) { widget_state_blend(wt->wcol.item, wcol_state->inner_driven, blend); - else if (state & UI_BUT_OVERRIDEN) + } + else if (state & UI_BUT_OVERRIDEN) { widget_state_blend(wt->wcol.item, wcol_state->inner_overridden, blend); + } } } @@ -2431,10 +2495,12 @@ static void widget_state_option_menu(uiWidgetType *wt, int state, int drawflag) widget_state(wt, state, drawflag); /* if not selected we get theme from menu back */ - if (state & UI_SELECT) + if (state & UI_SELECT) { copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel); - else + } + else { copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text); + } } @@ -2525,14 +2591,17 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r const float radout = UI_ThemeMenuShadowWidth(); /* disabled shadow */ - if (radout == 0.0f) + if (radout == 0.0f) { return; + } /* prevent tooltips to not show round shadow */ - if (radout > 0.2f * BLI_rcti_size_y(&rect1)) + if (radout > 0.2f * BLI_rcti_size_y(&rect1)) { rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1); - else + } + else { rect1.ymax -= radout; + } /* inner part */ totvert = round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f); @@ -2638,10 +2707,12 @@ void ui_hsvcircle_pos_from_vals( ang = 2.0f * (float)M_PI * hsv[0] + (float)M_PI_2; - if (cpicker->use_color_cubic && (U.color_picker_type == USER_CP_CIRCLE_HSV)) + if (cpicker->use_color_cubic && (U.color_picker_type == USER_CP_CIRCLE_HSV)) { radius_t = (1.0f - pow3f(1.0f - hsv[1])); - else + } + else { radius_t = hsv[1]; + } radius = clamp_f(radius_t, 0.0f, 1.0f) * radius; *r_xpos = centx + cosf(-ang) * radius; @@ -2986,10 +3057,12 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) ui_but_v3_get(but, rgb); ui_scene_linear_to_color_picker_space(but, rgb); - if (but->a1 == UI_GRAD_L_ALT) + if (but->a1 == UI_GRAD_L_ALT) { rgb_to_hsl_v(rgb, hsv); - else + } + else { rgb_to_hsv_v(rgb, hsv); + } v = hsv[2]; /* map v from property range to [0,1] */ @@ -3078,8 +3151,9 @@ static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int const float rad = wcol->roundness * BLI_rcti_size_y(rect); const int handle_width = min_ii(BLI_rcti_size_x(rect) / 3, BLI_rcti_size_y(rect) * 0.7f); - if (state & UI_SELECT) + if (state & UI_SELECT) { SWAP(short, wcol->shadetop, wcol->shadedown); + } widget_init(&wtb); @@ -3198,16 +3272,19 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s /* determine horizontal/vertical */ horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect)); - if (horizontal) + if (horizontal) { rad = wcol->roundness * BLI_rcti_size_y(rect); - else + } + else { rad = wcol->roundness * BLI_rcti_size_x(rect); + } wtb.uniform_params.shade_dir = (horizontal) ? 1.0f : 0.0; /* draw back part, colors swapped and shading inverted */ - if (horizontal) + if (horizontal) { SWAP(short, wcol->shadetop, wcol->shadedown); + } round_box_edges(&wtb, UI_CNR_ALL, rect, rad); widgetbase_draw(&wtb, wcol); @@ -3221,9 +3298,12 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s copy_v4_v4_char(wcol->inner, wcol->item); - if (wcol->shadetop > wcol->shadedown) + if (wcol->shadetop > wcol->shadedown) { wcol->shadetop += 20; /* XXX violates themes... */ - else wcol->shadedown += 20; + } + else { + wcol->shadedown += 20; + } if (state & UI_SCROLL_PRESSED) { wcol->inner[0] = wcol->inner[0] >= 250 ? 255 : wcol->inner[0] + 5; @@ -3242,9 +3322,15 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s round_box_edges(&wtb, UI_CNR_ALL, slider, rad); if (state & UI_SCROLL_ARROWS) { - if (wcol->item[0] > 48) wcol->item[0] -= 48; - if (wcol->item[1] > 48) wcol->item[1] -= 48; - if (wcol->item[2] > 48) wcol->item[2] -= 48; + if (wcol->item[0] > 48) { + wcol->item[0] -= 48; + } + if (wcol->item[1] > 48) { + wcol->item[1] -= 48; + } + if (wcol->item[2] > 48) { + wcol->item[2] -= 48; + } wcol->item[3] = 255; if (horizontal) { @@ -3318,10 +3404,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat } } - if (state & UI_SELECT) + if (state & UI_SELECT) { state = UI_SCROLL_PRESSED; - else + } + else { state = 0; + } UI_draw_widget_scroll(wcol, rect, &rect1, state); } @@ -3484,8 +3572,9 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat round_box_edges(&wtb, roundboxalign, rect, rad); } - if (!ui_but_is_color_gamma(but)) + if (!ui_but_is_color_gamma(but)) { ui_block_cm_to_display_space_v3(but->block, col); + } rgba_float_to_uchar((uchar *)wcol->inner, col); const bool show_alpha_checkers = (wcol->inner[3] < 255); @@ -3560,8 +3649,9 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun uiWidgetBase wtb; float rad; - if (state & UI_SELECT) + if (state & UI_SELECT) { SWAP(short, wcol->shadetop, wcol->shadedown); + } widget_init(&wtb); @@ -3744,10 +3834,12 @@ static void widget_state_label(uiWidgetType *wt, int state, int drawflag) else { /* call this for option button */ widget_state(wt, state, drawflag); - if (state & UI_SELECT) + if (state & UI_SELECT) { UI_GetThemeColor3ubv(TH_TEXT_HI, (uchar *)wt->wcol.text); - else + } + else { UI_GetThemeColor3ubv(TH_TEXT, (uchar *)wt->wcol.text); + } } if (state & UI_BUT_REDALERT) { @@ -4109,10 +4201,12 @@ static int widget_roundbox_set(uiBut *but, rcti *rect) if ((but->drawflag & UI_BUT_ALIGN) && but->type != UI_BTYPE_PULLDOWN) { /* ui_popup_block_position has this correction too, keep in sync */ - if (but->drawflag & (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_STITCH_TOP)) + if (but->drawflag & (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_STITCH_TOP)) { rect->ymax += U.pixelsize; - if (but->drawflag & (UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_STITCH_LEFT)) + } + if (but->drawflag & (UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_STITCH_LEFT)) { rect->xmin -= U.pixelsize; + } switch (but->drawflag & UI_BUT_ALIGN) { case UI_BUT_ALIGN_TOP: @@ -4149,10 +4243,10 @@ static int widget_roundbox_set(uiBut *but, rcti *rect) if (but->active && (but->type != UI_BTYPE_POPOVER)) { int direction = ui_but_menu_direction(but); - if (direction == UI_DIR_UP) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT); - else if (direction == UI_DIR_DOWN) roundbox &= ~(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); - else if (direction == UI_DIR_LEFT) roundbox &= ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); - else if (direction == UI_DIR_RIGHT) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); + if (direction == UI_DIR_UP) { roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT); } + else if (direction == UI_DIR_DOWN) { roundbox &= ~(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); } + else if (direction == UI_DIR_LEFT) { roundbox &= ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); } + else if (direction == UI_DIR_RIGHT) { roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); } } return roundbox; @@ -4441,25 +4535,31 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct } } - if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) - if (but->dt != UI_EMBOSS_PULLDOWN) + if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { + if (but->dt != UI_EMBOSS_PULLDOWN) { disabled = true; + } + } if (drawflag & UI_BUT_TEXT_RIGHT) { state |= UI_STATE_TEXT_BEFORE_WIDGET; } - if (disabled) + if (disabled) { ui_widget_color_disabled(wt); + } wt->state(wt, state, drawflag); - if (wt->custom) + if (wt->custom) { wt->custom(but, &wt->wcol, rect, state, roundboxalign); - else if (wt->draw) + } + else if (wt->draw) { wt->draw(&wt->wcol, rect, state, roundboxalign); + } - if (disabled) + if (disabled) { GPU_blend(true); + } #ifdef USE_UI_POPOVER_ONCE if (but->block->flag & UI_BLOCK_POPOVER_ONCE) { @@ -4480,12 +4580,15 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct #endif wt->text(fstyle, &wt->wcol, but, rect); - if (disabled) + if (disabled) { GPU_blend(false); + } -// if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) -// if (but->dt != UI_EMBOSS_PULLDOWN) +// if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { +// if (but->dt != UI_EMBOSS_PULLDOWN) { // widget_disabled(&disablerect); +// } +// } } } @@ -4516,10 +4619,12 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK); wt->state(wt, 0, 0); - if (block) + if (block) { wt->draw(&wt->wcol, rect, block->flag, block->direction); - else + } + else { wt->draw(&wt->wcol, rect, 0, 0); + } ui_draw_clip_tri(block, rect, wt); } @@ -4776,7 +4881,9 @@ void ui_draw_menu_item(const uiFontStyle *fstyle, rcti *rect, const char *name, /* text location offset */ rect->xmin += 0.25f * UI_UNIT_X; - if (iconid) rect->xmin += UI_DPI_ICON_SIZE; + if (iconid) { + rect->xmin += UI_DPI_ICON_SIZE; + } /* cut string in 2 parts? */ if (use_sep) { @@ -4787,7 +4894,8 @@ void ui_draw_menu_item(const uiFontStyle *fstyle, rcti *rect, const char *name, /* need to set this first */ UI_fontstyle_set(fstyle); - if (fstyle->kerning == 1) { /* for BLF_width */ + if (fstyle->kerning == 1) { + /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); } @@ -4868,8 +4976,9 @@ void ui_draw_preview_item(const uiFontStyle *fstyle, rcti *rect, const char *nam trect.xmax = trect.xmin + font_dims[0] + U.widget_unit / 2; trect.ymin += U.widget_unit / 2; trect.ymax = trect.ymin + font_dims[1]; - if (trect.xmax > rect->xmax - PREVIEW_PAD) + if (trect.xmax > rect->xmax - PREVIEW_PAD) { trect.xmax = rect->xmax - PREVIEW_PAD; + } { char drawstr[UI_MAX_DRAW_STR]; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 48b24da8f5c..e39f244fd40 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -167,18 +167,24 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) switch (colorid) { case TH_BACK: - if (ELEM(theme_regionid, RGN_TYPE_WINDOW, RGN_TYPE_PREVIEW)) + if (ELEM(theme_regionid, RGN_TYPE_WINDOW, RGN_TYPE_PREVIEW)) { cp = ts->back; - else if (theme_regionid == RGN_TYPE_CHANNELS) + } + else if (theme_regionid == RGN_TYPE_CHANNELS) { cp = ts->list; - else if (theme_regionid == RGN_TYPE_HEADER) + } + else if (theme_regionid == RGN_TYPE_HEADER) { cp = ts->header; - else if (theme_regionid == RGN_TYPE_NAV_BAR) + } + else if (theme_regionid == RGN_TYPE_NAV_BAR) { cp = ts->navigation_bar; - else if (theme_regionid == RGN_TYPE_EXECUTE) + } + else if (theme_regionid == RGN_TYPE_EXECUTE) { cp = ts->execution_buts; - else + } + else { cp = ts->button; + } copy_v4_v4_char(back, cp); if (!ED_region_is_overlap(spacetype, theme_regionid)) { @@ -195,34 +201,46 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) setting = ts->show_back_grad; break; case TH_TEXT: - if (theme_regionid == RGN_TYPE_WINDOW) + if (theme_regionid == RGN_TYPE_WINDOW) { cp = ts->text; - else if (theme_regionid == RGN_TYPE_CHANNELS) + } + else if (theme_regionid == RGN_TYPE_CHANNELS) { cp = ts->list_text; - else if (theme_regionid == RGN_TYPE_HEADER) + } + else if (theme_regionid == RGN_TYPE_HEADER) { cp = ts->header_text; - else + } + else { cp = ts->button_text; + } break; case TH_TEXT_HI: - if (theme_regionid == RGN_TYPE_WINDOW) + if (theme_regionid == RGN_TYPE_WINDOW) { cp = ts->text_hi; - else if (theme_regionid == RGN_TYPE_CHANNELS) + } + else if (theme_regionid == RGN_TYPE_CHANNELS) { cp = ts->list_text_hi; - else if (theme_regionid == RGN_TYPE_HEADER) + } + else if (theme_regionid == RGN_TYPE_HEADER) { cp = ts->header_text_hi; - else + } + else { cp = ts->button_text_hi; + } break; case TH_TITLE: - if (theme_regionid == RGN_TYPE_WINDOW) + if (theme_regionid == RGN_TYPE_WINDOW) { cp = ts->title; - else if (theme_regionid == RGN_TYPE_CHANNELS) + } + else if (theme_regionid == RGN_TYPE_CHANNELS) { cp = ts->list_title; - else if (theme_regionid == RGN_TYPE_HEADER) + } + else if (theme_regionid == RGN_TYPE_HEADER) { cp = ts->header_title; - else + } + else { cp = ts->button_title; + } break; case TH_HEADER: diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 64f5cc037de..5f0b8f8935a 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -103,10 +103,12 @@ BLI_INLINE void clamp_rctf_to_rcti(rcti *dst, const rctf *src) */ static int view2d_scroll_mapped(int scroll) { - if (scroll & V2D_SCROLL_HORIZONTAL_FULLR) + if (scroll & V2D_SCROLL_HORIZONTAL_FULLR) { scroll &= ~(V2D_SCROLL_HORIZONTAL); - if (scroll & V2D_SCROLL_VERTICAL_FULLR) + } + if (scroll & V2D_SCROLL_VERTICAL_FULLR) { scroll &= ~(V2D_SCROLL_VERTICAL); + } return scroll; } @@ -137,18 +139,22 @@ static void view2d_masks(View2D *v2d, bool check_scrollers, const rcti *mask_scr /* check size if hiding flag is set: */ if (v2d->scroll & V2D_SCROLL_HORIZONTAL_HIDE) { if (!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL)) { - if (BLI_rctf_size_x(&v2d->tot) > BLI_rctf_size_x(&v2d->cur)) + if (BLI_rctf_size_x(&v2d->tot) > BLI_rctf_size_x(&v2d->cur)) { v2d->scroll &= ~V2D_SCROLL_HORIZONTAL_FULLR; - else + } + else { v2d->scroll |= V2D_SCROLL_HORIZONTAL_FULLR; + } } } if (v2d->scroll & V2D_SCROLL_VERTICAL_HIDE) { if (!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)) { - if (BLI_rctf_size_y(&v2d->tot) + 0.01f > BLI_rctf_size_y(&v2d->cur)) + if (BLI_rctf_size_y(&v2d->tot) + 0.01f > BLI_rctf_size_y(&v2d->cur)) { v2d->scroll &= ~V2D_SCROLL_VERTICAL_FULLR; - else + } + else { v2d->scroll |= V2D_SCROLL_VERTICAL_FULLR; + } } } } @@ -377,10 +383,12 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* set 'tot' rect before setting cur? */ /* XXX confusing stuff here still - * I made this function not check scroller hide - that happens in totrect_set */ - if (tot_changed) + if (tot_changed) { UI_view2d_totRect_set_resize(v2d, winx, winy, !do_init); - else + } + else { ui_view2d_curRect_validate_resize(v2d, !do_init, 0); + } } @@ -423,19 +431,29 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas curheight = height = BLI_rctf_size_y(cur); /* if zoom is locked, size on the appropriate axis is reset to mask size */ - if (v2d->keepzoom & V2D_LOCKZOOM_X) + if (v2d->keepzoom & V2D_LOCKZOOM_X) { width = winx; - if (v2d->keepzoom & V2D_LOCKZOOM_Y) + } + if (v2d->keepzoom & V2D_LOCKZOOM_Y) { height = winy; + } /* values used to divide, so make it safe * NOTE: width and height must use FLT_MIN instead of 1, otherwise it is impossible to * get enough resolution in Graph Editor for editing some curves */ - if (width < FLT_MIN) width = 1; - if (height < FLT_MIN) height = 1; - if (winx < 1) winx = 1; - if (winy < 1) winy = 1; + if (width < FLT_MIN) { + width = 1; + } + if (height < FLT_MIN) { + height = 1; + } + if (winx < 1) { + winx = 1; + } + if (winy < 1) { + winy = 1; + } /* V2D_LIMITZOOM indicates that zoom level should be preserved when the window size changes */ if (resize && (v2d->keepzoom & V2D_KEEPZOOM)) { @@ -445,16 +463,18 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas zoom = winx / width; oldzoom = v2d->oldwinx / curwidth; - if (oldzoom != zoom) + if (oldzoom != zoom) { width *= zoom / oldzoom; + } } if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { zoom = winy / height; oldzoom = v2d->oldwiny / curheight; - if (oldzoom != zoom) + if (oldzoom != zoom) { height *= zoom / oldzoom; + } } } /* keepzoom (V2D_LIMITZOOM set), indicates that zoom level on each axis must not exceed limits @@ -499,8 +519,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas /* when a window edge changes, the aspect ratio can't be used to * find which is the best new 'cur' rect. that's why it stores 'old' */ - if (winx != v2d->oldwinx) do_x = true; - if (winy != v2d->oldwiny) do_y = true; + if (winx != v2d->oldwinx) { + do_x = true; + } + if (winy != v2d->oldwiny) { + do_y = true; + } curRatio = height / width; winRatio = winy / winx; @@ -509,8 +533,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas if (do_x == do_y) { if (do_x && do_y) { /* here is 1,1 case, so all others must be 0,0 */ - if (fabsf(winx - v2d->oldwinx) > fabsf(winy - v2d->oldwiny)) do_y = false; - else do_x = false; + if (fabsf(winx - v2d->oldwinx) > fabsf(winy - v2d->oldwiny)) { + do_y = false; + } + else { + do_x = false; + } } else if (winRatio > curRatio) { do_x = false; @@ -587,10 +615,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas cur->xmax += width - BLI_rctf_size_x(cur); } else if (v2d->keepofs & V2D_KEEPOFS_X) { - if (v2d->align & V2D_ALIGN_NO_POS_X) + if (v2d->align & V2D_ALIGN_NO_POS_X) { cur->xmin -= width - BLI_rctf_size_x(cur); - else + } + else { cur->xmax += width - BLI_rctf_size_x(cur); + } } else { temp = BLI_rctf_cent_x(cur); @@ -605,10 +635,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas cur->ymax += height - BLI_rctf_size_y(cur); } else if (v2d->keepofs & V2D_KEEPOFS_Y) { - if (v2d->align & V2D_ALIGN_NO_POS_Y) + if (v2d->align & V2D_ALIGN_NO_POS_Y) { cur->ymin -= height - BLI_rctf_size_y(cur); - else + } + else { cur->ymax += height - BLI_rctf_size_y(cur); + } } else { temp = BLI_rctf_cent_y(cur); @@ -631,8 +663,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas /* width */ if ((curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_X | V2D_LIMITZOOM))) { /* if zoom doesn't have to be maintained, just clamp edges */ - if (cur->xmin < tot->xmin) cur->xmin = tot->xmin; - if (cur->xmax > tot->xmax) cur->xmax = tot->xmax; + if (cur->xmin < tot->xmin) { + cur->xmin = tot->xmin; + } + if (cur->xmax > tot->xmax) { + cur->xmax = tot->xmax; + } } else if (v2d->keeptot == V2D_KEEPTOT_STRICT) { /* This is an exception for the outliner (and later channel-lists, headers) @@ -715,8 +751,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas /* height */ if ((curheight > totheight) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_Y | V2D_LIMITZOOM))) { /* if zoom doesn't have to be maintained, just clamp edges */ - if (cur->ymin < tot->ymin) cur->ymin = tot->ymin; - if (cur->ymax > tot->ymax) cur->ymax = tot->ymax; + if (cur->ymin < tot->ymin) { + cur->ymin = tot->ymin; + } + if (cur->ymax > tot->ymax) { + cur->ymax = tot->ymax; + } } else { /* This here occurs when: @@ -814,8 +854,9 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag) ARegion *ar; /* don't continue if no view syncing to be done */ - if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME | V2D_VIEWSYNC_AREA_VERTICAL)) == 0) + if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME | V2D_VIEWSYNC_AREA_VERTICAL)) == 0) { return; + } /* check if doing within area syncing (i.e. channels/vertical) */ if ((v2dcur->flag & V2D_VIEWSYNC_AREA_VERTICAL) && (area)) { @@ -936,14 +977,17 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz /* hrumf! */ /* XXX: there are work arounds for this in the panel and file browse code. */ /* round to int, because this is called with width + V2D_SCROLL_WIDTH */ -// if (scroll & V2D_SCROLL_HORIZONTAL) +// if (scroll & V2D_SCROLL_HORIZONTAL) { // width -= (int)V2D_SCROLL_WIDTH; -// if (scroll & V2D_SCROLL_VERTICAL) +// } +// if (scroll & V2D_SCROLL_VERTICAL) { // height -= (int)V2D_SCROLL_HEIGHT; +// } if (ELEM(0, width, height)) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n", (void *)v2d, width, height); // XXX temp debug info + } return; } @@ -1012,10 +1056,12 @@ bool UI_view2d_tab_set(View2D *v2d, int tab) /* if tab changed, change offset */ if (tab != v2d->tab_cur && v2d->tab_offset) { - if (tab < v2d->tab_num) + if (tab < v2d->tab_num) { offset = &v2d->tab_offset[tab * 2]; - else + } + else { offset = default_offset; + } v2d->cur.xmax += offset[0] - v2d->cur.xmin; v2d->cur.xmin = offset[0]; @@ -1083,15 +1129,19 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked) float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1); float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1); - if (v2d->mask.xmin != 0) + if (v2d->mask.xmin != 0) { curmasked->xmin -= dx * (float)v2d->mask.xmin; - if (v2d->mask.xmax + 1 != v2d->winx) + } + if (v2d->mask.xmax + 1 != v2d->winx) { curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1); + } - if (v2d->mask.ymin != 0) + if (v2d->mask.ymin != 0) { curmasked->ymin -= dy * (float)v2d->mask.ymin; - if (v2d->mask.ymax + 1 != v2d->winy) + } + if (v2d->mask.ymax + 1 != v2d->winy) { curmasked->ymax += dy * (float)(v2d->winy - v2d->mask.ymax - 1); + } } } } @@ -1110,10 +1160,12 @@ void UI_view2d_view_ortho(View2D *v2d) */ /* XXX brecht: instead of zero at least use a tiny offset, otherwise * pixel rounding is effectively random due to float inaccuracy */ - if (sizex > 0) + if (sizex > 0) { xofs = eps * BLI_rctf_size_x(&v2d->cur) / sizex; - if (sizey > 0) + } + if (sizey > 0) { yofs = eps * BLI_rctf_size_y(&v2d->cur) / sizey; + } /* apply mask-based adjustments to cur rect (due to scrollers), * to eliminate scaling artifacts */ @@ -1157,10 +1209,12 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, const bool xaxis) view2d_map_cur_using_mask(v2d, &curmasked); /* only set matrix with 'cur' coordinates on relevant axes */ - if (xaxis) + if (xaxis) { wmOrtho2(curmasked.xmin - xofs, curmasked.xmax - xofs, -yofs, ar->winy - yofs); - else + } + else { wmOrtho2(-xofs, ar->winx - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs); + } } @@ -1201,9 +1255,15 @@ static void step_to_grid(float *step, int *power, int unit) rem = (float)pow(10.0, rem); if (loga < 0.0f) { - if (rem < 0.2f) rem = 0.2f; - else if (rem < 0.5f) rem = 0.5f; - else rem = 1.0f; + if (rem < 0.2f) { + rem = 0.2f; + } + else if (rem < 0.5f) { + rem = 0.5f; + } + else { + rem = 1.0f; + } *step = rem * (float)pow(10.0, (*power)); @@ -1216,18 +1276,28 @@ static void step_to_grid(float *step, int *power, int unit) } /* prevents printing 1.0 2.0 3.0 etc */ - if (rem == 1.0f) (*power)++; + if (rem == 1.0f) { + (*power)++; + } } else { - if (rem < 2.0f) rem = 2.0f; - else if (rem < 5.0f) rem = 5.0f; - else rem = 10.0f; + if (rem < 2.0f) { + rem = 2.0f; + } + else if (rem < 5.0f) { + rem = 5.0f; + } + else { + rem = 10.0f; + } *step = rem * (float)pow(10.0, (*power)); (*power)++; /* prevents printing 1.0, 2.0, 3.0, etc. */ - if (rem == 10.0f) (*power)++; + if (rem == 10.0f) { + (*power)++; + } } } @@ -1254,8 +1324,9 @@ View2DGrid *UI_view2d_grid_calc( float space, seconddiv; /* check that there are at least some workable args */ - if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp)) + if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp)) { return NULL; + } /* grid here is allocated... */ grid = MEM_callocN(sizeof(View2DGrid), "View2DGrid"); @@ -1308,17 +1379,23 @@ View2DGrid *UI_view2d_grid_calc( /* calculate start position */ if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) { grid->startx = seconddiv * (v2d->cur.xmin / seconddiv - (float)fmod(v2d->cur.xmin / seconddiv, grid->dx / seconddiv)); - if (v2d->cur.xmin < 0.0f) grid->startx -= grid->dx; + if (v2d->cur.xmin < 0.0f) { + grid->startx -= grid->dx; + } } - else + else { grid->startx = v2d->cur.xmin; + } if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) { grid->starty = (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy)); - if (v2d->cur.ymin < 0.0f) grid->starty -= grid->dy; + if (v2d->cur.ymin < 0.0f) { + grid->starty -= grid->dy; + } } - else + else { grid->starty = v2d->cur.ymin; + } return grid; } @@ -1333,8 +1410,9 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) uchar grid_line_color[3]; /* check for grid first, as it may not exist */ - if (grid == NULL) + if (grid == NULL) { return; + } /* Count the needed vertices for the gridlines */ unsigned vertex_count = 0; @@ -1348,18 +1426,22 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) vertex_count += 2 * (horizontal_major_step + 1); /* major gridlines */ /* fine lines */ - if (flag & V2D_HORIZONTAL_FINELINES) + if (flag & V2D_HORIZONTAL_FINELINES) { vertex_count += 2 * (horizontal_major_step + 1); + } } /* axes */ - if (flag & V2D_HORIZONTAL_AXIS) + if (flag & V2D_HORIZONTAL_AXIS) { vertex_count += 2; - if (flag & V2D_VERTICAL_AXIS) + } + if (flag & V2D_VERTICAL_AXIS) { vertex_count += 2; + } /* If there is nothing to render, exit early */ - if (vertex_count == 0) + if (vertex_count == 0) { return; + } GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -1481,26 +1563,34 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step) int count_x, count_y; start_x = v2d->cur.xmin; - if (start_x < 0.0) + if (start_x < 0.0) { start_x += -(float)fmod(v2d->cur.xmin, step); - else + } + else { start_x += (step - (float)fmod(v2d->cur.xmin, step)); + } - if (start_x > v2d->cur.xmax) + if (start_x > v2d->cur.xmax) { count_x = 0; - else + } + else { count_x = (v2d->cur.xmax - start_x) / step + 1; + } start_y = v2d->cur.ymin; - if (start_y < 0.0) + if (start_y < 0.0) { start_y += -(float)fmod(v2d->cur.ymin, step); - else + } + else { start_y += (step - (float)fabs(fmod(v2d->cur.ymin, step))); + } - if (start_y > v2d->cur.ymax) + if (start_y > v2d->cur.ymax) { count_y = 0; - else + } + else { count_y = (v2d->cur.ymax - start_y) / step + 1; + } if (count_x > 0 || count_y > 0) { GPUVertFormat *format = immVertexFormat(); @@ -1542,8 +1632,9 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step) void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_size, int totlevels) { /* Exit if there is nothing to draw */ - if (totlevels == 0) + if (totlevels == 0) { return; + } int offset = -10; float lstep = step; @@ -1567,13 +1658,15 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s UI_GetThemeColorShade3ubv(colorid, offset, grid_line_color); int i = (int)(v2d->cur.xmin / lstep); - if (v2d->cur.xmin > 0.0f) + if (v2d->cur.xmin > 0.0f) { i++; + } float start = i * lstep; for (; start < v2d->cur.xmax; start += lstep, ++i) { - if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) + if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) { continue; + } immAttrSkip(color); immVertex2f(pos, start, v2d->cur.ymin); @@ -1582,13 +1675,15 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s } i = (int)(v2d->cur.ymin / lstep); - if (v2d->cur.ymin > 0.0f) + if (v2d->cur.ymin > 0.0f) { i++; + } start = i * lstep; for (; start < v2d->cur.ymax; start += lstep, ++i) { - if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) + if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) { continue; + } immAttrSkip(color); immVertex2f(pos, v2d->cur.xmin, start); @@ -1684,15 +1779,19 @@ View2DScrollers *UI_view2d_scrollers_calc( /* width of sliders */ smaller = (int)(0.1f * U.widget_unit); - if (scroll & V2D_SCROLL_BOTTOM) + if (scroll & V2D_SCROLL_BOTTOM) { hor.ymin += smaller; - else + } + else { hor.ymax -= smaller; + } - if (scroll & V2D_SCROLL_LEFT) + if (scroll & V2D_SCROLL_LEFT) { vert.xmin += smaller; - else + } + else { vert.xmax -= smaller; + } CLAMP(vert.ymin, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE); CLAMP(hor.xmin, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE); @@ -1711,23 +1810,30 @@ View2DScrollers *UI_view2d_scrollers_calc( /* scroller 'button' extents */ totsize = BLI_rctf_size_x(&v2d->tot); scrollsize = (float)BLI_rcti_size_x(&hor); - if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */ + if (totsize == 0.0f) { + totsize = 1.0f; /* avoid divide by zero */ + } fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize; - if (fac1 <= 0.0f) + if (fac1 <= 0.0f) { scrollers->hor_min = hor.xmin; - else + } + else { scrollers->hor_min = (int)(hor.xmin + (fac1 * scrollsize)); + } fac2 = (v2d->cur.xmax - v2d->tot.xmin) / totsize; - if (fac2 >= 1.0f) + if (fac2 >= 1.0f) { scrollers->hor_max = hor.xmax; - else + } + else { scrollers->hor_max = (int)(hor.xmin + (fac2 * scrollsize)); + } /* prevent inverted sliders */ - if (scrollers->hor_min > scrollers->hor_max) + if (scrollers->hor_min > scrollers->hor_max) { scrollers->hor_min = scrollers->hor_max; + } /* prevent sliders from being too small, and disappearing */ if ((scrollers->hor_max - scrollers->hor_min) < V2D_SCROLLER_HANDLE_SIZE) { scrollers->hor_max = scrollers->hor_min + V2D_SCROLLER_HANDLE_SIZE; @@ -1743,23 +1849,30 @@ View2DScrollers *UI_view2d_scrollers_calc( /* scroller 'button' extents */ totsize = BLI_rctf_size_y(&v2d->tot); scrollsize = (float)BLI_rcti_size_y(&vert); - if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */ + if (totsize == 0.0f) { + totsize = 1.0f; /* avoid divide by zero */ + } fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize; - if (fac1 <= 0.0f) + if (fac1 <= 0.0f) { scrollers->vert_min = vert.ymin; - else + } + else { scrollers->vert_min = (int)(vert.ymin + (fac1 * scrollsize)); + } fac2 = (v2d->cur.ymax - v2d->tot.ymin) / totsize; - if (fac2 >= 1.0f) + if (fac2 >= 1.0f) { scrollers->vert_max = vert.ymax; - else + } + else { scrollers->vert_max = (int)(vert.ymin + (fac2 * scrollsize)); + } /* prevent inverted sliders */ - if (scrollers->vert_min > scrollers->vert_max) + if (scrollers->vert_min > scrollers->vert_max) { scrollers->vert_min = scrollers->vert_max; + } /* prevent sliders from being too small, and disappearing */ if ((scrollers->vert_max - scrollers->vert_min) < V2D_SCROLLER_HANDLE_SIZE) { @@ -1821,10 +1934,12 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power len = strlen(timecode_str); if (dir == 'h') { /* seconds/timecode display has slightly longer strings... */ - if (unit == V2D_UNIT_SECONDS) + if (unit == V2D_UNIT_SECONDS) { x -= 3 * len; - else + } + else { x -= 4 * len; + } } /* Add degree sympbol to end of string for vertical scrollbar? */ @@ -1916,8 +2031,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v dfac *= 2.0f; } } - if (vs->xunits == V2D_UNIT_FRAMES) + if (vs->xunits == V2D_UNIT_FRAMES) { grid->powerx = 1; + } /* draw numbers in the appropriate range */ if (dfac > 0.0f) { @@ -1928,8 +2044,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v for (; fac < hor.xmax - 0.5f * U.widget_unit; fac += dfac, val += grid->dx) { /* make prints look nicer for scrollers */ - if (fac < hor.xmin + 0.5f * U.widget_unit) + if (fac < hor.xmin + 0.5f * U.widget_unit) { continue; + } switch (vs->xunits) { case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/ @@ -2018,8 +2135,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v /* if vertical clamping (to whole numbers) is used (i.e. in Sequencer), * apply correction */ - if (vs->yclamp == V2D_GRID_CLAMP) + if (vs->yclamp == V2D_GRID_CLAMP) { fac += 0.5f * dfac; + } /* draw vertical steps */ if (dfac > 0.0f) { @@ -2029,8 +2147,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v for (; fac < vert.ymax - 10; fac += dfac, val += grid->dy) { /* make prints look nicer for scrollers */ - if (fac < vert.ymin + 10) + if (fac < vert.ymin + 10) { continue; + } scroll_printstr(scene, (float)(vert.xmax) - 2.0f, fac, val, grid->powery, vs->yunits, 'v'); } @@ -2127,23 +2246,31 @@ void UI_view2d_listview_view_to_cell( /* sizes must not be negative */ if ((v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0))) { - if (column) *column = 0; - if (row) *row = 0; + if (column) { + *column = 0; + } + if (row) { + *row = 0; + } return; } /* get column */ - if ((column) && (columnwidth > 0)) + if ((column) && (columnwidth > 0)) { *column = x / columnwidth; - else if (column) + } + else if (column) { *column = 0; + } /* get row */ - if ((row) && (rowheight > 0)) + if ((row) && (rowheight > 0)) { *row = y / rowheight; - else if (row) + } + else if (row) { *row = 0; + } } /** @@ -2350,8 +2477,12 @@ View2D *UI_view2d_fromcontext(const bContext *C) ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - if (area == NULL) return NULL; - if (region == NULL) return NULL; + if (area == NULL) { + return NULL; + } + if (region == NULL) { + return NULL; + } return &(region->v2d); } @@ -2361,8 +2492,12 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C) ScrArea *sa = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - if (sa == NULL) return NULL; - if (region == NULL) return NULL; + if (sa == NULL) { + return NULL; + } + if (region == NULL) { + return NULL; + } if (region->regiontype != RGN_TYPE_WINDOW) { ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); return ar ? &(ar->v2d) : NULL; @@ -2381,16 +2516,24 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C) */ void UI_view2d_scale_get(View2D *v2d, float *x, float *y) { - if (x) *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur); - if (y) *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur); + if (x) { + *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur); + } + if (y) { + *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur); + } } /** * Same as ``UI_view2d_scale_get() - 1.0f / x, y`` */ void UI_view2d_scale_get_inverse(View2D *v2d, float *x, float *y) { - if (x) *x = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); - if (y) *y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); + if (x) { + *x = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); + } + if (y) { + *y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); + } } /** @@ -2400,8 +2543,12 @@ void UI_view2d_scale_get_inverse(View2D *v2d, float *x, float *y) void UI_view2d_center_get(struct View2D *v2d, float *x, float *y) { /* get center */ - if (x) *x = BLI_rctf_cent_x(&v2d->cur); - if (y) *y = BLI_rctf_cent_y(&v2d->cur); + if (x) { + *x = BLI_rctf_cent_x(&v2d->cur); + } + if (y) { + *y = BLI_rctf_cent_y(&v2d->cur); + } } void UI_view2d_center_set(struct View2D *v2d, float x, float y) { @@ -2465,10 +2612,14 @@ char UI_view2d_mouse_in_scrollers_ex( /* check if within scrollbars */ if (scroll & V2D_SCROLL_HORIZONTAL) { - if (IN_2D_HORIZ_SCROLL(v2d, co)) return 'h'; + if (IN_2D_HORIZ_SCROLL(v2d, co)) { + return 'h'; + } } if (scroll & V2D_SCROLL_VERTICAL) { - if (IN_2D_VERT_SCROLL(v2d, co)) return 'v'; + if (IN_2D_VERT_SCROLL(v2d, co)) { + return 'v'; + } } /* not found */ @@ -2582,17 +2733,20 @@ void UI_view2d_text_cache_draw(ARegion *ar) int xofs = 0, yofs; yofs = ceil(0.5f * (BLI_rcti_size_y(&v2s->rect) - default_height)); - if (yofs < 1) yofs = 1; + if (yofs < 1) { + yofs = 1; + } if (col_pack_prev != v2s->col.pack) { BLF_color3ubv(font_id, v2s->col.ub); col_pack_prev = v2s->col.pack; } - if (v2s->rect.xmin >= v2s->rect.xmax) + if (v2s->rect.xmin >= v2s->rect.xmax) { BLF_draw_default( (float)(v2s->mval[0] + xofs), (float)(v2s->mval[1] + yofs), 0.0, v2s->str, BLF_DRAW_STR_DUMMY_MAX); + } else { BLF_enable(font_id, BLF_CLIPPING); BLF_clipping(font_id, v2s->rect.xmin - 4, v2s->rect.ymin - 4, v2s->rect.xmax + 4, v2s->rect.ymax + 4); diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index e6cce1f0df9..790b92a357e 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -104,13 +104,15 @@ static int view_pan_init(bContext *C, wmOperator *op) float winx, winy; /* regions now have v2d-data by default, so check for region */ - if (ar == NULL) + if (ar == NULL) { return 0; + } /* check if panning is allowed at all */ v2d = &ar->v2d; - if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y)) + if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y)) { return 0; + } /* set custom-data for operator */ vpd = MEM_callocN(sizeof(v2dViewPanData), "v2dViewPanData"); @@ -138,13 +140,15 @@ static bool view_pan_poll(bContext *C) View2D *v2d; /* check if there's a region in context to work with */ - if (ar == NULL) + if (ar == NULL) { return 0; + } v2d = &ar->v2d; /* check that 2d-view can pan */ - if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y)) + if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y)) { return 0; + } /* view can pan */ return 1; @@ -207,8 +211,9 @@ static void view_pan_exit(wmOperator *op) /* for 'redo' only, with no user input */ static int view_pan_exec(bContext *C, wmOperator *op) { - if (!view_pan_init(C, op)) + if (!view_pan_init(C, op)) { return OPERATOR_CANCELLED; + } view_pan_apply(C, op); view_pan_exit(op); @@ -223,8 +228,9 @@ static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event) View2D *v2d; /* set up customdata */ - if (!view_pan_init(C, op)) + if (!view_pan_init(C, op)) { return OPERATOR_PASS_THROUGH; + } vpd = op->customdata; v2d = vpd->v2d; @@ -246,12 +252,15 @@ static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event) RNA_int_set(op->ptr, "deltax", 0); RNA_int_set(op->ptr, "deltay", 0); - if (v2d->keepofs & V2D_LOCKOFS_X) + if (v2d->keepofs & V2D_LOCKOFS_X) { WM_cursor_modal_set(window, BC_NS_SCROLLCURSOR); - else if (v2d->keepofs & V2D_LOCKOFS_Y) + } + else if (v2d->keepofs & V2D_LOCKOFS_Y) { WM_cursor_modal_set(window, BC_EW_SCROLLCURSOR); - else + } + else { WM_cursor_modal_set(window, BC_NSEW_SCROLLCURSOR); + } /* add temp handler */ WM_event_add_modal_handler(C, op); @@ -347,8 +356,9 @@ static int view_scrollright_exec(bContext *C, wmOperator *op) v2dViewPanData *vpd; /* initialize default settings (and validate if ok to run) */ - if (!view_pan_init(C, op)) + if (!view_pan_init(C, op)) { return OPERATOR_PASS_THROUGH; + } /* also, check if can pan in horizontal axis */ vpd = op->customdata; @@ -391,8 +401,9 @@ static int view_scrollleft_exec(bContext *C, wmOperator *op) v2dViewPanData *vpd; /* initialize default settings (and validate if ok to run) */ - if (!view_pan_init(C, op)) + if (!view_pan_init(C, op)) { return OPERATOR_PASS_THROUGH; + } /* also, check if can pan in horizontal axis */ vpd = op->customdata; @@ -434,8 +445,9 @@ static int view_scrolldown_exec(bContext *C, wmOperator *op) v2dViewPanData *vpd; /* initialize default settings (and validate if ok to run) */ - if (!view_pan_init(C, op)) + if (!view_pan_init(C, op)) { return OPERATOR_PASS_THROUGH; + } /* also, check if can pan in vertical axis */ vpd = op->customdata; @@ -485,8 +497,9 @@ static int view_scrollup_exec(bContext *C, wmOperator *op) v2dViewPanData *vpd; /* initialize default settings (and validate if ok to run) */ - if (!view_pan_init(C, op)) + if (!view_pan_init(C, op)) { return OPERATOR_PASS_THROUGH; + } /* also, check if can pan in vertical axis */ vpd = op->customdata; @@ -577,8 +590,9 @@ static void view_zoom_axis_lock_defaults(bContext *C, bool r_do_zoom_xy[2]) if (sa && sa->spacetype == SPACE_SEQ) { ARegion *ar = CTX_wm_region(C); - if (ar && ar->regiontype == RGN_TYPE_WINDOW) + if (ar && ar->regiontype == RGN_TYPE_WINDOW) { r_do_zoom_xy[1] = false; + } } } @@ -590,13 +604,15 @@ static int view_zoomdrag_init(bContext *C, wmOperator *op) View2D *v2d; /* regions now have v2d-data by default, so check for region */ - if (ar == NULL) + if (ar == NULL) { return 0; + } v2d = &ar->v2d; /* check that 2d-view is zoomable */ - if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y)) + if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y)) { return 0; + } /* set custom-data for operator */ vzd = MEM_callocN(sizeof(v2dViewZoomData), "v2dViewZoomData"); @@ -616,18 +632,21 @@ static bool view_zoom_poll(bContext *C) View2D *v2d; /* check if there's a region in context to work with */ - if (ar == NULL) + if (ar == NULL) { return false; + } /* Do not show that in 3DView context. */ - if (CTX_wm_region_view3d(C)) + if (CTX_wm_region_view3d(C)) { return false; + } v2d = &ar->v2d; /* check that 2d-view is zoomable */ - if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y)) + if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y)) { return false; + } /* view is zoomable */ return true; @@ -662,10 +681,12 @@ static void view_zoomstep_apply_ex( v2d->cur.xmax -= 2 * dx; } else if (v2d->keepofs & V2D_KEEPOFS_X) { - if (v2d->align & V2D_ALIGN_NO_POS_X) + if (v2d->align & V2D_ALIGN_NO_POS_X) { v2d->cur.xmin += 2 * dx; - else + } + else { v2d->cur.xmax -= 2 * dx; + } } else { @@ -696,10 +717,12 @@ static void view_zoomstep_apply_ex( v2d->cur.ymax -= 2 * dy; } else if (v2d->keepofs & V2D_KEEPOFS_Y) { - if (v2d->align & V2D_ALIGN_NO_POS_Y) + if (v2d->align & V2D_ALIGN_NO_POS_Y) { v2d->cur.ymin += 2 * dy; - else + } + else { v2d->cur.ymax -= 2 * dy; + } } else { @@ -768,8 +791,9 @@ static int view_zoomin_exec(bContext *C, wmOperator *op) bool do_zoom_xy[2]; /* check that there's an active region, as View2D data resides there */ - if (!view_zoom_poll(C)) + if (!view_zoom_poll(C)) { return OPERATOR_PASS_THROUGH; + } view_zoom_axis_lock_defaults(C, do_zoom_xy); @@ -790,8 +814,9 @@ static int view_zoomin_invoke(bContext *C, wmOperator *op, const wmEvent *event) { v2dViewZoomData *vzd; - if (!view_zoomdrag_init(C, op)) + if (!view_zoomdrag_init(C, op)) { return OPERATOR_PASS_THROUGH; + } vzd = op->customdata; @@ -835,8 +860,9 @@ static int view_zoomout_exec(bContext *C, wmOperator *op) bool do_zoom_xy[2]; /* check that there's an active region, as View2D data resides there */ - if (!view_zoom_poll(C)) + if (!view_zoom_poll(C)) { return OPERATOR_PASS_THROUGH; + } view_zoom_axis_lock_defaults(C, do_zoom_xy); @@ -856,8 +882,9 @@ static int view_zoomout_invoke(bContext *C, wmOperator *op, const wmEvent *event { v2dViewZoomData *vzd; - if (!view_zoomdrag_init(C, op)) + if (!view_zoomdrag_init(C, op)) { return OPERATOR_PASS_THROUGH; + } vzd = op->customdata; @@ -995,8 +1022,9 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op) if (op->customdata) { v2dViewZoomData *vzd = op->customdata; - if (vzd->timer) + if (vzd->timer) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), vzd->timer); + } MEM_freeN(op->customdata); op->customdata = NULL; @@ -1011,8 +1039,9 @@ static void view_zoomdrag_cancel(bContext *C, wmOperator *op) /* for 'redo' only, with no user input */ static int view_zoomdrag_exec(bContext *C, wmOperator *op) { - if (!view_zoomdrag_init(C, op)) + if (!view_zoomdrag_init(C, op)) { return OPERATOR_PASS_THROUGH; + } view_zoomdrag_apply(C, op); view_zoomdrag_exit(C, op); @@ -1027,8 +1056,9 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even View2D *v2d; /* set up customdata */ - if (!view_zoomdrag_init(C, op)) + if (!view_zoomdrag_init(C, op)) { return OPERATOR_PASS_THROUGH; + } vzd = op->customdata; v2d = vzd->v2d; @@ -1044,17 +1074,20 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even */ fac = 0.01f * (event->prevx - event->x); dx = fac * BLI_rctf_size_x(&v2d->cur) / 10.0f; - if (event->type == MOUSEPAN) + if (event->type == MOUSEPAN) { fac = 0.01f * (event->prevy - event->y); + } dy = fac * BLI_rctf_size_y(&v2d->cur) / 10.0f; /* support trackpad zoom to always zoom entirely - the v2d code uses portrait or * landscape exceptions */ if (v2d->keepzoom & V2D_KEEPASPECT) { - if (fabsf(dx) > fabsf(dy)) + if (fabsf(dx) > fabsf(dy)) { dy = dx; - else + } + else { dx = dy; + } } RNA_float_set(op->ptr, "deltax", dx); RNA_float_set(op->ptr, "deltay", dy); @@ -1083,12 +1116,15 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even &vzd->mx_2d, &vzd->my_2d); } - if (v2d->keepofs & V2D_LOCKOFS_X) + if (v2d->keepofs & V2D_LOCKOFS_X) { WM_cursor_modal_set(window, BC_NS_SCROLLCURSOR); - else if (v2d->keepofs & V2D_LOCKOFS_Y) + } + else if (v2d->keepofs & V2D_LOCKOFS_Y) { WM_cursor_modal_set(window, BC_EW_SCROLLCURSOR); - else + } + else { WM_cursor_modal_set(window, BC_NSEW_SCROLLCURSOR); + } /* add temp handler */ WM_event_add_modal_handler(C, op); @@ -1136,8 +1172,9 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event float fac, zoomfac = 0.01f; /* some view2d's (graph) don't have min/max zoom, or extreme ones */ - if (v2d->maxzoom > 0.0f) + if (v2d->maxzoom > 0.0f) { zoomfac = clamp_f(0.001f * v2d->maxzoom, 0.001f, 0.01f); + } /* x-axis transform */ fac = zoomfac * (event->x - vzd->lastx); @@ -1152,10 +1189,12 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event /* support zoom to always zoom entirely - the v2d code uses portrait or * landscape exceptions */ if (v2d->keepzoom & V2D_KEEPASPECT) { - if (fabsf(dx) > fabsf(dy)) + if (fabsf(dx) > fabsf(dy)) { dy = dx; - else + } + else { dx = dy; + } } /* set transform amount, and add current deltas to stored total delta (for redo) */ @@ -1180,15 +1219,19 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event if (event->val == KM_RELEASE) { /* for redo, store the overall deltas - need to respect zoom-locks here... */ - if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) + if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { RNA_float_set(op->ptr, "deltax", vzd->dx); - else + } + else { RNA_float_set(op->ptr, "deltax", 0); + } - if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) + if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { RNA_float_set(op->ptr, "deltay", vzd->dy); - else + } + else { RNA_float_set(op->ptr, "deltay", 0); + } /* free customdata */ view_zoomdrag_exit(C, op); @@ -1363,8 +1406,9 @@ static int view2d_ndof_invoke(bContext *C, wmOperator *op, const wmEvent *event) bool do_zoom_xy[2]; - if (U.ndof_flag & NDOF_ZOOM_INVERT) + if (U.ndof_flag & NDOF_ZOOM_INVERT) { zoom_factor = -zoom_factor; + } view_zoom_axis_lock_defaults(C, do_zoom_xy); @@ -1440,12 +1484,16 @@ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b) /* axis translation normalized to scale */ tfac = fabsf(cent_a[i] - cent_b[i]) / min_ff(size_a[i], size_b[i]); fac_max = max_ff(fac_max, tfac); - if (fac_max >= 1.0f) break; + if (fac_max >= 1.0f) { + break; + } /* axis scale difference, x2 so doubling or half gives 1.0f */ tfac = (1.0f - (min_ff(size_a[i], size_b[i]) / max_ff(size_a[i], size_b[i]))) * 2.0f; fac_max = max_ff(fac_max, tfac); - if (fac_max >= 1.0f) break; + if (fac_max >= 1.0f) { + break; + } } return min_ff(fac_max, 1.0f); } @@ -1468,7 +1516,9 @@ void UI_view2d_smooth_view( sms.new_cur = v2d->cur; /* store the options we want to end with */ - if (cur) sms.new_cur = *cur; + if (cur) { + sms.new_cur = *cur; + } if (cur) { fac = smooth_view_rect_to_fac(&v2d->cur, cur); @@ -1477,8 +1527,9 @@ void UI_view2d_smooth_view( if (smooth_viewtx && fac > FLT_EPSILON) { bool changed = false; - if (BLI_rctf_compare(&sms.new_cur, &v2d->cur, FLT_EPSILON) == false) + if (BLI_rctf_compare(&sms.new_cur, &v2d->cur, FLT_EPSILON) == false) { changed = true; + } /* The new view is different from the old one * so animate the view */ @@ -1491,11 +1542,13 @@ void UI_view2d_smooth_view( sms.time_allowed *= (double)fac; /* keep track of running timer! */ - if (v2d->sms == NULL) + if (v2d->sms == NULL) { v2d->sms = MEM_mallocN(sizeof(struct SmoothView2DStore), "smoothview v2d"); + } *v2d->sms = sms; - if (v2d->smooth_timer) + if (v2d->smooth_timer) { WM_event_remove_timer(wm, win, v2d->smooth_timer); + } /* TIMER1 is hardcoded in keymap */ /* max 30 frs/sec */ v2d->smooth_timer = WM_event_add_timer(wm, win, TIMER1, 1.0 / 100.0); @@ -1523,13 +1576,16 @@ static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w float step; /* escape if not our timer */ - if (v2d->smooth_timer == NULL || v2d->smooth_timer != event->customdata) + if (v2d->smooth_timer == NULL || v2d->smooth_timer != event->customdata) { return OPERATOR_PASS_THROUGH; + } - if (sms->time_allowed != 0.0) + if (sms->time_allowed != 0.0) { step = (float)((v2d->smooth_timer->duration) / sms->time_allowed); - else + } + else { step = 1.0f; + } /* end timer */ if (step >= 1.0f) { @@ -1662,14 +1718,24 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ * - 'bubble' fills entire scroller * - 'bubble' completely out of view on either side */ - if ((sh_min <= sc_min) && (sh_max >= sc_max)) in_view = 0; + if ((sh_min <= sc_min) && (sh_max >= sc_max)) { + in_view = 0; + } if (sh_min == sh_max) { - if (sh_min <= sc_min) in_view = 0; - if (sh_max >= sc_max) in_view = 0; + if (sh_min <= sc_min) { + in_view = 0; + } + if (sh_max >= sc_max) { + in_view = 0; + } } else { - if (sh_max <= sc_min) in_view = 0; - if (sh_min >= sc_max) in_view = 0; + if (sh_max <= sc_min) { + in_view = 0; + } + if (sh_min >= sc_max) { + in_view = 0; + } } @@ -1685,16 +1751,21 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ out_min = mouse < (sh_min - V2D_SCROLLER_HANDLE_SIZE); out_max = mouse > (sh_max + V2D_SCROLLER_HANDLE_SIZE); - if (in_bar) + if (in_bar) { return SCROLLHANDLE_BAR; - else if (in_max) + } + else if (in_max) { return SCROLLHANDLE_MAX; - else if (in_min) + } + else if (in_min) { return SCROLLHANDLE_MIN; - else if (out_min) + } + else if (out_min) { return SCROLLHANDLE_MIN_OUTSIDE; - else if (out_max) + } + else if (out_max) { return SCROLLHANDLE_MAX_OUTSIDE; + } /* unlikely to happen, though we just cover it in case */ return SCROLLHANDLE_BAR; @@ -1833,19 +1904,23 @@ static void scroller_activate_apply(bContext *C, wmOperator *op) switch (vsm->zone) { case SCROLLHANDLE_MIN: /* only expand view on axis if zoom is allowed */ - if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X)) + if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X)) { v2d->cur.xmin -= temp; - if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y)) + } + if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y)) { v2d->cur.ymin -= temp; + } break; case SCROLLHANDLE_MAX: /* only expand view on axis if zoom is allowed */ - if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X)) + if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X)) { v2d->cur.xmax += temp; - if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y)) + } + if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y)) { v2d->cur.ymax += temp; + } break; case SCROLLHANDLE_MIN_OUTSIDE: @@ -1925,10 +2000,12 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *e if (event->val == KM_RELEASE) { /* single-click was in empty space outside bubble, so scroll by 1 'page' */ if (ELEM(vsm->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) { - if (vsm->zone == SCROLLHANDLE_MIN_OUTSIDE) + if (vsm->zone == SCROLLHANDLE_MIN_OUTSIDE) { vsm->delta = -vsm->scrollbarwidth * 0.8f; - else if (vsm->zone == SCROLLHANDLE_MAX_OUTSIDE) + } + else if (vsm->zone == SCROLLHANDLE_MAX_OUTSIDE) { vsm->delta = vsm->scrollbarwidth * 0.8f; + } scroller_activate_apply(C, op); scroller_activate_exit(C, op); @@ -2023,10 +2100,12 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent * } /* activate the scroller */ - if (vsm->scroller == 'h') + if (vsm->scroller == 'h') { v2d->scroll_ui |= V2D_SCROLL_H_ACTIVE; - else + } + else { v2d->scroll_ui |= V2D_SCROLL_V_ACTIVE; + } /* still ok, so can add */ WM_event_add_modal_handler(C, op); -- cgit v1.2.3