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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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/blender/editors/interface/interface_templates.c
parent88ada5e218835f060a23cbe0f1f2da7452e81b07 (diff)
Cleanup: use const variables in interface code
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r--source/blender/editors/interface/interface_templates.c73
1 files changed, 37 insertions, 36 deletions
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++) {