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

Aaron Carlisle noreply at git.blender.org
Thu Oct 21 04:17:42 CEST 2021


Commit: 69102786047dccdcbaee0df6307a8c3364d28fe0
Author: Aaron Carlisle
Date:   Wed Oct 20 20:49:02 2021 -0300
Branches: master
https://developer.blender.org/rB69102786047dccdcbaee0df6307a8c3364d28fe0

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.

Reviewed By: campbellbarton

Ref D12950

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/include/UI_view2d.h
M	source/blender/editors/interface/interface_context_menu.c
M	source/blender/editors/interface/interface_dropboxes.cc
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_query.c
M	source/blender/editors/interface/interface_region_search.c
M	source/blender/editors/interface/interface_view.cc
M	source/blender/editors/interface/tree_view.cc
M	source/blender/editors/interface/view2d.c
M	source/blender/editors/interface/view2d_edge_pan.c
M	source/blender/editors/interface/view2d_ops.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_console/space_console.c
M	source/blender/editors/transform/transform_convert_node.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 047340ac304..ed132422d3b 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2788,7 +2788,8 @@ void UI_tree_view_item_context_menu_build(struct bContext *C,
                                           const uiTreeViewItemHandle *item,
                                           uiLayout *column);
 
-uiTreeViewItemHandle *UI_block_tree_view_find_item_at(const struct ARegion *region, int x, int y);
+uiTreeViewItemHandle *UI_block_tree_view_find_item_at(const struct ARegion *region,
+                                                      const int xy[2]) ATTR_NONNULL(1, 2);
 uiTreeViewItemHandle *UI_block_tree_view_find_active_item(const struct ARegion *region);
 
 #ifdef __cplusplus
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index fdfa07a7e02..13895879f01 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -249,19 +249,20 @@ void UI_view2d_center_set(struct View2D *v2d, float x, float y);
 
 void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac);
 
