diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-10-19 04:22:06 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-10-19 04:50:07 +0300 |
commit | b74f2c7d74dc18ab9afa105a2cfe547fabb42d57 (patch) | |
tree | 71f8f9e3cc325a06990b8638b3947ca2d6cd949e /source | |
parent | a3457704fb63a59045b093dc4499b43f6676fabb (diff) |
Fix image cache margin calculation
This margin was inconsistently calculated: only taking the
visible region and interface scale into account in some cases.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/ED_image.h | 9 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_edit.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 9 | ||||
-rw-r--r-- | source/blender/editors/util/ed_util_imbuf.c | 3 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 8 |
6 files changed, 26 insertions, 20 deletions
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index f0e8f7f0a39..1400bcf5ee3 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -53,13 +53,13 @@ float ED_space_image_increment_snap_value(const int grid_dimesnions, const float zoom_factor); /* image_edit.c, exported for transform */ -struct Image *ED_space_image(struct SpaceImage *sima); +struct Image *ED_space_image(const struct SpaceImage *sima); void ED_space_image_set(struct Main *bmain, struct SpaceImage *sima, struct Image *ima, bool automatic); void ED_space_image_auto_set(const struct bContext *C, struct SpaceImage *sima); -struct Mask *ED_space_image_get_mask(struct SpaceImage *sima); +struct Mask *ED_space_image_get_mask(const struct SpaceImage *sima); void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask); bool ED_space_image_get_position(struct SpaceImage *sima, @@ -136,7 +136,10 @@ void ED_image_draw_info(struct Scene *scene, const int *zp, const float *zpf); -bool ED_space_image_show_cache(struct SpaceImage *sima); +bool ED_space_image_show_cache(const struct SpaceImage *sima); +bool ED_space_image_show_cache_and_mval_over(const struct SpaceImage *sima, + struct ARegion *region, + const int mval[2]); bool ED_image_should_save_modified(const struct Main *bmain); int ED_image_save_all_modified_info(const struct Main *bmain, struct ReportList *reports); 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; } } diff --git a/source/blender/editors/util/ed_util_imbuf.c b/source/blender/editors/util/ed_util_imbuf.c index ca21f88b230..159826568d1 100644 --- a/source/blender/editors/util/ed_util_imbuf.c +++ b/source/blender/editors/util/ed_util_imbuf.c @@ -491,9 +491,8 @@ int ED_imbuf_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (sa && sa->spacetype == SPACE_IMAGE) { SpaceImage *sima = CTX_wm_space_image(C); - if (region->regiontype == RGN_TYPE_WINDOW) { - if (event->mval[1] <= 16 && ED_space_image_show_cache(sima)) { + if (ED_space_image_show_cache_and_mval_over(sima, region, event->mval)) { return OPERATOR_PASS_THROUGH; } } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 0757e177235..acdffd5ff98 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1765,11 +1765,9 @@ static int uv_set_2d_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *e float location[2]; if (region->regiontype == RGN_TYPE_WINDOW) { - if (event->mval[1] <= 16) { - SpaceImage *sima = CTX_wm_space_image(C); - if (sima && ED_space_image_show_cache(sima)) { - return OPERATOR_PASS_THROUGH; - } + SpaceImage *sima = CTX_wm_space_image(C); + if (sima && ED_space_image_show_cache_and_mval_over(sima, region, event->mval)) { + return OPERATOR_PASS_THROUGH; } } |