diff options
author | Julian Eisel <julian@blender.org> | 2020-03-06 18:56:42 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-03-06 19:19:23 +0300 |
commit | b2ee1770d4c31078518f4ec9edd5196a41345162 (patch) | |
tree | 6b7f6ff9057322245fc3b3407bece3f1c0cb3eb5 /source/blender/editors/space_image | |
parent | b825a95ec311a169d33fe21e28418f11a516c82f (diff) |
Cleanup: Rename ARegion variables from ar to region
The old convention was easy to confuse with ScrArea.
Part of https://developer.blender.org/T74432.
This is mostly a batch rename with some manual fixing. Only single word
variable names are changed, no prefixed/suffixed names.
Brecht van Lommel and Campbell Barton both gave me a green light for
this convention change.
Also ran clan clang format on affected files.
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 97 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_edit.c | 31 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 175 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 228 |
5 files changed, 275 insertions, 260 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index c455b7d7c54..d1b2c2330ac 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -78,7 +78,7 @@ #include "image_intern.h" static void draw_render_info( - const bContext *C, Scene *scene, Image *ima, ARegion *ar, float zoomx, float zoomy) + const bContext *C, Scene *scene, Image *ima, ARegion *region, float zoomx, float zoomy) { Render *re = RE_GetSceneRender(scene); RenderData *rd = RE_engine_get_render_data(re); @@ -91,7 +91,7 @@ static void draw_render_info( if (rr && rr->text) { float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.25f}; - ED_region_info_draw(ar, rr->text, fill_color, true); + ED_region_info_draw(region, rr->text, fill_color, true); } BKE_image_release_renderresult(stats_scene, ima); @@ -104,7 +104,7 @@ static void draw_render_info( if (total_tiles) { /* find window pixel coordinates of origin */ int x, y; - UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); + UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &x, &y); GPU_matrix_push(); GPU_matrix_translate_2f(x, y); @@ -141,7 +141,7 @@ static void draw_render_info( /* used by node view too */ void ED_image_draw_info(Scene *scene, - ARegion *ar, + ARegion *region, bool color_manage, bool use_default_view, int channels, @@ -157,7 +157,7 @@ void ED_image_draw_info(Scene *scene, char str[256]; int dx = 6; /* local coordinate visible rect inside region, to accommodate overlapping ui */ - const rcti *rect = ED_region_visible_rect(ar); + const rcti *rect = ED_region_visible_rect(region); const int ymin = rect->ymin; const int dy = ymin + 0.3f * UI_UNIT_Y; @@ -185,7 +185,7 @@ void ED_image_draw_info(Scene *scene, /* noisy, high contrast make impossible to read if lower alpha is used. */ immUniformColor4ub(0, 0, 0, 190); - immRecti(pos, 0, ymin, BLI_rcti_size_x(&ar->winrct) + 1, ymin + UI_UNIT_Y); + immRecti(pos, 0, ymin, BLI_rcti_size_x(®ion->winrct) + 1, ymin + UI_UNIT_Y); immUnbindProgram(); @@ -532,7 +532,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, MEM_freeN(rectf); } -static void draw_udim_label(ARegion *ar, float fx, float fy, const char *label) +static void draw_udim_label(ARegion *region, float fx, float fy, const char *label) { if (label == NULL || !label[0]) { return; @@ -540,14 +540,14 @@ static void draw_udim_label(ARegion *ar, float fx, float fy, const char *label) /* find window pixel coordinates of origin */ int x, y; - UI_view2d_view_to_region(&ar->v2d, fx, fy, &x, &y); + UI_view2d_view_to_region(®ion->v2d, fx, fy, &x, &y); GPU_blend_set_func_separate( GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); int textwidth = BLF_width(blf_mono_font, label, strlen(label)) + 10; - float stepx = BLI_rcti_size_x(&ar->v2d.mask) / BLI_rctf_size_x(&ar->v2d.cur); + float stepx = BLI_rcti_size_x(®ion->v2d.mask) / BLI_rctf_size_x(®ion->v2d.cur); float opacity; if (textwidth < 0.5f * (stepx - 10)) { opacity = 1.0f; @@ -567,7 +567,7 @@ static void draw_udim_label(ARegion *ar, float fx, float fy, const char *label) static void draw_image_buffer(const bContext *C, SpaceImage *sima, - ARegion *ar, + ARegion *region, Scene *scene, ImBuf *ibuf, float fx, @@ -578,7 +578,7 @@ static void draw_image_buffer(const bContext *C, int x, y; /* find window pixel coordinates of origin */ - UI_view2d_view_to_region(&ar->v2d, fx, fy, &x, &y); + UI_view2d_view_to_region(®ion->v2d, fx, fy, &x, &y); /* this part is generic image display */ if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) { @@ -595,7 +595,7 @@ static void draw_image_buffer(const bContext *C, else { int clip_max_x, clip_max_y; UI_view2d_view_to_region( - &ar->v2d, ar->v2d.cur.xmax, ar->v2d.cur.ymax, &clip_max_x, &clip_max_y); + ®ion->v2d, region->v2d.cur.xmax, region->v2d.cur.ymax, &clip_max_x, &clip_max_y); if (sima->flag & SI_USE_ALPHA) { imm_draw_box_checker_2d(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy); @@ -669,7 +669,7 @@ static void draw_image_buffer(const bContext *C, static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, - ARegion *ar, + ARegion *region, Scene *scene, ImBuf *ibuf, float zoomx, @@ -677,14 +677,14 @@ static void draw_image_buffer_repeated(const bContext *C, { const double time_current = PIL_check_seconds_timer(); - const int xmax = ceil(ar->v2d.cur.xmax); - const int ymax = ceil(ar->v2d.cur.ymax); - const int xmin = floor(ar->v2d.cur.xmin); - const int ymin = floor(ar->v2d.cur.ymin); + const int xmax = ceil(region->v2d.cur.xmax); + const int ymax = ceil(region->v2d.cur.ymax); + const int xmin = floor(region->v2d.cur.xmin); + const int ymin = floor(region->v2d.cur.ymin); for (int x = xmin; x < xmax; x++) { for (int y = ymin; y < ymax; y++) { - draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy); + draw_image_buffer(C, sima, region, scene, ibuf, x, y, zoomx, zoomy); /* only draw until running out of time */ if ((PIL_check_seconds_timer() - time_current) > 0.25) { @@ -744,7 +744,7 @@ void draw_image_sample_line(SpaceImage *sima) } static void draw_image_paint_helpers( - const bContext *C, ARegion *ar, Scene *scene, float zoomx, float zoomy) + const bContext *C, ARegion *region, Scene *scene, float zoomx, float zoomy) { Brush *brush; int x, y; @@ -758,7 +758,8 @@ static void draw_image_paint_helpers( if (ibuf) { void *cache_handle = NULL; float col[4] = {1.0f, 1.0f, 1.0f, brush->clone.alpha}; - UI_view2d_view_to_region(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y); + UI_view2d_view_to_region( + ®ion->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y); uchar *display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); @@ -796,7 +797,7 @@ static void draw_image_paint_helpers( static void draw_udim_tile_grid(uint pos_attr, uint color_attr, - ARegion *ar, + ARegion *region, int x, int y, float stepx, @@ -804,7 +805,7 @@ static void draw_udim_tile_grid(uint pos_attr, const float color[3]) { float x1, y1; - UI_view2d_view_to_region_fl(&ar->v2d, x, y, &x1, &y1); + UI_view2d_view_to_region_fl(®ion->v2d, x, y, &x1, &y1); int gridpos[5][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; for (int i = 0; i < 4; i++) { immAttr3fv(color_attr, color); @@ -814,7 +815,7 @@ static void draw_udim_tile_grid(uint pos_attr, } } -static void draw_udim_tile_grids(ARegion *ar, SpaceImage *sima, Image *ima) +static void draw_udim_tile_grids(ARegion *region, SpaceImage *sima, Image *ima) { int num_tiles; if (ima != NULL) { @@ -828,8 +829,8 @@ static void draw_udim_tile_grids(ARegion *ar, SpaceImage *sima, Image *ima) num_tiles = sima->tile_grid_shape[0] * sima->tile_grid_shape[1]; } - float stepx = BLI_rcti_size_x(&ar->v2d.mask) / BLI_rctf_size_x(&ar->v2d.cur); - float stepy = BLI_rcti_size_y(&ar->v2d.mask) / BLI_rctf_size_y(&ar->v2d.cur); + float stepx = BLI_rcti_size_x(®ion->v2d.mask) / BLI_rctf_size_x(®ion->v2d.cur); + float stepy = BLI_rcti_size_y(®ion->v2d.mask) / BLI_rctf_size_y(®ion->v2d.cur); GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -849,20 +850,20 @@ static void draw_udim_tile_grids(ARegion *ar, SpaceImage *sima, Image *ima) if (tile != cur_tile) { int x = (tile->tile_number - 1001) % 10; int y = (tile->tile_number - 1001) / 10; - draw_udim_tile_grid(pos, color, ar, x, y, stepx, stepy, theme_color); + draw_udim_tile_grid(pos, color, region, x, y, stepx, stepy, theme_color); } } if (cur_tile != NULL) { int cur_x = (cur_tile->tile_number - 1001) % 10; int cur_y = (cur_tile->tile_number - 1001) / 10; - draw_udim_tile_grid(pos, color, ar, cur_x, cur_y, stepx, stepy, selected_color); + draw_udim_tile_grid(pos, color, region, cur_x, cur_y, stepx, stepy, selected_color); } } else { for (int y = 0; y < sima->tile_grid_shape[1]; y++) { for (int x = 0; x < sima->tile_grid_shape[0]; x++) { - draw_udim_tile_grid(pos, color, ar, x, y, stepx, stepy, theme_color); + draw_udim_tile_grid(pos, color, region, x, y, stepx, stepy, theme_color); } } } @@ -873,7 +874,7 @@ static void draw_udim_tile_grids(ARegion *ar, SpaceImage *sima, Image *ima) /* draw main image region */ -void draw_image_main(const bContext *C, ARegion *ar) +void draw_image_main(const bContext *C, ARegion *region) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); @@ -905,7 +906,7 @@ void draw_image_main(const bContext *C, ARegion *ar) /* retrieve the image and information about it */ ima = ED_space_image(sima); - ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); + ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); /* Tag image as in active use for garbage collector. */ if (ima) { @@ -949,31 +950,31 @@ void draw_image_main(const bContext *C, ARegion *ar) LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) { int x = (tile->tile_number - 1001) % 10; int y = (tile->tile_number - 1001) / 10; - ED_region_grid_draw(ar, zoomx, zoomy, x, y); + ED_region_grid_draw(region, zoomx, zoomy, x, y); } } else { for (int y = 0; y < sima->tile_grid_shape[1]; y++) { for (int x = 0; x < sima->tile_grid_shape[0]; x++) { - ED_region_grid_draw(ar, zoomx, zoomy, x, y); + ED_region_grid_draw(region, zoomx, zoomy, x, y); } } } } else { if (sima->flag & SI_DRAW_TILE) { - draw_image_buffer_repeated(C, sima, ar, scene, ibuf, zoomx, zoomy); + draw_image_buffer_repeated(C, sima, region, scene, ibuf, zoomx, zoomy); } else { main_w = ibuf->x; main_h = ibuf->y; - draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); + draw_image_buffer(C, sima, region, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); if (ima->source == IMA_SRC_TILED) { ImageTile *tile = BKE_image_get_tile(ima, 0); char label[sizeof(tile->label)]; BKE_image_get_tile_label(ima, tile, label, sizeof(label)); - draw_udim_label(ar, 0.0f, 0.0f, label); + draw_udim_label(region, 0.0f, 0.0f, label); } } @@ -982,7 +983,7 @@ void draw_image_main(const bContext *C, ARegion *ar) rctf frame; BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y); - UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); + UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &x, &y); ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx, zoomy); } @@ -1005,18 +1006,18 @@ void draw_image_main(const bContext *C, ARegion *ar) float tile_zoomx = (zoomx * main_w) / ibuf->x; float tile_zoomy = (zoomy * main_h) / ibuf->y; - draw_image_buffer(C, sima, ar, scene, ibuf, x_pos, y_pos, tile_zoomx, tile_zoomy); - draw_udim_label(ar, x_pos, y_pos, label); + draw_image_buffer(C, sima, region, scene, ibuf, x_pos, y_pos, tile_zoomx, tile_zoomy); + draw_udim_label(region, x_pos, y_pos, label); } ED_space_image_release_buffer(sima, ibuf, lock); } } - draw_udim_tile_grids(ar, sima, ima); + draw_udim_tile_grids(region, sima, ima); /* paint helpers */ if (show_paint) { - draw_image_paint_helpers(C, ar, scene, zoomx, zoomy); + draw_image_paint_helpers(C, region, scene, zoomx, zoomy); } if (show_viewer) { @@ -1025,7 +1026,7 @@ void draw_image_main(const bContext *C, ARegion *ar) /* render info */ if (ima && show_render) { - draw_render_info(C, sima->iuser.scene, ima, ar, zoomx, zoomy); + draw_render_info(C, sima->iuser.scene, ima, region, zoomx, zoomy); } } @@ -1045,12 +1046,12 @@ bool ED_space_image_show_cache(SpaceImage *sima) return true; } -void draw_image_cache(const bContext *C, ARegion *ar) +void draw_image_cache(const bContext *C, ARegion *region) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); Image *image = ED_space_image(sima); - float x, cfra = CFRA, sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1); + float x, cfra = CFRA, sfra = SFRA, efra = EFRA, framelen = region->winx / (efra - sfra + 1); Mask *mask = NULL; if (!ED_space_image_show_cache(sima)) { @@ -1062,7 +1063,7 @@ void draw_image_cache(const bContext *C, ARegion *ar) } /* Local coordinate visible rect inside region, to accommodate overlapping ui. */ - const rcti *rect_visible = ED_region_visible_rect(ar); + const rcti *rect_visible = ED_region_visible_rect(region); const int region_bottom = rect_visible->ymin; GPU_blend(true); @@ -1070,7 +1071,7 @@ void draw_image_cache(const bContext *C, ARegion *ar) GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* Draw cache background. */ - ED_region_cache_draw_background(ar); + ED_region_cache_draw_background(region); /* Draw cached segments. */ if (image != NULL && image->cache != NULL && @@ -1080,13 +1081,13 @@ void draw_image_cache(const bContext *C, ARegion *ar) IMB_moviecache_get_cache_segments(image->cache, IMB_PROXY_NONE, 0, &num_segments, &points); ED_region_cache_draw_cached_segments( - ar, num_segments, points, sfra + sima->iuser.offset, efra + sima->iuser.offset); + region, num_segments, points, sfra + sima->iuser.offset, efra + sima->iuser.offset); } GPU_blend(false); /* Draw current frame. */ - x = (cfra - sfra) / (efra - sfra + 1) * ar->winx; + x = (cfra - sfra) / (efra - sfra + 1) * region->winx; uint pos = GPU_vertformat_attr_add( immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); @@ -1098,6 +1099,6 @@ void draw_image_cache(const bContext *C, ARegion *ar) ED_region_cache_draw_curfra_label(cfra, x, region_bottom + 8.0f * UI_DPI_FAC); if (mask != NULL) { - ED_mask_draw_frames(mask, ar, cfra, sfra, efra); + ED_mask_draw_frames(mask, region, cfra, sfra, efra); } } diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 862d32815f4..9d07780f756 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -240,16 +240,16 @@ void ED_space_image_get_aspect(SpaceImage *sima, float *aspx, float *aspy) } } -void ED_space_image_get_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy) +void ED_space_image_get_zoom(SpaceImage *sima, ARegion *region, float *zoomx, float *zoomy) { int width, height; ED_space_image_get_size(sima, &width, &height); - *zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / - (float)(BLI_rctf_size_x(&ar->v2d.cur) * width); - *zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / - (float)(BLI_rctf_size_y(&ar->v2d.cur) * height); + *zoomx = (float)(BLI_rcti_size_x(®ion->winrct) + 1) / + (float)(BLI_rctf_size_x(®ion->v2d.cur) * width); + *zoomy = (float)(BLI_rcti_size_y(®ion->winrct) + 1) / + (float)(BLI_rctf_size_y(®ion->v2d.cur) * height); } void ED_space_image_get_uv_aspect(SpaceImage *sima, float *aspx, float *aspy) @@ -290,15 +290,15 @@ void ED_image_get_uv_aspect(Image *ima, ImageUser *iuser, float *aspx, float *as } /* takes event->mval */ -void ED_image_mouse_pos(SpaceImage *sima, ARegion *ar, const int mval[2], float co[2]) +void ED_image_mouse_pos(SpaceImage *sima, ARegion *region, const int mval[2], float co[2]) { int sx, sy, width, height; float zoomx, zoomy; - ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); + ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); ED_space_image_get_size(sima, &width, &height); - UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy); + UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &sx, &sy); co[0] = ((mval[0] - sx) / zoomx) / width; co[1] = ((mval[1] - sy) / zoomy) / height; @@ -316,29 +316,32 @@ void ED_image_view_center_to_point(SpaceImage *sima, float x, float y) sima->yof = (y - 0.5f) * height * aspy; } -void ED_image_point_pos(SpaceImage *sima, ARegion *ar, float x, float y, float *xr, float *yr) +void ED_image_point_pos(SpaceImage *sima, ARegion *region, float x, float y, float *xr, float *yr) { int sx, sy, width, height; float zoomx, zoomy; - ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); + ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); ED_space_image_get_size(sima, &width, &height); - UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy); + UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &sx, &sy); *xr = ((x - sx) / zoomx) / width; *yr = ((y - sy) / zoomy) / height; } -void ED_image_point_pos__reverse(SpaceImage *sima, ARegion *ar, const float co[2], float r_co[2]) +void ED_image_point_pos__reverse(SpaceImage *sima, + ARegion *region, + const float co[2], + float r_co[2]) { float zoomx, zoomy; int width, height; int sx, sy; - UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy); + UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &sx, &sy); ED_space_image_get_size(sima, &width, &height); - ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); + ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); r_co[0] = (co[0] * width * zoomx) + (float)sx; r_co[1] = (co[1] * height * zoomy) + (float)sy; diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index f3ec68db562..ae26363ad79 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -37,8 +37,8 @@ struct wmOperatorType; extern const char *image_context_dir[]; /* doc access */ /* image_draw.c */ -void draw_image_main(const struct bContext *C, struct ARegion *ar); -void draw_image_cache(const struct bContext *C, struct ARegion *ar); +void draw_image_main(const struct bContext *C, struct ARegion *region); +void draw_image_cache(const struct bContext *C, struct ARegion *region); void draw_image_grease_pencil(struct bContext *C, bool onlyv2d); void draw_image_sample_line(struct SpaceImage *sima); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 86cb27465c7..6f5102ed828 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -111,7 +111,7 @@ * \{ */ static void sima_zoom_set( - SpaceImage *sima, ARegion *ar, float zoom, const float location[2], const bool zoom_to_pos) + SpaceImage *sima, ARegion *region, float zoom, const float location[2], const bool zoom_to_pos) { float oldzoom = sima->zoom; int width, height; @@ -128,10 +128,10 @@ static void sima_zoom_set( if ((width < 4) && (height < 4) && sima->zoom < oldzoom) { sima->zoom = oldzoom; } - else if (BLI_rcti_size_x(&ar->winrct) <= sima->zoom) { + else if (BLI_rcti_size_x(®ion->winrct) <= sima->zoom) { sima->zoom = oldzoom; } - else if (BLI_rcti_size_y(&ar->winrct) <= sima->zoom) { + else if (BLI_rcti_size_y(®ion->winrct) <= sima->zoom) { sima->zoom = oldzoom; } } @@ -150,16 +150,19 @@ static void sima_zoom_set( } } -static void sima_zoom_set_factor( - SpaceImage *sima, ARegion *ar, float zoomfac, const float location[2], const bool zoom_to_pos) +static void sima_zoom_set_factor(SpaceImage *sima, + ARegion *region, + float zoomfac, + const float location[2], + const bool zoom_to_pos) { - sima_zoom_set(sima, ar, sima->zoom * zoomfac, location, zoom_to_pos); + sima_zoom_set(sima, region, sima->zoom * zoomfac, location, zoom_to_pos); } /** * Fits the view to the bounds exactly, caller should add margin if needed. */ -static void sima_zoom_set_from_bounds(SpaceImage *sima, ARegion *ar, const rctf *bounds) +static void sima_zoom_set_from_bounds(SpaceImage *sima, ARegion *region, const rctf *bounds) { int image_size[2]; float aspx, aspy; @@ -175,13 +178,13 @@ static void sima_zoom_set_from_bounds(SpaceImage *sima, ARegion *ar, const rctf sima->yof = roundf((BLI_rctf_cent_y(bounds) - 0.5f) * image_size[1]); float size_xy[2], size; - size_xy[0] = BLI_rcti_size_x(&ar->winrct) / (BLI_rctf_size_x(bounds) * image_size[0]); - size_xy[1] = BLI_rcti_size_y(&ar->winrct) / (BLI_rctf_size_y(bounds) * image_size[1]); + size_xy[0] = BLI_rcti_size_x(®ion->winrct) / (BLI_rctf_size_x(bounds) * image_size[0]); + size_xy[1] = BLI_rcti_size_y(®ion->winrct) / (BLI_rctf_size_y(bounds) * image_size[1]); size = min_ff(size_xy[0], size_xy[1]); CLAMP_MAX(size, 100.0f); - sima_zoom_set(sima, ar, size, NULL, false); + sima_zoom_set(sima, region, size, NULL, false); } static Image *image_from_context(const bContext *C) @@ -252,10 +255,10 @@ static bool image_not_packed_poll(bContext *C) bool space_image_main_region_poll(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); - /* XXX ARegion *ar = CTX_wm_region(C); */ + /* XXX ARegion *region = CTX_wm_region(C); */ if (sima) { - return true; /* XXX (ar && ar->type->regionid == RGN_TYPE_WINDOW); */ + return true; /* XXX (region && region->type->regionid == RGN_TYPE_WINDOW); */ } return false; } @@ -462,14 +465,14 @@ typedef struct ViewZoomData { /* */ SpaceImage *sima; - ARegion *ar; + ARegion *region; } ViewZoomData; static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); ViewZoomData *vpd; op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ImageViewZoomData"); @@ -486,7 +489,7 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *eve vpd->launch_event = WM_userdef_event_type_from_keymap_type(event->type); UI_view2d_region_to_view( - &ar->v2d, event->mval[0], event->mval[1], &vpd->location[0], &vpd->location[1]); + ®ion->v2d, event->mval[0], event->mval[1], &vpd->location[0], &vpd->location[1]); if (U.viewzoom == USER_ZOOM_CONT) { /* needs a timer to continue redrawing */ @@ -495,7 +498,7 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *eve } vpd->sima = sima; - vpd->ar = ar; + vpd->region = region; WM_event_add_modal_handler(C, op); } @@ -523,11 +526,11 @@ static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel) static int image_view_zoom_exec(bContext *C, wmOperator *op) { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); - sima_zoom_set_factor(sima, ar, RNA_float_get(op->ptr, "factor"), NULL, false); + sima_zoom_set_factor(sima, region, RNA_float_get(op->ptr, "factor"), NULL, false); - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return OPERATOR_FINISHED; } @@ -542,10 +545,11 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev { if (event->type == MOUSEZOOM || event->type == MOUSEPAN) { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); float delta, factor, location[2]; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); + UI_view2d_region_to_view( + ®ion->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); delta = event->prevx - event->x + event->prevy - event->y; @@ -557,11 +561,11 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev RNA_float_set(op->ptr, "factor", factor); const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init"); sima_zoom_set(sima, - ar, + region, sima->zoom * factor, location, (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS))); - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return OPERATOR_FINISHED; } @@ -616,8 +620,8 @@ static void image_zoom_apply(ViewZoomData *vpd, } RNA_float_set(op->ptr, "factor", factor); - sima_zoom_set(vpd->sima, vpd->ar, vpd->zoom * factor, vpd->location, zoom_to_pos); - ED_region_tag_redraw(vpd->ar); + sima_zoom_set(vpd->sima, vpd->region, vpd->zoom * factor, vpd->location, zoom_to_pos); + ED_region_tag_redraw(vpd->region); } static int image_view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event) @@ -715,7 +719,7 @@ static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmE } else { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); float pan_vec[3]; const wmNDOFMotionData *ndof = event->customdata; @@ -726,11 +730,11 @@ static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmE mul_v2_fl(pan_vec, (speed * ndof->dt) / sima->zoom); pan_vec[2] *= -ndof->dt; - sima_zoom_set_factor(sima, ar, 1.0f + pan_vec[2], NULL, false); + sima_zoom_set_factor(sima, region, 1.0f + pan_vec[2], NULL, false); sima->xof += pan_vec[0]; sima->yof += pan_vec[1]; - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return OPERATOR_FINISHED; } @@ -766,14 +770,14 @@ void IMAGE_OT_view_ndof(wmOperatorType *ot) static int image_view_all_exec(bContext *C, wmOperator *op) { SpaceImage *sima; - ARegion *ar; + ARegion *region; float aspx, aspy, zoomx, zoomy, w, h; int width, height; const bool fit_view = RNA_boolean_get(op->ptr, "fit_view"); /* retrieve state */ sima = CTX_wm_space_image(C); - ar = CTX_wm_region(C); + region = CTX_wm_region(C); ED_space_image_get_size(sima, &width, &height); ED_space_image_get_aspect(sima, &aspx, &aspy); @@ -805,8 +809,8 @@ static int image_view_all_exec(bContext *C, wmOperator *op) } /* check if the image will fit in the image with (zoom == 1) */ - width = BLI_rcti_size_x(&ar->winrct) + 1; - height = BLI_rcti_size_y(&ar->winrct) + 1; + width = BLI_rcti_size_x(®ion->winrct) + 1; + height = BLI_rcti_size_y(®ion->winrct) + 1; if (fit_view) { const int margin = 5; /* margin from border */ @@ -814,7 +818,7 @@ static int image_view_all_exec(bContext *C, wmOperator *op) zoomx = (float)width / (w + 2 * margin); zoomy = (float)height / (h + 2 * margin); - sima_zoom_set(sima, ar, min_ff(zoomx, zoomy), NULL, false); + sima_zoom_set(sima, region, min_ff(zoomx, zoomy), NULL, false); } else { if ((w >= width || h >= height) && (width > 0 && height > 0)) { @@ -822,17 +826,17 @@ static int image_view_all_exec(bContext *C, wmOperator *op) zoomy = (float)height / h; /* find the zoom value that will fit the image in the image space */ - sima_zoom_set(sima, ar, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL, false); + sima_zoom_set(sima, region, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL, false); } else { - sima_zoom_set(sima, ar, 1.0f, NULL, false); + sima_zoom_set(sima, region, 1.0f, NULL, false); } } sima->xof = xof; sima->yof = yof; - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return OPERATOR_FINISHED; } @@ -867,11 +871,11 @@ void IMAGE_OT_view_all(wmOperatorType *ot) static int view_center_cursor_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); ED_image_view_center_to_point(sima, sima->cursor[0], sima->cursor[1]); - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return OPERATOR_FINISHED; } @@ -897,7 +901,7 @@ void IMAGE_OT_view_center_cursor(wmOperatorType *ot) static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceImage *sima; - ARegion *ar; + ARegion *region; Scene *scene; ViewLayer *view_layer; Object *obedit; @@ -905,7 +909,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* retrieve state */ sima = CTX_wm_space_image(C); - ar = CTX_wm_region(C); + region = CTX_wm_region(C); scene = CTX_data_scene(C); view_layer = CTX_data_view_layer(C); obedit = CTX_data_edit_object(C); @@ -934,9 +938,9 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* add some margin */ BLI_rctf_scale(&bounds, 1.4f); - sima_zoom_set_from_bounds(sima, ar, &bounds); + sima_zoom_set_from_bounds(sima, region, &bounds); - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return OPERATOR_FINISHED; } @@ -967,25 +971,26 @@ void IMAGE_OT_view_selected(wmOperatorType *ot) static int image_view_zoom_in_exec(bContext *C, wmOperator *op) { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); float location[2]; RNA_float_get_array(op->ptr, "location", location); sima_zoom_set_factor( - sima, ar, powf(2.0f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS); + sima, region, powf(2.0f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS); - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return OPERATOR_FINISHED; } static int image_view_zoom_in_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); float location[2]; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); + UI_view2d_region_to_view( + ®ion->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); RNA_float_set_array(op->ptr, "location", location); return image_view_zoom_in_exec(C, op); @@ -1025,25 +1030,26 @@ void IMAGE_OT_view_zoom_in(wmOperatorType *ot) static int image_view_zoom_out_exec(bContext *C, wmOperator *op) { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); float location[2]; RNA_float_get_array(op->ptr, "location", location); sima_zoom_set_factor( - sima, ar, powf(0.5f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS); + sima, region, powf(0.5f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS); - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return OPERATOR_FINISHED; } static int image_view_zoom_out_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); float location[2]; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); + UI_view2d_region_to_view( + ®ion->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); RNA_float_set_array(op->ptr, "location", location); return image_view_zoom_out_exec(C, op); @@ -1089,15 +1095,15 @@ void IMAGE_OT_view_zoom_out(wmOperatorType *ot) static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op) { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); - sima_zoom_set(sima, ar, RNA_float_get(op->ptr, "ratio"), NULL, false); + sima_zoom_set(sima, region, RNA_float_get(op->ptr, "ratio"), NULL, false); /* ensure pixel exact locations for draw */ sima->xof = (int)sima->xof; sima->yof = (int)sima->yof; - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return OPERATOR_FINISHED; } @@ -1137,13 +1143,13 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot) static int image_view_zoom_border_exec(bContext *C, wmOperator *op) { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); rctf bounds; const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out"); WM_operator_properties_border_to_rctf(op, &bounds); - UI_view2d_region_to_view_rctf(&ar->v2d, &bounds, &bounds); + UI_view2d_region_to_view_rctf(®ion->v2d, &bounds, &bounds); const struct { float xof; @@ -1155,7 +1161,7 @@ static int image_view_zoom_border_exec(bContext *C, wmOperator *op) .zoom = sima->zoom, }; - sima_zoom_set_from_bounds(sima, ar, &bounds); + sima_zoom_set_from_bounds(sima, region, &bounds); /* zoom out */ if (!zoom_in) { @@ -1164,7 +1170,7 @@ static int image_view_zoom_border_exec(bContext *C, wmOperator *op) sima->zoom = sima_view_prev.zoom * (sima_view_prev.zoom / sima->zoom); } - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return OPERATOR_FINISHED; } @@ -3120,7 +3126,7 @@ typedef struct ImageSampleInfo { int use_default_view; } ImageSampleInfo; -static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info) +static void image_sample_draw(const bContext *C, ARegion *region, void *arg_info) { ImageSampleInfo *info = arg_info; if (!info->draw) { @@ -3129,7 +3135,7 @@ static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info) Scene *scene = CTX_data_scene(C); ED_image_draw_info(scene, - ar, + region, info->color_manage, info->use_default_view, info->channels, @@ -3155,9 +3161,10 @@ static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info) /* TODO(campbell): lock to pixels. */ rctf sample_rect_fl; - BLI_rctf_init_pt_radius(&sample_rect_fl, - (float[2]){event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}, - (float)(info->sample_size / 2.0f) * sima->zoom); + BLI_rctf_init_pt_radius( + &sample_rect_fl, + (float[2]){event->x - region->winrct.xmin, event->y - region->winrct.ymin}, + (float)(info->sample_size / 2.0f) * sima->zoom); glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); @@ -3174,13 +3181,13 @@ static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info) } /* Returns color in linear space, matching ED_space_node_color_sample(). */ -bool ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], float r_col[3]) +bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, int mval[2], float r_col[3]) { if (sima->image == NULL) { return false; } float uv[2]; - UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &uv[0], &uv[1]); + UI_view2d_region_to_view(®ion->v2d, mval[0], mval[1], &uv[0], &uv[1]); int tile = BKE_image_get_tile_from_pos(sima->image, uv, uv, NULL); void *lock; @@ -3295,11 +3302,11 @@ static void image_sample_rect_color_float(ImBuf *ibuf, const rcti *rect, float r static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event) { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); Image *image = ED_space_image(sima); float uv[2]; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &uv[0], &uv[1]); + UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &uv[0], &uv[1]); int tile = BKE_image_get_tile_from_pos(sima->image, uv, uv, NULL); void *lock; @@ -3439,10 +3446,10 @@ static void image_sample_exit(bContext *C, wmOperator *op) static int image_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event) { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); ImageSampleInfo *info; - if (ar->regiontype == RGN_TYPE_WINDOW) { + if (region->regiontype == RGN_TYPE_WINDOW) { if (event->mval[1] <= 16 && ED_space_image_show_cache(sima)) { return OPERATOR_PASS_THROUGH; } @@ -3454,9 +3461,9 @@ static int image_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); - info->art = ar->type; + info->art = region->type; info->draw_handle = ED_region_draw_cb_activate( - ar->type, image_sample_draw, info, REGION_DRAW_POST_PIXEL); + region->type, image_sample_draw, info, REGION_DRAW_POST_PIXEL); info->sample_size = RNA_int_get(op->ptr, "size"); op->customdata = info; @@ -3521,7 +3528,7 @@ void IMAGE_OT_sample(wmOperatorType *ot) static int image_sample_line_exec(bContext *C, wmOperator *op) { SpaceImage *sima = CTX_wm_space_image(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); Image *ima = ED_space_image(sima); @@ -3531,8 +3538,8 @@ static int image_sample_line_exec(bContext *C, wmOperator *op) int y_end = RNA_int_get(op->ptr, "yend"); float uv1[2], uv2[2], ofs[2]; - UI_view2d_region_to_view(&ar->v2d, x_start, y_start, &uv1[0], &uv1[1]); - UI_view2d_region_to_view(&ar->v2d, x_end, y_end, &uv2[0], &uv2[1]); + UI_view2d_region_to_view(®ion->v2d, x_start, y_start, &uv1[0], &uv1[1]); + UI_view2d_region_to_view(®ion->v2d, x_end, y_end, &uv2[0], &uv2[1]); /* If the image has tiles, shift the positions accordingly. */ int tile = BKE_image_get_tile_from_pos(ima, uv1, uv1, ofs); @@ -3834,19 +3841,19 @@ static int change_frame_exec(bContext *C, wmOperator *op) static int frame_from_event(bContext *C, const wmEvent *event) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); int framenr = 0; - if (ar->regiontype == RGN_TYPE_WINDOW) { - float sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1); + if (region->regiontype == RGN_TYPE_WINDOW) { + float sfra = SFRA, efra = EFRA, framelen = region->winx / (efra - sfra + 1); framenr = sfra + event->mval[0] / framelen; } else { float viewx, viewy; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy); + UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &viewx, &viewy); framenr = round_fl_to_int(viewx); } @@ -3856,13 +3863,13 @@ static int frame_from_event(bContext *C, const wmEvent *event) static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); - if (ar->regiontype == RGN_TYPE_WINDOW) { + if (region->regiontype == RGN_TYPE_WINDOW) { SpaceImage *sima = CTX_wm_space_image(C); /* Local coordinate visible rect inside region, to accommodate overlapping ui. */ - const rcti *rect_visible = ED_region_visible_rect(ar); + const rcti *rect_visible = ED_region_visible_rect(region); const int region_bottom = rect_visible->ymin; if (event->mval[1] > (region_bottom + 16 * UI_DPI_FAC) || !ED_space_image_show_cache(sima)) { @@ -3963,7 +3970,7 @@ void IMAGE_OT_read_viewlayers(wmOperatorType *ot) static int render_border_exec(bContext *C, wmOperator *op) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); Render *re = RE_GetSceneRender(scene); RenderData *rd; @@ -3982,7 +3989,7 @@ static int render_border_exec(bContext *C, wmOperator *op) /* get rectangle from operator */ WM_operator_properties_border_to_rctf(op, &border); - UI_view2d_region_to_view_rctf(&ar->v2d, &border, &border); + UI_view2d_region_to_view_rctf(®ion->v2d, &border, &border); /* actually set border */ CLAMP(border.xmin, 0.0f, 1.0f); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index e18eb062741..dc546e5baf5 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -86,11 +86,11 @@ static void image_scopes_tag_refresh(ScrArea *sa) { SpaceImage *sima = (SpaceImage *)sa->spacedata.first; - ARegion *ar; + ARegion *region; /* only while histogram is visible */ - for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_TOOL_PROPS && ar->flag & RGN_FLAG_HIDDEN) { + for (region = sa->regionbase.first; region; region = region->next) { + if (region->regiontype == RGN_TYPE_TOOL_PROPS && region->flag & RGN_FLAG_HIDDEN) { return; } } @@ -119,7 +119,7 @@ static void image_user_refresh_scene(const bContext *C, SpaceImage *sima) static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) { - ARegion *ar; + ARegion *region; SpaceImage *simage; simage = MEM_callocN(sizeof(SpaceImage), "initimage"); @@ -138,41 +138,41 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce simage->tile_grid_shape[1] = 1; /* tool header */ - ar = MEM_callocN(sizeof(ARegion), "tool header for image"); + region = MEM_callocN(sizeof(ARegion), "tool header for image"); - BLI_addtail(&simage->regionbase, ar); - ar->regiontype = RGN_TYPE_TOOL_HEADER; - ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; - ar->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; + BLI_addtail(&simage->regionbase, region); + region->regiontype = RGN_TYPE_TOOL_HEADER; + region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; + region->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; /* header */ - ar = MEM_callocN(sizeof(ARegion), "header for image"); + region = MEM_callocN(sizeof(ARegion), "header for image"); - BLI_addtail(&simage->regionbase, ar); - ar->regiontype = RGN_TYPE_HEADER; - ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; + BLI_addtail(&simage->regionbase, region); + region->regiontype = RGN_TYPE_HEADER; + region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* buttons/list view */ - ar = MEM_callocN(sizeof(ARegion), "buttons for image"); + region = MEM_callocN(sizeof(ARegion), "buttons for image"); - BLI_addtail(&simage->regionbase, ar); - ar->regiontype = RGN_TYPE_UI; - ar->alignment = RGN_ALIGN_RIGHT; - ar->flag = RGN_FLAG_HIDDEN; + BLI_addtail(&simage->regionbase, region); + region->regiontype = RGN_TYPE_UI; + region->alignment = RGN_ALIGN_RIGHT; + region->flag = RGN_FLAG_HIDDEN; /* scopes/uv sculpt/paint */ - ar = MEM_callocN(sizeof(ARegion), "buttons for image"); + region = MEM_callocN(sizeof(ARegion), "buttons for image"); - BLI_addtail(&simage->regionbase, ar); - ar->regiontype = RGN_TYPE_TOOLS; - ar->alignment = RGN_ALIGN_LEFT; - ar->flag = RGN_FLAG_HIDDEN; + BLI_addtail(&simage->regionbase, region); + region->regiontype = RGN_TYPE_TOOLS; + region->alignment = RGN_ALIGN_LEFT; + region->flag = RGN_FLAG_HIDDEN; /* main area */ - ar = MEM_callocN(sizeof(ARegion), "main area for image"); + region = MEM_callocN(sizeof(ARegion), "main area for image"); - BLI_addtail(&simage->regionbase, ar); - ar->regiontype = RGN_TYPE_WINDOW; + BLI_addtail(&simage->regionbase, region); + region->regiontype = RGN_TYPE_WINDOW; return (SpaceLink *)simage; } @@ -536,7 +536,7 @@ static void image_widgets(void) /************************** main region ***************************/ /* sets up the fields of the View2D from zoom and offset */ -static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar) +static void image_main_region_set_view2d(SpaceImage *sima, ARegion *region) { Image *ima = ED_space_image(sima); @@ -550,79 +550,79 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar) h *= ima->aspy / ima->aspx; } - int winx = BLI_rcti_size_x(&ar->winrct) + 1; - int winy = BLI_rcti_size_y(&ar->winrct) + 1; + int winx = BLI_rcti_size_x(®ion->winrct) + 1; + int winy = BLI_rcti_size_y(®ion->winrct) + 1; /* For region overlap, move center so image doesn't overlap header. */ - const rcti *visible_rect = ED_region_visible_rect(ar); + const rcti *visible_rect = ED_region_visible_rect(region); const int visible_winy = BLI_rcti_size_y(visible_rect) + 1; int visible_centerx = 0; int visible_centery = visible_rect->ymin + (visible_winy - winy) / 2; - ar->v2d.tot.xmin = 0; - ar->v2d.tot.ymin = 0; - ar->v2d.tot.xmax = w; - ar->v2d.tot.ymax = h; + region->v2d.tot.xmin = 0; + region->v2d.tot.ymin = 0; + region->v2d.tot.xmax = w; + region->v2d.tot.ymax = h; - ar->v2d.mask.xmin = ar->v2d.mask.ymin = 0; - ar->v2d.mask.xmax = winx; - ar->v2d.mask.ymax = winy; + region->v2d.mask.xmin = region->v2d.mask.ymin = 0; + region->v2d.mask.xmax = winx; + region->v2d.mask.ymax = winy; /* which part of the image space do we see? */ - float x1 = ar->winrct.xmin + visible_centerx + (winx - sima->zoom * w) / 2.0f; - float y1 = ar->winrct.ymin + visible_centery + (winy - sima->zoom * h) / 2.0f; + float x1 = region->winrct.xmin + visible_centerx + (winx - sima->zoom * w) / 2.0f; + float y1 = region->winrct.ymin + visible_centery + (winy - sima->zoom * h) / 2.0f; x1 -= sima->zoom * sima->xof; y1 -= sima->zoom * sima->yof; /* relative display right */ - ar->v2d.cur.xmin = ((ar->winrct.xmin - (float)x1) / sima->zoom); - ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx / sima->zoom); + region->v2d.cur.xmin = ((region->winrct.xmin - (float)x1) / sima->zoom); + region->v2d.cur.xmax = region->v2d.cur.xmin + ((float)winx / sima->zoom); /* relative display left */ - ar->v2d.cur.ymin = ((ar->winrct.ymin - (float)y1) / sima->zoom); - ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy / sima->zoom); + region->v2d.cur.ymin = ((region->winrct.ymin - (float)y1) / sima->zoom); + region->v2d.cur.ymax = region->v2d.cur.ymin + ((float)winy / sima->zoom); /* normalize 0.0..1.0 */ - ar->v2d.cur.xmin /= w; - ar->v2d.cur.xmax /= w; - ar->v2d.cur.ymin /= h; - ar->v2d.cur.ymax /= h; + region->v2d.cur.xmin /= w; + region->v2d.cur.xmax /= w; + region->v2d.cur.ymin /= h; + region->v2d.cur.ymax /= h; } /* add handlers, stuff you only do once or on area/region changes */ -static void image_main_region_init(wmWindowManager *wm, ARegion *ar) +static void image_main_region_init(wmWindowManager *wm, ARegion *region) { wmKeyMap *keymap; // image space manages own v2d - // UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); + // UI_view2d_region_reinit(®ion->v2d, V2D_COMMONVIEW_STANDARD, region->winx, region->winy); /* mask polls mode */ keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0); - WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); + WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap); /* image paint polls for mode */ keymap = WM_keymap_ensure(wm->defaultconf, "Curve", 0, 0); - WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); + WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Paint Curve", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Image Paint", 0, 0); - WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); + WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "UV Editor", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); /* own keymaps */ keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Image", SPACE_IMAGE, 0); - WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap); + WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap); } -static void image_main_region_draw(const bContext *C, ARegion *ar) +static void image_main_region_draw(const bContext *C, ARegion *region) { /* draw entirely, view changes should be handled here */ SpaceImage *sima = CTX_wm_space_image(C); @@ -634,7 +634,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) bool show_curve = false; Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - View2D *v2d = &ar->v2d; + View2D *v2d = ®ion->v2d; // View2DScrollers *scrollers; float col[3]; @@ -643,7 +643,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) gpu_batch_presets_reset(); GPUViewport *viewport = - ar->draw_buffer->viewport[ar->draw_buffer->stereo ? sima->iuser.multiview_eye : 0]; + region->draw_buffer->viewport[region->draw_buffer->stereo ? sima->iuser.multiview_eye : 0]; DefaultFramebufferList *fbl = GPU_viewport_framebuffer_list_get(viewport); GPU_framebuffer_bind(fbl->default_fb); GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); @@ -664,15 +664,15 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) image_user_refresh_scene(C, sima); /* we set view2d from own zoom and offset each time */ - image_main_region_set_view2d(sima, ar); + image_main_region_set_view2d(sima, region); /* we draw image in pixelspace */ - draw_image_main(C, ar); + draw_image_main(C, region); /* and uvs in 0.0-1.0 space */ UI_view2d_view_ortho(v2d); - ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); + ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW); ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph); @@ -687,7 +687,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) show_curve = true; } - ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); + ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW); if (sima->flag & SI_SHOW_GPENCIL) { /* Grease Pencil too (in addition to UV's) */ @@ -727,7 +727,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) ED_mask_draw_region(depsgraph, mask, - ar, + region, sima->mask_info.draw_flag, sima->mask_info.draw_type, sima->mask_info.overlay_mode, @@ -743,51 +743,54 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) if (show_uvedit || mask || show_curve) { UI_view2d_view_ortho(v2d); - ED_image_draw_cursor(ar, sima->cursor); + ED_image_draw_cursor(region, sima->cursor); UI_view2d_view_restore(C); } - WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); + WM_gizmomap_draw(region->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); - draw_image_cache(C, ar); + draw_image_cache(C, region); } -static void image_main_region_listener( - wmWindow *UNUSED(win), ScrArea *sa, ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene)) +static void image_main_region_listener(wmWindow *UNUSED(win), + ScrArea *sa, + ARegion *region, + wmNotifier *wmn, + const Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { case NC_GEOM: if (ELEM(wmn->data, ND_DATA, ND_SELECT)) { - WM_gizmomap_tag_refresh(ar->gizmo_map); + WM_gizmomap_tag_refresh(region->gizmo_map); } break; case NC_GPENCIL: if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } else if (wmn->data & ND_GPENCIL_EDITMODE) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_IMAGE: if (wmn->action == NA_PAINTING) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } - WM_gizmomap_tag_refresh(ar->gizmo_map); + WM_gizmomap_tag_refresh(region->gizmo_map); break; case NC_MATERIAL: if (wmn->data == ND_SHADING_LINKS) { SpaceImage *sima = sa->spacedata.first; if (sima->iuser.scene && (sima->iuser.scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } } break; case NC_SCREEN: if (ELEM(wmn->data, ND_LAYER)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; } @@ -796,18 +799,18 @@ static void image_main_region_listener( /* *********************** buttons region ************************ */ /* add handlers, stuff you only do once or on area/region changes */ -static void image_buttons_region_init(wmWindowManager *wm, ARegion *ar) +static void image_buttons_region_init(wmWindowManager *wm, ARegion *region) { wmKeyMap *keymap; - ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; - ED_region_panels_init(wm, ar); + region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; + ED_region_panels_init(wm, region); keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); } -static void image_buttons_region_layout(const bContext *C, ARegion *ar) +static void image_buttons_region_layout(const bContext *C, ARegion *region) { const enum eContextObjectMode mode = CTX_data_mode_enum(C); const char *contexts_base[3] = {NULL}; @@ -831,10 +834,11 @@ static void image_buttons_region_layout(const bContext *C, ARegion *ar) } const bool vertical = true; - ED_region_panels_layout_ex(C, ar, &ar->type->paneltypes, contexts_base, -1, vertical, NULL); + ED_region_panels_layout_ex( + C, region, ®ion->type->paneltypes, contexts_base, -1, vertical, NULL); } -static void image_buttons_region_draw(const bContext *C, ARegion *ar) +static void image_buttons_region_draw(const bContext *C, ARegion *region) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); @@ -842,7 +846,7 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar) /* TODO(lukas): Support tiles in scopes? */ ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0); /* XXX performance regression if name of scopes category changes! */ - PanelCategoryStack *category = UI_panel_category_active_find(ar, "Scopes"); + PanelCategoryStack *category = UI_panel_category_active_find(region, "Scopes"); /* only update scopes if scope category is active */ if (category) { @@ -862,12 +866,12 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar) ED_space_image_release_buffer(sima, ibuf, lock); /* Layout handles details. */ - ED_region_panels_draw(C, ar); + ED_region_panels_draw(C, region); } static void image_buttons_region_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), - ARegion *ar, + ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) { @@ -877,33 +881,33 @@ static void image_buttons_region_listener(wmWindow *UNUSED(win), case NC_MATERIAL: /* sending by texture render job and needed to properly update displaying * brush texture icon */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case NC_SCENE: switch (wmn->data) { case ND_MODE: case ND_RENDER_RESULT: case ND_COMPO_RESULT: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; case NC_IMAGE: if (wmn->action != NA_PAINTING) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_NODE: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case NC_GPENCIL: if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_BRUSH: if (wmn->action == NA_EDITED) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; } @@ -912,25 +916,25 @@ static void image_buttons_region_listener(wmWindow *UNUSED(win), /* *********************** scopes region ************************ */ /* add handlers, stuff you only do once or on area/region changes */ -static void image_tools_region_init(wmWindowManager *wm, ARegion *ar) +static void image_tools_region_init(wmWindowManager *wm, ARegion *region) { wmKeyMap *keymap; - ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; - ED_region_panels_init(wm, ar); + region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; + ED_region_panels_init(wm, region); keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); } -static void image_tools_region_draw(const bContext *C, ARegion *ar) +static void image_tools_region_draw(const bContext *C, ARegion *region) { - ED_region_panels(C, ar); + ED_region_panels(C, region); } static void image_tools_region_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), - ARegion *ar, + ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) { @@ -938,13 +942,13 @@ static void image_tools_region_listener(wmWindow *UNUSED(win), switch (wmn->category) { case NC_GPENCIL: if (wmn->data == ND_DATA || ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_BRUSH: /* NA_SELECTED is used on brush changes */ if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_SCENE: @@ -952,17 +956,17 @@ static void image_tools_region_listener(wmWindow *UNUSED(win), case ND_MODE: case ND_RENDER_RESULT: case ND_COMPO_RESULT: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; case NC_IMAGE: if (wmn->action != NA_PAINTING) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_NODE: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } } @@ -970,24 +974,24 @@ static void image_tools_region_listener(wmWindow *UNUSED(win), /************************* header region **************************/ /* add handlers, stuff you only do once or on area/region changes */ -static void image_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar) +static void image_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region) { - ED_region_header_init(ar); + ED_region_header_init(region); } -static void image_header_region_draw(const bContext *C, ARegion *ar) +static void image_header_region_draw(const bContext *C, ARegion *region) { ScrArea *sa = CTX_wm_area(C); SpaceImage *sima = sa->spacedata.first; image_user_refresh_scene(C, sima); - ED_region_header(C, ar); + ED_region_header(C, region); } static void image_header_region_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), - ARegion *ar, + ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) { @@ -997,7 +1001,7 @@ static void image_header_region_listener(wmWindow *UNUSED(win), switch (wmn->data) { case ND_MODE: case ND_TOOLSETTINGS: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; @@ -1005,13 +1009,13 @@ static void image_header_region_listener(wmWindow *UNUSED(win), switch (wmn->data) { case ND_DATA: case ND_SELECT: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; case NC_BRUSH: if (wmn->action == NA_EDITED) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; } |