-char UI_view2d_mouse_in_scrollers_ex(
-    const struct ARegion *region, const struct View2D *v2d, int x, int y, int *r_scroll);
+char UI_view2d_mouse_in_scrollers_ex(const struct ARegion *region,
+                                     const struct View2D *v2d,
+                                     const int xy[2],
+                                     int *r_scroll) ATTR_NONNULL(1, 2, 3, 4);
 char UI_view2d_mouse_in_scrollers(const struct ARegion *region,
                                   const struct View2D *v2d,
-                                  int x,
-                                  int y);
+                                  const int xy[2]) ATTR_NONNULL(1, 2, 3);
 char UI_view2d_rect_in_scrollers_ex(const struct ARegion *region,
                                     const struct View2D *v2d,
                                     const struct rcti *rect,
-                                    int *r_scroll);
+                                    int *r_scroll) ATTR_NONNULL(1, 2, 3);
 char UI_view2d_rect_in_scrollers(const struct ARegion *region,
                                  const struct View2D *v2d,
-                                 const struct rcti *rect);
+                                 const struct rcti *rect) ATTR_NONNULL(1, 2, 3);
 
 /* cached text drawing in v2d, to allow pixel-aligned draw as post process */
 void UI_view2d_text_cache_add(struct View2D *v2d,
@@ -354,7 +355,8 @@ void UI_view2d_edge_pan_init(struct bContext *C,
 void UI_view2d_edge_pan_reset(struct View2DEdgePanData *vpd);
 
 /* Apply transform to view (i.e. adjust 'cur' rect). */
-void UI_view2d_edge_pan_apply(struct bContext *C, struct View2DEdgePanData *vpd, int x, int y);
+void UI_view2d_edge_pan_apply(struct bContext *C, struct View2DEdgePanData *vpd, const int xy[2])
+    ATTR_NONNULL(1, 2, 3);
 
 /* Apply transform to view using mouse events. */
 void UI_view2d_edge_pan_apply_event(struct bContext *C,
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index 7d5295aa758..9e436601132 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -927,8 +927,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
 
   {
     const ARegion *region = CTX_wm_region(C);
-    uiButTreeRow *treerow_but = (uiButTreeRow *)ui_tree_row_find_mouse_over(
-        region, event->xy[0], event->xy[1]);
+    uiButTreeRow *treerow_but = (uiButTreeRow *)ui_tree_row_find_mouse_over(region, event->xy);
     if (treerow_but) {
       BLI_assert(treerow_but->but.type == UI_BTYPE_TREEROW);
       UI_tree_view_item_context_menu_build(
@@ -1216,8 +1215,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
   ARegion *region = CTX_wm_region(C);
   const bool is_inside_listbox = ui_list_find_mouse_over(region, event) != NULL;
   const bool is_inside_listrow = is_inside_listbox ?
-                                     ui_list_row_find_mouse_over(
-                                         region, event->xy[0], event->xy[1]) != NULL :
+                                     ui_list_row_find_mouse_over(region, event->xy) != NULL :
                                      false;
   if (is_inside_listrow) {
     MenuType *mt = WM_menutype_find("UI_MT_list_item_context_menu", true);
diff --git a/source/blender/editors/interface/interface_dropboxes.cc b/source/blender/editors/interface/interface_dropboxes.cc
index 34bd5f17881..62250a34cf4 100644
--- a/source/blender/editors/interface/interface_dropboxes.cc
+++ b/source/blender/editors/interface/interface_dropboxes.cc
@@ -29,8 +29,8 @@
 static bool ui_tree_view_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
 {
   const ARegion *region = CTX_wm_region(C);
-  const uiTreeViewItemHandle *hovered_tree_item = UI_block_tree_view_find_item_at(
-      region, event->xy[0], event->xy[1]);
+  const uiTreeViewItemHandle *hovered_tree_item = UI_block_tree_view_find_item_at(region,
+                                                                                  event->xy);
   if (!hovered_tree_item) {
     return false;
   }
@@ -44,8 +44,8 @@ static char *ui_tree_view_drop_tooltip(bContext *C,
                                        wmDropBox *UNUSED(drop))
 {
   const ARegion *region = CTX_wm_region(C);
-  const uiTreeViewItemHandle *hovered_tree_item = UI_block_tree_view_find_item_at(
-      region, event->xy[0], event->xy[1]);
+  const uiTreeViewItemHandle *hovered_tree_item = UI_block_tree_view_find_item_at(region,
+                                                                                  event->xy);
   if (!hovered_tree_item) {
     return nullptr;
   }
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 129f3143451..243ebe4e75c 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1684,7 +1684,7 @@ static void ui_drag_toggle_set(bContext *C, uiDragToggleHandle *drag_info, const
    */
   if (drag_info->is_xy_lock_init == false) {
     /* first store the buttons original coords */
-    uiBut *but = ui_but_find_mouse_over_ex(region, xy_input[0], xy_input[1], true, NULL, NULL);
+    uiBut *but = ui_but_find_mouse_over_ex(region, xy_input, true, NULL, NULL);
 
     if (but) {
       if (but->flag & UI_BUT_DRAG_LOCK) {
@@ -1754,8 +1754,7 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void
   if (done) {
     wmWindow *win = CTX_wm_window(C);
     const ARegion *region = CTX_wm_region(C);
-    uiBut *but = ui_but_find_mouse_over_ex(
-        region, drag_info->xy_init[0], drag_info->xy_init[1], true, NULL, NULL);
+    uiBut *but = ui_but_find_mouse_over_ex(region, drag_info->xy_init, true, NULL, NULL);
 
     if (but) {
       ui_apply_but_undo(but);
@@ -3738,7 +3737,7 @@ static void ui_do_but_textedit(
       /* exit on LMB only on RELEASE for searchbox, to mimic other popups,
        * and allow multiple menu levels */
       if (data->searchbox) {
-        inbox = ui_searchbox_inside(data->searchbox, event->xy[0], event->xy[1]);
+        inbox = ui_searchbox_inside(data->searchbox, event->xy);
       }
 
       /* for double click: we do a press again for when you first click on button
@@ -4360,8 +4359,7 @@ static uiBut *ui_but_list_row_text_activate(bContext *C,
                                             uiButtonActivateType activate_type)
 {
   ARegion *region = CTX_wm_region(C);
-  uiBut *labelbut = ui_but_find_mouse_over_ex(
-      region, event->xy[0], event->xy[1], true, NULL, NULL);
+  uiBut *labelbut = ui_but_find_mouse_over_ex(region, event->xy, true, NULL, NULL);
 
   if (labelbut && labelbut->type == UI_BTYPE_TEXT && !(labelbut->flag & UI_BUT_DISABLED)) {
     /* exit listrow */
@@ -4565,8 +4563,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C,
 
     if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
       /* only cancel if click outside the button */
-      if (ui_but_contains_point_px(but, but->active->region, event->xy[0], event->xy[1]) ==
-          false) {
+      if (ui_but_contains_point_px(but, but->active->region, event->xy) == false) {
         /* data->cancel doesn't work, this button opens immediate */
         if (but->flag & UI_BUT_IMMEDIATE) {
           ui_but_value_set(but, 0);
@@ -8815,7 +8812,7 @@ uiBlock *UI_region_block_find_mouse_over(const struct ARegion *region,
                                          const int xy[2],
                                          bool only_clip)
 {
-  return ui_block_find_mouse_over_ex(region, xy[0], xy[1], only_clip);
+  return ui_block_find_mouse_over_ex(region, xy, only_clip);
 }
 
 /**
@@ -9214,7 +9211,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
         /* always deactivate button for pie menus,
          * else moving to blank space will leave activated */
         if ((!ui_block_is_menu(block) || ui_block_is_pie_menu(block)) &&
-            !ui_but_contains_point_px(but, region, event->xy[0], event->xy[1])) {
+            !ui_but_contains_point_px(but, region, event->xy)) {
           exit = true;
         }
         else if (but_other && ui_but_is_editable(but_other) && (but_other != but)) {
@@ -9242,7 +9239,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
           WM_event_remove_timer(data->wm, data->window, data->autoopentimer);
           data->autoopentimer = NULL;
 
-          if (ui_but_contains_point_px(but, region, event->xy[0], event->xy[1]) || but->active) {
+          if (ui_but_contains_point_px(but, region, event->xy) || but->active) {
             button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
           }
         }
@@ -9292,7 +9289,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
   

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list