[Bf-blender-cvs] [5297bf318e6] master: Cleanup: Use array as a parameter for event x/y functions

Aaron Carlisle noreply at git.blender.org
Thu Oct 21 06:56:38 CEST 2021


Commit: 5297bf318e6f18c9165c9968728e6c9d27f8ae3c
Author: Aaron Carlisle
Date:   Thu Oct 21 00:56:31 2021 -0400
Branches: master
https://developer.blender.org/rB5297bf318e6f18c9165c9968728e6c9d27f8ae3c

Cleanup: Use array as a parameter for event x/y functions

This change simplifies the parameter list for these functions
and reduces the chance of typos mixing up array indices.

Missed in rB69102786047dccdcbaee0df6307a8c3364d28fe0

===================================================================

M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_query.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 556474f6df4..8ec97c1df10 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2079,8 +2079,8 @@ static bool ui_but_drag_init(bContext *C,
       drag_info->pushed_state = ui_drag_toggle_but_pushed_state(but);
       drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect);
       drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect);
-      copy_v2_v2_int(drag_info->xy_init, &event->xy[0]);
-      copy_v2_v2_int(drag_info->xy_last, &event->xy[0]);
+      copy_v2_v2_int(drag_info->xy_init, event->xy);
+      copy_v2_v2_int(drag_info->xy_last, event->xy);
 
       /* needed for toggle drag on popups */
       region_prev = CTX_wm_region(C);
@@ -9915,7 +9915,7 @@ static bool ui_mouse_motion_towards_check(uiBlock *block,
 static void ui_mouse_motion_keynav_init(struct uiKeyNavLock *keynav, const wmEvent *event)
 {
   keynav->is_keynav = true;
-  copy_v2_v2_int(keynav->event_xy, &event->xy[0]);
+  copy_v2_v2_int(keynav->event_xy, &event->xy);
 }
 /**
  * Return true if key-input isn't blocking mouse-motion,
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index b91dafeb02b..fc4de89944f 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -1226,7 +1226,7 @@ bool ui_region_contains_point_px(const struct ARegion *region, const int xy[2])
     ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
 bool ui_region_contains_rect_px(const struct ARegion *region, const rcti *rect_px);
 
-struct ARegion *ui_screen_region_find_mouse_over_ex(struct bScreen *screen, int x, int y);
+struct ARegion *ui_screen_region_find_mouse_over_ex(struct bScreen *screen, const int xy[2]) ATTR_NONNULL(1, 2);
 struct ARegion *ui_screen_region_find_mouse_over(struct bScreen *screen,
                                                  const struct wmEvent *event);
 
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index 85f829c7f48..bdf93d7c82e 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -799,14 +799,14 @@ bool ui_region_contains_rect_px(const ARegion *region, const rcti *rect_px)
  * \{ */
 
 /** Check if the cursor is over any popups. */
-ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y)
+ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, const int xy[2])
 {
   LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
     rcti winrct;
 
     ui_region_winrct_get_no_margin(region, &winrct);
 
-    if (BLI_rcti_isect_pt(&winrct, x, y)) {
+    if (BLI_rcti_isect_pt_v(&winrct, xy)) {
       return region;
     }
   }
@@ -815,7 +815,7 @@ ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y)
 
 ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const wmEvent *event)
 {
-  return ui_screen_region_find_mouse_over_ex(screen, event->xy[0], event->xy[1]);
+  return ui_screen_region_find_mouse_over_ex(screen, event->xy);
 }
 
 /** \} */



More information about the Bf-blender-cvs mailing list