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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-08-26 03:11:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-08-26 03:31:44 +0300
commitadd48c007428419ca57a899331e79d934cb1799b (patch)
treec870c0a5718eaccafe4e5fc563984a7f419b0f25 /source
parent88ada5e218835f060a23cbe0f1f2da7452e81b07 (diff)
Cleanup: use const variables in interface code
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface.c72
-rw-r--r--source/blender/editors/interface/interface_anim.c4
-rw-r--r--source/blender/editors/interface/interface_context_menu.c12
-rw-r--r--source/blender/editors/interface/interface_draw.c167
-rw-r--r--source/blender/editors/interface/interface_eyedropper_colorband.c6
-rw-r--r--source/blender/editors/interface/interface_eyedropper_datablock.c2
-rw-r--r--source/blender/editors/interface/interface_eyedropper_driver.c6
-rw-r--r--source/blender/editors/interface/interface_handlers.c132
-rw-r--r--source/blender/editors/interface/interface_icons.c60
-rw-r--r--source/blender/editors/interface/interface_icons_event.c8
-rw-r--r--source/blender/editors/interface/interface_layout.c32
-rw-r--r--source/blender/editors/interface/interface_ops.c26
-rw-r--r--source/blender/editors/interface/interface_panel.c57
-rw-r--r--source/blender/editors/interface/interface_query.c4
-rw-r--r--source/blender/editors/interface/interface_region_color_picker.c2
-rw-r--r--source/blender/editors/interface/interface_region_hud.c4
-rw-r--r--source/blender/editors/interface/interface_region_menu_pie.c2
-rw-r--r--source/blender/editors/interface/interface_region_popover.c4
-rw-r--r--source/blender/editors/interface/interface_region_popup.c8
-rw-r--r--source/blender/editors/interface/interface_region_search.c8
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c26
-rw-r--r--source/blender/editors/interface/interface_style.c5
-rw-r--r--source/blender/editors/interface/interface_template_search_menu.c6
-rw-r--r--source/blender/editors/interface/interface_template_search_operator.c2
-rw-r--r--source/blender/editors/interface/interface_templates.c73
-rw-r--r--source/blender/editors/interface/interface_utils.c4
-rw-r--r--source/blender/editors/interface/interface_widgets.c148
-rw-r--r--source/blender/editors/interface/view2d.c32
-rw-r--r--source/blender/editors/interface/view2d_draw.c54
-rw-r--r--source/blender/editors/interface/view2d_ops.c48
30 files changed, 515 insertions, 499 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e04531bb1dd..f076ed083bb 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -304,11 +304,11 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block)
/* How much the next block overlap with the current segment */
int overlap = ((i == sepr_flex_len - 1) ? buttons_width - spacers_pos[i] :
(spacers_pos[i + 1] - spacers_pos[i]) / 2);
- int segment_end = segment_width * (i + 1);
- int spacer_end = segment_end - overlap;
- int spacer_sta = spacers_pos[i] + offset;
+ const int segment_end = segment_width * (i + 1);
+ const int spacer_end = segment_end - overlap;
+ const int spacer_sta = spacers_pos[i] + offset;
if (spacer_end > spacer_sta) {
- float step = min_ff(remaining_space, spacer_end - spacer_sta);
+ const float step = min_ff(remaining_space, spacer_end - spacer_sta);
remaining_space -= step;
offset += step;
}
@@ -329,9 +329,9 @@ static void ui_update_window_matrix(const wmWindow *window, const ARegion *regio
else {
/* No subwindow created yet, for menus for example, so we use the main
* window instead, since buttons are created there anyway. */
- int width = WM_window_pixels_x(window);
- int height = WM_window_pixels_y(window);
- rcti winrct = {0, width - 1, 0, height - 1};
+ const int width = WM_window_pixels_x(window);
+ const int height = WM_window_pixels_y(window);
+ const rcti winrct = {0, width - 1, 0, height - 1};
wmGetProjectionMatrix(block->winmat, &winrct);
block->aspect = 2.0f / fabsf(width * block->winmat[0][0]);
@@ -1130,7 +1130,7 @@ static bool ui_but_event_operator_string_from_menu(const bContext *C,
IDProperty *prop_menu;
/* annoying, create a property */
- IDPropertyTemplate val = {0};
+ const IDPropertyTemplate val = {0};
prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */
IDP_AddToGroup(prop_menu, IDP_NewString(mt->idname, "name", sizeof(mt->idname)));
@@ -1156,7 +1156,7 @@ static bool ui_but_event_operator_string_from_panel(const bContext *C,
IDProperty *prop_panel;
/* annoying, create a property */
- IDPropertyTemplate val = {0};
+ const IDPropertyTemplate val = {0};
prop_panel = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */
IDP_AddToGroup(prop_panel, IDP_NewString(pt->idname, "name", sizeof(pt->idname)));
IDP_AddToGroup(prop_panel,
@@ -1361,7 +1361,7 @@ static bool ui_but_event_property_operator_string(const bContext *C,
/* create a property to host the "datapath" property we're sending to the operators */
IDProperty *prop_path;
- IDPropertyTemplate val = {0};
+ const IDPropertyTemplate val = {0};
prop_path = IDP_New(IDP_GROUP, &val, __func__);
if (data_path) {
IDP_AddToGroup(prop_path, IDP_NewString(data_path, "data_path", strlen(data_path) + 1));
@@ -1370,11 +1370,11 @@ static bool ui_but_event_property_operator_string(const bContext *C,
const EnumPropertyItem *item;
bool free;
RNA_property_enum_items((bContext *)C, ptr, prop, &item, NULL, &free);
- int index = RNA_enum_from_value(item, prop_enum_value);
+ const int index = RNA_enum_from_value(item, prop_enum_value);
if (index != -1) {
IDProperty *prop_value;
if (prop_enum_value_is_int) {
- int value = item[index].value;
+ const int value = item[index].value;
prop_value = IDP_New(IDP_INT,
&(IDPropertyTemplate){
.i = value,
@@ -1656,7 +1656,7 @@ static PredefinedExtraOpIconType ui_but_icon_extra_get(uiBut *but)
*/
static void ui_but_predefined_extra_operator_icons_add(uiBut *but)
{
- PredefinedExtraOpIconType extra_icon = ui_but_icon_extra_get(but);
+ const PredefinedExtraOpIconType extra_icon = ui_but_icon_extra_get(but);
wmOperatorType *optype = NULL;
BIFIconID icon = ICON_NONE;
@@ -2047,7 +2047,7 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
/* uiBut.custom_data points to data this tab represents (e.g. workspace).
* uiBut.rnapoin/prop store an active value (e.g. active workspace). */
if (RNA_property_type(but->rnaprop) == PROP_POINTER) {
- PointerRNA active_ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
+ const PointerRNA active_ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
if (active_ptr.data == but->custom_data) {
is_push = true;
}
@@ -2518,7 +2518,7 @@ uiBut *ui_but_drag_multi_edit_get(uiBut *but)
static double ui_get_but_scale_unit(uiBut *but, double value)
{
UnitSettings *unit = but->block->unit;
- int unit_type = UI_but_unit_type_get(but);
+ const int unit_type = UI_but_unit_type_get(but);
/* Time unit is a bit special, not handled by BKE_scene_unit_scale() for now. */
if (unit_type == PROP_UNIT_TIME) { /* WARNING - using evil_C :| */
@@ -2533,7 +2533,7 @@ void ui_but_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen)
{
if (ui_but_is_unit(but)) {
UnitSettings *unit = but->block->unit;
- int unit_type = UI_but_unit_type_get(but);
+ const int unit_type = UI_but_unit_type_get(but);
char *orig_str;
orig_str = BLI_strdup(str);
@@ -2551,7 +2551,7 @@ static void ui_get_but_string_unit(
uiBut *but, char *str, int len_max, double value, bool pad, int float_precision)
{
UnitSettings *unit = but->block->unit;
- int unit_type = UI_but_unit_type_get(but);
+ const int unit_type = UI_but_unit_type_get(but);
int precision;
if (unit->scale_length < 0.0001f) {
@@ -2584,7 +2584,7 @@ static void ui_get_but_string_unit(
static float ui_get_but_step_unit(uiBut *but, float step_default)
{
- int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but));
+ const int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but));
const double step_orig = step_default * UI_PRECISION_FLOAT_SCALE;
/* Scaling up 'step_origg ' here is a bit arbitrary,
* its just giving better scales from user POV */
@@ -2655,7 +2655,7 @@ void ui_but_string_get_ex(uiBut *but,
}
else if (type == PROP_ENUM) {
/* RNA enum */
- int value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
+ const int value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
if (RNA_property_enum_name(but->block->evil_C, &but->rnapoin, but->rnaprop, value, &buf)) {
BLI_strncpy(str, buf, maxlen);
buf = str;
@@ -2774,7 +2774,7 @@ char *ui_but_string_get_dynamic(uiBut *but, int *r_str_size)
}
else if (type == PROP_ENUM) {
/* RNA enum */
- int value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
+ const int value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
const char *value_id;
if (!RNA_property_enum_name(
but->block->evil_C, &but->rnapoin, but->rnaprop, value, &value_id)) {
@@ -2845,10 +2845,10 @@ static bool ui_number_from_string(bContext *C, const char *str, double *r_value)
static bool ui_number_from_string_factor(bContext *C, const char *str, double *r_value)
{
- int len = strlen(str);
+ const int len = strlen(str);
if (BLI_strn_endswith(str, "%", len)) {
char *str_new = BLI_strdupn(str, len - 1);
- bool success = ui_number_from_string(C, str_new, r_value);
+ const bool success = ui_number_from_string(C, str_new, r_value);
MEM_freeN(str_new);
*r_value /= 100.0;
return success;
@@ -2864,10 +2864,10 @@ static bool ui_number_from_string_factor(bContext *C, const char *str, double *r
static bool ui_number_from_string_percentage(bContext *C, const char *str, double *r_value)
{
- int len = strlen(str);
+ const int len = strlen(str);
if (BLI_strn_endswith(str, "%", len)) {
char *str_new = BLI_strdupn(str, len - 1);
- bool success = ui_number_from_string(C, str_new, r_value);
+ const bool success = ui_number_from_string(C, str_new, r_value);
MEM_freeN(str_new);
return success;
}
@@ -3078,7 +3078,7 @@ static double soft_range_round_up(double value, double max)
{
/* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, ..
* checking for 0.0 prevents floating point exceptions */
- double newmax = (value != 0.0) ? pow(10.0, ceil(log(value) / M_LN10)) : 0.0;
+ const double newmax = (value != 0.0) ? pow(10.0, ceil(log(value) / M_LN10)) : 0.0;
if (newmax * 0.2 >= max && newmax * 0.2 >= value) {
return newmax * 0.2;
@@ -3093,7 +3093,7 @@ static double soft_range_round_down(double value, double max)
{
/* round down to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, ..
* checking for 0.0 prevents floating point exceptions */
- double newmax = (value != 0.0) ? pow(10.0, floor(log(value) / M_LN10)) : 0.0;
+ const double newmax = (value != 0.0) ? pow(10.0, floor(log(value) / M_LN10)) : 0.0;
if (newmax * 5.0 <= max && newmax * 5.0 <= value) {
return newmax * 5.0;
@@ -3488,15 +3488,15 @@ static void ui_but_build_drawstr_float(uiBut *but, double value)
STR_CONCAT(but->drawstr, slen, "-inf");
}
else if (subtype == PROP_PERCENTAGE) {
- int prec = ui_but_calc_float_precision(but, value);
+ const int prec = ui_but_calc_float_precision(but, value);
STR_CONCATF(but->drawstr, slen, "%.*f%%", prec, value);
}
else if (subtype == PROP_PIXEL) {
- int prec = ui_but_calc_float_precision(but, value);
+ const int prec = ui_but_calc_float_precision(but, value);
STR_CONCATF(but->drawstr, slen, "%.*f px", prec, value);
}
else if (subtype == PROP_FACTOR) {
- int precision = ui_but_calc_float_precision(but, value);
+ const int precision = ui_but_calc_float_precision(but, value);
if (U.factor_display_type == USER_FACTOR_AS_FACTOR) {
STR_CONCATF(but->drawstr, slen, "%.*f", precision, value);
@@ -3511,7 +3511,7 @@ static void ui_but_build_drawstr_float(uiBut *but, double value)
STR_CONCAT(but->drawstr, slen, new_str);
}
else {
- int prec = ui_but_calc_float_precision(but, value);
+ const int prec = ui_but_calc_float_precision(but, value);
STR_CONCATF(but->drawstr, slen, "%.*f", prec, value);
}
}
@@ -3601,12 +3601,12 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
/* only needed for menus in popup blocks that don't recreate buttons on redraw */
if (but->block->flag & UI_BLOCK_LOOP) {
if (but->rnaprop && (RNA_property_type(but->rnaprop) == PROP_ENUM)) {
- int value_enum = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
+ const int value_enum = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
EnumPropertyItem item;
if (RNA_property_enum_item_from_value_gettexted(
but->block->evil_C, &but->rnapoin, but->rnaprop, value_enum, &item)) {
- size_t slen = strlen(item.name);
+ const size_t slen = strlen(item.name);
ui_but_string_free_internal(but);
ui_but_string_set_internal(but, item.name, slen);
but->icon = item.icon;
@@ -4797,7 +4797,7 @@ static uiBut *uiDefButBit(uiBlock *block,
float a2,
const char *tip)
{
- int bitIdx = findBitIndex(bit);
+ const int bitIdx = findBitIndex(bit);
if (bitIdx == -1) {
return NULL;
}
@@ -5182,7 +5182,7 @@ static uiBut *uiDefIconButBit(uiBlock *block,
float a2,
const char *tip)
{
- int bitIdx = findBitIndex(bit);
+ const int bitIdx = findBitIndex(bit);
if (bitIdx == -1) {
return NULL;
}
@@ -5568,7 +5568,7 @@ static uiBut *uiDefIconTextButBit(uiBlock *block,
float a2,
const char *tip)
{
- int bitIdx = findBitIndex(bit);
+ const int bitIdx = findBitIndex(bit);
if (bitIdx == -1) {
return NULL;
}
@@ -6127,7 +6127,7 @@ void UI_but_unit_type_set(uiBut *but, const int unit_type)
int UI_but_unit_type_get(const uiBut *but)
{
- 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)
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 56df49981e0..6fb9b99632e 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -60,7 +60,7 @@ static FCurve *ui_but_get_fcurve(
{
/* for entire array buttons we check the first component, it's not perfect
* but works well enough in typical cases */
- int rnaindex = (but->rnaindex == -1) ? 0 : but->rnaindex;
+ const int rnaindex = (but->rnaindex == -1) ? 0 : but->rnaindex;
return BKE_fcurve_find_by_rna_context_ui(
but->block->evil_C, &but->rnapoin, but->rnaprop, rnaindex, adt, action, r_driven, r_special);
@@ -158,7 +158,7 @@ void ui_but_anim_decorate_update_from_flag(uiButDecorator *decorator_but)
return;
}
- int flag = but_anim->flag;
+ const int flag = but_anim->flag;
if (flag & UI_BUT_DRIVEN) {
but->icon = ICON_DECORATE_DRIVER;
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index 59178e209db..9889c81ca55 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -91,7 +91,7 @@ static IDProperty *shortcut_property_from_rna(bContext *C, uiBut *but)
/* Create ID property of data path, to pass to the operator. */
IDProperty *prop;
- IDPropertyTemplate val = {0};
+ const IDPropertyTemplate val = {0};
prop = IDP_New(IDP_GROUP, &val, __func__);
IDP_AddToGroup(prop, IDP_NewString(final_data_path, "data_path", strlen(final_data_path) + 1));
@@ -517,7 +517,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
uiLayout *layout;
{
- uiStringInfo label = {BUT_GET_LABEL, NULL};
+ const uiStringInfo label = {BUT_GET_LABEL, NULL};
/* highly unlikely getting the label ever fails */
UI_but_string_info_get(C, but, &label, NULL);
@@ -548,9 +548,9 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
const PropertyType type = RNA_property_type(prop);
const PropertySubType subtype = RNA_property_subtype(prop);
bool is_anim = RNA_property_animateable(ptr, prop);
- bool is_editable = RNA_property_editable(ptr, prop);
- bool is_idprop = RNA_property_is_idprop(prop);
- bool is_set = RNA_property_is_set(ptr, prop);
+ const bool is_editable = RNA_property_editable(ptr, prop);
+ const bool is_idprop = RNA_property_is_idprop(prop);
+ const bool is_set = RNA_property_is_set(ptr, prop);
/* second slower test,
* saved people finding keyframe items in menus when its not possible */
@@ -1044,7 +1044,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
if (idname != NULL) {
uiBlock *block = uiLayoutGetBlock(layout);
uiBut *but2;
- int w = uiLayoutGetWidth(layout);
+ const int w = uiLayoutGetWidth(layout);
wmKeyMap *km;
/* We want to know if this op has a shortcut, be it hotkey or not. */
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index ba878be3dc7..25c5e63d23e 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -622,10 +622,10 @@ void UI_draw_roundbox_shade_y(bool filled,
void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4])
{
- int ofs_y = 4 * U.pixelsize;
+ const int ofs_y = 4 * U.pixelsize;
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
@@ -644,8 +644,9 @@ void ui_draw_but_TAB_outline(const rcti *rect,
uchar highlight_fade[3])
{
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint col = GPU_vertformat_attr_add(
+ format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
/* add a 1px offset, looks nicer */
const int minx = rect->xmin + U.pixelsize, maxx = rect->xmax - U.pixelsize;
const int miny = rect->ymin + U.pixelsize, maxy = rect->ymax - U.pixelsize;
@@ -741,8 +742,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(region),
return;
}
- int w = BLI_rcti_size_x(rect);
- int h = BLI_rcti_size_y(rect);
+ const int w = BLI_rcti_size_x(rect);
+ const int h = BLI_rcti_size_y(rect);
/* scissor doesn't seem to be doing the right thing...? */
# if 0
@@ -813,13 +814,13 @@ void UI_draw_safe_areas(uint pos,
for (int i = 0; i < safe_len; i++) {
if (safe_areas[i][0] || safe_areas[i][1]) {
- float margin_x = safe_areas[i][0] * size_x_half;
- float margin_y = safe_areas[i][1] * size_y_half;
+ const float margin_x = safe_areas[i][0] * size_x_half;
+ const float margin_y = safe_areas[i][1] * size_y_half;
- float minx = x1 + margin_x;
- float miny = y1 + margin_y;
- float maxx = x2 - margin_x;
- float maxy = y2 - margin_y;
+ const float minx = x1 + margin_x;
+ const float miny = y1 + margin_y;
+ const float maxx = x2 - margin_x;
+ const float maxy = y2 - margin_y;
imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
}
@@ -868,7 +869,7 @@ static void histogram_draw_one(float r,
immBegin(GPU_PRIM_LINE_STRIP, res);
for (int i = 0; i < res; i++) {
- float x2 = x + i * (w / (float)res);
+ const float x2 = x + i * (w / (float)res);
immVertex2f(pos_attr, x2, y + (data[i] * h));
}
immEnd();
@@ -879,7 +880,7 @@ static void histogram_draw_one(float r,
immVertex2f(pos_attr, x, y);
immVertex2f(pos_attr, x, y + (data[0] * h));
for (int i = 1; i < res; i++) {
- float x2 = x + i * (w / (float)res);
+ const float x2 = x + i * (w / (float)res);
immVertex2f(pos_attr, x2, y + (data[i] * h));
immVertex2f(pos_attr, x2, y);
}
@@ -891,7 +892,7 @@ static void histogram_draw_one(float r,
GPU_blend(GPU_BLEND_ALPHA);
immBegin(GPU_PRIM_LINE_STRIP, res);
for (int i = 0; i < res; i++) {
- float x2 = x + i * (w / (float)res);
+ const float x2 = x + i * (w / (float)res);
immVertex2f(pos_attr, x2, y + (data[i] * h));
}
immEnd();
@@ -908,7 +909,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
const rcti *recti)
{
Histogram *hist = (Histogram *)but->poin;
- int res = hist->x_resolution;
+ const int res = hist->x_resolution;
const bool is_line = (hist->flag & HISTO_FLAG_LINE) != 0;
rctf rect = {
@@ -918,8 +919,8 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
.ymax = (float)recti->ymax - 1,
};
- float w = BLI_rctf_size_x(&rect);
- float h = BLI_rctf_size_y(&rect) * hist->ymax;
+ const float w = BLI_rctf_size_x(&rect);
+ const float h = BLI_rctf_size_y(&rect) * hist->ymax;
GPU_blend(GPU_BLEND_ALPHA);
@@ -938,7 +939,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
(rect.ymax + 1) - (rect.ymin - 1));
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1000,7 +1001,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
static void waveform_draw_one(float *waveform, int nbr, const float col[3])
{
GPUVertFormat format = {0};
- uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
GPU_vertbuf_data_alloc(vbo, nbr);
@@ -1043,13 +1044,13 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
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;
- float w3 = w / 3.0f;
+ const float w = BLI_rctf_size_x(&rect) - 7;
+ const float h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
+ const float yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) * 0.5f;
+ const float w3 = w / 3.0f;
/* log scale for alpha */
- float alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha;
+ const float alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha;
unit_m3(colors);
@@ -1093,7 +1094,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
GPU_blend(GPU_BLEND_ALPHA);
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1200,7 +1201,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
SCOPES_WAVEFRM_YCC_601,
SCOPES_WAVEFRM_YCC_709,
SCOPES_WAVEFRM_YCC_JPEG)) {
- int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE);
+ const int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE);
GPU_matrix_push();
GPU_matrix_translate_2f(rect.xmin, yofs);
@@ -1384,13 +1385,13 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
.ymax = (float)recti->ymax - 1,
};
- float w = BLI_rctf_size_x(&rect);
- float h = BLI_rctf_size_y(&rect);
- float centerx = rect.xmin + w * 0.5f;
- float centery = rect.ymin + h * 0.5f;
- float diam = (w < h) ? w : h;
+ const float w = BLI_rctf_size_x(&rect);
+ const float h = BLI_rctf_size_y(&rect);
+ const float centerx = rect.xmin + w * 0.5f;
+ const float centery = rect.ymin + h * 0.5f;
+ const float diam = (w < h) ? w : h;
- float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha;
+ const float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha;
GPU_blend(GPU_BLEND_ALPHA);
@@ -1409,7 +1410,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
(rect.ymax + 1) - (rect.ymin - 1));
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1538,11 +1539,11 @@ static void ui_draw_colorband_handle(uint shdr_pos,
const float min_width = 3.0f;
float colf[3] = {UNPACK3(rgb)};
- float half_width = floorf(sizey / 3.5f);
- float height = half_width * 1.4f;
+ const float half_width = floorf(sizey / 3.5f);
+ const float height = half_width * 1.4f;
float y1 = rect->ymin + (sizey * 0.16f);
- float y2 = rect->ymax;
+ const float y2 = rect->ymax;
/* align to pixels */
x = floorf(x + 0.5f);
@@ -1637,11 +1638,11 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
return;
}
- float x1 = rect->xmin;
- float sizex = rect->xmax - x1;
- float sizey = BLI_rcti_size_y(rect);
- float sizey_solid = sizey * 0.25f;
- float y1 = rect->ymin;
+ const float x1 = rect->xmin;
+ const float sizex = rect->xmax - x1;
+ const float sizey = BLI_rcti_size_y(rect);
+ const float sizey_solid = sizey * 0.25f;
+ const float y1 = rect->ymin;
/* exit early if too narrow */
if (sizex <= 0) {
@@ -1680,7 +1681,7 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
for (int a = 0; a <= sizex; a++) {
- float pos = ((float)a) / sizex;
+ const float pos = ((float)a) / sizex;
BKE_colorband_evaluate(coba, pos, colf);
if (display) {
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
@@ -1700,7 +1701,7 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
for (int a = 0; a <= sizex; a++) {
- float pos = ((float)a) / sizex;
+ const float pos = ((float)a) / sizex;
BKE_colorband_evaluate(coba, pos, colf);
if (display) {
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
@@ -1748,7 +1749,7 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
/* layer: draw handles */
for (int a = 0; a < coba->tot; a++, cbd++) {
if (a != coba->cur) {
- float pos = x1 + cbd->pos * (sizex - 1) + 1;
+ const float pos = x1 + cbd->pos * (sizex - 1) + 1;
ui_draw_colorband_handle(pos_id, rect, pos, &cbd->r, display, false);
}
}
@@ -1756,7 +1757,7 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
/* layer: active handle */
if (coba->tot != 0) {
cbd = &coba->data[coba->cur];
- float pos = x1 + cbd->pos * (sizex - 1) + 1;
+ const float pos = x1 + cbd->pos * (sizex - 1) + 1;
ui_draw_colorband_handle(pos_id, rect, pos, &cbd->r, display, true);
}
@@ -1783,7 +1784,7 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec
/* transform to button */
GPU_matrix_push();
- bool use_project_matrix = (size >= -GPU_MATRIX_ORTHO_CLIP_NEAR_DEFAULT);
+ const bool use_project_matrix = (size >= -GPU_MATRIX_ORTHO_CLIP_NEAR_DEFAULT);
if (use_project_matrix) {
GPU_matrix_push_projection();
GPU_matrix_ortho_set_z(-size, size);
@@ -1804,7 +1805,7 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec
/* AA circle */
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ubv(wcol->inner);
@@ -1827,13 +1828,13 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec
static void ui_draw_but_curve_grid(
uint pos, const rcti *rect, float zoomx, float zoomy, float offsx, float offsy, float step)
{
- float dx = step * zoomx;
+ const float dx = step * zoomx;
float fx = rect->xmin + zoomx * (-offsx);
if (fx > rect->xmin) {
fx -= dx * (floorf(fx - rect->xmin));
}
- float dy = step * zoomy;
+ const float dy = step * zoomy;
float fy = rect->ymin + zoomy * (-offsy);
if (fy > rect->ymin) {
fy -= dy * (floorf(fy - rect->ymin));
@@ -1885,8 +1886,8 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
CurveMapping *cumap = (but_cumap->edit_cumap == NULL) ? (CurveMapping *)but->poin :
but_cumap->edit_cumap;
- float clip_size_x = BLI_rctf_size_x(&cumap->curr);
- float clip_size_y = BLI_rctf_size_y(&cumap->curr);
+ const float clip_size_x = BLI_rctf_size_x(&cumap->curr);
+ const float clip_size_y = BLI_rctf_size_y(&cumap->curr);
/* zero-sized curve */
if (clip_size_x == 0.0f || clip_size_y == 0.0f) {
@@ -1894,10 +1895,10 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
}
/* calculate offset and zoom */
- float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / clip_size_x;
- float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / clip_size_y;
- float offsx = cumap->curr.xmin - (1.0f / zoomx);
- float offsy = cumap->curr.ymin - (1.0f / zoomy);
+ const float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / clip_size_x;
+ const float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / clip_size_y;
+ const float offsx = cumap->curr.xmin - (1.0f / zoomx);
+ const float offsy = cumap->curr.ymin - (1.0f / zoomy);
/* exit early if too narrow */
if (zoomx == 0.0f) {
@@ -1915,7 +1916,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
.xmax = rect->xmax,
.ymax = rect->ymax,
};
- rcti scissor_region = {0, region->winx, 0, region->winy};
+ const rcti scissor_region = {0, region->winx, 0, region->winy};
BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
GPU_scissor(scissor_new.xmin,
scissor_new.ymin,
@@ -2014,7 +2015,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
immVertex2f(pos, rect->xmin + zoomx * (hsv[0] - offsx), rect->ymax);
}
else if (cumap->cur == 3) {
- float lum = IMB_colormanagement_get_luminance(cumap->sample);
+ const float lum = IMB_colormanagement_get_luminance(cumap->sample);
immUniformColor3ub(240, 240, 240);
immVertex2f(pos, rect->xmin + zoomx * (lum - offsx), rect->ymin);
@@ -2073,8 +2074,8 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
immVertex2f(pos, line_range.xmin, rect->ymin);
immVertex2f(pos, line_range.xmin, line_range.ymin);
for (int a = 0; a <= CM_TABLE; a++) {
- float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
- float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
+ const float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
+ const float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
immVertex2f(pos, fx, rect->ymin);
immVertex2f(pos, fx, fy);
}
@@ -2089,8 +2090,8 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
immBegin(GPU_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2);
immVertex2f(pos, line_range.xmin, line_range.ymin);
for (int a = 0; a <= CM_TABLE; a++) {
- float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
- float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
+ const float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
+ const float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
immVertex2f(pos, fx, fy);
}
immVertex2f(pos, line_range.xmax, line_range.ymax);
@@ -2104,7 +2105,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
/* The points, use aspect to make them visible on edges. */
format = immVertexFormat();
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ const uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
/* Calculate vertex colors based on text theme. */
@@ -2123,8 +2124,8 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
GPU_point_size(max_ff(1.0f, min_ff(UI_DPI_FAC / but->block->aspect * 4.0f, 4.0f)));
immBegin(GPU_PRIM_POINTS, cuma->totpoint);
for (int a = 0; a < cuma->totpoint; a++) {
- float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
- float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
+ const float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
+ const float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
immAttr4fv(col, (cmp[a].flag & CUMA_SELECT) ? color_vert_select : color_vert);
immVertex2f(pos, fx, fy);
}
@@ -2171,10 +2172,10 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
but_profile->edit_profile;
/* Calculate offset and zoom. */
- float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&profile->view_rect);
- float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&profile->view_rect);
- float offsx = profile->view_rect.xmin - (1.0f / zoomx);
- float offsy = profile->view_rect.ymin - (1.0f / zoomy);
+ const float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&profile->view_rect);
+ const float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&profile->view_rect);
+ const float offsx = profile->view_rect.xmin - (1.0f / zoomx);
+ const float offsy = profile->view_rect.ymin - (1.0f / zoomy);
/* Exit early if too narrow. */
if (zoomx == 0.0f) {
@@ -2190,7 +2191,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
.xmax = rect->xmax,
.ymax = rect->ymax,
};
- rcti scissor_region = {0, region->winx, 0, region->winy};
+ const rcti scissor_region = {0, region->winx, 0, region->winy};
BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
GPU_scissor(scissor_new.xmin,
scissor_new.ymin,
@@ -2235,10 +2236,10 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
}
CurveProfilePoint *pts = profile->table;
/* Also add the last points on the right and bottom edges to close off the fill polygon. */
- bool add_left_tri = profile->view_rect.xmin < 0.0f;
- bool add_bottom_tri = profile->view_rect.ymin < 0.0f;
+ const bool add_left_tri = profile->view_rect.xmin < 0.0f;
+ const bool add_bottom_tri = profile->view_rect.ymin < 0.0f;
uint tot_points = (uint)PROF_TABLE_LEN(profile->path_len) + 1 + add_left_tri + add_bottom_tri;
- uint tot_triangles = tot_points - 2;
+ const uint tot_triangles = tot_points - 2;
/* Create array of the positions of the table's points. */
float(*table_coords)[2] = MEM_mallocN(sizeof(*table_coords) * tot_points, "table x coords");
@@ -2349,7 +2350,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
/* New GPU instructions for control points and sampled points. */
format = immVertexFormat();
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ const uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
/* Calculate vertex colors based on text theme. */
@@ -2448,8 +2449,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
.ymax = (float)recti->ymax - 1,
};
- int width = BLI_rctf_size_x(&rect) + 1;
- int height = BLI_rctf_size_y(&rect);
+ const int width = BLI_rctf_size_x(&rect) + 1;
+ const int height = BLI_rctf_size_y(&rect);
GPU_blend(GPU_BLEND_ALPHA);
@@ -2535,8 +2536,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
GPU_scissor(rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), BLI_rctf_size_y(&rect));
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
UI_GetThemeColor4fv(TH_SEL_MARKER, col_sel);
@@ -2547,10 +2548,10 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
const float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f};
for (int axe = 0; axe < 2; axe++) {
for (int i = 0; i < 7; i++) {
- float x1 = pos_sel[i] * (1 - axe);
- float y1 = pos_sel[i] * axe;
- float x2 = pos_sel[i + 1] * (1 - axe);
- float y2 = pos_sel[i + 1] * axe;
+ const float x1 = pos_sel[i] * (1 - axe);
+ const float y1 = pos_sel[i] * axe;
+ const float x2 = pos_sel[i + 1] * (1 - axe);
+ const float y2 = pos_sel[i + 1] * axe;
if (i % 2 == 1) {
immAttr4fv(col, col_sel);
@@ -2669,7 +2670,7 @@ void UI_draw_box_shadow(uchar alpha, float minx, float miny, float maxx, float m
GPU_blend(GPU_BLEND_ALPHA);
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
uint color = GPU_vertformat_attr_add(
format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
diff --git a/source/blender/editors/interface/interface_eyedropper_colorband.c b/source/blender/editors/interface/interface_eyedropper_colorband.c
index b757341ae13..76b361a9e68 100644
--- a/source/blender/editors/interface/interface_eyedropper_colorband.c
+++ b/source/blender/editors/interface/interface_eyedropper_colorband.c
@@ -109,7 +109,7 @@ static bool eyedropper_colorband_init(bContext *C, wmOperator *op)
}
if (!band) {
- PointerRNA ptr = CTX_data_pointer_get_type(C, "color_ramp", &RNA_ColorRamp);
+ const PointerRNA ptr = CTX_data_pointer_get_type(C, "color_ramp", &RNA_ColorRamp);
if (ptr.data != NULL) {
band = ptr.data;
@@ -200,7 +200,7 @@ static void eyedropper_colorband_apply(bContext *C, wmOperator *op)
{
EyedropperColorband *eye = op->customdata;
/* Always filter, avoids noise in resulting color-band. */
- bool filter_samples = true;
+ const bool filter_samples = true;
BKE_colorband_init_from_table_rgba(
eye->color_band, eye->color_buffer, eye->color_buffer_len, filter_samples);
eye->is_set = true;
@@ -339,7 +339,7 @@ static bool eyedropper_colorband_poll(bContext *C)
if (but && but->type == UI_BTYPE_COLORBAND) {
return true;
}
- PointerRNA ptr = CTX_data_pointer_get_type(C, "color_ramp", &RNA_ColorRamp);
+ const PointerRNA ptr = CTX_data_pointer_get_type(C, "color_ramp", &RNA_ColorRamp);
if (ptr.data != NULL) {
return true;
}
diff --git a/source/blender/editors/interface/interface_eyedropper_datablock.c b/source/blender/editors/interface/interface_eyedropper_datablock.c
index a162cac1b02..dd55d2c364b 100644
--- a/source/blender/editors/interface/interface_eyedropper_datablock.c
+++ b/source/blender/editors/interface/interface_eyedropper_datablock.c
@@ -117,7 +117,7 @@ static int datadropper_init(bContext *C, wmOperator *op)
* because this struct has very short lifetime. */
ddr->idcode_name = TIP_(BKE_idtype_idcode_to_name(ddr->idcode));
- PointerRNA ptr = RNA_property_pointer_get(&ddr->ptr, ddr->prop);
+ const PointerRNA ptr = RNA_property_pointer_get(&ddr->ptr, ddr->prop);
ddr->init_id = ptr.owner_id;
return true;
diff --git a/source/blender/editors/interface/interface_eyedropper_driver.c b/source/blender/editors/interface/interface_eyedropper_driver.c
index 0162e205c29..d13e47624ee 100644
--- a/source/blender/editors/interface/interface_eyedropper_driver.c
+++ b/source/blender/editors/interface/interface_eyedropper_driver.c
@@ -95,8 +95,8 @@ static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *eve
DriverDropper *ddr = (DriverDropper *)op->customdata;
uiBut *but = eyedropper_get_property_button_under_mouse(C, event);
- short mapping_type = RNA_enum_get(op->ptr, "mapping_type");
- short flag = 0;
+ const short mapping_type = RNA_enum_get(op->ptr, "mapping_type");
+ const short flag = 0;
/* we can only add a driver if we know what RNA property it corresponds to */
if (but == NULL) {
@@ -105,7 +105,7 @@ static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *eve
/* Get paths for src... */
PointerRNA *target_ptr = &but->rnapoin;
PropertyRNA *target_prop = but->rnaprop;
- int target_index = but->rnaindex;
+ const int target_index = but->rnaindex;
char *target_path = RNA_path_from_ID_to_property(target_ptr, target_prop);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index e5d597bc832..14f3c74824b 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1446,7 +1446,7 @@ static bool ui_drag_toggle_set_xy_xy(
/* execute the button */
if (ui_drag_toggle_but_is_supported(but)) {
/* is it pressed? */
- int pushed_state_but = ui_drag_toggle_but_pushed_state(C, but);
+ const int pushed_state_but = ui_drag_toggle_but_pushed_state(C, but);
if (pushed_state_but != pushed_state) {
UI_but_execute(C, region, but);
if (do_check) {
@@ -1596,7 +1596,7 @@ static bool ui_selectcontext_begin(bContext *C, uiBut *but, uiSelectContextStore
PointerRNA ptr = but->rnapoin;
PropertyRNA *prop = but->rnaprop;
- int index = but->rnaindex;
+ const int index = but->rnaindex;
/* for now don't support whole colors */
if (index == -1) {
@@ -1724,7 +1724,7 @@ static void ui_selectcontext_apply(bContext *C,
if (selctx_data->elems) {
PropertyRNA *prop = but->rnaprop;
PropertyRNA *lprop = but->rnaprop;
- int index = but->rnaindex;
+ const int index = but->rnaindex;
const bool use_delta = (selctx_data->is_copy == false);
union {
@@ -1767,7 +1767,7 @@ static void ui_selectcontext_apply(bContext *C,
# ifdef USE_ALLSELECT_LAYER_HACK
/* make up for not having 'handle_layer_buttons' */
{
- PropertySubType subtype = RNA_property_subtype(prop);
+ const PropertySubType subtype = RNA_property_subtype(prop);
if ((rna_type == PROP_BOOLEAN) && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER) && is_array &&
/* could check for 'handle_layer_buttons' */
@@ -2324,7 +2324,7 @@ static void float_array_to_string(float *values,
static void ui_but_copy_numeric_array(uiBut *but, char *output, int output_len_max)
{
- int array_length = get_but_property_array_length(but);
+ const int array_length = get_but_property_array_length(but);
float *values = alloca(array_length * sizeof(float));
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, values);
float_array_to_string(values, array_length, output, output_len_max);
@@ -2336,7 +2336,8 @@ static bool parse_float_array(char *text, float *values, int expected_length)
BLI_assert(0 <= expected_length && expected_length <= 4);
float v[5];
- int actual_length = sscanf(text, "[%f, %f, %f, %f, %f]", &v[0], &v[1], &v[2], &v[3], &v[4]);
+ const int actual_length = sscanf(
+ text, "[%f, %f, %f, %f, %f]", &v[0], &v[1], &v[2], &v[3], &v[4]);
if (actual_length == expected_length) {
memcpy(values, v, sizeof(float) * expected_length);
@@ -2350,7 +2351,7 @@ static void ui_but_paste_numeric_array(bContext *C,
uiHandleButtonData *data,
char *buf_paste)
{
- int array_length = get_but_property_array_length(but);
+ const int array_length = get_but_property_array_length(but);
if (array_length > 4) {
// not supported for now
return;
@@ -2441,7 +2442,7 @@ static void ui_but_paste_color(bContext *C, uiBut *but, char *buf_paste)
}
/* Some color properties are RGB, not RGBA. */
- int array_len = get_but_property_array_length(but);
+ const int array_len = get_but_property_array_length(but);
BLI_assert(ELEM(array_len, 3, 4));
ui_but_set_float_array(C, but, NULL, rgba, array_len);
}
@@ -2578,7 +2579,7 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
/* Left false for copying internal data (color-band for eg). */
bool is_buf_set = false;
- bool has_required_data = !(but->poin == NULL && but->rnapoin.data == NULL);
+ const bool has_required_data = !(but->poin == NULL && but->rnapoin.data == NULL);
switch (but->type) {
case UI_BTYPE_NUM:
@@ -2669,7 +2670,7 @@ static void ui_but_paste(bContext *C, uiBut *but, uiHandleButtonData *data, cons
char *buf_paste;
ui_but_get_pasted_text_from_clipboard(&buf_paste, &buf_paste_len);
- bool has_required_data = !(but->poin == NULL && but->rnapoin.data == NULL);
+ const bool has_required_data = !(but->poin == NULL && but->rnapoin.data == NULL);
switch (but->type) {
case UI_BTYPE_NUM:
@@ -2873,7 +2874,7 @@ static bool ui_textedit_set_cursor_pos_foreach_glyph(const char *UNUSED(str),
void *user_data)
{
int *cursor_data = user_data;
- float center = glyph_step_bounds->xmin + (BLI_rctf_size_x(glyph_bounds) / 2.0f);
+ const float center = glyph_step_bounds->xmin + (BLI_rctf_size_x(glyph_bounds) / 2.0f);
if (cursor_data[0] < center) {
cursor_data[1] = str_step_ofs;
return false;
@@ -2942,7 +2943,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
else {
str_last = &str[but->ofs];
const int str_last_len = strlen(str_last);
- int x_pos = (int)(x - startx);
+ const int x_pos = (int)(x - startx);
int glyph_data[2] = {
x_pos, /* horizontal position to test. */
-1, /* Write the character offset here. */
@@ -2990,7 +2991,7 @@ static bool ui_textedit_insert_buf(uiBut *but,
int buf_len)
{
int len = strlen(data->str);
- int len_new = len - (but->selend - but->selsta) + 1;
+ const int len_new = len - (but->selend - but->selsta) + 1;
bool changed = false;
if (data->is_str_dynamic) {
@@ -3190,7 +3191,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
/* cut & copy */
else if (ELEM(mode, UI_TEXTEDIT_COPY, UI_TEXTEDIT_CUT)) {
/* copy the contents to the copypaste buffer */
- int sellen = but->selend - but->selsta;
+ const int sellen = but->selend - but->selsta;
char *buf = MEM_mallocN(sizeof(char) * (sellen + 1), "ui_textedit_copypaste");
BLI_strncpy(buf, data->str + but->selsta, sellen + 1);
@@ -3350,7 +3351,7 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
if (but) {
if (UI_but_is_utf8(but)) {
- int strip = BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr));
+ const int strip = BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr));
/* not a file?, strip non utf-8 chars */
if (strip) {
/* wont happen often so isn't that annoying to keep it here for a while */
@@ -3466,9 +3467,9 @@ static void ui_do_but_textedit(
#ifdef WITH_INPUT_IME
wmWindow *win = CTX_wm_window(C);
wmIMEData *ime_data = win->ime_data;
- bool is_ime_composing = ime_data && ime_data->is_ime_composing;
+ const bool is_ime_composing = ime_data && ime_data->is_ime_composing;
#else
- bool is_ime_composing = false;
+ const bool is_ime_composing = false;
#endif
switch (event->type) {
@@ -3515,7 +3516,7 @@ static void ui_do_but_textedit(
}
break;
case LEFTMOUSE: {
- bool had_selection = but->selsta != but->selend;
+ const bool had_selection = but->selsta != but->selend;
/* exit on LMB only on RELEASE for searchbox, to mimic other popups,
* and allow multiple menu levels */
@@ -3673,7 +3674,7 @@ static void ui_do_but_textedit(
case EVT_TABKEY:
/* there is a key conflict here, we can't tab with autocomplete */
if (but->autocomplete_func || data->searchbox) {
- int autocomplete = ui_textedit_autocomplete(C, but, data);
+ const int autocomplete = ui_textedit_autocomplete(C, but, data);
changed = autocomplete != AUTOCOMPLETE_NO_MATCH;
if (autocomplete == AUTOCOMPLETE_FULL_MATCH) {
@@ -3737,7 +3738,7 @@ static void ui_do_but_textedit(
}
if (utf8_buf && utf8_buf[0]) {
- int utf8_buf_len = BLI_str_utf8_size(utf8_buf);
+ const int utf8_buf_len = BLI_str_utf8_size(utf8_buf);
BLI_assert(utf8_buf_len != -1);
changed = ui_textedit_insert_buf(but, data, event->utf8_buf, utf8_buf_len);
}
@@ -4372,7 +4373,7 @@ static int ui_do_but_TAB(
return WM_UI_HANDLER_BREAK;
}
if (ELEM(event->type, LEFTMOUSE, EVT_PADENTER, EVT_RETKEY)) {
- int event_val = (is_property) ? KM_PRESS : KM_CLICK;
+ const int event_val = (is_property) ? KM_PRESS : KM_CLICK;
if (event->val == event_val) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
@@ -4580,7 +4581,7 @@ static float ui_numedit_apply_snapf(
if (ui_but_is_unit(but)) {
UnitSettings *unit = but->block->unit;
- int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but));
+ const int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but));
if (bUnit_IsValid(unit->system, unit_type)) {
fac = (float)bUnit_BaseScalar(unit->system, unit_type);
@@ -4603,7 +4604,7 @@ static float ui_numedit_apply_snapf(
* but allow for rotations */
if (softrange >= 21.0f) {
UnitSettings *unit = but->block->unit;
- int unit_type = UI_but_unit_type_get(but);
+ const int unit_type = UI_but_unit_type_get(but);
if ((unit_type == PROP_UNIT_ROTATION) && (unit->system_rotation != USER_UNIT_ROT_RADIANS)) {
/* pass (degrees)*/
}
@@ -4847,7 +4848,7 @@ static bool ui_numedit_but_NUM(uiBut *but,
static void ui_numedit_set_active(uiBut *but)
{
- int oldflag = but->drawflag;
+ const int oldflag = but->drawflag;
but->drawflag &= ~(UI_BUT_ACTIVE_LEFT | UI_BUT_ACTIVE_RIGHT);
uiHandleButtonData *data = but->active;
@@ -5119,7 +5120,7 @@ static bool ui_numedit_but_SLI(uiBut *but,
(but->softmax - but->softmin + but->a1);
}
else {
- float offs = (BLI_rctf_size_y(&but->rect) / 2.0f);
+ const float offs = (BLI_rctf_size_y(&but->rect) / 2.0f);
cursor_x_range = (BLI_rctf_size_x(&but->rect) - offs);
}
@@ -5414,7 +5415,7 @@ static int ui_do_but_SCROLL(
bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
int retval = WM_UI_HANDLER_CONTINUE;
- bool horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect));
+ const bool horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect));
int mx = event->x;
int my = event->y;
@@ -5632,8 +5633,8 @@ static bool ui_numedit_but_UNITVEC(
* else we'll get a harmless but annoying jump when first clicking */
float *fp = data->origvec;
- float rad = BLI_rctf_size_x(&but->rect);
- float radsq = rad * rad;
+ const float rad = BLI_rctf_size_x(&but->rect);
+ const float radsq = rad * rad;
int mdx, mdy;
if (fp[2] > 0.0f) {
@@ -5754,7 +5755,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
hsv[2] = clamp_f(hsv[2] + 0.05f, 0.0f, 1.0f);
}
else {
- float fac = 0.005 * (event->y - event->prevy);
+ const float fac = 0.005 * (event->y - event->prevy);
hsv[2] = clamp_f(hsv[2] + fac, 0.0f, 1.0f);
}
@@ -5973,7 +5974,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but,
float rgb[3];
float x, y;
float mx_fl, my_fl;
- bool changed = true;
+ const bool changed = true;
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
@@ -6046,7 +6047,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but,
break;
case UI_GRAD_V_ALT: {
/* vertical 'value' strip */
- float min = but->softmin, max = but->softmax;
+ const float min = but->softmin, max = but->softmax;
/* exception only for value strip - use the range set in but->min/max */
hsv[2] = y * (max - min) + min;
break;
@@ -6089,7 +6090,7 @@ static void ui_ndofedit_but_HSVCUBE(uiButHSVCube *hsv_but,
float *hsv = cpicker->color_data;
const float hsv_v_max = max_ff(hsv[2], hsv_but->but.softmax);
float rgb[3];
- float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
+ const float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
ui_but_v3_get(&hsv_but->but, rgb);
ui_scene_linear_to_color_picker_space(&hsv_but->but, rgb);
@@ -6252,7 +6253,7 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but,
const enum eSnapType snap,
const bool shift)
{
- bool changed = true;
+ const bool changed = true;
ColorPicker *cpicker = but->custom_data;
float *hsv = cpicker->color_data;
@@ -6356,7 +6357,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but,
float *hsv = cpicker->color_data;
float rgb[3];
float phi, r /*, sqr */ /* UNUSED */, v[2];
- float sensitivity = (shift ? 0.06f : 0.3f) * ndof->dt;
+ const float sensitivity = (shift ? 0.06f : 0.3f) * ndof->dt;
ui_but_v3_get(but, rgb);
ui_scene_linear_to_color_picker_space(but, rgb);
@@ -6541,7 +6542,7 @@ static bool ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int m
return changed;
}
- float dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect);
+ const float dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect);
data->dragcbd->pos += dx;
CLAMP(data->dragcbd->pos, 0.0f, 1.0f);
@@ -6567,7 +6568,7 @@ static int ui_do_but_COLORBAND(
if (event->ctrl) {
/* insert new key on mouse location */
- float pos = ((float)(mx - but->rect.xmin)) / BLI_rctf_size_x(&but->rect);
+ const float pos = ((float)(mx - but->rect.xmin)) / BLI_rctf_size_x(&but->rect);
BKE_colorband_element_add(coba, pos);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -6679,7 +6680,7 @@ static bool ui_numedit_but_CURVE(uiBlock *block,
for (int a = 0; a < cuma->totpoint; a++) {
if (cmp[a].flag & CUMA_SELECT) {
- float origx = cmp[a].x, origy = cmp[a].y;
+ const float origx = cmp[a].x, origy = cmp[a].y;
cmp[a].x += fx;
cmp[a].y += fy;
if (snap) {
@@ -7201,8 +7202,8 @@ static int ui_do_but_CURVEPROFILE(
static bool ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx, int my)
{
Histogram *hist = (Histogram *)but->poin;
- bool changed = true;
- float dy = my - data->draglasty;
+ const bool changed = true;
+ const float dy = my - data->draglasty;
/* scale histogram values (dy / 10 for better control) */
const float yfac = min_ff(pow2f(hist->ymax), 1.0f) * 0.5f;
@@ -7275,9 +7276,9 @@ static int ui_do_but_HISTOGRAM(
static bool ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, int my)
{
Scopes *scopes = (Scopes *)but->poin;
- bool changed = true;
+ const bool changed = true;
- float dy = my - data->draglasty;
+ const float dy = my - data->draglasty;
/* scale waveform values */
scopes->wavefrm_yfac += dy / 200.0f;
@@ -7349,7 +7350,7 @@ static bool ui_numedit_but_TRACKPREVIEW(
bContext *C, uiBut *but, uiHandleButtonData *data, int mx, int my, const bool shift)
{
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
- bool changed = true;
+ const bool changed = true;
float dx = mx - data->draglastx;
float dy = my - data->draglasty;
@@ -7361,7 +7362,7 @@ static bool ui_numedit_but_TRACKPREVIEW(
if (!scopes->track_locked) {
const MovieClip *clip = CTX_data_edit_movieclip(C);
- int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scopes->framenr);
+ const int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scopes->framenr);
if (scopes->marker->framenr != clip_framenr) {
scopes->marker = BKE_tracking_marker_ensure(scopes->track, clip_framenr);
}
@@ -7433,7 +7434,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
uiHandleButtonData *data = but->active;
int retval = WM_UI_HANDLER_CONTINUE;
- bool is_disabled = but->flag & UI_BUT_DISABLED;
+ const bool is_disabled = but->flag & UI_BUT_DISABLED;
/* if but->pointype is set, but->poin should be too */
BLI_assert(!but->pointype || but->poin);
@@ -7446,8 +7447,8 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
/* handle copy and paste */
bool is_press_ctrl_but_no_shift = event->val == KM_PRESS && IS_EVENT_MOD(event, ctrl, oskey) &&
!event->shift;
- bool do_copy = event->type == EVT_CKEY && is_press_ctrl_but_no_shift;
- bool do_paste = event->type == EVT_VKEY && is_press_ctrl_but_no_shift;
+ const bool do_copy = event->type == EVT_CKEY && is_press_ctrl_but_no_shift;
+ const bool do_paste = event->type == EVT_VKEY && is_press_ctrl_but_no_shift;
/* Specific handling for listrows, we try to find their overlapping tex button. */
if ((do_copy || do_paste) && but->type == UI_BTYPE_LISTROW) {
@@ -7764,8 +7765,8 @@ static void button_tooltip_timer_reset(bContext *C, uiBut *but)
if ((U.flag & USER_TOOLTIPS) || (data->tooltip_force)) {
if (!but->block->tooltipdisabled) {
if (!wm->drags.first) {
- bool is_label = UI_but_has_tooltip_label(but);
- double delay = is_label ? UI_TOOLTIP_DELAY_LABEL : UI_TOOLTIP_DELAY;
+ const bool is_label = UI_but_has_tooltip_label(but);
+ const double delay = is_label ? UI_TOOLTIP_DELAY_LABEL : UI_TOOLTIP_DELAY;
WM_tooltip_timer_init_ex(
C, data->window, data->area, data->region, ui_but_tooltip_init, delay);
if (is_label) {
@@ -8576,7 +8577,7 @@ static bool ui_handle_button_activate_by_type(bContext *C, ARegion *region, uiBu
static bool ui_button_value_default(uiBut *but, double *r_value)
{
if (but->rnaprop != NULL && ui_but_is_rna_valid(but)) {
- int type = RNA_property_type(but->rnaprop);
+ const int type = RNA_property_type(but->rnaprop);
if (ELEM(type, PROP_FLOAT, PROP_INT)) {
double default_value;
switch (type) {
@@ -8826,7 +8827,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
data = but->active;
if (data && data->state == BUTTON_STATE_EXIT) {
uiBut *post_but = data->postbut;
- uiButtonActivateType post_type = data->posttype;
+ const uiButtonActivateType post_type = data->posttype;
/* Reset the button value when empty text is typed. */
if ((data->cancel == false) && (data->str != NULL) && (data->str[0] == '\0') &&
@@ -8930,7 +8931,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *regi
const int *new_order = dyn_data->items_filter_neworder;
int org_idx = -1, len = dyn_data->items_len;
int current_idx = -1;
- int filter_exclude = ui_list->filter_flag & UILST_FLT_EXCLUDE;
+ const int filter_exclude = ui_list->filter_flag & UILST_FLT_EXCLUDE;
for (int i = 0; i < len; i++) {
if (!dyn_data->items_filter_flags ||
@@ -9438,7 +9439,7 @@ float ui_block_calc_pie_segment(uiBlock *block, const float event_xy[2])
float seg2[2];
sub_v2_v2v2(seg2, event_xy, seg1);
- float len = normalize_v2_v2(block->pie_data.pie_dir, seg2);
+ const float len = normalize_v2_v2(block->pie_data.pie_dir, seg2);
if (len < U.pie_menu_threshold * U.dpi_fac) {
block->pie_data.flags |= UI_PIE_INVALID_DIR;
@@ -9469,9 +9470,9 @@ static int ui_handle_menu_event(bContext *C,
ui_window_to_block(region, block, &mx, &my);
/* check if mouse is inside block */
- bool inside = BLI_rctf_isect_pt(&block->rect, mx, my);
+ const bool inside = BLI_rctf_isect_pt(&block->rect, mx, my);
/* check for title dragging */
- bool inside_title = inside && ((my + (UI_UNIT_Y * 1.5f)) > block->rect.ymax);
+ const bool inside_title = inside && ((my + (UI_UNIT_Y * 1.5f)) > block->rect.ymax);
/* if there's an active modal button, don't check events or outside, except for search menu */
but = ui_region_find_active_but(region);
@@ -9650,7 +9651,7 @@ static int ui_handle_menu_event(bContext *C,
if (val == KM_PRESS) {
/* Determine scroll operation. */
uiMenuScrollType scrolltype;
- bool ui_block_flipped = (block->flag & UI_BLOCK_IS_FLIP) != 0;
+ const bool ui_block_flipped = (block->flag & UI_BLOCK_IS_FLIP) != 0;
if (ELEM(type, EVT_PAGEUPKEY, EVT_HOMEKEY)) {
scrolltype = ui_block_flipped ? MENU_SCROLL_TOP : MENU_SCROLL_BOTTOM;
@@ -10116,7 +10117,7 @@ static int ui_but_pie_menu_apply(bContext *C,
uiBut *but,
bool force_close)
{
- int retval = WM_UI_HANDLER_BREAK;
+ const int retval = WM_UI_HANDLER_BREAK;
if (but && ui_but_pie_menu_supported_apply(but)) {
if (but->type == UI_BTYPE_MENU) {
@@ -10193,7 +10194,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
ARegion *region = menu->region;
uiBlock *block = region->uiblocks.first;
- bool is_click_style = (block->pie_data.flags & UI_PIE_CLICK_STYLE);
+ const bool is_click_style = (block->pie_data.flags & UI_PIE_CLICK_STYLE);
/* if there's an active modal button, don't check events or outside, except for search menu */
uiBut *but_active = ui_region_find_active_but(region);
@@ -10204,14 +10205,14 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
menu->scrolltimer->duration = 0.0;
}
- double duration = menu->scrolltimer->duration;
+ const double duration = menu->scrolltimer->duration;
float event_xy[2] = {event->x, event->y};
ui_window_to_block_fl(region, block, &event_xy[0], &event_xy[1]);
/* Distance from initial point. */
- float dist = ui_block_calc_pie_segment(block, event_xy);
+ const float dist = ui_block_calc_pie_segment(block, event_xy);
if (but_active && button_modal_state(but_active->active->state)) {
retval = ui_handle_menu_button(C, event, menu);
@@ -10226,9 +10227,9 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
/* handle animation */
if (!(block->pie_data.flags & UI_PIE_ANIMATION_FINISHED)) {
- double final_time = 0.01 * U.pie_animation_timeout;
+ const double final_time = 0.01 * U.pie_animation_timeout;
float fac = duration / final_time;
- float pie_radius = U.pie_menu_radius * UI_DPI_FAC;
+ const float pie_radius = U.pie_menu_radius * UI_DPI_FAC;
if (fac > 1.0f) {
fac = 1.0f;
@@ -10318,7 +10319,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
switch (event->type) {
case MOUSEMOVE:
if (!is_click_style) {
- float len_sq = len_squared_v2v2(event_xy, block->pie_data.pie_center_init);
+ const float len_sq = len_squared_v2v2(event_xy, block->pie_data.pie_center_init);
/* here we use the initial position explicitly */
if (len_sq > PIE_CLICK_THRESHOLD_SQ) {
@@ -10455,7 +10456,8 @@ static int ui_handle_menus_recursive(bContext *C,
bool inside = false;
/* root pie menus accept the key that spawned
* them as double click to improve responsiveness */
- bool do_recursion = (!(block->flag & UI_BLOCK_RADIAL) || event->type != block->pie_data.event);
+ const bool do_recursion = (!(block->flag & UI_BLOCK_RADIAL) ||
+ event->type != block->pie_data.event);
if (do_recursion) {
if (is_parent_inside == false) {
@@ -10510,7 +10512,7 @@ static int ui_handle_menus_recursive(bContext *C,
bool handled = false;
if (listbox) {
- int retval_test = ui_handle_list_event(C, event, menu->region, listbox);
+ const int retval_test = ui_handle_list_event(C, event, menu->region, listbox);
if (retval_test != WM_UI_HANDLER_CONTINUE) {
retval = retval_test;
handled = true;
@@ -10743,7 +10745,7 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
if (menu->menuretval) {
wmWindow *win = CTX_wm_window(C);
/* copy values, we have to free first (closes region) */
- uiPopupBlockHandle temp = *menu;
+ const uiPopupBlockHandle temp = *menu;
uiBlock *block = menu->region->uiblocks.first;
/* set last pie event to allow chained pie spawning */
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index edf66d82cbc..887f149ee12 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -264,9 +264,9 @@ static void viconutil_set_point(GLint pt[2], int x, int y)
static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
{
GLint pts[3][2];
- int cx = x + w / 2 - 4;
- int cy = y + w / 2;
- int d = w / 5, d2 = w / 7;
+ const int cx = x + w / 2 - 4;
+ const int cy = y + w / 2;
+ const int d = w / 5, d2 = w / 7;
viconutil_set_point(pts[0], cx - d2, cy + d);
viconutil_set_point(pts[1], cx - d2, cy - d);
@@ -301,17 +301,17 @@ static void vicon_keytype_draw_wrapper(
* while the draw_keyframe_shape() function needs the midpoint for
* the keyframe
*/
- float xco = x + w / 2 + 0.5f;
- float yco = y + h / 2 + 0.5f;
+ const float xco = x + w / 2 + 0.5f;
+ const float yco = y + h / 2 + 0.5f;
GPUVertFormat *format = immVertexFormat();
- uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ const uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
uint color_id = GPU_vertformat_attr_add(
format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
uint outline_color_id = GPU_vertformat_attr_add(
format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
- uint flags_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT);
+ const uint flags_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT);
GPU_program_point_size(true);
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
@@ -323,7 +323,7 @@ static void vicon_keytype_draw_wrapper(
* - size: (default icon size == 16, default dopesheet icon size == 10)
* - sel: true unless in handletype icons (so that "keyframe" state shows the iconic yellow icon)
*/
- bool sel = (handle_type == KEYFRAME_HANDLE_NONE);
+ const bool sel = (handle_type == KEYFRAME_HANDLE_NONE);
draw_keyframe_shape(xco,
yco,
@@ -490,7 +490,7 @@ static void init_brush_icons(void)
# define INIT_BRUSH_ICON(icon_id, name) \
{ \
uchar *rect = (uchar *)datatoc_##name##_png; \
- int size = datatoc_##name##_png_size; \
+ const int size = datatoc_##name##_png_size; \
DrawInfo *di; \
\
di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_BUFFER, 0); \
@@ -732,7 +732,7 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
for (int y = 0; y < ICON_GRID_ROWS; y++) {
for (int x = 0; x < ICON_GRID_COLS; x++) {
- IconType icontype = icontypes[y * ICON_GRID_COLS + x];
+ const IconType icontype = icontypes[y * ICON_GRID_COLS + x];
if (icontype.type != ICON_TYPE_MONO_TEXTURE) {
continue;
}
@@ -743,7 +743,7 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
sy = sy / resolution_divider;
/* blur the alpha channel and store it in blurred_alpha_buffer */
- int blur_size = 2 / resolution_divider;
+ const int blur_size = 2 / resolution_divider;
for (int bx = 0; bx < icon_width; bx++) {
const int asx = MAX2(bx - blur_size, 0);
const int aex = MIN2(bx + blur_size + 1, icon_width);
@@ -758,7 +758,7 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
for (int ax = asx; ax < aex; ax++) {
for (int ay = asy; ay < aey; ay++) {
const int offset_read = (sy + ay) * buf->x + (sx + ax);
- uint color_read = buf->rect[offset_read];
+ const uint color_read = buf->rect[offset_read];
const float alpha_read = ((color_read & 0xff000000) >> 24) / 255.0;
alpha_accum += alpha_read;
alpha_samples += 1;
@@ -790,8 +790,8 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
blend_color_interpolate_float(dest_rgba, orig_rgba, border_rgba, 1.0 - orig_rgba[3]);
linearrgb_to_srgb_v4(dest_srgb, dest_rgba);
- uint alpha_mask = ((uint)(dest_srgb[3] * 255)) << 24;
- uint cpack = rgb_to_cpack(dest_srgb[0], dest_srgb[1], dest_srgb[2]) | alpha_mask;
+ const uint alpha_mask = ((uint)(dest_srgb[3] * 255)) << 24;
+ const uint cpack = rgb_to_cpack(dest_srgb[0], dest_srgb[1], dest_srgb[2]) | alpha_mask;
result->rect[offset_write] = cpack;
}
}
@@ -820,7 +820,7 @@ void UI_icons_reload_internal_textures(void)
bTheme *btheme = UI_GetTheme();
ImBuf *b16buf = NULL, *b32buf = NULL, *b16buf_border = NULL, *b32buf_border = NULL;
const float icon_border_intensity = btheme->tui.icon_border_intensity;
- bool need_icons_with_border = icon_border_intensity > 0.0f;
+ const bool need_icons_with_border = icon_border_intensity > 0.0f;
if (b16buf == NULL) {
b16buf = IMB_ibImageFromMemory((const uchar *)datatoc_blender_icons16_png,
@@ -936,7 +936,7 @@ static void init_internal_icons(void)
for (y = 0; y < ICON_GRID_ROWS; y++) {
/* Row W has monochrome icons. */
for (x = 0; x < ICON_GRID_COLS; x++) {
- IconType icontype = icontypes[y * ICON_GRID_COLS + x];
+ const IconType icontype = icontypes[y * ICON_GRID_COLS + x];
if (!ELEM(icontype.type, ICON_TYPE_COLOR_TEXTURE, ICON_TYPE_MONO_TEXTURE)) {
continue;
}
@@ -1130,7 +1130,7 @@ void UI_icons_free_drawinfo(void *drawinfo)
*/
static DrawInfo *icon_create_drawinfo(Icon *icon)
{
- int icon_data_type = icon->obj_type;
+ const int icon_data_type = icon->obj_type;
DrawInfo *di = NULL;
di = MEM_callocN(sizeof(DrawInfo), "di_icon");
@@ -1246,7 +1246,7 @@ int UI_preview_render_size(enum eIconSizes size)
*/
static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
{
- uint render_size = UI_preview_render_size(size);
+ const uint render_size = UI_preview_render_size(size);
if (!prv_img) {
if (G.debug & G_DEBUG) {
@@ -1351,7 +1351,7 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi
img->w = STUDIOLIGHT_ICON_SIZE;
img->h = STUDIOLIGHT_ICON_SIZE;
- size_t size = STUDIOLIGHT_ICON_SIZE * STUDIOLIGHT_ICON_SIZE * sizeof(uint);
+ const size_t size = STUDIOLIGHT_ICON_SIZE * STUDIOLIGHT_ICON_SIZE * sizeof(uint);
img->rect = MEM_mallocN(size, __func__);
memset(img->rect, 0, size);
di->data.buffer.image = img;
@@ -1479,7 +1479,7 @@ static void icon_draw_rect(float x,
return;
}
/* modulate color */
- float col[4] = {alpha, alpha, alpha, alpha};
+ const float col[4] = {alpha, alpha, alpha, alpha};
/* rect contains image in 'rendersize', we only scale if needed */
if (rw != w || rh != h) {
@@ -1565,8 +1565,8 @@ static void icon_draw_cache_texture_flush_ex(GPUTexture *texture,
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR);
GPU_shader_bind(shader);
- int img_binding = GPU_shader_get_texture_binding(shader, "image");
- int data_loc = GPU_shader_get_uniform(shader, "calls_data");
+ const int img_binding = GPU_shader_get_texture_binding(shader, "image");
+ const int data_loc = GPU_shader_get_uniform(shader, "calls_data");
GPU_texture_bind(texture, img_binding);
GPU_sampler_icon_bind(img_binding);
@@ -1703,10 +1703,10 @@ static void icon_draw_texture(float x,
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
GPU_shader_bind(shader);
- int img_binding = GPU_shader_get_texture_binding(shader, "image");
- int color_loc = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR);
- int rect_tex_loc = GPU_shader_get_uniform(shader, "rect_icon");
- int rect_geom_loc = GPU_shader_get_uniform(shader, "rect_geom");
+ const int img_binding = GPU_shader_get_texture_binding(shader, "image");
+ const int color_loc = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR);
+ const int rect_tex_loc = GPU_shader_get_uniform(shader, "rect_icon");
+ const int rect_geom_loc = GPU_shader_get_uniform(shader, "rect_geom");
if (rgb) {
GPU_shader_uniform_vector(shader, color_loc, 4, 1, (float[4]){UNPACK3(rgb), alpha});
@@ -1838,7 +1838,7 @@ static void icon_draw_size(float x,
}
else if (di->type == ICON_TYPE_MONO_TEXTURE) {
/* Monochrome icon that uses text or theme color. */
- bool with_border = mono_border && (btheme->tui.icon_border_intensity > 0.0f);
+ const bool with_border = mono_border && (btheme->tui.icon_border_intensity > 0.0f);
float color[4];
if (mono_rgba) {
rgba_uchar_to_float(color, (const uchar *)mono_rgba);
@@ -2222,7 +2222,7 @@ int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big
/* get icon from ID */
if (id) {
- int icon = ui_id_icon_get(C, id, big);
+ const int icon = ui_id_icon_get(C, id, big);
return icon ? icon : rnaicon;
}
@@ -2334,7 +2334,7 @@ void UI_icon_draw_ex(float x,
const uchar mono_color[4],
const bool mono_border)
{
- int draw_size = get_draw_size(ICON_SIZE_ICON);
+ const int draw_size = get_draw_size(ICON_SIZE_ICON);
icon_draw_size(x,
y,
icon_id,
diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c
index 4be2dbc0b4e..223fcbfd45b 100644
--- a/source/blender/editors/interface/interface_icons_event.c
+++ b/source/blender/editors/interface/interface_icons_event.c
@@ -85,8 +85,8 @@ static void icon_draw_rect_input_text(const rctf *rect,
BLF_size(font_id, font_size * U.pixelsize, U.dpi);
float width, height;
BLF_width_and_height(font_id, str, BLF_DRAW_STR_DUMMY_MAX, &width, &height);
- float x = rect->xmin + (((rect->xmax - rect->xmin) - width) / 2.0f);
- float y = rect->ymin + (((rect->ymax - rect->ymin) - height) / 2.0f);
+ const float x = rect->xmin + (((rect->xmax - rect->xmin) - width) / 2.0f);
+ const float y = rect->ymin + (((rect->ymax - rect->ymin) - height) / 2.0f);
BLF_position(font_id, x, y, 0.0f);
BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_batch_draw_flush();
@@ -98,8 +98,8 @@ static void icon_draw_rect_input_symbol(const rctf *rect, const float color[4],
const int font_id = blf_mono_font;
BLF_color4fv(font_id, color);
BLF_size(font_id, 19 * U.pixelsize, U.dpi);
- float x = rect->xmin + (2.0f * U.pixelsize);
- float y = rect->ymin + (1.0f * U.pixelsize);
+ const float x = rect->xmin + (2.0f * U.pixelsize);
+ const float y = rect->ymin + (1.0f * U.pixelsize);
BLF_position(font_id, x, y, 0.0f);
BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_batch_draw_flush();
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index ad76466b67c..8184962a54b 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -225,7 +225,7 @@ typedef struct uiLayoutItemRoot {
static const char *ui_item_name_add_colon(const char *name, char namestr[UI_MAX_NAME_STR])
{
- int len = strlen(name);
+ const int len = strlen(name);
if (len != 0 && len + 1 < UI_MAX_NAME_STR) {
memcpy(namestr, name, len);
@@ -251,7 +251,7 @@ static int ui_item_fit(
return available - pos;
}
- float width = *extra_pixel + (item * available) / (float)all;
+ const float width = *extra_pixel + (item * available) / (float)all;
*extra_pixel = width - (int)width;
return (int)width;
}
@@ -262,7 +262,7 @@ static int ui_item_fit(
return available - pos;
}
- float width = *extra_pixel + (item * available) / (float)all;
+ const float width = *extra_pixel + (item * available) / (float)all;
*extra_pixel = width - (int)width;
return (int)width;
}
@@ -457,8 +457,8 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
PointerRNA *ptr = &but->rnapoin;
PropertyRNA *prop = but->rnaprop;
int i, index = POINTER_AS_INT(arg_index);
- int shift = win->eventstate->shift;
- int len = RNA_property_array_length(ptr, prop);
+ const int shift = win->eventstate->shift;
+ const int len = RNA_property_array_length(ptr, prop);
if (!shift) {
RNA_property_boolean_set_index(ptr, prop, index, true);
@@ -519,7 +519,7 @@ static void ui_item_array(uiLayout *layout,
if (type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) {
/* special check for layer layout */
int butw, buth, unit;
- int cols = (len >= 20) ? 2 : 1;
+ const int cols = (len >= 20) ? 2 : 1;
const uint colbuts = len / (2 * cols);
uint layer_used = 0;
uint layer_active = 0;
@@ -721,7 +721,7 @@ static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2)
if (!win->eventstate->shift) {
uiBut *but = (uiBut *)arg1;
- int enum_value = POINTER_AS_INT(arg2);
+ const int enum_value = POINTER_AS_INT(arg2);
int current_value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
if (!(current_value & enum_value)) {
@@ -814,7 +814,7 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
BLI_assert(RNA_property_type(prop) == PROP_ENUM);
uiLayout *layout_radial = NULL;
- bool radial = (layout->root->type == UI_LAYOUT_PIEMENU);
+ const bool radial = (layout->root->type == UI_LAYOUT_PIEMENU);
if (radial) {
RNA_property_enum_items_gettexted_all(block->evil_C, ptr, prop, &item_array, NULL, &free);
}
@@ -1179,7 +1179,7 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
w = ui_text_icon_width(layout, name, icon, 0);
- int prev_emboss = layout->emboss;
+ const int prev_emboss = layout->emboss;
if (flag & UI_ITEM_R_NO_BG) {
layout->emboss = UI_EMBOSS_NONE;
}
@@ -1223,7 +1223,7 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
opptr->data = properties;
}
else {
- IDPropertyTemplate val = {0};
+ const IDPropertyTemplate val = {0};
opptr->data = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
}
if (r_opptr) {
@@ -2043,7 +2043,7 @@ void uiItemFullR(uiLayout *layout,
if ((layout->root->type == UI_LAYOUT_MENU) ||
/* Use checkboxes only as a fallback in pie-menu's, when no icon is defined. */
((layout->root->type == UI_LAYOUT_PIEMENU) && (icon == ICON_NONE))) {
- int prop_flag = RNA_property_flag(prop);
+ const int prop_flag = RNA_property_flag(prop);
if (type == PROP_BOOLEAN) {
if ((is_array == false) || (index != RNA_NO_INDEX)) {
if (prop_flag & PROP_ICONS_CONSECUTIVE) {
@@ -2060,7 +2060,7 @@ void uiItemFullR(uiLayout *layout,
}
else if (type == PROP_ENUM) {
if (index == RNA_ENUM_VALUE) {
- int enum_value = RNA_property_enum_get(ptr, prop);
+ const int enum_value = RNA_property_enum_get(ptr, prop);
if (prop_flag & PROP_ICONS_CONSECUTIVE) {
icon = ICON_CHECKBOX_DEHLT; /* but->iconadd will set to correct icon */
}
@@ -2099,7 +2099,7 @@ void uiItemFullR(uiLayout *layout,
int w, h;
ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, compact, &w, &h);
- int prev_emboss = layout->emboss;
+ const int prev_emboss = layout->emboss;
if (no_bg) {
layout->emboss = UI_EMBOSS_NONE;
}
@@ -3193,7 +3193,7 @@ uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int
{
if (layout->item.flag & UI_ITEM_PROP_SEP) {
uiBlock *block = uiLayoutGetBlock(layout);
- uiPropertySplitWrapper split_wrapper = uiItemPropertySplitWrapperCreate(layout);
+ const uiPropertySplitWrapper split_wrapper = uiItemPropertySplitWrapperCreate(layout);
/* Further items added to 'layout' will automatically be added to split_wrapper.property_row */
uiItemL_(split_wrapper.label_column, text, icon);
@@ -3272,7 +3272,7 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval)
void uiItemS_ex(uiLayout *layout, float factor)
{
uiBlock *block = layout->root->block;
- bool is_menu = ui_block_is_menu(block);
+ const bool is_menu = ui_block_is_menu(block);
if (is_menu && !UI_block_can_add_separator(block)) {
return;
}
@@ -3794,7 +3794,7 @@ static void ui_litem_layout_radial(uiLayout *litem)
* also the old code at http://developer.blender.org/T5103
*/
- int pie_radius = U.pie_menu_radius * UI_DPI_FAC;
+ const int pie_radius = U.pie_menu_radius * UI_DPI_FAC;
x = litem->x;
y = litem->y;
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index e47761236ca..82e6e01056c 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -201,7 +201,7 @@ static int copy_as_driver_button_exec(bContext *C, wmOperator *op)
if (ptr.owner_id && ptr.data && prop) {
ID *id;
- int dim = RNA_property_array_dimension(&ptr, prop, NULL);
+ const int dim = RNA_property_array_dimension(&ptr, prop, NULL);
char *path = RNA_path_from_real_ID_to_property_index(bmain, &ptr, prop, dim, index, &id);
if (path) {
@@ -378,7 +378,7 @@ static bool assign_default_button_poll(bContext *C)
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
- PropertyType type = RNA_property_type(prop);
+ const PropertyType type = RNA_property_type(prop);
return RNA_property_is_idprop(prop) && !RNA_property_array_check(prop) &&
ELEM(type, PROP_INT, PROP_FLOAT);
@@ -1174,7 +1174,7 @@ bool ui_jump_to_target_button_poll(bContext *C)
static int jump_to_target_button_exec(bContext *C, wmOperator *UNUSED(op))
{
- bool success = jump_to_target_button(C, false);
+ const bool success = jump_to_target_button(C, false);
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1474,16 +1474,16 @@ static int edittranslation_exec(bContext *C, wmOperator *op)
const char *root = U.i18ndir;
const char *uilng = BLT_lang_get();
- uiStringInfo but_label = {BUT_GET_LABEL, NULL};
- uiStringInfo rna_label = {BUT_GET_RNA_LABEL, NULL};
- uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL};
- uiStringInfo but_tip = {BUT_GET_TIP, NULL};
- uiStringInfo rna_tip = {BUT_GET_RNA_TIP, NULL};
- uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL};
- uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL};
- uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL};
- uiStringInfo rna_enum = {BUT_GET_RNAENUM_IDENTIFIER, NULL};
- uiStringInfo rna_ctxt = {BUT_GET_RNA_LABEL_CONTEXT, NULL};
+ const uiStringInfo but_label = {BUT_GET_LABEL, NULL};
+ const uiStringInfo rna_label = {BUT_GET_RNA_LABEL, NULL};
+ const uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL};
+ const uiStringInfo but_tip = {BUT_GET_TIP, NULL};
+ const uiStringInfo rna_tip = {BUT_GET_RNA_TIP, NULL};
+ const uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL};
+ const uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL};
+ const uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL};
+ const uiStringInfo rna_enum = {BUT_GET_RNAENUM_IDENTIFIER, NULL};
+ const uiStringInfo rna_ctxt = {BUT_GET_RNA_LABEL_CONTEXT, NULL};
if (!BLI_is_dir(root)) {
BKE_report(op->reports,
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 4f3c36c0b3b..0b4bf0493f4 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -489,7 +489,7 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
*/
static bool panel_set_expand_from_list_data_recursive(Panel *panel, short flag, short *flag_index)
{
- bool open = (flag & (1 << *flag_index));
+ const bool open = (flag & (1 << *flag_index));
bool changed = (open == (bool)(panel->flag & PNL_CLOSED));
SET_FLAG_FROM_TEST(panel->flag, !open, PNL_CLOSED);
@@ -514,7 +514,7 @@ void UI_panel_set_expand_from_list_data(const bContext *C, Panel *panel)
return;
}
- short expand_flag = panel->type->get_list_data_expand_flag(C, panel);
+ const short expand_flag = panel->type->get_list_data_expand_flag(C, panel);
short flag_index = 0;
/* Start panel animation if the open state was changed. */
@@ -528,7 +528,7 @@ void UI_panel_set_expand_from_list_data(const bContext *C, Panel *panel)
*/
static void get_panel_expand_flag(Panel *panel, short *flag, short *flag_index)
{
- bool open = !(panel->flag & PNL_CLOSED);
+ const bool open = !(panel->flag & PNL_CLOSED);
SET_FLAG_FROM_TEST(*flag, open, (1 << *flag_index));
LISTBASE_FOREACH (Panel *, child, &panel->children) {
@@ -574,7 +574,7 @@ static void set_panels_list_data_expand_flag(const bContext *C, ARegion *region)
*/
static bool panel_set_flag_recursive(Panel *panel, int flag, bool value)
{
- short flag_original = panel->flag;
+ const short flag_original = panel->flag;
SET_FLAG_FROM_TEST(panel->flag, value, flag);
@@ -760,8 +760,8 @@ void UI_panel_end(const ARegion *region, uiBlock *block, int width, int height,
panel->sizey = height;
}
else {
- int old_sizex = panel->sizex, old_sizey = panel->sizey;
- int old_region_ofsx = panel->runtime.region_ofsx;
+ const int old_sizex = panel->sizex, old_sizey = panel->sizey;
+ const int old_region_ofsx = panel->runtime.region_ofsx;
/* update width/height if non-zero */
if (width != 0) {
@@ -791,7 +791,7 @@ static void ui_offset_panel_block(uiBlock *block)
/* compute bounds and offset */
ui_block_bounds_calc(block);
- int ofsy = block->panel->sizey - style->panelspace;
+ const int ofsy = block->panel->sizey - style->panelspace;
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
but->rect.ymin += ofsy;
@@ -808,9 +808,9 @@ static void ui_offset_panel_block(uiBlock *block)
/* triangle 'icon' for panel header */
void UI_draw_icon_tri(float x, float y, char dir, const float color[4])
{
- float f3 = 0.05 * U.widget_unit;
- float f5 = 0.15 * U.widget_unit;
- float f7 = 0.25 * U.widget_unit;
+ const float f3 = 0.05 * U.widget_unit;
+ const float f5 = 0.15 * U.widget_unit;
+ const float f7 = 0.25 * U.widget_unit;
if (dir == 'h') {
UI_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y, color);
@@ -849,7 +849,7 @@ static void ui_draw_aligned_panel_header(const uiStyle *style,
const uiFontStyle *fontstyle = (is_subpanel) ? &style->widgetlabel : &style->paneltitle;
/* + 0.001f to avoid flirting with float inaccuracy */
- int pnl_icons = (panel->labelofs + (1.1f * PNL_ICON)) / block->aspect + 0.001f;
+ const int pnl_icons = (panel->labelofs + (1.1f * PNL_ICON)) / block->aspect + 0.001f;
/* draw text label */
uchar col_title[4];
@@ -892,7 +892,8 @@ void ui_draw_aligned_panel(const uiStyle *style,
box_wcol = &btheme->tui.wcol_box;
}
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
if (show_background) {
@@ -940,8 +941,8 @@ void ui_draw_aligned_panel(const uiStyle *style,
/* Draw the header backdrop. */
if (show_background && !is_subpanel && !draw_box_style) {
- float minx = rect->xmin;
- float y = headrect.ymax;
+ const float minx = rect->xmin;
+ const float y = headrect.ymax;
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
GPU_blend(GPU_BLEND_ALPHA);
@@ -1113,7 +1114,7 @@ static int get_panel_size_y(const Panel *panel)
static int get_panel_real_size_y(const Panel *panel)
{
- int sizey = (panel->flag & PNL_CLOSED) ? 0 : panel->sizey;
+ const int sizey = (panel->flag & PNL_CLOSED) ? 0 : panel->sizey;
if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
return sizey;
@@ -1272,8 +1273,8 @@ static bool uiAlignPanelStep(ARegion *region, const float fac, const bool drag)
for (i = 0; i < tot - 1; i++, ps++) {
PanelSort *psnext = ps + 1;
- bool use_box = ps->panel->type && ps->panel->type->flag & PNL_DRAW_BOX;
- bool use_box_next = psnext->panel->type && psnext->panel->type->flag & PNL_DRAW_BOX;
+ const bool use_box = ps->panel->type && ps->panel->type->flag & PNL_DRAW_BOX;
+ const bool use_box_next = psnext->panel->type && psnext->panel->type->flag & PNL_DRAW_BOX;
psnext->panel->ofsx = ps->panel->ofsx;
psnext->panel->ofsy = get_panel_real_ofsy(ps->panel) - get_panel_size_y(psnext->panel);
@@ -1329,8 +1330,8 @@ static void ui_panels_size(ARegion *region, int *r_x, int *r_y)
/* compute size taken up by panels, for setting in view2d */
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
if (panel->runtime_flag & PNL_ACTIVE) {
- int pa_sizex = panel->ofsx + panel->sizex;
- int pa_sizey = get_panel_real_ofsy(panel);
+ const int pa_sizex = panel->ofsx + panel->sizex;
+ const int pa_sizey = get_panel_real_ofsy(panel);
sizex = max_ii(sizex, pa_sizex);
sizey = min_ii(sizey, pa_sizey);
@@ -1462,7 +1463,7 @@ void UI_panels_scale(ARegion *region, float new_width)
{
LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
if (block->panel) {
- float fac = new_width / (float)block->panel->sizex;
+ const float fac = new_width / (float)block->panel->sizex;
block->panel->sizex = new_width;
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
@@ -1482,8 +1483,8 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
ARegion *region = CTX_wm_region(C);
/* Keep the drag position in the region with a small pad to keep the panel visible. */
- int x = clamp_i(event->x, region->winrct.xmin, region->winrct.xmax + DRAG_REGION_PAD);
- int y = clamp_i(event->y, region->winrct.ymin, region->winrct.ymax + DRAG_REGION_PAD);
+ const int x = clamp_i(event->x, region->winrct.xmin, region->winrct.xmax + DRAG_REGION_PAD);
+ const int y = clamp_i(event->y, region->winrct.ymin, region->winrct.ymax + DRAG_REGION_PAD);
float dx = (float)(x - data->startx);
float dy = (float)(y - data->starty);
@@ -1568,7 +1569,7 @@ static void ui_panel_drag_collapse(const bContext *C,
if (panel == NULL || (panel->type && (panel->type->flag & PNL_NO_HEADER))) {
continue;
}
- int oldflag = panel->flag;
+ const int oldflag = panel->flag;
/* lock axis */
xy_b_block[0] = dragcol_data->xy_init[0];
@@ -1990,14 +1991,14 @@ static void ui_panel_category_draw_tab(bool filled,
}
if (use_flip_x) {
- float midx = (minx + maxx) / 2.0f;
+ const float midx = (minx + maxx) / 2.0f;
for (int i = 0; i < buf_index; i++) {
vbuf[i][0] = midx - (vbuf[i][0] - midx);
}
}
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
uint color = GPU_vertformat_attr_add(
format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
@@ -2169,7 +2170,7 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
const rcti *rct = &pc_dyn->rect;
const char *category_id = pc_dyn->idname;
const char *category_id_draw = IFACE_(category_id);
- int category_width = BLI_rcti_size_y(rct) - (tab_v_pad_text * 2);
+ const int category_width = BLI_rcti_size_y(rct) - (tab_v_pad_text * 2);
size_t category_draw_len = BLF_DRAW_STR_DUMMY_MAX;
// int category_width = BLF_width(fontid, category_id_draw, BLF_DRAW_STR_DUMMY_MAX);
@@ -2522,7 +2523,7 @@ PointerRNA *UI_region_panel_custom_data_under_cursor(const bContext *C, const wm
int mx = event->x;
int my = event->y;
ui_window_to_block(region, block, &mx, &my);
- int mouse_state = ui_panel_mouse_state_get(block, panel, mx, my);
+ const int mouse_state = ui_panel_mouse_state_get(block, panel, mx, my);
if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) {
break;
}
@@ -2588,7 +2589,7 @@ static void panel_activate_state(const bContext *C, Panel *panel, uiHandlePanelS
return;
}
- bool was_drag_drop = (data && data->state == PANEL_STATE_DRAG);
+ const bool was_drag_drop = (data && data->state == PANEL_STATE_DRAG);
/* Set selection state for the panel and its sub-panels, which need to know they are selected
* too so they can be drawn above their parent when it's dragged. */
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index 8648a54f7d5..9dcfe8c872b 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -256,7 +256,7 @@ bool ui_but_contains_point_px_icon(const uiBut *but, ARegion *region, const wmEv
rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect));
}
else {
- int delta = BLI_rcti_size_x(&rect) - BLI_rcti_size_y(&rect);
+ const int delta = BLI_rcti_size_x(&rect) - BLI_rcti_size_y(&rect);
rect.xmin += delta / 2;
rect.xmax -= delta / 2;
}
@@ -315,7 +315,7 @@ uiBut *ui_but_find_rect_over(const struct ARegion *region, const rcti *rect_px)
}
/* Currently no need to expose this at the moment. */
- bool labeledit = true;
+ const bool labeledit = true;
rctf rect_px_fl;
BLI_rctf_rcti_copy(&rect_px_fl, rect_px);
uiBut *butover = NULL;
diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.c
index 8bc0f18886b..de80d6270bf 100644
--- a/source/blender/editors/interface/interface_region_color_picker.c
+++ b/source/blender/editors/interface/interface_region_color_picker.c
@@ -351,7 +351,7 @@ static void ui_colorpicker_hide_reveal(uiBlock *block, enum ePickerType colormod
static void ui_colorpicker_create_mode_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
{
uiBut *bt = bt1;
- short colormode = ui_but_value_get(bt);
+ const short colormode = ui_but_value_get(bt);
ui_colorpicker_hide_reveal(bt->block, colormode);
}
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c
index 204653f047d..d34bcb0e1e9 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -178,7 +178,7 @@ static void hud_region_layout(const bContext *C, ARegion *region)
}
ScrArea *area = CTX_wm_area(C);
- int size_y = region->sizey;
+ const int size_y = region->sizey;
ED_region_panels_layout(C, region);
@@ -316,7 +316,7 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *area)
}
bool init = false;
- bool was_hidden = region == NULL || region->visible == false;
+ const bool was_hidden = region == NULL || region->visible == false;
ARegion *region_op = CTX_wm_region(C);
BLI_assert((region_op == NULL) || (region_op->regiontype != RGN_TYPE_HUD));
if (!last_redo_poll(C, region_op ? region_op->regiontype : -1)) {
diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c
index 1371c7524ae..631f395390f 100644
--- a/source/blender/editors/interface/interface_region_menu_pie.c
+++ b/source/blender/editors/interface/interface_region_menu_pie.c
@@ -387,7 +387,7 @@ void ui_pie_menu_level_create(uiBlock *block,
{
const int totitem_parent = PIE_MAX_ITEMS - 1;
const int totitem_remain = totitem - totitem_parent;
- size_t array_size = sizeof(EnumPropertyItem) * totitem_remain;
+ const size_t array_size = sizeof(EnumPropertyItem) * totitem_remain;
/* used as but->func_argN so freeing is handled elsewhere */
EnumPropertyItem *remaining = MEM_mallocN(array_size + sizeof(EnumPropertyItem),
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 43233205877..9ef68e9e187 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -151,7 +151,7 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
UI_block_bounds_set_normal(block, block_margin);
/* If menu slides out of other menu, override direction. */
- bool slideout = ui_block_is_menu(pup->but->block);
+ const bool slideout = ui_block_is_menu(pup->but->block);
if (slideout) {
UI_block_direction_set(block, UI_DIR_RIGHT);
}
@@ -254,7 +254,7 @@ uiPopupBlockHandle *ui_popover_panel_create(
/* FIXME: maybe one day we want non panel popovers? */
{
- int ui_units_x = ((PanelType *)arg)->ui_units_x;
+ const int ui_units_x = ((PanelType *)arg)->ui_units_x;
pup->ui_size_x = U.widget_unit * (ui_units_x ? ui_units_x : UI_POPOVER_WIDTH_UNITS);
}
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index 947bdca4f9e..5445b098e5b 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -565,8 +565,8 @@ uiBlock *ui_popup_block_refresh(bContext *C,
wmWindow *window = CTX_wm_window(C);
ARegion *region = handle->region;
- uiBlockCreateFunc create_func = handle->popup_create_vars.create_func;
- uiBlockHandleCreateFunc handle_create_func = handle->popup_create_vars.handle_create_func;
+ const uiBlockCreateFunc create_func = handle->popup_create_vars.create_func;
+ const uiBlockHandleCreateFunc handle_create_func = handle->popup_create_vars.handle_create_func;
void *arg = handle->popup_create_vars.arg;
uiBlock *block_old = region->uiblocks.first;
@@ -638,7 +638,7 @@ uiBlock *ui_popup_block_refresh(bContext *C,
}
if (block->flag & UI_BLOCK_RADIAL) {
- int win_width = UI_SCREEN_MARGIN;
+ const int win_width = UI_SCREEN_MARGIN;
int winx, winy;
int x_offset = 0, y_offset = 0;
@@ -712,7 +712,7 @@ uiBlock *ui_popup_block_refresh(bContext *C,
* the same height. */
if (handle->refresh && handle->prev_block_rect.ymax > block->rect.ymax) {
if (block->bounds_type != UI_BLOCK_BOUNDS_POPUP_CENTER) {
- float offset = handle->prev_block_rect.ymax - block->rect.ymax;
+ const float offset = handle->prev_block_rect.ymax - block->rect.ymax;
UI_block_translate(block, 0, offset);
block->rect.ymin = handle->prev_block_rect.ymin;
}
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index adb2c1c802f..0711d953ebd 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -256,8 +256,8 @@ static void ui_searchbox_butrect(rcti *r_rect, uiSearchboxData *data, int itemnr
{
/* thumbnail preview */
if (data->preview) {
- int butw = (BLI_rcti_size_x(&data->bbox) - 2 * MENU_BORDER) / data->prv_cols;
- int buth = (BLI_rcti_size_y(&data->bbox) - 2 * MENU_BORDER) / data->prv_rows;
+ const int butw = (BLI_rcti_size_x(&data->bbox) - 2 * MENU_BORDER) / data->prv_cols;
+ const int buth = (BLI_rcti_size_y(&data->bbox) - 2 * MENU_BORDER) / data->prv_rows;
int row, col;
*r_rect = data->bbox;
@@ -273,7 +273,7 @@ static void ui_searchbox_butrect(rcti *r_rect, uiSearchboxData *data, int itemnr
}
/* list view */
else {
- int buth = (BLI_rcti_size_y(&data->bbox) - 2 * UI_POPUP_MENU_TOP) / SEARCH_ITEMS;
+ const int buth = (BLI_rcti_size_y(&data->bbox) - 2 * UI_POPUP_MENU_TOP) / SEARCH_ITEMS;
*r_rect = data->bbox;
r_rect->xmin = data->bbox.xmin + 3.0f;
@@ -701,7 +701,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearc
static ARegionType type;
ARegion *region;
uiSearchboxData *data;
- float aspect = but->block->aspect;
+ const float aspect = but->block->aspect;
rctf rect_fl;
rcti rect_i;
const int margin = UI_POPUP_MARGIN;
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index c324e27dff9..afeeb4cedc9 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -221,8 +221,8 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region
/* offset to the end of the last line */
if (field->text_suffix) {
- float xofs = field->geom.x_pos;
- float yofs = data->lineh * (field->geom.lines - 1);
+ const float xofs = field->geom.x_pos;
+ const float yofs = data->lineh * (field->geom.lines - 1);
bbox.xmin += xofs;
bbox.ymax -= yofs;
@@ -535,13 +535,13 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
char *shortcut = NULL;
{
- uiStringInfo op_keymap = {BUT_GET_OP_KEYMAP, NULL};
+ const uiStringInfo op_keymap = {BUT_GET_OP_KEYMAP, NULL};
UI_but_string_info_get(C, but, &op_keymap, NULL);
shortcut = op_keymap.strinfo;
}
if (shortcut == NULL) {
- ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
+ const ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
const char *tool_attr = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
if (tool_attr != NULL) {
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
@@ -768,14 +768,14 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but)
{
- uiStringInfo but_label = {BUT_GET_LABEL, NULL};
- uiStringInfo but_tip = {BUT_GET_TIP, NULL};
- uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL};
- uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL};
- uiStringInfo op_keymap = {BUT_GET_OP_KEYMAP, NULL};
- uiStringInfo prop_keymap = {BUT_GET_PROP_KEYMAP, NULL};
- uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL};
- uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL};
+ const uiStringInfo but_label = {BUT_GET_LABEL, NULL};
+ const uiStringInfo but_tip = {BUT_GET_TIP, NULL};
+ const uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL};
+ const uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL};
+ const uiStringInfo op_keymap = {BUT_GET_OP_KEYMAP, NULL};
+ const uiStringInfo prop_keymap = {BUT_GET_PROP_KEYMAP, NULL};
+ const uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL};
+ const uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL};
char buf[512];
@@ -884,7 +884,7 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but)
}
if (but->rnaprop) {
- int unit_type = UI_but_unit_type_get(but);
+ const int unit_type = UI_but_unit_type_get(but);
if (unit_type == PROP_UNIT_ROTATION) {
if (RNA_property_type(but->rnaprop) == PROP_FLOAT) {
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 28279996559..b38ad9f6adb 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -184,7 +184,7 @@ void UI_fontstyle_draw_ex(const uiFontStyle *fs,
}
else {
/* draw from boundbox center */
- float height = BLF_ascender(fs->uifont_id) + BLF_descender(fs->uifont_id);
+ const float height = BLF_ascender(fs->uifont_id) + BLF_descender(fs->uifont_id);
yofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));
}
@@ -517,7 +517,8 @@ void uiStyleInit(void)
/* Set default flags based on UI preferences (not render fonts) */
{
- int flag_disable = (BLF_MONOCHROME | BLF_HINTING_NONE | BLF_HINTING_SLIGHT | BLF_HINTING_FULL);
+ const int flag_disable = (BLF_MONOCHROME | BLF_HINTING_NONE | BLF_HINTING_SLIGHT |
+ BLF_HINTING_FULL);
int flag_enable = 0;
if (U.text_render & USER_TEXT_HINTING_NONE) {
diff --git a/source/blender/editors/interface/interface_template_search_menu.c b/source/blender/editors/interface/interface_template_search_menu.c
index 0708714c659..d148ff70751 100644
--- a/source/blender/editors/interface/interface_template_search_menu.c
+++ b/source/blender/editors/interface/interface_template_search_menu.c
@@ -535,7 +535,7 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
RNA_pointer_create(&screen->id, &RNA_Area, area, &ptr);
const int space_type_ui = RNA_property_enum_get(&ptr, prop_ui_type);
- int space_type_ui_index = RNA_enum_from_value(space_type_ui_items, space_type_ui);
+ const int space_type_ui_index = RNA_enum_from_value(space_type_ui_items, space_type_ui);
if (space_type_ui_index == -1) {
continue;
}
@@ -952,7 +952,7 @@ static void menu_search_exec_fn(bContext *C, void *UNUSED(arg1), void *arg2)
case MENU_SEARCH_TYPE_RNA: {
PointerRNA *ptr = &item->rna.ptr;
PropertyRNA *prop = item->rna.prop;
- int index = item->rna.index;
+ const int index = item->rna.index;
const int prop_type = RNA_property_type(prop);
bool changed = false;
@@ -1131,7 +1131,7 @@ void UI_but_func_menu_search(uiBut *but)
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
/* When run from top-bar scan all areas in the current window. */
- bool include_all_areas = (area && (area->spacetype == SPACE_TOPBAR));
+ const bool include_all_areas = (area && (area->spacetype == SPACE_TOPBAR));
struct MenuSearch_Data *data = menu_items_from_ui_create(
C, win, area, region, include_all_areas);
UI_but_func_search_set(but,
diff --git a/source/blender/editors/interface/interface_template_search_operator.c b/source/blender/editors/interface/interface_template_search_operator.c
index b8070ccbb25..76a6abe22cb 100644
--- a/source/blender/editors/interface/interface_template_search_operator.c
+++ b/source/blender/editors/interface/interface_template_search_operator.c
@@ -91,7 +91,7 @@ static void operator_search_update_fn(const bContext *C,
if (index == words_len) {
if (WM_operator_poll((bContext *)C, ot)) {
char name[256];
- int len = strlen(ot_ui_name);
+ const int len = strlen(ot_ui_name);
/* display name for menu, can hold hotkey */
BLI_strncpy(name, ot_ui_name, sizeof(name));
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index d0f45e4eb9b..8962755ea90 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -139,7 +139,7 @@ static void template_add_button_search_menu(const bContext *C,
const bool editable,
const bool live_icon)
{
- PointerRNA active_ptr = RNA_property_pointer_get(ptr, prop);
+ const PointerRNA active_ptr = RNA_property_pointer_get(ptr, prop);
ID *id = (active_ptr.data && RNA_struct_is_ID(active_ptr.type)) ? active_ptr.data : NULL;
const ID *idfrom = ptr->owner_id;
const StructRNA *type = active_ptr.type ? active_ptr.type : RNA_property_pointer_type(ptr, prop);
@@ -164,7 +164,7 @@ static void template_add_button_search_menu(const bContext *C,
but = uiDefBlockButN(block, block_func, block_argN, "", 0, 0, width, height, tip);
if (use_preview_icon) {
- int icon = id ? ui_id_icon_get(C, id, use_big_size) : RNA_struct_ui_icon(type);
+ const int icon = id ? ui_id_icon_get(C, id, use_big_size) : RNA_struct_ui_icon(type);
ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
}
else {
@@ -183,7 +183,7 @@ static void template_add_button_search_menu(const bContext *C,
but = uiDefBlockButN(block, block_func, block_argN, "", 0, 0, UI_UNIT_X * 1.6, UI_UNIT_Y, tip);
if (live_icon) {
- int icon = id ? ui_id_icon_get(C, id, false) : RNA_struct_ui_icon(type);
+ const int icon = id ? ui_id_icon_get(C, id, false) : RNA_struct_ui_icon(type);
ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
}
else {
@@ -395,7 +395,7 @@ static void id_search_cb(const bContext *C,
{
TemplateID *template_ui = (TemplateID *)arg_template;
ListBase *lb = template_ui->idlb;
- int flag = RNA_property_flag(template_ui->prop);
+ const int flag = RNA_property_flag(template_ui->prop);
/* ID listbase */
LISTBASE_FOREACH (ID *, id, lb) {
@@ -415,7 +415,7 @@ static void id_search_cb_tagged(const bContext *C,
{
TemplateID *template_ui = (TemplateID *)arg_template;
ListBase *lb = template_ui->idlb;
- int flag = RNA_property_flag(template_ui->prop);
+ const int flag = RNA_property_flag(template_ui->prop);
/* ID listbase */
LISTBASE_FOREACH (ID *, id, lb) {
@@ -520,7 +520,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
TemplateID *template_ui = (TemplateID *)arg_litem;
PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
ID *id = idptr.data;
- int event = POINTER_AS_INT(arg_event);
+ const int event = POINTER_AS_INT(arg_event);
const char *undo_push_label = NULL;
switch (event) {
@@ -1058,7 +1058,7 @@ static void template_ID(const bContext *C,
RNA_int_set(but->opptr, "id_type", GS(id->name));
}
else if (flag & UI_ID_OPEN) {
- int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
+ const int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
if (openop) {
but = uiDefIconTextButO(block,
@@ -1864,7 +1864,7 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
Object *ob = ED_object_active_context(C);
ListBase *modifiers = &ob->modifiers;
- bool panels_match = UI_panel_list_matches_data(region, modifiers, modifier_panel_id);
+ const bool panels_match = UI_panel_list_matches_data(region, modifiers, modifier_panel_id);
if (!panels_match) {
UI_panels_free_instanced(C, region);
@@ -1967,7 +1967,7 @@ static ListBase *get_constraints(const bContext *C, bool use_bone_constraints)
*/
static void constraint_reorder(bContext *C, Panel *panel, int new_index)
{
- bool constraint_from_bone = constraint_panel_is_bone(panel);
+ const bool constraint_from_bone = constraint_panel_is_bone(panel);
ListBase *lb = get_constraints(C, constraint_from_bone);
bConstraint *con = BLI_findlink(lb, panel->runtime.list_index);
@@ -1987,7 +1987,7 @@ static void constraint_reorder(bContext *C, Panel *panel, int new_index)
*/
static short get_constraint_expand_flag(const bContext *C, Panel *panel)
{
- bool constraint_from_bone = constraint_panel_is_bone(panel);
+ const bool constraint_from_bone = constraint_panel_is_bone(panel);
ListBase *lb = get_constraints(C, constraint_from_bone);
bConstraint *con = BLI_findlink(lb, panel->runtime.list_index);
@@ -1999,7 +1999,7 @@ static short get_constraint_expand_flag(const bContext *C, Panel *panel)
*/
static void set_constraint_expand_flag(const bContext *C, Panel *panel, short expand_flag)
{
- bool constraint_from_bone = constraint_panel_is_bone(panel);
+ const bool constraint_from_bone = constraint_panel_is_bone(panel);
ListBase *lb = get_constraints(C, constraint_from_bone);
bConstraint *con = BLI_findlink(lb, panel->runtime.list_index);
@@ -2044,7 +2044,7 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
uiListPanelIDFromDataFunc panel_id_func = use_bone_constraints ? bone_constraint_panel_id :
object_constraint_panel_id;
- bool panels_match = UI_panel_list_matches_data(region, constraints, panel_id_func);
+ const bool panels_match = UI_panel_list_matches_data(region, constraints, panel_id_func);
if (!panels_match) {
UI_panels_free_instanced(C, region);
@@ -2119,7 +2119,8 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
Object *ob = ED_object_active_context(C);
ListBase *modifiers = &ob->greasepencil_modifiers;
- bool panels_match = UI_panel_list_matches_data(region, modifiers, gpencil_modifier_panel_id);
+ const bool panels_match = UI_panel_list_matches_data(
+ region, modifiers, gpencil_modifier_panel_id);
if (!panels_match) {
UI_panels_free_instanced(C, region);
@@ -2206,7 +2207,7 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C)
Object *ob = ED_object_active_context(C);
ListBase *shaderfx = &ob->shader_fx;
- bool panels_match = UI_panel_list_matches_data(region, shaderfx, shaderfx_panel_id);
+ const bool panels_match = UI_panel_list_matches_data(region, shaderfx, shaderfx_panel_id);
if (!panels_match) {
UI_panels_free_instanced(C, region);
@@ -2302,7 +2303,7 @@ static eAutoPropButsReturn template_operator_property_buts_draw_single(
eAutoPropButsReturn return_info = 0;
if (!op->properties) {
- IDPropertyTemplate val = {0};
+ const IDPropertyTemplate val = {0};
op->properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
}
@@ -3027,8 +3028,8 @@ static void colorband_distribute_cb(bContext *C, ColorBand *coba, bool evenly)
{
if (coba->tot > 1) {
int a;
- int tot = evenly ? coba->tot - 1 : coba->tot;
- float gap = 1.0f / tot;
+ const int tot = evenly ? coba->tot - 1 : coba->tot;
+ const float gap = 1.0f / tot;
float pos = 0.0f;
for (a = 0; a < coba->tot; a++) {
coba->data[a].pos = pos;
@@ -3210,9 +3211,9 @@ static void colorband_buttons_layout(uiLayout *layout,
{
uiLayout *row, *split, *subsplit;
uiBut *bt;
- float unit = BLI_rctf_size_x(butr) / 14.0f;
- float xs = butr->xmin;
- float ys = butr->ymin;
+ const float unit = BLI_rctf_size_x(butr) / 14.0f;
+ const float xs = butr->xmin;
+ const float ys = butr->ymin;
PointerRNA ptr;
RNA_pointer_create(cb->ptr.owner_id, &RNA_ColorRamp, coba, &ptr);
@@ -3885,7 +3886,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap
CurveMapping *cumap = cumap_v;
uiBlock *block;
uiBut *bt;
- float width = 8 * UI_UNIT_X;
+ const float width = 8 * UI_UNIT_X;
block = UI_block_begin(C, region, __func__, UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT);
@@ -4227,7 +4228,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
uiLayout *row, *sub, *split;
uiBlock *block;
uiBut *bt;
- float dx = UI_UNIT_X;
+ const float dx = UI_UNIT_X;
int icon, size;
int bg = -1, i;
@@ -4700,7 +4701,7 @@ static uiBlock *CurveProfile_tools_func(bContext *C, ARegion *region, CurveProfi
{
uiBlock *block;
short yco = 0;
- short menuwidth = 10 * UI_UNIT_X;
+ const short menuwidth = 10 * UI_UNIT_X;
block = UI_block_begin(C, region, __func__, UI_EMBOSS);
UI_block_func_butmenu_set(block, CurveProfile_tools_dofunc, profile);
@@ -5409,7 +5410,7 @@ void uiTemplatePalette(uiLayout *layout,
uiBut *but = NULL;
int row_cols = 0, col_id = 0;
- int cols_per_row = MAX2(uiLayoutGetWidth(layout) / UI_UNIT_X, 1);
+ const int cols_per_row = MAX2(uiLayoutGetWidth(layout) / UI_UNIT_X, 1);
if (!prop) {
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
@@ -5556,7 +5557,7 @@ void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propn
static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
{
uiBut *but = arg1;
- int cur = POINTER_AS_INT(arg2);
+ const int cur = POINTER_AS_INT(arg2);
wmWindow *win = CTX_wm_window(C);
int i, tot, shift = win->eventstate->shift;
@@ -5591,7 +5592,7 @@ void uiTemplateLayers(uiLayout *layout,
PropertyRNA *prop, *used_prop = NULL;
int groups, cols, layers;
int group, col, layer, row;
- int cols_per_group = 5;
+ const int cols_per_group = 5;
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -5639,7 +5640,7 @@ void uiTemplateLayers(uiLayout *layout,
/* add layers as toggle buts */
for (col = 0; (col < cols_per_group) && (layer < layers); col++, layer++) {
int icon = 0;
- int butlay = 1 << layer;
+ const int butlay = 1 << layer;
if (active_layer & butlay) {
icon = ICON_LAYER_ACTIVE;
@@ -5754,7 +5755,7 @@ static void uilist_filter_items_default(struct uiList *ui_list,
const bool filter_exclude = (ui_list->filter_flag & UILST_FLT_EXCLUDE) != 0;
const bool order_by_name = (ui_list->filter_sort_flag & UILST_FLT_SORT_MASK) ==
UILST_FLT_SORT_ALPHA;
- int len = RNA_property_collection_length(dataptr, prop);
+ const int len = RNA_property_collection_length(dataptr, prop);
dyn_data->items_shown = dyn_data->items_len = len;
@@ -5766,7 +5767,7 @@ static void uilist_filter_items_default(struct uiList *ui_list,
names = MEM_callocN(sizeof(StringCmp) * len, "StringCmp");
}
if (filter_raw[0]) {
- size_t slen = strlen(filter_raw);
+ const size_t slen = strlen(filter_raw);
dyn_data->items_filter_flags = MEM_callocN(sizeof(int) * len, "items_filter_flags");
dyn_data->items_shown = 0;
@@ -6204,8 +6205,8 @@ void uiTemplateList(uiLayout *layout,
for (i = layoutdata.start_idx; i < layoutdata.end_idx; i++) {
PointerRNA *itemptr = &items_ptr[i].item;
void *dyntip_data;
- int org_i = items_ptr[i].org_idx;
- int flt_flag = items_ptr[i].flt_flag;
+ const int org_i = items_ptr[i].org_idx;
+ const int flt_flag = items_ptr[i].flt_flag;
subblock = uiLayoutGetBlock(col);
overlap = uiLayoutOverlap(col);
@@ -6291,7 +6292,7 @@ void uiTemplateList(uiLayout *layout,
if ((dataptr->data && prop) && (dyn_data->items_shown > 0) && (activei >= 0) &&
(activei < dyn_data->items_shown)) {
PointerRNA *itemptr = &items_ptr[activei].item;
- int org_i = items_ptr[activei].org_idx;
+ const int org_i = items_ptr[activei].org_idx;
icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false);
if (icon == ICON_DOT) {
@@ -6341,8 +6342,8 @@ void uiTemplateList(uiLayout *layout,
/* create list items */
for (i = layoutdata.start_idx; i < layoutdata.end_idx; i++) {
PointerRNA *itemptr = &items_ptr[i].item;
- int org_i = items_ptr[i].org_idx;
- int flt_flag = items_ptr[i].flt_flag;
+ const int org_i = items_ptr[i].org_idx;
+ const int flt_flag = items_ptr[i].flt_flag;
/* create button */
if (!(i % columns)) {
@@ -6730,7 +6731,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
if (owner) {
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
- bool active = !(G.is_break || WM_jobs_is_stopped(wm, owner));
+ const bool active = !(G.is_break || WM_jobs_is_stopped(wm, owner));
uiLayout *row = uiLayoutRow(layout, false);
block = uiLayoutGetBlock(row);
@@ -7078,7 +7079,7 @@ bool uiTemplateEventFromKeymapItem(struct uiLayout *layout,
#ifdef WITH_HEADLESS
int icon = 0;
#else
- int icon = UI_icon_from_keymap_item(kmi, icon_mod);
+ const int icon = UI_icon_from_keymap_item(kmi, icon_mod);
#endif
if (icon != 0) {
for (int j = 0; j < ARRAY_SIZE(icon_mod) && icon_mod[j]; j++) {
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index f44987ac1d2..6be281cd050 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -249,7 +249,7 @@ uiBut *uiDefAutoButR(uiBlock *block,
break;
case PROP_POINTER: {
if (icon == 0) {
- PointerRNA pptr = RNA_property_pointer_get(ptr, prop);
+ const 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) {
@@ -436,7 +436,7 @@ void ui_rna_collection_search_update_fn(const struct bContext *C,
int name_prefix_offset = 0;
int iconid = ICON_NONE;
bool has_sep_char = false;
- bool is_id = itemptr.type && RNA_struct_is_ID(itemptr.type);
+ const bool is_id = itemptr.type && RNA_struct_is_ID(itemptr.type);
if (is_id) {
iconid = ui_id_icon_get(C, itemptr.data, false);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index bf64672fd81..ab0f6d90caa 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -475,7 +475,7 @@ GPUBatch *ui_batch_roundbox_shadow_get(void)
uint32_t last_data;
GPUVertBufRaw vflag_step;
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format());
- int vcount = (WIDGET_SIZE_MAX + 1) * 2 + 2 + WIDGET_SIZE_MAX;
+ const int vcount = (WIDGET_SIZE_MAX + 1) * 2 + 2 + WIDGET_SIZE_MAX;
GPU_vertbuf_data_alloc(vbo, vcount);
GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step);
@@ -528,7 +528,8 @@ void UI_draw_anti_tria(
GPU_blend(GPU_BLEND_ALPHA);
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(draw_color);
@@ -552,12 +553,12 @@ void UI_draw_anti_tria(
void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4])
{
if (dir == 'h') {
- float half = 0.5f * BLI_rctf_size_y(rect);
+ const float half = 0.5f * BLI_rctf_size_y(rect);
UI_draw_anti_tria(
rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half, color);
}
else {
- float half = 0.5f * BLI_rctf_size_x(rect);
+ const float half = 0.5f * BLI_rctf_size_x(rect);
UI_draw_anti_tria(
rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin, color);
}
@@ -572,7 +573,8 @@ void UI_draw_anti_fan(float tri_array[][2], uint length, const float color[4])
GPU_blend(GPU_BLEND_ALPHA);
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(draw_color);
@@ -706,14 +708,14 @@ static void round_box__edges(
uiWidgetBase *wt, int roundboxalign, const rcti *rect, float rad, float radi)
{
float vec[WIDGET_CURVE_RESOLU][2], veci[WIDGET_CURVE_RESOLU][2];
- float minx = rect->xmin, miny = rect->ymin, maxx = rect->xmax, maxy = rect->ymax;
- float minxi = minx + U.pixelsize; /* boundbox inner */
- float maxxi = maxx - U.pixelsize;
- float minyi = miny + U.pixelsize;
- float maxyi = maxy - U.pixelsize;
+ const float minx = rect->xmin, miny = rect->ymin, maxx = rect->xmax, maxy = rect->ymax;
+ const float minxi = minx + U.pixelsize; /* boundbox inner */
+ const float maxxi = maxx - U.pixelsize;
+ const float minyi = miny + U.pixelsize;
+ const float maxyi = maxy - U.pixelsize;
/* for uv, can divide by zero */
- float facxi = (maxxi != minxi) ? 1.0f / (maxxi - minxi) : 0.0f;
- float facyi = (maxyi != minyi) ? 1.0f / (maxyi - minyi) : 0.0f;
+ const float facxi = (maxxi != minxi) ? 1.0f / (maxxi - minxi) : 0.0f;
+ const float facyi = (maxyi != minyi) ? 1.0f / (maxyi - minyi) : 0.0f;
int a, tot = 0, minsize;
const int hnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT)) ==
(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT) ||
@@ -1012,8 +1014,8 @@ static void widget_draw_vertex_buffer(uint pos,
static void shape_preset_trias_from_rect_menu(uiWidgetTrias *tria, const rcti *rect)
{
- float width = BLI_rcti_size_x(rect);
- float height = BLI_rcti_size_y(rect);
+ const float width = BLI_rcti_size_x(rect);
+ const float height = BLI_rcti_size_y(rect);
float centx, centy, size;
tria->type = ROUNDBOX_TRIA_MENU;
@@ -1120,7 +1122,7 @@ static void widgetbase_set_uniform_alpha_check(uiWidgetBase *wtb, const bool alp
static void widgetbase_set_uniform_discard_factor(uiWidgetBase *wtb, const float discard_factor)
{
- bool alpha_check = wtb->uniform_params.alpha_discard < 0.0f;
+ const bool alpha_check = wtb->uniform_params.alpha_discard < 0.0f;
widgetbase_set_uniform_alpha_discard(wtb, alpha_check, discard_factor);
}
@@ -1344,8 +1346,8 @@ static void widget_draw_preview(BIFIconID icon, float alpha, const rcti *rect)
size -= PREVIEW_PAD * 2; /* padding */
if (size > 0) {
- int x = rect->xmin + w / 2 - size / 2;
- int y = rect->ymin + h / 2 - size / 2;
+ const int x = rect->xmin + w / 2 - size / 2;
+ const int y = rect->ymin + h / 2 - size / 2;
UI_icon_draw_preview(x, y, icon, 1.0f, alpha, size);
}
@@ -1406,7 +1408,7 @@ static void widget_draw_icon(
GPU_blend(GPU_BLEND_ALPHA);
if (icon && icon != ICON_BLANK1) {
- float ofs = 1.0f / aspect;
+ const float ofs = 1.0f / aspect;
if (but->drawflag & UI_BUT_ICON_LEFT) {
/* special case - icon_only pie buttons */
@@ -1434,7 +1436,7 @@ static void widget_draw_icon(
/* Get theme color. */
uchar color[4] = {mono_color[0], mono_color[1], mono_color[2], mono_color[3]};
- bool has_theme = UI_icon_get_theme_color(icon, color);
+ const bool has_theme = UI_icon_get_theme_color(icon, color);
/* to indicate draggable */
if (but->dragpoin && (but->flag & UI_ACTIVE)) {
@@ -1486,7 +1488,7 @@ static void widget_draw_submenu_tria(const uiBut *but,
static void ui_text_clip_give_prev_off(uiBut *but, const char *str)
{
const char *prev_utf8 = BLI_str_find_prev_char_utf8(str, str + but->ofs);
- int bytes = str + but->ofs - prev_utf8;
+ const int bytes = str + but->ofs - prev_utf8;
but->ofs -= bytes;
}
@@ -1494,7 +1496,7 @@ static void ui_text_clip_give_prev_off(uiBut *but, const char *str)
static void ui_text_clip_give_next_off(uiBut *but, const char *str)
{
const char *next_utf8 = BLI_str_find_next_char_utf8(str + but->ofs, NULL);
- int bytes = next_utf8 - (str + but->ofs);
+ const int bytes = next_utf8 - (str + but->ofs);
but->ofs += bytes;
}
@@ -1823,7 +1825,7 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
/* chop off the leading text, starting from the right */
while (but->strwidth > okwidth && cp2 > but->drawstr) {
const char *prev_utf8 = BLI_str_find_prev_char_utf8(but->drawstr, cp2);
- int bytes = cp2 - prev_utf8;
+ const int bytes = cp2 - prev_utf8;
/* shift the text after and including cp2 back by 1 char,
* +1 to include null terminator */
@@ -2286,7 +2288,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
rcti *rect)
{
const bool show_menu_icon = ui_but_draw_menu_icon(but);
- float alpha = (float)wcol->text[3] / 255.0f;
+ const float alpha = (float)wcol->text[3] / 255.0f;
char password_str[UI_MAX_DRAW_STR];
bool no_text_padding = but->drawflag & UI_BUT_NO_TEXT_PADDING;
@@ -2354,7 +2356,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
#endif
const BIFIconID icon = ui_but_icon(but);
- int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT;
+ const int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT;
const float icon_size = icon_size_init / (but->block->aspect * U.inv_dpi_fac);
const float icon_padding = 2 * UI_DPI_FAC;
@@ -2399,7 +2401,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
rect->xmin += text_padding;
}
else if (but->flag & UI_BUT_DRAG_MULTI) {
- bool text_is_edited = ui_but_drag_multi_edit_get(but) != NULL;
+ const bool text_is_edited = ui_but_drag_multi_edit_get(but) != NULL;
if (text_is_edited || (but->drawflag & UI_BUT_TEXT_LEFT)) {
rect->xmin += text_padding;
}
@@ -2487,7 +2489,7 @@ static void ui_widget_color_disabled(uiWidgetType *wt)
static void widget_active_color(uiWidgetColors *wcol)
{
- bool dark = (rgb_to_grayscale_byte(wcol->text) > rgb_to_grayscale_byte(wcol->inner));
+ const bool dark = (rgb_to_grayscale_byte(wcol->text) > rgb_to_grayscale_byte(wcol->inner));
color_mul_hsl_v3(wcol->inner, 1.0f, 1.15f, dark ? 1.2f : 1.1f);
color_mul_hsl_v3(wcol->outline, 1.0f, 1.15f, 1.15f);
color_mul_hsl_v3(wcol->text, 1.0f, 1.15f, dark ? 1.25f : 0.8f);
@@ -2746,12 +2748,13 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r
/* we draw a number of increasing size alpha quad strips */
alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout;
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
for (step = 1; step <= (int)radout; step++) {
- float expfac = sqrtf(step / radout);
+ const float expfac = sqrtf(step / radout);
round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step);
@@ -2798,7 +2801,8 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
static void ui_hsv_cursor(float x, float y)
{
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -2861,11 +2865,11 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const
const float radstep = 2.0f * (float)M_PI / (float)tot;
const float centx = BLI_rcti_cent_x_fl(rect);
const float centy = BLI_rcti_cent_y_fl(rect);
- float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
+ const float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
ColorPicker *cpicker = but->custom_data;
float rgb[3], hsv[3], rgb_center[3];
- bool is_color_gamma = ui_but_is_color_gamma(but);
+ const bool is_color_gamma = ui_but_is_color_gamma(but);
/* Initialize for compatibility. */
copy_v3_v3(hsv, cpicker->color_data);
@@ -2899,7 +2903,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ const uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
@@ -2909,8 +2913,8 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const
float ang = 0.0f;
for (int a = 0; a <= tot; a++, ang += radstep) {
- float si = sinf(ang);
- float co = cosf(ang);
+ const float si = sinf(ang);
+ const float co = cosf(ang);
float hsv_ang[3];
float rgb_ang[3];
@@ -2975,7 +2979,7 @@ void ui_draw_gradient(const rcti *rect,
const int steps = 48;
const float color_step = 1.0f / steps;
int a;
- float h = hsv[0], s = hsv[1], v = hsv[2];
+ const float h = hsv[0], s = hsv[1], v = hsv[2];
float dx, dy, sx1, sx2, sy;
float col0[4][3]; /* left half, rect bottom to top */
float col1[4][3]; /* right half, rect bottom to top */
@@ -3030,8 +3034,8 @@ void ui_draw_gradient(const rcti *rect,
/* old below */
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
immBegin(GPU_PRIM_TRIS, steps * 3 * 6);
@@ -3193,7 +3197,8 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
ui_hsv_cursor(x, y);
/* outline */
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ub(0, 0, 0);
imm_draw_box_wire_2d(pos, (rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax));
@@ -3224,7 +3229,7 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
/* map v from property range to [0,1] */
if (hsv_but->gradient_type == UI_GRAD_V_ALT) {
- float min = but->softmin, max = but->softmax;
+ const float min = but->softmin, max = but->softmax;
v = (v - min) / (max - min);
}
@@ -3259,7 +3264,7 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
/** Separator for menus. */
static void ui_draw_separator(const rcti *rect, const uiWidgetColors *wcol)
{
- int y = rect->ymin + BLI_rcti_size_y(rect) / 2 - 1;
+ const int y = rect->ymin + BLI_rcti_size_y(rect) / 2 - 1;
const uchar col[4] = {
wcol->text[0],
wcol->text[1],
@@ -3267,7 +3272,8 @@ static void ui_draw_separator(const rcti *rect, const uiWidgetColors *wcol)
30,
};
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
GPU_blend(GPU_BLEND_ALPHA);
@@ -3619,8 +3625,8 @@ static void widget_progressbar(
widget_init(&wtb_bar);
/* round corners */
- float value = but_progressbar->progress;
- float offs = wcol->roundness * BLI_rcti_size_y(&rect_prog);
+ const float value = but_progressbar->progress;
+ const float offs = wcol->roundness * BLI_rcti_size_y(&rect_prog);
float w = value * BLI_rcti_size_x(&rect_prog);
/* ensure minimium size */
@@ -3647,7 +3653,7 @@ static void widget_nodesocket(
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
{
uiWidgetBase wtb;
- int radi = 5;
+ const int radi = 5;
uchar old_inner[3], old_outline[3];
widget_init(&wtb);
@@ -3663,8 +3669,8 @@ static void widget_nodesocket(
wcol->outline[2] = 0;
wcol->outline[3] = 150;
- int cent_x = BLI_rcti_cent_x(rect);
- int cent_y = BLI_rcti_cent_y(rect);
+ const int cent_x = BLI_rcti_cent_x(rect);
+ const int cent_y = BLI_rcti_cent_y(rect);
rect->xmin = cent_x - radi;
rect->xmax = cent_x + radi;
rect->ymin = cent_y - radi;
@@ -3712,7 +3718,7 @@ static void widget_numslider(
rect1 = *rect;
float factor, factor_ui;
float factor_discard = 1.0f; /* No discard. */
- float value = (float)ui_but_value_get(but);
+ const float value = (float)ui_but_value_get(but);
if (but->rnaprop && (RNA_property_subtype(but->rnaprop) == PROP_PERCENTAGE)) {
factor = value / but->softmax;
@@ -3721,7 +3727,7 @@ static void widget_numslider(
factor = (value - but->softmin) / (but->softmax - but->softmin);
}
- float width = (float)BLI_rcti_size_x(rect);
+ const float width = (float)BLI_rcti_size_x(rect);
factor_ui = factor * width;
if (factor_ui <= offs) {
@@ -3829,8 +3835,8 @@ static void widget_swatch(
widgetbase_draw_ex(&wtb, wcol, show_alpha_checkers);
if (color_but->is_pallete_color &&
((Palette *)but->rnapoin.owner_id)->active_color == color_but->palette_color_index) {
- float width = rect->xmax - rect->xmin;
- float height = rect->ymax - rect->ymin;
+ const float width = rect->xmax - rect->xmin;
+ const float height = rect->ymax - rect->ymin;
/* find color luminance and change it slightly */
float bw = rgb_to_grayscale(col);
@@ -3841,7 +3847,8 @@ static void widget_swatch(
UI_widgetbase_draw_cache_flush();
GPU_blend(GPU_BLEND_NONE);
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3f(bw, bw, bw);
@@ -3969,7 +3976,7 @@ static void widget_menu_radial_itembut(
{
uiWidgetBase wtb;
float rad;
- float fac = but->block->pie_data.alphafac;
+ const float fac = but->block->pie_data.alphafac;
widget_init(&wtb);
@@ -4011,7 +4018,7 @@ static void widget_optionbut(uiWidgetColors *wcol,
int state,
int UNUSED(roundboxalign))
{
- bool text_before_widget = (state & UI_STATE_TEXT_BEFORE_WIDGET);
+ const bool text_before_widget = (state & UI_STATE_TEXT_BEFORE_WIDGET);
uiWidgetBase wtb;
rcti recttemp = *rect;
float rad;
@@ -4233,7 +4240,8 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
but->block->drawextra(
C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect);
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* make mask to draw over image */
@@ -4475,7 +4483,7 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
/* align with open menu */
if (but->active && (but->type != UI_BTYPE_POPOVER) && !ui_but_menu_draw_as_popover(but)) {
- int direction = ui_but_menu_direction(but);
+ const int direction = ui_but_menu_direction(but);
if (direction == UI_DIR_UP) {
roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT);
@@ -4923,7 +4931,8 @@ static void ui_draw_popover_back_impl(const uiWidgetColors *wcol,
/* Draw popover arrow (top/bottom) */
if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) {
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
const bool is_down = (direction == UI_DIR_DOWN);
@@ -5044,18 +5053,18 @@ static void draw_disk_shaded(float start,
void ui_draw_pie_center(uiBlock *block)
{
bTheme *btheme = UI_GetTheme();
- float cx = block->pie_data.pie_center_spawned[0];
- float cy = block->pie_data.pie_center_spawned[1];
+ const float cx = block->pie_data.pie_center_spawned[0];
+ const float cy = block->pie_data.pie_center_spawned[1];
float *pie_dir = block->pie_data.pie_dir;
- float pie_radius_internal = U.dpi_fac * U.pie_menu_threshold;
- float pie_radius_external = U.dpi_fac * (U.pie_menu_threshold + 7.0f);
+ const float pie_radius_internal = U.dpi_fac * U.pie_menu_threshold;
+ const float pie_radius_external = U.dpi_fac * (U.pie_menu_threshold + 7.0f);
- int subd = 40;
+ const int subd = 40;
- float angle = atan2f(pie_dir[1], pie_dir[0]);
- float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4;
+ const float angle = atan2f(pie_dir[1], pie_dir[0]);
+ const float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4;
GPU_matrix_push();
GPU_matrix_translate_2f(cx, cy);
@@ -5118,7 +5127,7 @@ void ui_draw_pie_center(uiBlock *block)
}
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ubv(btheme->tui.wcol_pie_menu.outline);
@@ -5129,8 +5138,9 @@ void ui_draw_pie_center(uiBlock *block)
if (U.pie_menu_confirm > 0 &&
!(block->pie_data.flags & (UI_PIE_INVALID_DIR | UI_PIE_CLICK_STYLE))) {
- float pie_confirm_radius = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm);
- float pie_confirm_external = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm + 7.0f);
+ const float pie_confirm_radius = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm);
+ const float pie_confirm_external = U.dpi_fac *
+ (pie_radius_internal + U.pie_menu_confirm + 7.0f);
const uchar col[4] = {UNPACK3(btheme->tui.wcol_pie_menu.text_sel), 64};
draw_disk_shaded(angle - range / 2.0f,
@@ -5213,7 +5223,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
int *r_xmax)
{
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
- rcti _rect = *rect;
+ const rcti _rect = *rect;
char *cpoin = NULL;
wt->state(wt, state, 0);
@@ -5283,8 +5293,8 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
if (iconid) {
float height, aspect;
- int xs = rect->xmin + 0.2f * UI_UNIT_X;
- int ys = rect->ymin + 0.1f * BLI_rcti_size_y(rect);
+ const int xs = rect->xmin + 0.2f * UI_UNIT_X;
+ const int ys = rect->ymin + 0.1f * BLI_rcti_size_y(rect);
height = ICON_SIZE_FROM_BUTRECT(rect);
aspect = ICON_DEFAULT_HEIGHT / height;
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index d4f81a89bc3..7651989c2df 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -351,7 +351,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
v2d->scroll |= (V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE);
if (do_init) {
- float panelzoom = (style) ? style->panelzoom : 1.0f;
+ const float panelzoom = (style) ? style->panelzoom : 1.0f;
v2d->tot.xmin = 0.0f;
v2d->tot.xmax = winx;
@@ -566,7 +566,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize)
* - width is not adjusted for changed ratios here.
*/
if (winx < v2d->oldwinx) {
- float temp = v2d->oldwinx - winx;
+ const float temp = v2d->oldwinx - winx;
cur->xmin -= temp;
cur->xmax -= temp;
@@ -588,7 +588,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize)
*/
if (winy < v2d->oldwiny) {
- float temp = v2d->oldwiny - winy;
+ const float temp = v2d->oldwiny - winy;
if (v2d->align & V2D_ALIGN_NO_NEG_Y) {
cur->ymin -= temp;
@@ -1121,14 +1121,14 @@ static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked)
*r_curmasked = v2d->cur;
if (view2d_scroll_mapped(v2d->scroll)) {
- float sizex = BLI_rcti_size_x(&v2d->mask);
- float sizey = BLI_rcti_size_y(&v2d->mask);
+ const float sizex = BLI_rcti_size_x(&v2d->mask);
+ const float sizey = BLI_rcti_size_y(&v2d->mask);
/* prevent tiny or narrow regions to get
* invalid coordinates - mask can get negative even... */
if (sizex > 0.0f && sizey > 0.0f) {
- float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1);
- float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1);
+ const float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1);
+ const float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1);
if (v2d->mask.xmin != 0) {
r_curmasked->xmin -= dx * (float)v2d->mask.xmin;
@@ -1225,8 +1225,8 @@ void UI_view2d_view_orthoSpecial(ARegion *region, View2D *v2d, const bool xaxis)
void UI_view2d_view_restore(const bContext *C)
{
ARegion *region = CTX_wm_region(C);
- int width = BLI_rcti_size_x(&region->winrct) + 1;
- int height = BLI_rcti_size_y(&region->winrct) + 1;
+ 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);
GPU_matrix_identity_set();
@@ -1278,8 +1278,8 @@ void UI_view2d_constant_grid_draw(const View2D *v2d, float step)
if (count_x > 0 || count_y > 0) {
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
float theme_color[3];
UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color);
@@ -1331,7 +1331,7 @@ void UI_view2d_multi_grid_draw(
vertex_count += 2 * ((int)((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1);
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
uint color = GPU_vertformat_attr_add(
format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
@@ -1428,7 +1428,7 @@ void UI_view2d_scrollers_calc(View2D *v2d,
{
rcti vert, hor;
float fac1, fac2, totsize, scrollsize;
- int scroll = view2d_scroll_mapped(v2d->scroll);
+ const int scroll = view2d_scroll_mapped(v2d->scroll);
int smaller;
/* Always update before drawing (for dynamically sized scrollers). */
@@ -1910,7 +1910,7 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C)
* disabled. */
void UI_view2d_scroller_size_get(const View2D *v2d, float *r_x, float *r_y)
{
- int scroll = view2d_scroll_mapped(v2d->scroll);
+ const int scroll = view2d_scroll_mapped(v2d->scroll);
if (r_x) {
if (scroll & V2D_SCROLL_VERTICAL) {
@@ -2128,7 +2128,7 @@ void UI_view2d_text_cache_add(
BLI_assert(str_len == strlen(str));
if (UI_view2d_view_to_region_clip(v2d, x, y, &mval[0], &mval[1])) {
- int alloc_len = str_len + 1;
+ const int alloc_len = str_len + 1;
View2DString *v2s;
if (g_v2d_strings_arena == NULL) {
@@ -2159,7 +2159,7 @@ void UI_view2d_text_cache_add_rectf(
BLI_assert(str_len == strlen(str));
if (UI_view2d_view_to_region_rcti_clip(v2d, rect_view, &rect)) {
- int alloc_len = str_len + 1;
+ const int alloc_len = str_len + 1;
View2DString *v2s;
if (g_v2d_strings_arena == NULL) {
diff --git a/source/blender/editors/interface/view2d_draw.c b/source/blender/editors/interface/view2d_draw.c
index 54b25939baf..5801b7cdbdb 100644
--- a/source/blender/editors/interface/view2d_draw.c
+++ b/source/blender/editors/interface/view2d_draw.c
@@ -67,10 +67,10 @@ static float select_major_distance(const float *possible_distances,
return possible_distances[0];
}
- float pixels_per_view_unit = pixel_width / view_width;
+ const float pixels_per_view_unit = pixel_width / view_width;
for (uint i = 0; i < amount; i++) {
- float distance = possible_distances[i];
+ const float distance = possible_distances[i];
if (pixels_per_view_unit * distance >= MIN_MAJOR_LINE_DISTANCE) {
return distance;
}
@@ -111,7 +111,7 @@ static float view2d_major_step_y__continuous(const View2D *v2d)
static float view2d_major_step_x__time(const View2D *v2d, const Scene *scene)
{
- double fps = FPS;
+ const double fps = FPS;
float *possible_distances = NULL;
BLI_array_staticdeclare(possible_distances, 32);
@@ -207,7 +207,7 @@ static void draw_parallel_lines(const ParallelLinesSet *lines,
}
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
if (U.pixelsize > 1.0f) {
float viewport[4];
@@ -227,14 +227,14 @@ static void draw_parallel_lines(const ParallelLinesSet *lines,
if (direction == 'v') {
for (uint i = 0; i < steps; i++) {
- float xpos = first + i * lines->distance;
+ const float xpos = first + i * lines->distance;
immVertex2f(pos, xpos, rect->ymin);
immVertex2f(pos, xpos, rect->ymax);
}
}
else {
for (uint i = 0; i < steps; i++) {
- float ypos = first + i * lines->distance;
+ const float ypos = first + i * lines->distance;
immVertex2f(pos, rect->xmin, ypos);
immVertex2f(pos, rect->xmax, ypos);
}
@@ -322,16 +322,16 @@ static void draw_horizontal_scale_indicators(const ARegion *region,
BLF_batch_draw_begin();
- float ypos = rect->ymin + 4 * UI_DPI_FAC;
- float xmin = rect->xmin;
- float xmax = rect->xmax;
+ const float ypos = rect->ymin + 4 * UI_DPI_FAC;
+ const float xmin = rect->xmin;
+ const float xmax = rect->xmax;
for (uint i = 0; i < steps; i++) {
- float xpos_view = start + i * distance;
- float xpos_region = UI_view2d_view_to_region_x(v2d, xpos_view);
+ const float xpos_view = start + i * distance;
+ const float xpos_region = UI_view2d_view_to_region_x(v2d, xpos_view);
char text[32];
to_string(to_string_data, xpos_view, distance, sizeof(text), text);
- float text_width = BLF_width(font_id, text, strlen(text));
+ const float text_width = BLF_width(font_id, text, strlen(text));
if (xpos_region - text_width / 2.0f >= xmin && xpos_region + text_width / 2.0f <= xmax) {
BLF_draw_default_ascii(xpos_region - text_width / 2.0f, ypos, 0.0f, text, sizeof(text));
@@ -384,16 +384,16 @@ static void draw_vertical_scale_indicators(const ARegion *region,
BLF_batch_draw_begin();
- float xpos = rect->xmax - 2.0f * UI_DPI_FAC;
- float ymin = rect->ymin;
- float ymax = rect->ymax;
+ const float xpos = rect->xmax - 2.0f * UI_DPI_FAC;
+ const float ymin = rect->ymin;
+ const float ymax = rect->ymax;
for (uint i = 0; i < steps; i++) {
- float ypos_view = start + i * distance;
- float ypos_region = UI_view2d_view_to_region_y(v2d, ypos_view + display_offset);
+ const float ypos_view = start + i * distance;
+ const float ypos_region = UI_view2d_view_to_region_y(v2d, ypos_view + display_offset);
char text[32];
to_string(to_string_data, ypos_view, distance, sizeof(text), text);
- float text_width = BLF_width(font_id, text, strlen(text));
+ const float text_width = BLF_width(font_id, text, strlen(text));
if (ypos_region - text_width / 2.0f >= ymin && ypos_region + text_width / 2.0f <= ymax) {
BLF_draw_default_ascii(xpos, ypos_region - text_width / 2.0f, 0.0f, text, sizeof(text));
@@ -417,7 +417,7 @@ static void view_to_string__time(
{
const Scene *scene = (const Scene *)user_data;
- int brevity_level = 0;
+ const int brevity_level = 0;
BLI_timecode_string_from_time(
r_str, max_len, brevity_level, v2d_pos / (float)FPS, FPS, U.timecode_style);
}
@@ -462,25 +462,25 @@ float UI_view2d_grid_resolution_y__values(const struct View2D *v2d)
void UI_view2d_draw_lines_x__discrete_values(const View2D *v2d)
{
- uint major_line_distance = view2d_major_step_x__discrete(v2d);
+ const uint major_line_distance = view2d_major_step_x__discrete(v2d);
view2d_draw_lines(v2d, major_line_distance, major_line_distance > 1, 'v');
}
void UI_view2d_draw_lines_x__values(const View2D *v2d)
{
- float major_line_distance = view2d_major_step_x__continuous(v2d);
+ const float major_line_distance = view2d_major_step_x__continuous(v2d);
view2d_draw_lines(v2d, major_line_distance, true, 'v');
}
void UI_view2d_draw_lines_y__values(const View2D *v2d)
{
- float major_line_distance = view2d_major_step_y__continuous(v2d);
+ const float major_line_distance = view2d_major_step_y__continuous(v2d);
view2d_draw_lines(v2d, major_line_distance, true, 'h');
}
void UI_view2d_draw_lines_x__discrete_time(const View2D *v2d, const Scene *scene)
{
- float major_line_distance = view2d_major_step_x__time(v2d, scene);
+ const float major_line_distance = view2d_major_step_x__time(v2d, scene);
view2d_draw_lines(v2d, major_line_distance, major_line_distance > 1, 'v');
}
@@ -516,7 +516,7 @@ static void UI_view2d_draw_scale_x__discrete_values(const ARegion *region,
const rcti *rect,
int colorid)
{
- float number_step = view2d_major_step_x__discrete(v2d);
+ const float number_step = view2d_major_step_x__discrete(v2d);
draw_horizontal_scale_indicators(
region, v2d, number_step, rect, view_to_string__frame_number, NULL, colorid);
}
@@ -524,7 +524,7 @@ static void UI_view2d_draw_scale_x__discrete_values(const ARegion *region,
static void UI_view2d_draw_scale_x__discrete_time(
const ARegion *region, const View2D *v2d, const rcti *rect, const Scene *scene, int colorid)
{
- float step = view2d_major_step_x__time(v2d, scene);
+ const float step = view2d_major_step_x__time(v2d, scene);
draw_horizontal_scale_indicators(
region, v2d, step, rect, view_to_string__time, (void *)scene, colorid);
}
@@ -534,7 +534,7 @@ static void UI_view2d_draw_scale_x__values(const ARegion *region,
const rcti *rect,
int colorid)
{
- float step = view2d_major_step_x__continuous(v2d);
+ const float step = view2d_major_step_x__continuous(v2d);
draw_horizontal_scale_indicators(region, v2d, step, rect, view_to_string__value, NULL, colorid);
}
@@ -543,7 +543,7 @@ void UI_view2d_draw_scale_y__values(const ARegion *region,
const rcti *rect,
int colorid)
{
- float step = view2d_major_step_y__continuous(v2d);
+ const float step = view2d_major_step_y__continuous(v2d);
draw_vertical_scale_indicators(
region, v2d, step, 0.0f, rect, view_to_string__value, NULL, colorid);
}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index eb47c5c3e6d..7234e279da8 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -436,8 +436,8 @@ static float edge_pan_speed(v2dViewPanData *vpd,
ARegion *region = vpd->region;
/* Find the distance from the start of the drag zone. */
- int min = (x_dir ? region->winrct.xmin : region->winrct.ymin) + EDGE_PAN_REGION_PAD;
- int max = (x_dir ? region->winrct.xmax : region->winrct.ymax) - EDGE_PAN_REGION_PAD;
+ const int min = (x_dir ? region->winrct.xmin : region->winrct.ymin) + EDGE_PAN_REGION_PAD;
+ const int max = (x_dir ? region->winrct.xmax : region->winrct.ymax) - EDGE_PAN_REGION_PAD;
int distance = 0.0;
if (event_loc > max) {
distance = event_loc - max;
@@ -451,8 +451,8 @@ static float edge_pan_speed(v2dViewPanData *vpd,
}
/* Apply a fade in to the speed based on a start time delay. */
- double start_time = x_dir ? vpd->edge_pan_start_time_x : vpd->edge_pan_start_time_y;
- float delay_factor = smootherstep(EDGE_PAN_DELAY, (float)(current_time - start_time));
+ const double start_time = x_dir ? vpd->edge_pan_start_time_x : vpd->edge_pan_start_time_y;
+ const float delay_factor = smootherstep(EDGE_PAN_DELAY, (float)(current_time - start_time));
return distance * EDGE_PAN_SPEED_PER_PIXEL * delay_factor;
}
@@ -475,7 +475,7 @@ static int view_edge_pan_modal(bContext *C, wmOperator *op, const wmEvent *event
* On successful handling, always pass events on to other handlers. */
const int success_retval = OPERATOR_PASS_THROUGH;
- int outside_padding = RNA_int_get(op->ptr, "outside_padding") * UI_UNIT_X;
+ const int outside_padding = RNA_int_get(op->ptr, "outside_padding") * UI_UNIT_X;
rcti padding_rect;
if (outside_padding != 0) {
padding_rect = region->winrct;
@@ -504,14 +504,14 @@ static int view_edge_pan_modal(bContext *C, wmOperator *op, const wmEvent *event
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. */
- 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) {
- float speed = edge_pan_speed(vpd, event->x, true, current_time);
+ const float speed = edge_pan_speed(vpd, event->x, true, current_time);
dx = dtime * speed * (float)pan_dir_x;
}
if (pan_dir_y != 0) {
- float speed = edge_pan_speed(vpd, event->y, false, current_time);
+ const float speed = edge_pan_speed(vpd, event->y, false, current_time);
dy = dtime * speed * (float)pan_dir_y;
}
vpd->edge_pan_last_time = current_time;
@@ -911,9 +911,9 @@ static void view_zoomstep_apply_ex(
/* only move view to mouse if zoom fac is inside minzoom/maxzoom */
if (((v2d->keepzoom & V2D_LIMITZOOM) == 0) ||
IN_RANGE_INCL(zoomx, v2d->minzoom, v2d->maxzoom)) {
- float mval_fac = (vzd->mx_2d - cur_old.xmin) / BLI_rctf_size_x(&cur_old);
- float mval_faci = 1.0f - mval_fac;
- float ofs = (mval_fac * dx) - (mval_faci * dx);
+ const float mval_fac = (vzd->mx_2d - cur_old.xmin) / BLI_rctf_size_x(&cur_old);
+ const float mval_faci = 1.0f - mval_fac;
+ const float ofs = (mval_fac * dx) - (mval_faci * dx);
v2d->cur.xmin += ofs;
v2d->cur.xmax += ofs;
@@ -946,9 +946,9 @@ static void view_zoomstep_apply_ex(
/* only move view to mouse if zoom fac is inside minzoom/maxzoom */
if (((v2d->keepzoom & V2D_LIMITZOOM) == 0) ||
IN_RANGE_INCL(zoomy, v2d->minzoom, v2d->maxzoom)) {
- float mval_fac = (vzd->my_2d - cur_old.ymin) / BLI_rctf_size_y(&cur_old);
- float mval_faci = 1.0f - mval_fac;
- float ofs = (mval_fac * dy) - (mval_faci * dy);
+ const float mval_fac = (vzd->my_2d - cur_old.ymin) / BLI_rctf_size_y(&cur_old);
+ const float mval_faci = 1.0f - mval_fac;
+ const float ofs = (mval_fac * dy) - (mval_faci * dy);
v2d->cur.ymin += ofs;
v2d->cur.ymax += ofs;
@@ -1167,8 +1167,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
/* continuous zoom shouldn't move that fast... */
if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
- double time = PIL_check_seconds_timer();
- float time_step = (float)(time - vzd->timer_lastdraw);
+ const double time = PIL_check_seconds_timer();
+ const float time_step = (float)(time - vzd->timer_lastdraw);
dx *= time_step * 0.5f;
dy *= time_step * 0.5f;
@@ -1183,9 +1183,9 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
else {
if (zoom_to_pos) {
- float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
- float mval_faci = 1.0f - mval_fac;
- float ofs = (mval_fac * dx) - (mval_faci * dx);
+ const float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
+ const float mval_faci = 1.0f - mval_fac;
+ const float ofs = (mval_fac * dx) - (mval_faci * dx);
v2d->cur.xmin += ofs + dx;
v2d->cur.xmax += ofs - dx;
@@ -1202,9 +1202,9 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
else {
if (zoom_to_pos) {
- float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
- float mval_faci = 1.0f - mval_fac;
- float ofs = (mval_fac * dy) - (mval_faci * dy);
+ const float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
+ const float mval_faci = 1.0f - mval_fac;
+ const float ofs = (mval_fac * dy) - (mval_faci * dy);
v2d->cur.ymin += ofs + dy;
v2d->cur.ymax += ofs - dy;
@@ -1987,8 +1987,8 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
(mouse >= (sh_min - V2D_SCROLL_HANDLE_SIZE_HOTSPOT)));
bool in_bar = ((mouse < (sh_max - V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) &&
(mouse > (sh_min + V2D_SCROLL_HANDLE_SIZE_HOTSPOT)));
- bool out_min = mouse < (sh_min - V2D_SCROLL_HANDLE_SIZE_HOTSPOT);
- bool out_max = mouse > (sh_max + V2D_SCROLL_HANDLE_SIZE_HOTSPOT);
+ const bool out_min = mouse < (sh_min - V2D_SCROLL_HANDLE_SIZE_HOTSPOT);
+ const bool out_max = mouse > (sh_max + V2D_SCROLL_HANDLE_SIZE_HOTSPOT);
if (in_bar) {
return SCROLLHANDLE_BAR;