From 67525b88d2e51db7ea5e6209b3589ce1c56f4959 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Fri, 24 Dec 2021 23:59:33 -0500 Subject: Cleanup: Use array for BKE cursor functions Differential Revision: https://developer.blender.org/D12962 --- source/blender/blenkernel/BKE_screen.h | 15 ++++++++------- source/blender/blenkernel/intern/screen.c | 22 +++++++++------------- 2 files changed, 17 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index fd0682ee8f0..9e26840b209 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -465,7 +465,9 @@ void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizm */ struct ARegion *BKE_area_find_region_type(const struct ScrArea *area, int type); struct ARegion *BKE_area_find_region_active_win(struct ScrArea *area); -struct ARegion *BKE_area_find_region_xy(struct ScrArea *area, const int regiontype, int x, int y); +struct ARegion *BKE_area_find_region_xy(struct ScrArea *area, + const int regiontype, + const int xy[2]) ATTR_NONNULL(1, 3); /** * \note This is only for screen level regions (typically menus/popups). */ @@ -476,9 +478,7 @@ struct ARegion *BKE_screen_find_region_xy(struct bScreen *screen, struct ARegion *BKE_screen_find_main_region_at_xy(struct bScreen *screen, const int space_type, - const int x, - const int y); - + const int xy[2]) ATTR_NONNULL(1, 3); /** * \note Ideally we can get the area from the context, * there are a few places however where this isn't practical. @@ -495,9 +495,10 @@ struct ScrArea *BKE_screen_find_big_area(struct bScreen *screen, const short min); struct ScrArea *BKE_screen_area_map_find_area_xy(const struct ScrAreaMap *areamap, const int spacetype, - int x, - int y); -struct ScrArea *BKE_screen_find_area_xy(struct bScreen *screen, const int spacetype, int x, int y); + const int xy[2]) ATTR_NONNULL(1, 3); +struct ScrArea *BKE_screen_find_area_xy(struct bScreen *screen, + const int spacetype, + const int xy[2]) ATTR_NONNULL(1, 3); void BKE_screen_gizmo_tag_refresh(struct bScreen *screen); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index cd8493ee559..363e1f85575 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -900,7 +900,7 @@ ARegion *BKE_area_find_region_active_win(ScrArea *area) return BKE_area_find_region_type(area, RGN_TYPE_WINDOW); } -ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int y) +ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, const int xy[2]) { if (area == NULL) { return NULL; @@ -908,7 +908,7 @@ ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) { - if (BLI_rcti_isect_pt(®ion->winrct, x, y)) { + if (BLI_rcti_isect_pt_v(®ion->winrct, xy)) { return region; } } @@ -961,11 +961,10 @@ ScrArea *BKE_screen_find_big_area(bScreen *screen, const int spacetype, const sh ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, const int spacetype, - int x, - int y) + const int xy[2]) { LISTBASE_FOREACH (ScrArea *, area, &areamap->areabase) { - if (BLI_rcti_isect_pt(&area->totrct, x, y)) { + if (BLI_rcti_isect_pt_v(&area->totrct, xy)) { if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) { return area; } @@ -974,9 +973,9 @@ ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, } return NULL; } -ScrArea *BKE_screen_find_area_xy(bScreen *screen, const int spacetype, int x, int y) +ScrArea *BKE_screen_find_area_xy(bScreen *screen, const int spacetype, const int xy[2]) { - return BKE_screen_area_map_find_area_xy(AREAMAP_FROM_SCREEN(screen), spacetype, x, y); + return BKE_screen_area_map_find_area_xy(AREAMAP_FROM_SCREEN(screen), spacetype, xy); } void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene) @@ -1016,16 +1015,13 @@ void BKE_screen_view3d_shading_init(View3DShading *shading) memcpy(shading, shading_default, sizeof(*shading)); } -ARegion *BKE_screen_find_main_region_at_xy(bScreen *screen, - const int space_type, - const int x, - const int y) +ARegion *BKE_screen_find_main_region_at_xy(bScreen *screen, const int space_type, const int xy[2]) { - ScrArea *area = BKE_screen_find_area_xy(screen, space_type, x, y); + ScrArea *area = BKE_screen_find_area_xy(screen, space_type, xy); if (!area) { return NULL; } - return BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, x, y); + return BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, xy); } /* Magic zoom calculation, no idea what it signifies, if you find out, tell me! -zr -- cgit v1.2.3