Commit: 67525b88d2e51db7ea5e6209b3589ce1c56f4959 Author: Aaron Carlisle Date: Fri Dec 24 23:59:33 2021 -0500 Branches: master https://developer.blender.org/rB67525b88d2e51db7ea5e6209b3589ce1c56f4959
Cleanup: Use array for BKE cursor functions Differential Revision: https://developer.blender.org/D12962 =================================================================== M source/blender/blenkernel/BKE_screen.h M source/blender/blenkernel/intern/screen.c M source/blender/editors/gpencil/annotate_paint.c M source/blender/editors/gpencil/gpencil_fill.c M source/blender/editors/gpencil/gpencil_paint.c M source/blender/editors/interface/interface_eyedropper.c M source/blender/editors/interface/interface_eyedropper_color.c M source/blender/editors/interface/interface_eyedropper_datablock.c M source/blender/editors/interface/interface_eyedropper_depth.c M source/blender/editors/mesh/editmesh_mask_extract.c M source/blender/editors/screen/screen_ops.c M source/blender/editors/screen/screendump.c M source/blender/editors/sculpt_paint/sculpt_detail.c M source/blender/windowmanager/intern/wm_dragdrop.c M source/blender/windowmanager/intern/wm_event_system.c =================================================================== 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 diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index fbc44ed58d8..8d7fd295c8d 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -2575,8 +2575,7 @@ static int annotation_draw_modal(bContext *C, wmOperator *op, const wmEvent *eve */ if ((p->region) && (p->region->regiontype == RGN_TYPE_TOOLS)) { /* Change to whatever region is now under the mouse */ - ARegion *current_region = BKE_area_find_region_xy( - p->area, RGN_TYPE_ANY, event->xy[0], event->xy[1]); + ARegion *current_region = BKE_area_find_region_xy(p->area, RGN_TYPE_ANY, event->xy); if (current_region) { /* Assume that since we found the cursor in here, it is in bounds diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index c3af28d4382..f0adb901f88 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -2108,8 +2108,7 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event) /* first time the event is not enabled to show help lines. */ if ((tgpf->oldkey != -1) || (!help_lines)) { - ARegion *region = BKE_area_find_region_xy( - CTX_wm_area(C), RGN_TYPE_ANY, event->xy[0], event->xy[1]); + ARegion *region = BKE_area_find_region_xy(CTX_wm_area(C), RGN_TYPE_ANY, event->xy); if (region) { bool in_bounds = false; /* Perform bounds check */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index d1fbd3bc507..5b70da80a5e 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -3681,8 +3681,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) */ if ((p->region) && (p->region->regiontype == RGN_TYPE_TOOLS)) { /* Change to whatever region is now under the mouse */ - ARegion *current_region = BKE_area_find_region_xy( - p->area, RGN_TYPE_ANY, event->xy[0], event->xy[1]); + ARegion *current_region = BKE_area_find_region_xy(p->area, RGN_TYPE_ANY, event->xy); if (current_region) { /* Assume that since we found the cursor in here, it is in bounds diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index 27fa2e5a22f..1f89699a43e 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -146,8 +146,8 @@ void eyedropper_draw_cursor_text_region(const int x, const int y, const char *na uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *event) { bScreen *screen = CTX_wm_screen(C); - ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->xy[0], event->xy[1]); - const ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_ANY, event->xy[0], event->xy[1]); + ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->xy); + const ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_ANY, event->xy); uiBut *but = ui_but_find_mouse_over(region, event); @@ -163,13 +163,13 @@ void datadropper_win_area_find( bScreen *screen = CTX_wm_screen(C); *r_win = CTX_wm_window(C); - *r_area = BKE_screen_find_area_xy(screen, -1, mval[0], mval[1]); + *r_area = BKE_screen_find_area_xy(screen, -1, mval); if (*r_area == NULL) { wmWindowManager *wm = CTX_wm_manager(C); *r_win = WM_window_find_under_cursor(wm, NULL, *r_win, mval, r_mval); if (*r_win) { screen = WM_window_get_active_screen(*r_win); - *r_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, r_mval[0], r_mval[1]); + *r_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, r_mval); } } else if (mval != r_mval) { diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index 0ac6ea4021b..68ddeb4cd02 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -263,12 +263,12 @@ static bool eyedropper_cryptomatte_sample_fl( } bScreen *screen = CTX_wm_screen(C); - ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my); + ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, (const int[2]){mx, my}); if (!sa || !ELEM(sa->spacetype, SPACE_IMAGE, SPACE_NODE, SPACE_CLIP)) { return false; } - ARegion *region = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my); + ARegion *region = BKE_area_find_region_xy(sa @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
