Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.cc126
-rw-r--r--source/blender/editors/interface/interface_dropboxes.cc2
-rw-r--r--source/blender/editors/interface/interface_panel.cc26
-rw-r--r--source/blender/editors/interface/interface_query.cc2
-rw-r--r--source/blender/editors/interface/interface_region_color_picker.cc2
-rw-r--r--source/blender/editors/interface/interface_region_popover.cc6
-rw-r--r--source/blender/editors/interface/interface_region_search.cc2
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.cc2
-rw-r--r--source/blender/editors/interface/interface_style.cc32
-rw-r--r--source/blender/editors/interface/interface_template_list.cc8
-rw-r--r--source/blender/editors/interface/interface_template_search_menu.cc8
-rw-r--r--source/blender/editors/interface/interface_utils.cc4
-rw-r--r--source/blender/editors/interface/view2d.cc108
-rw-r--r--source/blender/editors/interface/view2d_draw.cc10
-rw-r--r--source/blender/editors/interface/view2d_edge_pan.cc16
-rw-r--r--source/blender/editors/interface/view2d_ops.cc10
-rw-r--r--source/blender/editors/interface/views/grid_view.cc4
17 files changed, 184 insertions, 184 deletions
diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc
index 64f7e035d3f..b2d2fa64fde 100644
--- a/source/blender/editors/interface/interface.cc
+++ b/source/blender/editors/interface/interface.cc
@@ -133,10 +133,10 @@ void ui_block_to_region_fl(const ARegion *region, uiBlock *block, float *r_x, fl
gy += block->panel->ofsy;
}
- *r_x = ((float)getsizex) * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] +
- block->winmat[3][0]));
- *r_y = ((float)getsizey) * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] +
- block->winmat[3][1]));
+ *r_x = float(getsizex) * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] +
+ block->winmat[3][0]));
+ *r_y = float(getsizey) * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] +
+ block->winmat[3][1]));
}
void ui_block_to_window_fl(const ARegion *region, uiBlock *block, float *r_x, float *r_y)
@@ -153,8 +153,8 @@ void ui_block_to_window(const ARegion *region, uiBlock *block, int *r_x, int *r_
ui_block_to_window_fl(region, block, &fx, &fy);
- *r_x = (int)lround(fx);
- *r_y = (int)lround(fy);
+ *r_x = int(lround(fx));
+ *r_y = int(lround(fy));
}
void ui_block_to_region_rctf(const ARegion *region,
@@ -195,13 +195,13 @@ void ui_window_to_block_fl(const ARegion *region, uiBlock *block, float *r_x, fl
const int sx = region->winrct.xmin;
const int sy = region->winrct.ymin;
- const float a = 0.5f * ((float)getsizex) * block->winmat[0][0];
- const float b = 0.5f * ((float)getsizex) * block->winmat[1][0];
- const float c = 0.5f * ((float)getsizex) * (1.0f + block->winmat[3][0]);
+ const float a = 0.5f * float(getsizex) * block->winmat[0][0];
+ const float b = 0.5f * float(getsizex) * block->winmat[1][0];
+ const float c = 0.5f * float(getsizex) * (1.0f + block->winmat[3][0]);
- const float d = 0.5f * ((float)getsizey) * block->winmat[0][1];
- const float e = 0.5f * ((float)getsizey) * block->winmat[1][1];
- const float f = 0.5f * ((float)getsizey) * (1.0f + block->winmat[3][1]);
+ const float d = 0.5f * float(getsizey) * block->winmat[0][1];
+ const float e = 0.5f * float(getsizey) * block->winmat[1][1];
+ const float f = 0.5f * float(getsizey) * (1.0f + block->winmat[3][1]);
const float px = *r_x - sx;
const float py = *r_y - sy;
@@ -232,8 +232,8 @@ void ui_window_to_block(const ARegion *region, uiBlock *block, int *r_x, int *r_
ui_window_to_block_fl(region, block, &fx, &fy);
- *r_x = (int)lround(fx);
- *r_y = (int)lround(fy);
+ *r_x = int(lround(fx));
+ *r_y = int(lround(fy));
}
void ui_window_to_region(const ARegion *region, int *r_x, int *r_y)
@@ -279,8 +279,8 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block)
rcti rect;
ui_but_to_pixelrect(&rect, region, block, static_cast<const uiBut *>(block->buttons.last));
- const float buttons_width = (float)rect.xmax + UI_HEADER_OFFSET;
- const float region_width = (float)region->sizex * U.dpi_fac;
+ const float buttons_width = float(rect.xmax) + UI_HEADER_OFFSET;
+ const float region_width = float(region->sizex) * U.dpi_fac;
if (region_width <= buttons_width) {
return;
@@ -296,7 +296,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block)
}
const float view_scale_x = UI_view2d_scale_get_x(&region->v2d);
- const float segment_width = region_width / (float)sepr_flex_len;
+ const float segment_width = region_width / float(sepr_flex_len);
float offset = 0, remaining_space = region_width - buttons_width;
int i = 0;
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
@@ -502,8 +502,8 @@ static void ui_block_bounds_calc_centered(wmWindow *window, uiBlock *block)
static void ui_block_bounds_calc_centered_pie(uiBlock *block)
{
const int xy[2] = {
- (int)block->pie_data.pie_center_spawned[0],
- (int)block->pie_data.pie_center_spawned[1],
+ int(block->pie_data.pie_center_spawned[0]),
+ int(block->pie_data.pie_center_spawned[1]),
};
UI_block_translate(block, xy[0], xy[1]);
@@ -682,7 +682,7 @@ static int ui_but_calc_float_precision(uiBut *but, double value)
return 0;
}
- int prec = (int)ui_but_get_float_precision(but);
+ int prec = int(ui_but_get_float_precision(but));
/* first check for various special cases:
* * If button is radians, we want additional precision (see T39861).
@@ -1411,7 +1411,7 @@ static bool ui_but_event_property_operator_string(const bContext *C,
ui_def_but_rna__menu,
ui_def_but_rna__panel_type,
ui_def_but_rna__menu_type)) {
- prop_enum_value = (int)but->hardmin;
+ prop_enum_value = int(but->hardmin);
ptr = &but_parent->rnapoin;
prop = but_parent->rnaprop;
prop_enum_value_ok = true;
@@ -1804,7 +1804,7 @@ static void ui_but_predefined_extra_operator_icons_add(uiBut *but)
return;
}
}
- ui_but_extra_operator_icon_add_ptr(but, optype, WM_OP_INVOKE_DEFAULT, (int)icon);
+ ui_but_extra_operator_icon_add_ptr(but, optype, WM_OP_INVOKE_DEFAULT, int(icon));
}
}
@@ -1853,7 +1853,7 @@ static void ui_but_validate(const uiBut *but)
uiButNumber *number_but = (uiButNumber *)but;
if (ELEM(but->pointype, UI_BUT_POIN_CHAR, UI_BUT_POIN_SHORT, UI_BUT_POIN_INT)) {
- BLI_assert((int)number_but->step_size > 0);
+ BLI_assert(int(number_but->step_size) > 0);
}
}
}
@@ -2165,7 +2165,7 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N);
int lvalue;
UI_GET_BUT_VALUE_INIT(but, *value);
- lvalue = (int)*value;
+ lvalue = int(*value);
if (UI_BITBUT_TEST(lvalue, (but->bitnr))) {
is_push = state;
}
@@ -2187,7 +2187,7 @@ 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) {
+ if (*value != double(but->hardmin)) {
is_push = true;
}
break;
@@ -2220,12 +2220,12 @@ 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) {
+ if (int(*value) & int(but->hardmax)) {
is_push = true;
}
}
else {
- if (*value == (double)but->hardmax) {
+ if (*value == double(but->hardmax)) {
is_push = true;
}
}
@@ -2246,7 +2246,7 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
}
if ((but->drawflag & UI_BUT_CHECKBOX_INVERT) && (is_push != -1)) {
- is_push = !((bool)is_push);
+ is_push = !bool(is_push);
}
return is_push;
}
@@ -2315,9 +2315,9 @@ void ui_but_v3_get(uiBut *but, float vec[3])
}
else if (but->pointype == UI_BUT_POIN_CHAR) {
const char *cp = (char *)but->poin;
- vec[0] = ((float)cp[0]) / 255.0f;
- vec[1] = ((float)cp[1]) / 255.0f;
- vec[2] = ((float)cp[2]) / 255.0f;
+ vec[0] = float(cp[0]) / 255.0f;
+ vec[1] = float(cp[1]) / 255.0f;
+ vec[2] = float(cp[2]) / 255.0f;
}
else if (but->pointype == UI_BUT_POIN_FLOAT) {
const float *fp = (float *)but->poin;
@@ -2363,9 +2363,9 @@ void ui_but_v3_set(uiBut *but, const float vec[3])
}
else if (but->pointype == UI_BUT_POIN_CHAR) {
char *cp = (char *)but->poin;
- cp[0] = (char)lround(vec[0] * 255.0f);
- cp[1] = (char)lround(vec[1] * 255.0f);
- cp[2] = (char)lround(vec[2] * 255.0f);
+ cp[0] = char(lround(vec[0] * 255.0f));
+ cp[1] = char(lround(vec[1] * 255.0f));
+ cp[2] = char(lround(vec[2] * 255.0f));
}
else if (but->pointype == UI_BUT_POIN_FLOAT) {
float *fp = (float *)but->poin;
@@ -2572,10 +2572,10 @@ void ui_but_value_set(uiBut *but, double value)
break;
case PROP_INT:
if (RNA_property_array_check(prop)) {
- RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, (int)value);
+ RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, int(value));
}
else {
- RNA_property_int_set(&but->rnapoin, prop, (int)value);
+ RNA_property_int_set(&but->rnapoin, prop, int(value));
}
break;
case PROP_FLOAT:
@@ -2588,7 +2588,7 @@ void ui_but_value_set(uiBut *but, double value)
break;
case PROP_ENUM:
if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
- int ivalue = (int)value;
+ int ivalue = int(value);
/* toggle for enum/flag buttons */
ivalue ^= RNA_property_enum_get(&but->rnapoin, prop);
RNA_property_enum_set(&but->rnapoin, prop, ivalue);
@@ -2621,7 +2621,7 @@ void ui_but_value_set(uiBut *but, double value)
value = round_db_to_int_clamp(value);
}
else if (but->pointype == UI_BUT_POIN_FLOAT) {
- float fval = (float)value;
+ float fval = float(value);
if (fval >= -0.00001f && fval <= 0.00001f) {
/* prevent negative zero */
fval = 0.0f;
@@ -2634,16 +2634,16 @@ void ui_but_value_set(uiBut *but, double value)
value = *but->editval = value;
}
else if (but->pointype == UI_BUT_POIN_CHAR) {
- value = *((char *)but->poin) = (char)value;
+ value = *((char *)but->poin) = char(value);
}
else if (but->pointype == UI_BUT_POIN_SHORT) {
- value = *((short *)but->poin) = (short)value;
+ value = *((short *)but->poin) = short(value);
}
else if (but->pointype == UI_BUT_POIN_INT) {
- value = *((int *)but->poin) = (int)value;
+ value = *((int *)but->poin) = int(value);
}
else if (but->pointype == UI_BUT_POIN_FLOAT) {
- value = *((float *)but->poin) = (float)value;
+ value = *((float *)but->poin) = float(value);
}
}
@@ -2721,7 +2721,7 @@ static void ui_get_but_string_unit(
/* Use precision override? */
if (float_precision == -1) {
/* Sanity checks */
- precision = (int)ui_but_get_float_precision(but);
+ precision = int(ui_but_get_float_precision(but));
if (precision > UI_PRECISION_FLOAT_MAX) {
precision = UI_PRECISION_FLOAT_MAX;
}
@@ -2763,7 +2763,7 @@ static float ui_get_but_step_unit(uiBut *but, float step_default)
BLI_assert(step > 0.0);
- step_final = (step / scale_unit) / (double)UI_PRECISION_FLOAT_SCALE;
+ step_final = (step / scale_unit) / double(UI_PRECISION_FLOAT_SCALE);
if (step == step_unit) {
/* Logic here is to scale by the original 'step_orig'
@@ -2775,7 +2775,7 @@ static float ui_get_but_step_unit(uiBut *but, float step_default)
step_final *= step_orig;
}
- return (float)step_final;
+ return float(step_final);
}
void ui_but_string_get_ex(uiBut *but,
@@ -2904,7 +2904,7 @@ void ui_but_string_get_ex(uiBut *but,
}
}
else {
- BLI_snprintf(str, maxlen, "%d", (int)value);
+ BLI_snprintf(str, maxlen, "%d", int(value));
}
}
}
@@ -3211,10 +3211,10 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
}
/* not that we use hard limits here */
- if (value < (double)but->hardmin) {
+ if (value < double(but->hardmin)) {
value = but->hardmin;
}
- if (value > (double)but->hardmax) {
+ if (value > double(but->hardmax)) {
value = but->hardmax;
}
@@ -3307,8 +3307,8 @@ void ui_but_range_set_soft(uiBut *but)
if (is_array) {
int value_range[2];
RNA_property_int_get_array_range(&but->rnapoin, but->rnaprop, value_range);
- value_min = (double)value_range[0];
- value_max = (double)value_range[1];
+ value_min = double(value_range[0]);
+ value_max = double(value_range[1]);
}
else {
value_min = value_max = ui_but_value_get(but);
@@ -3319,8 +3319,8 @@ void ui_but_range_set_soft(uiBut *but)
float fmin, fmax, fstep, fprecision;
RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision);
- softmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin;
- softmax = (fmax == FLT_MAX) ? (float)1e4 : fmax;
+ softmin = (fmin == -FLT_MAX) ? float(-1e4) : fmin;
+ softmax = (fmax == FLT_MAX) ? float(1e4) : fmax;
// step = fstep; /* UNUSED */
// precision = fprecision; /* UNUSED */
@@ -3328,8 +3328,8 @@ void ui_but_range_set_soft(uiBut *but)
if (is_array && !(subtype == PROP_COLOR && but->rnaindex == 3)) {
float value_range[2];
RNA_property_float_get_array_range(&but->rnapoin, but->rnaprop, value_range);
- value_min = (double)value_range[0];
- value_max = (double)value_range[1];
+ value_min = double(value_range[0]);
+ value_max = double(value_range[1]);
}
else {
value_min = value_max = ui_but_value_get(but);
@@ -3348,8 +3348,8 @@ void ui_but_range_set_soft(uiBut *but)
softmin = soft_range_round_down(value_min, softmin);
}
- if (softmin < (double)but->hardmin) {
- softmin = (double)but->hardmin;
+ if (softmin < double(but->hardmin)) {
+ softmin = double(but->hardmin);
}
}
if (value_max - 1e-10 > softmax) {
@@ -3360,7 +3360,7 @@ void ui_but_range_set_soft(uiBut *but)
softmax = soft_range_round_up(value_max, softmax);
}
- if (softmax > (double)but->hardmax) {
+ if (softmax > double(but->hardmax)) {
softmax = but->hardmax;
}
}
@@ -3810,7 +3810,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
ui_but_build_drawstr_float(but, value);
}
else {
- ui_but_build_drawstr_int(but, (int)value);
+ ui_but_build_drawstr_int(but, int(value));
}
break;
@@ -3843,7 +3843,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
}
else {
UI_GET_BUT_VALUE_INIT(but, value);
- str = WM_key_event_string((short)value, false);
+ str = WM_key_event_string(short(value), false);
}
BLI_snprintf(but->drawstr, UI_MAX_DRAW_STR, "%s%s", but->str, str);
break;
@@ -4573,7 +4573,7 @@ static uiBut *ui_def_but_rna(uiBlock *block,
value = RNA_property_enum_get(ptr, prop);
}
else {
- value = (int)max;
+ value = int(max);
}
const int i = RNA_enum_from_value(item, value);
@@ -5938,7 +5938,7 @@ void UI_but_unit_type_set(uiBut *but, const int unit_type)
int UI_but_unit_type_get(const uiBut *but)
{
- const int ownUnit = (int)but->unit_type;
+ const int ownUnit = int(but->unit_type);
/* own unit define always takes precedence over RNA provided, allowing for overriding
* default value provided in RNA in a few special cases (i.e. Active Keyframe in Graph Edit)
@@ -6663,8 +6663,8 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
/* enum property */
ptr = &but->rnapoin;
prop = but->rnaprop;
- value = (ELEM(but->type, UI_BTYPE_ROW, UI_BTYPE_TAB)) ? (int)but->hardmax :
- (int)ui_but_value_get(but);
+ value = (ELEM(but->type, UI_BTYPE_ROW, UI_BTYPE_TAB)) ? int(but->hardmax) :
+ int(ui_but_value_get(but));
}
else if (but->optype) {
PointerRNA *opptr = UI_but_operator_ptr_get(but);
diff --git a/source/blender/editors/interface/interface_dropboxes.cc b/source/blender/editors/interface/interface_dropboxes.cc
index b72d8d2c238..378162a120e 100644
--- a/source/blender/editors/interface/interface_dropboxes.cc
+++ b/source/blender/editors/interface/interface_dropboxes.cc
@@ -87,7 +87,7 @@ static bool ui_drop_material_poll(bContext *C, wmDrag *drag, const wmEvent *UNUS
static void ui_drop_material_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
{
const ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, ID_MA);
- RNA_int_set(drop->ptr, "session_uuid", (int)id->session_uuid);
+ RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid));
}
static char *ui_drop_material_tooltip(bContext *C,
diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc
index 90572c45e8b..d25302616e5 100644
--- a/source/blender/editors/interface/interface_panel.cc
+++ b/source/blender/editors/interface/interface_panel.cc
@@ -142,7 +142,7 @@ static bool panel_active_animation_changed(ListBase *lb,
}
/* Detect changes in panel expansions. */
- if ((bool)(panel->runtime_flag & PANEL_WAS_CLOSED) != UI_panel_is_closed(panel)) {
+ if (bool(panel->runtime_flag & PANEL_WAS_CLOSED) != UI_panel_is_closed(panel)) {
*r_panel_animation = panel;
return false;
}
@@ -1232,7 +1232,7 @@ void ui_draw_aligned_panel(const uiStyle *style,
rect->xmin,
rect->xmax,
rect->ymax,
- rect->ymax + (int)floor(PNL_HEADER / block->aspect + 0.001f),
+ rect->ymax + int(floor(PNL_HEADER / block->aspect + 0.001f)),
};
if (show_background) {
@@ -1368,7 +1368,7 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
}
if (y_ofs > BLI_rcti_size_y(&v2d->mask)) {
- scaletabs = (float)BLI_rcti_size_y(&v2d->mask) / (float)y_ofs;
+ scaletabs = float(BLI_rcti_size_y(&v2d->mask)) / float(y_ofs);
LISTBASE_FOREACH (PanelCategoryDyn *, pc_dyn, &region->panels_category) {
rcti *rct = &pc_dyn->rect;
@@ -1705,12 +1705,12 @@ static bool uiAlignPanelStep(ARegion *region, const float factor, const bool dra
}
if (ps->new_offset_x != ps->panel->ofsx) {
- const float x = interpf((float)ps->new_offset_x, (float)ps->panel->ofsx, factor);
+ const float x = interpf(float(ps->new_offset_x), float(ps->panel->ofsx), factor);
ps->panel->ofsx = round_fl_to_int(x);
changed = true;
}
if (ps->new_offset_y != ps->panel->ofsy) {
- const float y = interpf((float)ps->new_offset_y, (float)ps->panel->ofsy, factor);
+ const float y = interpf(float(ps->new_offset_y), float(ps->panel->ofsy), factor);
ps->panel->ofsy = round_fl_to_int(y);
changed = true;
}
@@ -1875,13 +1875,13 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
/* Keep the drag position in the region with a small pad to keep the panel visible. */
const int y = clamp_i(event->xy[1], region->winrct.ymin, region->winrct.ymax + DRAG_REGION_PAD);
- float dy = (float)(y - data->starty);
+ float dy = float(y - data->starty);
/* Adjust for region zoom. */
- dy *= BLI_rctf_size_y(&region->v2d.cur) / (float)BLI_rcti_size_y(&region->winrct);
+ dy *= BLI_rctf_size_y(&region->v2d.cur) / float(BLI_rcti_size_y(&region->winrct));
/* Add the movement of the view due to edge scrolling while dragging. */
- dy += ((float)region->v2d.cur.ymin - data->start_cur_ymin);
+ dy += (float(region->v2d.cur.ymin) - data->start_cur_ymin);
panel->ofsy = data->startofsy + round_fl_to_int(dy);
@@ -1902,16 +1902,16 @@ static uiPanelMouseState ui_panel_mouse_state_get(const uiBlock *block,
const int mx,
const int my)
{
- if (!IN_RANGE((float)mx, block->rect.xmin, block->rect.xmax)) {
+ if (!IN_RANGE(float(mx), block->rect.xmin, block->rect.xmax)) {
return PANEL_MOUSE_OUTSIDE;
}
- if (IN_RANGE((float)my, block->rect.ymax, block->rect.ymax + PNL_HEADER)) {
+ if (IN_RANGE(float(my), block->rect.ymax, block->rect.ymax + PNL_HEADER)) {
return PANEL_MOUSE_INSIDE_HEADER;
}
if (!UI_panel_is_closed(panel)) {
- if (IN_RANGE((float)my, block->rect.ymin, block->rect.ymax + PNL_HEADER)) {
+ if (IN_RANGE(float(my), block->rect.ymin, block->rect.ymax + PNL_HEADER)) {
return PANEL_MOUSE_INSIDE_CONTENT;
}
}
@@ -1937,8 +1937,8 @@ static void ui_panel_drag_collapse(const bContext *C,
ARegion *region = CTX_wm_region(C);
LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
- float xy_a_block[2] = {(float)dragcol_data->xy_init[0], (float)dragcol_data->xy_init[1]};
- float xy_b_block[2] = {(float)xy_dst[0], (float)xy_dst[1]};
+ float xy_a_block[2] = {float(dragcol_data->xy_init[0]), float(dragcol_data->xy_init[1])};
+ float xy_b_block[2] = {float(xy_dst[0]), float(xy_dst[1])};
Panel *panel = block->panel;
if (panel == nullptr || (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER))) {
diff --git a/source/blender/editors/interface/interface_query.cc b/source/blender/editors/interface/interface_query.cc
index f084f3e06cb..63dc3017da0 100644
--- a/source/blender/editors/interface/interface_query.cc
+++ b/source/blender/editors/interface/interface_query.cc
@@ -182,7 +182,7 @@ void ui_but_pie_dir(RadialDirection dir, float vec[2])
BLI_assert(dir != UI_RADIAL_NONE);
- angle = DEG2RADF((float)ui_radial_dir_to_angle[dir]);
+ angle = DEG2RADF(float(ui_radial_dir_to_angle[dir]));
vec[0] = cosf(angle);
vec[1] = sinf(angle);
}
diff --git a/source/blender/editors/interface/interface_region_color_picker.cc b/source/blender/editors/interface/interface_region_color_picker.cc
index 72912b8c7f7..b49888005fa 100644
--- a/source/blender/editors/interface/interface_region_color_picker.cc
+++ b/source/blender/editors/interface/interface_region_color_picker.cc
@@ -542,7 +542,7 @@ static void ui_block_colorpicker(uiBlock *block,
UI_UNIT_Y,
&colormode,
0.0,
- (float)PICKER_TYPE_RGB,
+ float(PICKER_TYPE_RGB),
0,
0,
"");
diff --git a/source/blender/editors/interface/interface_region_popover.cc b/source/blender/editors/interface/interface_region_popover.cc
index 17c8d890755..e3bb4056608 100644
--- a/source/blender/editors/interface/interface_region_popover.cc
+++ b/source/blender/editors/interface/interface_region_popover.cc
@@ -146,8 +146,8 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
ui_block_to_window_fl(handle->ctx_region, pup->but->block, &center[0], &center[1]);
/* These variables aren't used for popovers,
* we could add new variables if there is a conflict. */
- block->bounds_offset[0] = (int)center[0];
- block->bounds_offset[1] = (int)center[1];
+ block->bounds_offset[0] = int(center[0]);
+ block->bounds_offset[1] = int(center[1]);
copy_v2_v2_int(handle->prev_bounds_offset, block->bounds_offset);
}
else {
@@ -245,7 +245,7 @@ uiPopupBlockHandle *ui_popover_panel_create(
/* Scale width by changes to Text Style point size. */
const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
pup->ui_size_x = ui_units_x * U.widget_unit *
- (text_points_max / (float)UI_DEFAULT_TEXT_POINTS);
+ (text_points_max / float(UI_DEFAULT_TEXT_POINTS));
}
pup->menu_func = menu_func;
diff --git a/source/blender/editors/interface/interface_region_search.cc b/source/blender/editors/interface/interface_region_search.cc
index fb7810792e9..fdef2c15d82 100644
--- a/source/blender/editors/interface/interface_region_search.cc
+++ b/source/blender/editors/interface/interface_region_search.cc
@@ -44,7 +44,7 @@
#include "interface_intern.h"
#include "interface_regions_intern.hh"
-#define MENU_BORDER (int)(0.3f * U.widget_unit)
+#define MENU_BORDER int(0.3f * U.widget_unit)
/* -------------------------------------------------------------------- */
/** \name Search Box Creation
diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc
index b1621f1a040..74985c50cc1 100644
--- a/source/blender/editors/interface/interface_region_tooltip.cc
+++ b/source/blender/editors/interface/interface_region_tooltip.cc
@@ -56,7 +56,7 @@
#include "interface_regions_intern.hh"
#define UI_TIP_PAD_FAC 1.3f
-#define UI_TIP_PADDING (int)(UI_TIP_PAD_FAC * UI_UNIT_Y)
+#define UI_TIP_PADDING int(UI_TIP_PAD_FAC * UI_UNIT_Y)
#define UI_TIP_MAXWIDTH 600
#define UI_TIP_STR_MAX 1024
diff --git a/source/blender/editors/interface/interface_style.cc b/source/blender/editors/interface/interface_style.cc
index 3895a687033..9493f40548d 100644
--- a/source/blender/editors/interface/interface_style.cc
+++ b/source/blender/editors/interface/interface_style.cc
@@ -319,20 +319,20 @@ const uiStyle *UI_style_get_dpi(void)
_style = *style;
- _style.paneltitle.shadx = (short)(UI_DPI_FAC * _style.paneltitle.shadx);
- _style.paneltitle.shady = (short)(UI_DPI_FAC * _style.paneltitle.shady);
- _style.grouplabel.shadx = (short)(UI_DPI_FAC * _style.grouplabel.shadx);
- _style.grouplabel.shady = (short)(UI_DPI_FAC * _style.grouplabel.shady);
- _style.widgetlabel.shadx = (short)(UI_DPI_FAC * _style.widgetlabel.shadx);
- _style.widgetlabel.shady = (short)(UI_DPI_FAC * _style.widgetlabel.shady);
-
- _style.columnspace = (short)(UI_DPI_FAC * _style.columnspace);
- _style.templatespace = (short)(UI_DPI_FAC * _style.templatespace);
- _style.boxspace = (short)(UI_DPI_FAC * _style.boxspace);
- _style.buttonspacex = (short)(UI_DPI_FAC * _style.buttonspacex);
- _style.buttonspacey = (short)(UI_DPI_FAC * _style.buttonspacey);
- _style.panelspace = (short)(UI_DPI_FAC * _style.panelspace);
- _style.panelouter = (short)(UI_DPI_FAC * _style.panelouter);
+ _style.paneltitle.shadx = short(UI_DPI_FAC * _style.paneltitle.shadx);
+ _style.paneltitle.shady = short(UI_DPI_FAC * _style.paneltitle.shady);
+ _style.grouplabel.shadx = short(UI_DPI_FAC * _style.grouplabel.shadx);
+ _style.grouplabel.shady = short(UI_DPI_FAC * _style.grouplabel.shady);
+ _style.widgetlabel.shadx = short(UI_DPI_FAC * _style.widgetlabel.shadx);
+ _style.widgetlabel.shady = short(UI_DPI_FAC * _style.widgetlabel.shady);
+
+ _style.columnspace = short(UI_DPI_FAC * _style.columnspace);
+ _style.templatespace = short(UI_DPI_FAC * _style.templatespace);
+ _style.boxspace = short(UI_DPI_FAC * _style.boxspace);
+ _style.buttonspacex = short(UI_DPI_FAC * _style.buttonspacex);
+ _style.buttonspacey = short(UI_DPI_FAC * _style.buttonspacey);
+ _style.panelspace = short(UI_DPI_FAC * _style.panelspace);
+ _style.panelouter = short(UI_DPI_FAC * _style.panelouter);
return &_style;
}
@@ -340,7 +340,7 @@ const uiStyle *UI_style_get_dpi(void)
int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str)
{
UI_fontstyle_set(fs);
- return (int)BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
+ return int(BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX));
}
int UI_fontstyle_string_width_with_block_aspect(const uiFontStyle *fs,
@@ -359,7 +359,7 @@ int UI_fontstyle_string_width_with_block_aspect(const uiFontStyle *fs,
if (aspect != 1.0f) {
/* While in most cases rounding up isn't important, it can make a difference
* with small fonts (3px or less), zooming out in the node-editor for e.g. */
- width = (int)ceilf(width * aspect);
+ width = int(ceilf(width * aspect));
}
return width;
}
diff --git a/source/blender/editors/interface/interface_template_list.cc b/source/blender/editors/interface/interface_template_list.cc
index d8a9591a021..f09eb5f3eb0 100644
--- a/source/blender/editors/interface/interface_template_list.cc
+++ b/source/blender/editors/interface/interface_template_list.cc
@@ -519,8 +519,8 @@ static void uilist_prepare(uiList *ui_list,
int activei_row;
if (columns > 1) {
- dyn_data->height = (int)ceil((double)items->tot_items / (double)columns);
- activei_row = (int)floor((double)items->active_item_idx / (double)columns);
+ dyn_data->height = int(ceil(double(items->tot_items) / double(columns)));
+ activei_row = int(floor(double(items->active_item_idx) / double(columns)));
}
else {
dyn_data->height = items->tot_items;
@@ -567,8 +567,8 @@ static void uilist_resize_update_cb(bContext *C, void *arg1, void *UNUSED(arg2))
uiListDyn *dyn_data = ui_list->dyn_data;
/* This way we get diff in number of additional items to show (positive) or hide (negative). */
- const int diff = round_fl_to_int((float)(dyn_data->resize - dyn_data->resize_prev) /
- (float)UI_UNIT_Y);
+ const int diff = round_fl_to_int(float(dyn_data->resize - dyn_data->resize_prev) /
+ float(UI_UNIT_Y));
if (diff != 0) {
ui_list->list_grip += diff;
diff --git a/source/blender/editors/interface/interface_template_search_menu.cc b/source/blender/editors/interface/interface_template_search_menu.cc
index c777b7834f2..f61baf65b58 100644
--- a/source/blender/editors/interface/interface_template_search_menu.cc
+++ b/source/blender/editors/interface/interface_template_search_menu.cc
@@ -191,7 +191,7 @@ static bool menu_items_from_ui_create_item_from_button(MenuSearch_Data *data,
if (drawstr_is_empty) {
if (prop_type == PROP_ENUM) {
- const int value_enum = (int)but->hardmax;
+ const int value_enum = int(but->hardmax);
EnumPropertyItem enum_item;
if (RNA_property_enum_item_from_value_gettexted((bContext *)but->block->evil_C,
&but->rnapoin,
@@ -227,7 +227,7 @@ static bool menu_items_from_ui_create_item_from_button(MenuSearch_Data *data,
item->rna.index = but->rnaindex;
if (prop_type == PROP_ENUM) {
- item->rna.enum_value = (int)but->hardmax;
+ item->rna.enum_value = int(but->hardmax);
}
}
}
@@ -544,8 +544,8 @@ static MenuSearch_Data *menu_items_from_ui_create(
if (wm_contexts[space_type_ui_index].space_type_ui_index != -1) {
ScrArea *area_best = wm_contexts[space_type_ui_index].area;
- const uint value_best = (uint)area_best->winx * (uint)area_best->winy;
- const uint value_test = (uint)area->winx * (uint)area->winy;
+ const uint value_best = uint(area_best->winx) * uint(area_best->winy);
+ const uint value_test = uint(area->winx) * uint(area->winy);
if (value_best > value_test) {
continue;
}
diff --git a/source/blender/editors/interface/interface_utils.cc b/source/blender/editors/interface/interface_utils.cc
index 4b94834ce97..139d3c9353f 100644
--- a/source/blender/editors/interface/interface_utils.cc
+++ b/source/blender/editors/interface/interface_utils.cc
@@ -495,7 +495,7 @@ static bool add_collection_search_item(CollItemSearch *cis,
cis->name,
cis->data,
cis->iconid,
- cis->has_sep_char ? (int)UI_BUT_HAS_SEP_CHAR : 0,
+ cis->has_sep_char ? int(UI_BUT_HAS_SEP_CHAR) : 0,
name_prefix_offset);
}
@@ -787,7 +787,7 @@ int UI_calc_float_precision(int prec, double value)
*/
value = fabs(value);
if ((value < pow10_neg[prec]) && (value > (1.0 / max_pow))) {
- int value_i = (int)lround(value * max_pow);
+ int value_i = int(lround(value * max_pow));
if (value_i != 0) {
const int prec_span = 3; /* show: 0.01001, 5 would allow 0.0100001 for eg. */
int test_prec;
diff --git a/source/blender/editors/interface/view2d.cc b/source/blender/editors/interface/view2d.cc
index 95e5c0ad7d8..bb660d6bf7d 100644
--- a/source/blender/editors/interface/view2d.cc
+++ b/source/blender/editors/interface/view2d.cc
@@ -53,16 +53,16 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize);
BLI_INLINE int clamp_float_to_int(const float f)
{
- const float min = (float)INT_MIN;
- const float max = (float)INT_MAX;
+ const float min = float(INT_MIN);
+ const float max = float(INT_MAX);
if (UNLIKELY(f < min)) {
return min;
}
if (UNLIKELY(f > max)) {
- return (int)max;
+ return int(max);
}
- return (int)f;
+ return int(f);
}
/**
@@ -244,8 +244,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
v2d->keeptot = V2D_KEEPTOT_BOUNDS;
if (do_init) {
v2d->tot.xmin = v2d->tot.ymin = 0.0f;
- v2d->tot.xmax = (float)(winx - 1);
- v2d->tot.ymax = (float)(winy - 1);
+ v2d->tot.xmax = float(winx - 1);
+ v2d->tot.ymax = float(winy - 1);
v2d->cur = v2d->tot;
}
@@ -297,8 +297,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
v2d->tot.ymax = winy;
v2d->cur = v2d->tot;
- v2d->min[0] = v2d->max[0] = (float)(winx - 1);
- v2d->min[1] = v2d->max[1] = (float)(winy - 1);
+ v2d->min[0] = v2d->max[0] = float(winx - 1);
+ v2d->min[1] = v2d->max[1] = float(winy - 1);
}
/* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
@@ -388,8 +388,8 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize)
/* use mask as size of region that View2D resides in, as it takes into account
* scroll-bars already - keep in sync with zoomx/zoomy in #view_zoomstep_apply_ex! */
- winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
- winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
+ winx = float(BLI_rcti_size_x(&v2d->mask) + 1);
+ winy = float(BLI_rcti_size_y(&v2d->mask) + 1);
/* get pointers to rcts for less typing */
cur = &v2d->cur;
@@ -584,8 +584,8 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize)
}
/* store region size for next time */
- v2d->oldwinx = (short)winx;
- v2d->oldwiny = (short)winy;
+ v2d->oldwinx = short(winx);
+ v2d->oldwiny = short(winy);
}
/* Step 2: apply new sizes to cur rect,
@@ -916,8 +916,8 @@ void UI_view2d_curRect_reset(View2D *v2d)
float width, height;
/* assume width and height of 'cur' rect by default, should be same size as mask */
- width = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
- height = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
+ width = float(BLI_rcti_size_x(&v2d->mask) + 1);
+ height = float(BLI_rcti_size_y(&v2d->mask) + 1);
/* handle width - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
@@ -980,17 +980,17 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
/* handle width - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
/* width is in negative-x half */
- v2d->tot.xmin = (float)-width;
+ v2d->tot.xmin = float(-width);
v2d->tot.xmax = 0.0f;
}
else if ((v2d->align & V2D_ALIGN_NO_NEG_X) && !(v2d->align & V2D_ALIGN_NO_POS_X)) {
/* width is in positive-x half */
v2d->tot.xmin = 0.0f;
- v2d->tot.xmax = (float)width;
+ v2d->tot.xmax = float(width);
}
else {
/* width is centered around (x == 0) */
- const float dx = (float)width / 2.0f;
+ const float dx = float(width) / 2.0f;
v2d->tot.xmin = -dx;
v2d->tot.xmax = dx;
@@ -999,17 +999,17 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
/* handle height - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
/* height is in negative-y half */
- v2d->tot.ymin = (float)-height;
+ v2d->tot.ymin = float(-height);
v2d->tot.ymax = 0.0f;
}
else if ((v2d->align & V2D_ALIGN_NO_NEG_Y) && !(v2d->align & V2D_ALIGN_NO_POS_Y)) {
/* height is in positive-y half */
v2d->tot.ymin = 0.0f;
- v2d->tot.ymax = (float)height;
+ v2d->tot.ymax = float(height);
}
else {
/* height is centered around (y == 0) */
- const float dy = (float)height / 2.0f;
+ const float dy = float(height) / 2.0f;
v2d->tot.ymin = -dy;
v2d->tot.ymax = dy;
@@ -1062,17 +1062,17 @@ static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked)
const float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1);
if (v2d->mask.xmin != 0) {
- r_curmasked->xmin -= dx * (float)v2d->mask.xmin;
+ r_curmasked->xmin -= dx * float(v2d->mask.xmin);
}
if (v2d->mask.xmax + 1 != v2d->winx) {
- r_curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1);
+ r_curmasked->xmax += dx * float(v2d->winx - v2d->mask.xmax - 1);
}
if (v2d->mask.ymin != 0) {
- r_curmasked->ymin -= dy * (float)v2d->mask.ymin;
+ r_curmasked->ymin -= dy * float(v2d->mask.ymin);
}
if (v2d->mask.ymax + 1 != v2d->winy) {
- r_curmasked->ymax += dy * (float)(v2d->winy - v2d->mask.ymax - 1);
+ r_curmasked->ymax += dy * float(v2d->winy - v2d->mask.ymax - 1);
}
}
}
@@ -1151,7 +1151,7 @@ void UI_view2d_view_restore(const bContext *C)
const int width = BLI_rcti_size_x(&region->winrct) + 1;
const int height = BLI_rcti_size_y(&region->winrct) + 1;
- wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
+ wmOrtho2(0.0f, float(width), 0.0f, float(height));
GPU_matrix_identity_set();
// ED_region_pixelspace(CTX_wm_region(C));
@@ -1177,8 +1177,8 @@ void UI_view2d_multi_grid_draw(
/* Make an estimate of at least how many vertices will be needed */
uint vertex_count = 4;
- vertex_count += 2 * ((int)((v2d->cur.xmax - v2d->cur.xmin) / lstep) + 1);
- vertex_count += 2 * ((int)((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1);
+ vertex_count += 2 * (int((v2d->cur.xmax - v2d->cur.xmin) / lstep) + 1);
+ vertex_count += 2 * (int((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1);
GPUVertFormat *format = immVertexFormat();
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -1195,7 +1195,7 @@ void UI_view2d_multi_grid_draw(
* or high contrast grid lines. This only has an effect if colorid != TH_GRID. */
UI_GetThemeColorBlendShade3ubv(colorid, TH_GRID, 0.25f, offset, grid_line_color);
- int i = (int)(v2d->cur.xmin / lstep);
+ int i = int(v2d->cur.xmin / lstep);
if (v2d->cur.xmin > 0.0f) {
i++;
}
@@ -1212,7 +1212,7 @@ void UI_view2d_multi_grid_draw(
immVertex2f(pos, start, v2d->cur.ymax);
}
- i = (int)(v2d->cur.ymin / lstep);
+ i = int(v2d->cur.ymin / lstep);
if (v2d->cur.ymin > 0.0f) {
i++;
}
@@ -1256,10 +1256,10 @@ static void grid_axis_start_and_count(
{
*r_start = min;
if (*r_start < 0.0f) {
- *r_start += -(float)fmod(min, step);
+ *r_start += -float(fmod(min, step));
}
else {
- *r_start += step - (float)fabs(fmod(min, step));
+ *r_start += step - float(fabs(fmod(min, step)));
}
if (*r_start > max) {
@@ -1280,7 +1280,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d,
return;
}
- const float zoom_x = (float)(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur);
+ const float zoom_x = float(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur);
GPUVertFormat *format = immVertexFormat();
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -1296,7 +1296,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d,
const int subdivision_scale = 5;
const float view_level = logf(min_step / zoom_x) / logf(subdivision_scale);
- const int largest_visible_level = (int)view_level;
+ const int largest_visible_level = int(view_level);
for (int level_offset = 0; level_offset <= grid_subdivisions; level_offset++) {
const int level = largest_visible_level - level_offset;
@@ -1408,7 +1408,7 @@ void UI_view2d_scrollers_calc(View2D *v2d,
vert.ymax -= UI_HEADER_OFFSET;
/* width of sliders */
- smaller = (int)(0.1f * U.widget_unit);
+ smaller = int(0.1f * U.widget_unit);
if (scroll & V2D_SCROLL_BOTTOM) {
hor.ymin += smaller;
}
@@ -1439,7 +1439,7 @@ void UI_view2d_scrollers_calc(View2D *v2d,
if (scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller 'button' extents */
totsize = BLI_rctf_size_x(&v2d->tot);
- scrollsize = (float)BLI_rcti_size_x(&hor);
+ scrollsize = float(BLI_rcti_size_x(&hor));
if (totsize == 0.0f) {
totsize = 1.0f; /* avoid divide by zero */
}
@@ -1449,7 +1449,7 @@ void UI_view2d_scrollers_calc(View2D *v2d,
r_scrollers->hor_min = hor.xmin;
}
else {
- r_scrollers->hor_min = (int)(hor.xmin + (fac1 * scrollsize));
+ r_scrollers->hor_min = int(hor.xmin + (fac1 * scrollsize));
}
fac2 = (v2d->cur.xmax - v2d->tot.xmin) / totsize;
@@ -1457,7 +1457,7 @@ void UI_view2d_scrollers_calc(View2D *v2d,
r_scrollers->hor_max = hor.xmax;
}
else {
- r_scrollers->hor_max = (int)(hor.xmin + (fac2 * scrollsize));
+ r_scrollers->hor_max = int(hor.xmin + (fac2 * scrollsize));
}
/* prevent inverted sliders */
@@ -1477,7 +1477,7 @@ void UI_view2d_scrollers_calc(View2D *v2d,
if (scroll & V2D_SCROLL_VERTICAL) {
/* scroller 'button' extents */
totsize = BLI_rctf_size_y(&v2d->tot);
- scrollsize = (float)BLI_rcti_size_y(&vert);
+ scrollsize = float(BLI_rcti_size_y(&vert));
if (totsize == 0.0f) {
totsize = 1.0f; /* avoid divide by zero */
}
@@ -1487,7 +1487,7 @@ void UI_view2d_scrollers_calc(View2D *v2d,
r_scrollers->vert_min = vert.ymin;
}
else {
- r_scrollers->vert_min = (int)(vert.ymin + (fac1 * scrollsize));
+ r_scrollers->vert_min = int(vert.ymin + (fac1 * scrollsize));
}
fac2 = (v2d->cur.ymax - v2d->tot.ymin) / totsize;
@@ -1495,7 +1495,7 @@ void UI_view2d_scrollers_calc(View2D *v2d,
r_scrollers->vert_max = vert.ymax;
}
else {
- r_scrollers->vert_max = (int)(vert.ymin + (fac2 * scrollsize));
+ r_scrollers->vert_max = int(vert.ymin + (fac2 * scrollsize));
}
/* prevent inverted sliders */
@@ -1673,8 +1673,8 @@ void UI_view2d_region_to_view(
void UI_view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst)
{
const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)};
- const float mask_size[2] = {(float)BLI_rcti_size_x(&v2d->mask),
- (float)BLI_rcti_size_y(&v2d->mask)};
+ const float mask_size[2] = {float(BLI_rcti_size_x(&v2d->mask)),
+ float(BLI_rcti_size_y(&v2d->mask))};
rect_dst->xmin = (v2d->cur.xmin +
(cur_size[0] * (rect_src->xmin - v2d->mask.xmin) / mask_size[0]));
@@ -1706,8 +1706,8 @@ bool UI_view2d_view_to_region_clip(
/* check if values are within bounds */
if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) {
- *r_region_x = (int)(v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask)));
- *r_region_y = (int)(v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask)));
+ *r_region_x = int(v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask)));
+ *r_region_y = int(v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask)));
return true;
}
@@ -1770,10 +1770,10 @@ bool UI_view2d_view_to_region_segment_clip(const View2D *v2d,
r_region_a[0] = r_region_b[0] = r_region_a[1] = r_region_b[1] = V2D_IS_CLIPPED;
if (BLI_rctf_isect_segment(&rect_unit, s_a, s_b)) {
- r_region_a[0] = (int)(v2d->mask.xmin + (s_a[0] * BLI_rcti_size_x(&v2d->mask)));
- r_region_a[1] = (int)(v2d->mask.ymin + (s_a[1] * BLI_rcti_size_y(&v2d->mask)));
- r_region_b[0] = (int)(v2d->mask.xmin + (s_b[0] * BLI_rcti_size_x(&v2d->mask)));
- r_region_b[1] = (int)(v2d->mask.ymin + (s_b[1] * BLI_rcti_size_y(&v2d->mask)));
+ r_region_a[0] = int(v2d->mask.xmin + (s_a[0] * BLI_rcti_size_x(&v2d->mask)));
+ r_region_a[1] = int(v2d->mask.ymin + (s_a[1] * BLI_rcti_size_y(&v2d->mask)));
+ r_region_b[0] = int(v2d->mask.xmin + (s_b[0] * BLI_rcti_size_x(&v2d->mask)));
+ r_region_b[1] = int(v2d->mask.ymin + (s_b[1] * BLI_rcti_size_y(&v2d->mask)));
return true;
}
@@ -1784,8 +1784,8 @@ bool UI_view2d_view_to_region_segment_clip(const View2D *v2d,
void UI_view2d_view_to_region_rcti(const View2D *v2d, const rctf *rect_src, rcti *rect_dst)
{
const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)};
- const float mask_size[2] = {(float)BLI_rcti_size_x(&v2d->mask),
- (float)BLI_rcti_size_y(&v2d->mask)};
+ const float mask_size[2] = {float(BLI_rcti_size_x(&v2d->mask)),
+ float(BLI_rcti_size_y(&v2d->mask))};
rctf rect_tmp;
/* Step 1: express given coordinates as proportional values. */
@@ -1814,8 +1814,8 @@ void UI_view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4])
bool UI_view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src, rcti *rect_dst)
{
const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)};
- const float mask_size[2] = {(float)BLI_rcti_size_x(&v2d->mask),
- (float)BLI_rcti_size_y(&v2d->mask)};
+ const float mask_size[2] = {float(BLI_rcti_size_x(&v2d->mask)),
+ float(BLI_rcti_size_y(&v2d->mask))};
rctf rect_tmp;
BLI_assert(rect_src->xmin <= rect_src->xmax && rect_src->ymin <= rect_src->ymax);
@@ -2153,8 +2153,8 @@ void UI_view2d_text_cache_draw(ARegion *region)
/* Don't use clipping if `v2s->rect` is not set. */
if (BLI_rcti_size_x(&v2s->rect) == 0 && BLI_rcti_size_y(&v2s->rect) == 0) {
- BLF_draw_default((float)(v2s->mval[0] + xofs),
- (float)(v2s->mval[1] + yofs),
+ BLF_draw_default(float(v2s->mval[0] + xofs),
+ float(v2s->mval[1] + yofs),
0.0,
v2s->str,
BLF_DRAW_STR_DUMMY_MAX);
diff --git a/source/blender/editors/interface/view2d_draw.cc b/source/blender/editors/interface/view2d_draw.cc
index ea4cf399a57..ca96c2abb9d 100644
--- a/source/blender/editors/interface/view2d_draw.cc
+++ b/source/blender/editors/interface/view2d_draw.cc
@@ -319,11 +319,11 @@ static void draw_horizontal_scale_indicators(const ARegion *region,
const float right_text_width = BLF_width(font_id, text, strlen(text));
const float max_text_width = max_ff(left_text_width, right_text_width);
const float max_label_count = BLI_rcti_size_x(&v2d->mask) / (max_text_width + 10.0f);
- draw_frequency = ceil((float)steps / max_label_count);
+ draw_frequency = ceil(float(steps) / max_label_count);
}
if (draw_frequency != 0) {
- const int start_index = abs((int)(start / distance)) % draw_frequency;
+ const int start_index = abs(int(start / distance)) % draw_frequency;
for (uint i = start_index; i < steps; i += draw_frequency) {
const float xpos_view = start + i * distance;
const float xpos_region = UI_view2d_view_to_region_x(v2d, xpos_view);
@@ -410,7 +410,7 @@ static void draw_vertical_scale_indicators(const ARegion *region,
static void view_to_string__frame_number(
void *UNUSED(user_data), float v2d_pos, float UNUSED(v2d_step), uint max_len, char *r_str)
{
- BLI_snprintf(r_str, max_len, "%d", (int)v2d_pos);
+ BLI_snprintf(r_str, max_len, "%d", int(v2d_pos));
}
static void view_to_string__time(
@@ -424,14 +424,14 @@ static void view_to_string__time(
}
BLI_timecode_string_from_time(
- r_str, max_len, brevity_level, v2d_pos / (float)FPS, FPS, U.timecode_style);
+ r_str, max_len, brevity_level, v2d_pos / float(FPS), FPS, U.timecode_style);
}
static void view_to_string__value(
void *UNUSED(user_data), float v2d_pos, float v2d_step, uint max_len, char *r_str)
{
if (v2d_step >= 1.0f) {
- BLI_snprintf(r_str, max_len, "%d", (int)v2d_pos);
+ BLI_snprintf(r_str, max_len, "%d", int(v2d_pos));
}
else if (v2d_step >= 0.1f) {
BLI_snprintf(r_str, max_len, "%.1f", v2d_pos);
diff --git a/source/blender/editors/interface/view2d_edge_pan.cc b/source/blender/editors/interface/view2d_edge_pan.cc
index 82959d96043..2d8c6970332 100644
--- a/source/blender/editors/interface/view2d_edge_pan.cc
+++ b/source/blender/editors/interface/view2d_edge_pan.cc
@@ -80,8 +80,8 @@ void UI_view2d_edge_pan_init(bContext *C,
vpd->enabled = false;
/* Calculate translation factor, based on size of view. */
- const float winx = (float)(BLI_rcti_size_x(&vpd->region->winrct) + 1);
- const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1);
+ const float winx = float(BLI_rcti_size_x(&vpd->region->winrct) + 1);
+ const float winy = float(BLI_rcti_size_y(&vpd->region->winrct) + 1);
vpd->facx = (BLI_rctf_size_x(&vpd->v2d->cur)) / winx;
vpd->facy = (BLI_rctf_size_y(&vpd->v2d->cur)) / winy;
@@ -165,16 +165,16 @@ static float edge_pan_speed(View2DEdgePanData *vpd,
/* Apply a fade in to the speed based on a start time delay. */
const double start_time = x_dir ? vpd->edge_pan_start_time_x : vpd->edge_pan_start_time_y;
const float delay_factor = vpd->delay > 0.01f ?
- smootherstep(vpd->delay, (float)(current_time - start_time)) :
+ smootherstep(vpd->delay, float(current_time - start_time)) :
1.0f;
/* Zoom factor increases speed when zooming in and decreases speed when zooming out. */
- const float zoomx = (float)(BLI_rcti_size_x(&region->winrct) + 1) /
+ const float zoomx = float(BLI_rcti_size_x(&region->winrct) + 1) /
BLI_rctf_size_x(&region->v2d.cur);
const float zoom_factor = 1.0f + CLAMPIS(vpd->zoom_influence, 0.0f, 1.0f) * (zoomx - 1.0f);
return distance_factor * delay_factor * zoom_factor * vpd->max_speed * U.widget_unit *
- (float)U.dpi_fac;
+ float(U.dpi_fac);
}
static void edge_pan_apply_delta(bContext *C, View2DEdgePanData *vpd, float dx, float dy)
@@ -252,15 +252,15 @@ void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, const int xy[
edge_pan_manage_delay_timers(vpd, pan_dir_x, pan_dir_y, current_time);
/* Calculate the delta since the last time the operator was called. */
- const float dtime = (float)(current_time - vpd->edge_pan_last_time);
+ const float dtime = float(current_time - vpd->edge_pan_last_time);
float dx = 0.0f, dy = 0.0f;
if (pan_dir_x != 0) {
const float speed = edge_pan_speed(vpd, xy[0], true, current_time);
- dx = dtime * speed * (float)pan_dir_x;
+ dx = dtime * speed * float(pan_dir_x);
}
if (pan_dir_y != 0) {
const float speed = edge_pan_speed(vpd, xy[1], false, current_time);
- dy = dtime * speed * (float)pan_dir_y;
+ dy = dtime * speed * float(pan_dir_y);
}
vpd->edge_pan_last_time = current_time;
diff --git a/source/blender/editors/interface/view2d_ops.cc b/source/blender/editors/interface/view2d_ops.cc
index 5f7d82e7b9a..1df2acd5ef7 100644
--- a/source/blender/editors/interface/view2d_ops.cc
+++ b/source/blender/editors/interface/view2d_ops.cc
@@ -127,8 +127,8 @@ static void view_pan_init(bContext *C, wmOperator *op)
vpd->v2d = &vpd->region->v2d;
/* calculate translation factor - based on size of view */
- const float winx = (float)(BLI_rcti_size_x(&vpd->region->winrct) + 1);
- const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1);
+ const float winx = float(BLI_rcti_size_x(&vpd->region->winrct) + 1);
+ const float winy = float(BLI_rcti_size_y(&vpd->region->winrct) + 1);
vpd->facx = (BLI_rctf_size_x(&vpd->v2d->cur)) / winx;
vpd->facy = (BLI_rctf_size_y(&vpd->v2d->cur)) / winy;
@@ -712,7 +712,7 @@ static void view_zoomstep_apply_ex(bContext *C,
if (vzd->zoom_to_mouse_pos) {
/* get zoom fac the same way as in
* ui_view2d_curRect_validate_resize - better keep in sync! */
- const float zoomx = (float)(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur);
+ const float zoomx = float(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur);
/* only move view to mouse if zoom fac is inside minzoom/maxzoom */
if (((v2d->keepzoom & V2D_LIMITZOOM) == 0) ||
@@ -747,7 +747,7 @@ static void view_zoomstep_apply_ex(bContext *C,
if (vzd->zoom_to_mouse_pos) {
/* get zoom fac the same way as in
* ui_view2d_curRect_validate_resize - better keep in sync! */
- const float zoomy = (float)(BLI_rcti_size_y(&v2d->mask) + 1) / BLI_rctf_size_y(&v2d->cur);
+ const float zoomy = float(BLI_rcti_size_y(&v2d->mask) + 1) / BLI_rctf_size_y(&v2d->cur);
/* only move view to mouse if zoom fac is inside minzoom/maxzoom */
if (((v2d->keepzoom & V2D_LIMITZOOM) == 0) ||
@@ -958,7 +958,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
* never uses the "Continuous" zoom method, and the 'timer' is not initialized. */
if ((U.viewzoom == USER_ZOOM_CONTINUE) && vzd->timer) { /* XXX store this setting as RNA prop? */
const double time = PIL_check_seconds_timer();
- const float time_step = (float)(time - vzd->timer_lastdraw);
+ const float time_step = float(time - vzd->timer_lastdraw);
dx *= time_step * 5.0f;
dy *= time_step * 5.0f;
diff --git a/source/blender/editors/interface/views/grid_view.cc b/source/blender/editors/interface/views/grid_view.cc
index 52ff1460cbd..ee2fa87b1dc 100644
--- a/source/blender/editors/interface/views/grid_view.cc
+++ b/source/blender/editors/interface/views/grid_view.cc
@@ -237,7 +237,7 @@ IndexRange BuildOnlyVisibleButtonsHelper::get_visible_range() const
const float scroll_ofs_y = abs(v2d_.cur.ymax - v2d_.tot.ymax);
if (!IS_EQF(scroll_ofs_y, 0)) {
- const int scrolled_away_rows = (int)scroll_ofs_y / style_.tile_height;
+ const int scrolled_away_rows = int(scroll_ofs_y) / style_.tile_height;
first_idx_in_view = scrolled_away_rows * cols_per_row_;
}
@@ -263,7 +263,7 @@ void BuildOnlyVisibleButtonsHelper::fill_layout_before_visible(uiBlock &block) c
return;
}
- const int scrolled_away_rows = (int)scroll_ofs_y / style_.tile_height;
+ const int scrolled_away_rows = int(scroll_ofs_y) / style_.tile_height;
add_spacer_button(block, scrolled_away_rows);
}