From b74f2c7d74dc18ab9afa105a2cfe547fabb42d57 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Oct 2021 12:22:06 +1100 Subject: Fix image cache margin calculation This margin was inconsistently calculated: only taking the visible region and interface scale into account in some cases. --- source/blender/editors/space_image/image_draw.c | 13 ++++++++++++- source/blender/editors/space_image/image_edit.c | 4 ++-- source/blender/editors/space_image/image_ops.c | 9 ++------- 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'source/blender/editors/space_image') diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index fb87c54c1db..22a43ea3794 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -500,7 +500,7 @@ void draw_image_main_helpers(const bContext *C, ARegion *region) } } -bool ED_space_image_show_cache(SpaceImage *sima) +bool ED_space_image_show_cache(const SpaceImage *sima) { Image *image = ED_space_image(sima); Mask *mask = NULL; @@ -516,6 +516,17 @@ bool ED_space_image_show_cache(SpaceImage *sima) return true; } +bool ED_space_image_show_cache_and_mval_over(const SpaceImage *sima, + ARegion *region, + const int mval[2]) +{ + const rcti *rect_visible = ED_region_visible_rect(region); + if (mval[1] > rect_visible->ymin + (16 * UI_DPI_FAC)) { + return false; + } + return ED_space_image_show_cache(sima); +} + void draw_image_cache(const bContext *C, ARegion *region) { SpaceImage *sima = CTX_wm_space_image(C); diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 594baf67aaf..c1aa2da9e00 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -52,7 +52,7 @@ #include "WM_types.h" /* NOTE: image_panel_properties() uses pointer to sima->image directly. */ -Image *ED_space_image(SpaceImage *sima) +Image *ED_space_image(const SpaceImage *sima) { return sima->image; } @@ -113,7 +113,7 @@ void ED_space_image_auto_set(const bContext *C, SpaceImage *sima) } } -Mask *ED_space_image_get_mask(SpaceImage *sima) +Mask *ED_space_image_get_mask(const SpaceImage *sima) { return sima->mask_info.mask; } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 94d44e047a4..0dbcb1885c2 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -3628,13 +3628,8 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event ARegion *region = CTX_wm_region(C); 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(region); - const int region_bottom = rect_visible->ymin; - - if (event->mval[1] > (region_bottom + 16 * UI_DPI_FAC) || !ED_space_image_show_cache(sima)) { + const SpaceImage *sima = CTX_wm_space_image(C); + if (!ED_space_image_show_cache_and_mval_over(sima, region, event->mval)) { return OPERATOR_PASS_THROUGH; } } -- cgit v1.2.3