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:
authorHans Goudey <h.goudey@me.com>2021-02-22 18:28:17 +0300
committerHans Goudey <h.goudey@me.com>2021-02-22 18:28:17 +0300
commitaf89c9f9a6d5b3b386ce2cbf73c13a2d62aa853d (patch)
treee1e517f49b9fe0e0d96da950eb6ac849bd0bf1dd
parent9ef2679ca9ffcc2aa6bd4eaf2697c185de1f6e1b (diff)
Cleanup: Decrease variable scope
-rw-r--r--source/blender/editors/interface/interface_region_search.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index d1d4290bd11..2c07f5c3c03 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -724,19 +724,13 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearc
wmWindow *win = CTX_wm_window(C);
const uiStyle *style = UI_style_get();
uiBut *but = &search_but->but;
- static ARegionType type;
- ARegion *region;
- uiSearchboxData *data;
const float aspect = but->block->aspect;
- rctf rect_fl;
- rcti rect_i;
const int margin = UI_POPUP_MARGIN;
- int winx /*, winy */, ofsx, ofsy;
- int i;
/* create area region */
- region = ui_region_temp_add(CTX_wm_screen(C));
+ ARegion *region = ui_region_temp_add(CTX_wm_screen(C));
+ static ARegionType type;
memset(&type, 0, sizeof(ARegionType));
type.draw = ui_searchbox_region_draw_cb;
type.free = ui_searchbox_region_free_cb;
@@ -744,7 +738,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearc
region->type = &type;
/* create searchbox data */
- data = MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData");
+ uiSearchboxData *data = MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData");
/* set font, get bb */
data->fstyle = style->widget; /* copy struct */
@@ -799,13 +793,14 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearc
else {
const int searchbox_width = UI_searchbox_size_x();
+ rctf rect_fl;
rect_fl.xmin = but->rect.xmin - 5; /* align text with button */
rect_fl.xmax = but->rect.xmax + 5; /* symmetrical */
rect_fl.ymax = but->rect.ymin;
rect_fl.ymin = rect_fl.ymax - UI_searchbox_size_y();
- ofsx = (but->block->panel) ? but->block->panel->ofsx : 0;
- ofsy = (but->block->panel) ? but->block->panel->ofsy : 0;
+ const int ofsx = (but->block->panel) ? but->block->panel->ofsx : 0;
+ const int ofsy = (but->block->panel) ? but->block->panel->ofsy : 0;
BLI_rctf_translate(&rect_fl, ofsx, ofsy);
@@ -815,6 +810,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearc
}
/* copy to int, gets projected if possible too */
+ rcti rect_i;
BLI_rcti_rctf_copy(&rect_i, &rect_fl);
if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
@@ -823,7 +819,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearc
BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin);
- winx = WM_window_pixels_x(win);
+ int winx = WM_window_pixels_x(win);
// winy = WM_window_pixels_y(win); /* UNUSED */
// wm_window_get_size(win, &winx, &winy);
@@ -885,7 +881,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearc
data->items.icons = MEM_callocN(data->items.maxitem * sizeof(int), "search icons");
data->items.states = MEM_callocN(data->items.maxitem * sizeof(int), "search flags");
data->items.name_prefix_offsets = NULL; /* Lazy initialized as needed. */
- for (i = 0; i < data->items.maxitem; i++) {
+ for (int i = 0; i < data->items.maxitem; i++) {
data->items.names[i] = MEM_callocN(but->hardmax + 1, "search pointers");
}
@@ -1000,10 +996,8 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe
ARegion *ui_searchbox_create_operator(bContext *C, ARegion *butregion, uiButSearch *search_but)
{
- ARegion *region;
-
UI_but_drawflag_enable(&search_but->but, UI_BUT_HAS_SHORTCUT);
- region = ui_searchbox_create_generic(C, butregion, search_but);
+ ARegion *region = ui_searchbox_create_generic(C, butregion, search_but);
region->type->draw = ui_searchbox_region_draw_cb__operator;
@@ -1022,10 +1016,8 @@ static void ui_searchbox_region_draw_cb__menu(const bContext *UNUSED(C), ARegion
ARegion *ui_searchbox_create_menu(bContext *C, ARegion *butregion, uiButSearch *search_but)
{
- ARegion *region;
-
UI_but_drawflag_enable(&search_but->but, UI_BUT_HAS_SHORTCUT);
- region = ui_searchbox_create_generic(C, butregion, search_but);
+ ARegion *region = ui_searchbox_create_generic(C, butregion, search_but);
if (false) {
region->type->draw = ui_searchbox_region_draw_cb__menu;