[Bf-blender-cvs] [e2983392894] master: Cleanup: Declare variables where initialized
Hans Goudey
noreply at git.blender.org
Fri Dec 18 19:40:08 CET 2020
Commit: e2983392894e380203966e49b2caa3807a661eb9
Author: Hans Goudey
Date: Fri Dec 18 12:39:50 2020 -0600
Branches: master
https://developer.blender.org/rBe2983392894e380203966e49b2caa3807a661eb9
Cleanup: Declare variables where initialized
Also decrease scope of some variable declarations.
===================================================================
M source/blender/editors/interface/interface_layout.c
===================================================================
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b3c34b3fb43..3b366688e59 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -3457,8 +3457,6 @@ static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void
void uiItemMenuEnumR_prop(
uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *name, int icon)
{
- MenuItemLevel *lvl;
-
if (!name) {
name = RNA_property_ui_name(prop);
}
@@ -3466,7 +3464,7 @@ void uiItemMenuEnumR_prop(
icon = ICON_BLANK1;
}
- lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
+ MenuItemLevel *lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
lvl->rnapoin = *ptr;
BLI_strncpy(lvl->propname, RNA_property_identifier(prop), sizeof(lvl->propname));
lvl->opcontext = layout->root->opcontext;
@@ -3550,15 +3548,15 @@ static int ui_litem_min_width(int itemw)
static void ui_litem_layout_row(uiLayout *litem)
{
uiItem *last_free_item = NULL;
- int x, y, w, tot, totw, neww, newtotw, itemw, minw, itemh, offset;
- int fixedw, freew, fixedx, freex, flag = 0, lastw = 0;
+ int x, neww, newtotw, itemw, minw, itemh, offset;
+ int freew, fixedx, freex, flag = 0, lastw = 0;
float extra_pixel;
/* x = litem->x; */ /* UNUSED */
- y = litem->y;
- w = litem->w;
- totw = 0;
- tot = 0;
+ int y = litem->y;
+ int w = litem->w;
+ int totw = 0;
+ int tot = 0;
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
ui_item_size(item, &itemw, &itemh);
@@ -3573,7 +3571,7 @@ static void ui_litem_layout_row(uiLayout *litem)
if (w != 0) {
w -= (tot - 1) * litem->space;
}
- fixedw = 0;
+ int fixedw = 0;
/* keep clamping items to fixed minimum size until all are done */
do {
@@ -3724,12 +3722,11 @@ static void ui_litem_estimate_column(uiLayout *litem, bool is_box)
static void ui_litem_layout_column(uiLayout *litem, bool is_box, bool is_menu)
{
- int itemw, itemh, x, y;
-
- x = litem->x;
- y = litem->y;
+ int x = litem->x;
+ int y = litem->y;
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
+ int itemw, itemh;
ui_item_size(item, &itemw, &itemh);
y -= itemh;
@@ -3753,15 +3750,13 @@ static void ui_litem_layout_column(uiLayout *litem, bool is_box, bool is_menu)
* stores a float vector in unit circle */
static RadialDirection ui_get_radialbut_vec(float vec[2], short itemnum)
{
- RadialDirection dir;
-
if (itemnum >= PIE_MAX_ITEMS) {
itemnum %= PIE_MAX_ITEMS;
printf("Warning: Pie menus with more than %i items are currently unsupported\n",
PIE_MAX_ITEMS);
}
- dir = ui_radial_dir_order[itemnum];
+ RadialDirection dir = ui_radial_dir_order[itemnum];
ui_but_pie_dir(dir, vec);
return dir;
@@ -3789,7 +3784,7 @@ static bool ui_item_is_radial_drawable(uiButtonItem *bitem)
static void ui_litem_layout_radial(uiLayout *litem)
{
- int itemh, itemw, x, y;
+ int itemh, itemw;
int itemnum = 0;
int totitems = 0;
@@ -3800,8 +3795,8 @@ static void ui_litem_layout_radial(uiLayout *litem)
const int pie_radius = U.pie_menu_radius * UI_DPI_FAC;
- x = litem->x;
- y = litem->y;
+ int x = litem->x;
+ int y = litem->y;
int minx = x, miny = y, maxx = x, maxy = y;
@@ -3921,16 +3916,14 @@ static void ui_litem_layout_box(uiLayout *litem)
{
uiLayoutItemBx *box = (uiLayoutItemBx *)litem;
const uiStyle *style = litem->root->style;
- uiBut *but;
- int w, h;
int boxspace = style->boxspace;
if (litem->root->type == UI_LAYOUT_HEADER) {
boxspace = 0;
}
- w = litem->w;
- h = litem->h;
+ int w = litem->w;
+ int h = litem->h;
litem->x += boxspace;
litem->y -= boxspace;
@@ -3955,7 +3948,7 @@ static void ui_litem_layout_box(uiLayout *litem)
}
/* roundbox around the sublayout */
- but = box->roundbox;
+ uiBut *but = box->roundbox;
but->rect.xmin = litem->x;
but->rect.ymin = litem->y;
but->rect.xmax = litem->x + litem->w;
@@ -3967,12 +3960,11 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
{
const uiStyle *style = litem->root->style;
uiLayoutItemFlow *flow = (uiLayoutItemFlow *)litem;
- int col, x, y, emh, emy, miny, itemw, itemh, maxw = 0;
- int toth, totitem;
+ int itemw, itemh, maxw = 0;
/* compute max needed width and total height */
- toth = 0;
- totitem = 0;
+ int toth = 0;
+ int totitem = 0;
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
ui_item_size(item, &itemw, &itemh);
maxw = MAX2(maxw, itemw);
@@ -3995,16 +3987,16 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
}
/* compute sizes */
- x = 0;
- y = 0;
- emy = 0;
- miny = 0;
+ int x = 0;
+ int y = 0;
+ int emy = 0;
+ int miny = 0;
maxw = 0;
- emh = toth / flow->totcol;
+ int emh = toth / flow->totcol;
/* create column per column */
- col = 0;
+ int col = 0;
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
ui_item_size(item, &itemw, &itemh);
@@ -4031,12 +4023,11 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
{
const uiStyle *style = litem->root->style;
uiLayoutItemFlow *flow = (uiLayoutItemFlow *)litem;
- int col, x, y, w, emh, emy, miny, itemw, itemh;
- int toth, totitem;
+ int col, emh, itemw, itemh;
/* compute max needed width and total height */
- toth = 0;
- totitem = 0;
+ int toth = 0;
+ int totitem = 0;
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
ui_item_size(item, &itemw, &itemh);
toth += itemh;
@@ -4044,12 +4035,12 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
}
/* compute sizes */
- x = litem->x;
- y = litem->y;
- emy = 0;
- miny = 0;
+ int x = litem->x;
+ int y = litem->y;
+ int emy = 0;
+ int miny = 0;
- w = litem->w - (flow->totcol - 1) * style->columnspace;
+ int w = litem->w - (flow->totcol - 1) * style->columnspace;
emh = toth / flow->totcol;
/* create column per column */
@@ -4457,14 +4448,13 @@ static void ui_litem_layout_grid_flow(uiLayout *litem)
/* free layout */
static void ui_litem_estimate_absolute(uiLayout *litem)
{
- int itemx, itemy, itemw, itemh, minx, miny;
-
- minx = 1e6;
- miny = 1e6;
+ int minx = 1e6;
+ int miny = 1e6;
litem->w = 0;
litem->h = 0;
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
+ int itemx, itemy, itemw, itemh;
ui_item_offset(item, &itemx, &itemy);
ui_item_size(item, &itemw, &itemh);
@@ -4482,12 +4472,12 @@ static void ui_litem_estimate_absolute(uiLayout *litem)
static void ui_litem_layout_absolute(uiLayout *litem)
{
float scalex = 1.0f, scaley = 1.0f;
- int x, y, newx, newy, itemx, itemy, itemh, itemw, minx, miny, totw, toth;
+ int x, y, newx, newy, itemx, itemy, itemh, itemw;
- minx = 1e6;
- miny = 1e6;
- totw = 0;
- toth = 0;
+ int minx = 1e6;
+ int miny = 1e6;
+ int totw = 0;
+ int toth = 0;
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
ui_item_offset(item, &itemx, &itemy);
@@ -4548,24 +4538,24 @@ static void ui_litem_estimate_split(uiLayout *litem)
static void ui_litem_layout_split(uiLayout *litem)
{
uiLayoutItemSplit *split = (uiLayoutItemSplit *)litem;
- float percentage, extra_pixel = 0.0f;
+ float extra_pixel = 0.0f;
const int tot = BLI_listbase_count(&litem->items);
- int itemh, x, y, w, colw = 0;
if (tot == 0) {
return;
}
- x = litem->x;
- y = litem->y;
+ int x = litem->x;
+ int y = litem->y;
- percentage = (split->percentage == 0.0f) ? 1.0f / (float)tot : split->percentage;
+ float percentage = (split->percentage == 0.0f) ? 1.0f / (float)tot : split->percentage;
- w = (litem->w - (tot - 1) * litem->space);
- colw = w * percentage;
+ int w = (litem->w - (tot - 1) * litem->space);
+ int colw = w * percentage;
colw = MAX2(colw, 0);
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
+ int itemh;
ui_item_size(item, NULL, &itemh);
ui_item_position(item, x, y - itemh, colw, itemh);
@@ -4590,12 +4580,11 @@ static void ui_litem_layout_split(uiLayout *litem)
/* overlap layout */
static void ui_litem_estimate_overlap(uiLayout *litem)
{
- int itemw, itemh;
-
litem->w = 0;
litem->h = 0;
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
+ int itemw, itemh;
ui_item_size(item, &itemw, &itemh);
litem->w = MAX2(itemw, litem->w);
@@ -4605,12 +4594,12 @@ static void ui_litem_estimate_overlap(uiLayout *litem)
static void ui_litem_layout_overlap(uiLayout *litem)
{
- int itemw, itemh, x, y;
- x = litem->x;
- y = litem->y;
+ int x = litem->x;
+ int y = litem->y;
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
+ int itemw, itemh;
ui_item_size(item, &itemw, &itemh);
ui_item_position(item, x, y - itemh, litem->w, itemh);
@@ -4657,9 +4646,7 @@ static void ui_layout_heading_set(uiLayout *layout, const char *heading)
/* layout create functions */
uiLayout *uiLayoutRow(uiLayout *layout, bool align)
{
- uiLayout *litem;
-
- litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRow");
+ uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRow");
ui_litem_init_from_parent(litem, layout, align);
litem->item.type = ITEM_LAYOUT_ROW;
@@ -4682,9 +4669,7 @@ uiLayout *uiLayoutRowWithHeading(uiLayout *layout, bool align, const char *headi
uiLayout *uiLayoutColumn(uiLayout *layout, bool align)
{
- uiLayout *litem;
-
- litem = MEM_callocN(sizeof(uiLayout), "uiLayoutColumn");
+ uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutColumn");
ui_litem_init_from_parent(litem, layout, align);
litem->item.type = ITEM_LAYOUT_COLUMN;
@@ -4710,9 +4695,7 @@ uiLayout *uiLayoutColumnWithHeading(uiLayout *layout, bool align, const char *he
uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, bool align)
{
- uiLayoutItemFlow *flow;
-
- flow = MEM_callocN(sizeof(uiLayoutItemFlow), "uiLayoutItemFlow");
+ uiLayoutItemFlow *flow = MEM_callocN(sizeof(uiLayoutItemFlow), "uiLayoutItemFlow");
ui_litem_init_from_parent(&flow->litem, layout, align);
flow->litem.item.type = ITEM_LAYOUT_COLUMN_FLOW;
@@ -4731,9 +4714,7 @@ uiLayout *uiLayoutGridFlow(uiLayout *layout,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list