Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Carlisle <carlisle.b3d@gmail.com>2021-10-21 02:49:02 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-10-21 05:15:41 +0300
commit69102786047dccdcbaee0df6307a8c3364d28fe0 (patch)
tree327a99274ee99dc576cbb2e9657f5e0c6e1c56fc /source/blender/editors/interface
parent2905b493fe5b569069d6035c9a17ed855c03fa17 (diff)
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
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_context_menu.c6
-rw-r--r--source/blender/editors/interface/interface_dropboxes.cc8
-rw-r--r--source/blender/editors/interface/interface_handlers.c39
-rw-r--r--source/blender/editors/interface/interface_intern.h36
-rw-r--r--source/blender/editors/interface/interface_ops.c5
-rw-r--r--source/blender/editors/interface/interface_panel.c2
-rw-r--r--source/blender/editors/interface/interface_query.c51
-rw-r--r--source/blender/editors/interface/interface_region_search.c4
-rw-r--r--source/blender/editors/interface/interface_view.cc6
-rw-r--r--source/blender/editors/interface/tree_view.cc4
-rw-r--r--source/blender/editors/interface/view2d.c14
-rw-r--r--source/blender/editors/interface/view2d_edge_pan.c18
-rw-r--r--source/blender/editors/interface/view2d_ops.c4
13 files changed, 90 insertions, 107 deletions
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)
case MOUSEMOVE: {
/* deselect the button when moving the mouse away */
/* also de-activate for buttons that only show highlights */
- if (ui_but_contains_point_px(but, region, event->xy[0], event->xy[1])) {
+ if (ui_but_contains_point_px(but, region, event->xy)) {
/* Drag on a hold button (used in the toolbar) now opens it immediately. */
if (data->hold_action_timer) {
@@ -9350,7 +9347,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
uiBut *bt;
if (data->menu && data->menu->region) {
- if (ui_region_contains_point_px(data->menu->region, event->xy[0], event->xy[1])) {
+ if (ui_region_contains_point_px(data->menu->region, event->xy)) {
break;
}
}
@@ -9466,7 +9463,7 @@ static int ui_list_activate_hovered_row(bContext *C,
}
const int *mouse_xy = ISTWEAK(event->type) ? &event->prev_click_xy[0] : &event->xy[0];
- uiBut *listrow = ui_list_row_find_mouse_over(region, mouse_xy[0], mouse_xy[1]);
+ uiBut *listrow = ui_list_row_find_mouse_over(region, mouse_xy);
if (listrow) {
wmOperatorType *custom_activate_optype = ui_list->dyn_data->custom_activate_optype;
@@ -9493,8 +9490,7 @@ static bool ui_list_is_hovering_draggable_but(bContext *C,
{
/* On a tweak event, uses the coordinates from where tweaking was started. */
const int *mouse_xy = ISTWEAK(event->type) ? &event->prev_click_xy[0] : &event->xy[0];
- const uiBut *hovered_but = ui_but_find_mouse_over_ex(
- region, mouse_xy[0], mouse_xy[1], false, NULL, NULL);
+ const uiBut *hovered_but = ui_but_find_mouse_over_ex(region, mouse_xy, false, NULL, NULL);
if (list->dyn_data->custom_drag_optype) {
if (ui_but_context_poll_operator(C, list->dyn_data->custom_drag_optype, hovered_but)) {
@@ -9736,7 +9732,7 @@ static int ui_handle_tree_hover(const wmEvent *event, const ARegion *region)
/* Always highlight the hovered tree-row, even if the mouse hovers another button inside of it.
*/
- uiBut *hovered_row_but = ui_tree_row_find_mouse_over(region, event->xy[0], event->xy[1]);
+ uiBut *hovered_row_but = ui_tree_row_find_mouse_over(region, event->xy);
if (hovered_row_but) {
hovered_row_but->flag |= UI_ACTIVE;
}
@@ -9779,8 +9775,7 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u
button_activate_exit(C, but, data, true, false);
}
else if (menu->menuretval & UI_RETURN_OUT) {
- if (event->type == MOUSEMOVE &&
- ui_but_contains_point_px(but, data->region, event->xy[0], event->xy[1])) {
+ if (event->type == MOUSEMOVE && ui_but_contains_point_px(but, data->region, event->xy)) {
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
}
else {
@@ -10119,13 +10114,13 @@ static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlock
else if (!ui_block_is_menu(but->block) || ui_block_is_pie_menu(but->block)) {
/* pass, skip for dialogs */
}
- else if (!ui_region_contains_point_px(but->active->region, event->xy[0], event->xy[1])) {
+ else if (!ui_region_contains_point_px(but->active->region, event->xy)) {
/* Pass, needed to click-exit outside of non-floating menus. */
ui_region_auto_open_clear(but->active->region);
}
else if ((!ELEM(event->type, MOUSEMOVE, WHEELUPMOUSE, WHEELDOWNMOUSE, MOUSEPAN)) &&
ISMOUSE(event->type)) {
- if (!ui_but_contains_point_px(but, but->active->region, event->xy[0], event->xy[1])) {
+ if (!ui_but_contains_point_px(but, but->active->region, event->xy)) {
but = NULL;
}
}
@@ -10723,7 +10718,7 @@ static int ui_handle_menu_event(bContext *C,
#ifdef USE_DRAG_POPUP
else if ((event->type == LEFTMOUSE) && (event->val == KM_PRESS) &&
(inside && is_floating && inside_title)) {
- if (!but || !ui_but_contains_point_px(but, region, event->xy[0], event->xy[1])) {
+ if (!but || !ui_but_contains_point_px(but, region, event->xy)) {
if (but) {
UI_but_tooltip_timer_remove(C, but);
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 0301ab9156e..b91dafeb02b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -830,7 +830,7 @@ struct ARegion *ui_searchbox_create_menu(struct bContext *C,
struct ARegion *butregion,
uiButSearch *search_but);
-bool ui_searchbox_inside(struct ARegion *region, int x, int y);
+bool ui_searchbox_inside(struct ARegion *region, const int xy[2]) ATTR_NONNULL(1, 2);
int ui_searchbox_find_index(struct ARegion *region, const char *name);
void ui_searchbox_update(struct bContext *C, struct ARegion *region, uiBut *but, const bool reset);
int ui_searchbox_autocomplete(struct bContext *C, struct ARegion *region, uiBut *but, char *str);
@@ -1163,37 +1163,36 @@ bool ui_but_contains_rect(const uiBut *but, const rctf *rect);
bool ui_but_contains_point_px_icon(const uiBut *but,
struct ARegion *region,
const struct wmEvent *event) ATTR_WARN_UNUSED_RESULT;
-bool ui_but_contains_point_px(const uiBut *but, const struct ARegion *region, int x, int y)
- ATTR_WARN_UNUSED_RESULT;
+bool ui_but_contains_point_px(const uiBut *but, const struct ARegion *region, const int xy[2])
+ ATTR_NONNULL(1, 2, 3) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_list_find_mouse_over(const struct ARegion *region,
const struct wmEvent *event) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_list_find_from_row(const struct ARegion *region,
const uiBut *row_but) ATTR_WARN_UNUSED_RESULT;
-uiBut *ui_list_row_find_mouse_over(const struct ARegion *region,
- int x,
- int y) ATTR_WARN_UNUSED_RESULT;
+uiBut *ui_list_row_find_mouse_over(const struct ARegion *region, const int xy[2])
+ ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_list_row_find_from_index(const struct ARegion *region,
const int index,
uiBut *listbox) ATTR_WARN_UNUSED_RESULT;
-uiBut *ui_tree_row_find_mouse_over(const struct ARegion *region, const int x, const int y);
+uiBut *ui_tree_row_find_mouse_over(const struct ARegion *region, const int xy[2])
+ ATTR_NONNULL(1, 2);
uiBut *ui_tree_row_find_active(const struct ARegion *region);
typedef bool (*uiButFindPollFn)(const uiBut *but, const void *customdata);
uiBut *ui_but_find_mouse_over_ex(const struct ARegion *region,
- const int x,
- const int y,
+ const int xy[2],
const bool labeledit,
const uiButFindPollFn find_poll,
- const void *find_custom_data) ATTR_WARN_UNUSED_RESULT;
+ const void *find_custom_data)
+ ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_but_find_mouse_over(const struct ARegion *region,
const struct wmEvent *event) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_but_find_rect_over(const struct ARegion *region,
const rcti *rect_px) ATTR_WARN_UNUSED_RESULT;
-uiBut *ui_list_find_mouse_over_ex(const struct ARegion *region,
- int x,
- int y) ATTR_WARN_UNUSED_RESULT;
+uiBut *ui_list_find_mouse_over_ex(const struct ARegion *region, const int xy[2])
+ ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
bool ui_but_contains_password(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
@@ -1213,10 +1212,8 @@ bool ui_block_is_popover(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
bool ui_block_is_pie_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
bool ui_block_is_popup_any(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
-uiBlock *ui_block_find_mouse_over_ex(const struct ARegion *region,
- const int x,
- const int y,
- bool only_clip);
+uiBlock *ui_block_find_mouse_over_ex(const struct ARegion *region, const int xy[2], bool only_clip)
+ ATTR_NONNULL(1, 2);
uiBlock *ui_block_find_mouse_over(const struct ARegion *region,
const struct wmEvent *event,
bool only_clip);
@@ -1225,9 +1222,8 @@ uiBut *ui_region_find_first_but_test_flag(struct ARegion *region,
int flag_include,
int flag_exclude);
uiBut *ui_region_find_active_but(struct ARegion *region) ATTR_WARN_UNUSED_RESULT;
-bool ui_region_contains_point_px(const struct ARegion *region,
- int x,
- int y) ATTR_WARN_UNUSED_RESULT;
+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);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index e58b2168dda..1a1d52b0425 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -1930,7 +1930,7 @@ static bool ui_tree_view_drop_poll(bContext *C)
const wmWindow *win = CTX_wm_window(C);
const ARegion *region = CTX_wm_region(C);
const uiTreeViewItemHandle *hovered_tree_item = UI_block_tree_view_find_item_at(
- region, win->eventstate->xy[0], win->eventstate->xy[1]);
+ region, win->eventstate->xy);
return hovered_tree_item != NULL;
}
@@ -1942,8 +1942,7 @@ static int ui_tree_view_drop_invoke(bContext *C, wmOperator *UNUSED(op), const w
}
const ARegion *region = CTX_wm_region(C);
- uiTreeViewItemHandle *hovered_tree_item = UI_block_tree_view_find_item_at(
- region, event->xy[0], event->xy[1]);
+ uiTreeViewItemHandle *hovered_tree_item = UI_block_tree_view_find_item_at(region, event->xy);
if (!UI_tree_view_item_drop_handle(hovered_tree_item, event->customdata)) {
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 11013e4cdf7..43536b23353 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -2363,7 +2363,7 @@ int ui_handler_panel_region(bContext *C,
}
/* Scroll-bars can overlap panels now, they have handling priority. */
- if (UI_view2d_mouse_in_scrollers(region, &region->v2d, event->xy[0], event->xy[1])) {
+ if (UI_view2d_mouse_in_scrollers(region, &region->v2d, event->xy)) {
return WM_UI_HANDLER_CONTINUE;
}
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index b80e0bfc3ca..85f829c7f48 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -222,14 +222,14 @@ bool ui_but_contains_rect(const uiBut *but, const rctf *rect)
return BLI_rctf_isect(&but->rect, rect, NULL);
}
-bool ui_but_contains_point_px(const uiBut *but, const ARegion *region, int x, int y)
+bool ui_but_contains_point_px(const uiBut *but, const ARegion *region, const int xy[2])
{
uiBlock *block = but->block;
- if (!ui_region_contains_point_px(region, x, y)) {
+ if (!ui_region_contains_point_px(region, xy)) {
return false;
}
- float mx = x, my = y;
+ float mx = xy[0], my = xy[1];
ui_window_to_block_fl(region, block, &mx, &my);
if (but->pie_dir != UI_RADIAL_NONE) {
@@ -286,19 +286,18 @@ static uiBut *ui_but_find(const ARegion *region,
/* x and y are only used in case event is NULL... */
uiBut *ui_but_find_mouse_over_ex(const ARegion *region,
- const int x,
- const int y,
+ const int xy[2],
const bool labeledit,
const uiButFindPollFn find_poll,
const void *find_custom_data)
{
uiBut *butover = NULL;
- if (!ui_region_contains_point_px(region, x, y)) {
+ if (!ui_region_contains_point_px(region, xy)) {
return NULL;
}
LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
- float mx = x, my = y;
+ float mx = xy[0], my = xy[1];
ui_window_to_block_fl(region, block, &mx, &my);
LISTBASE_FOREACH_BACKWARD (uiBut *, but, &block->buttons) {
@@ -333,8 +332,7 @@ uiBut *ui_but_find_mouse_over_ex(const ARegion *region,
uiBut *ui_but_find_mouse_over(const ARegion *region, const wmEvent *event)
{
- return ui_but_find_mouse_over_ex(
- region, event->xy[0], event->xy[1], event->ctrl != 0, NULL, NULL);
+ return ui_but_find_mouse_over_ex(region, event->xy, event->ctrl != 0, NULL, NULL);
}
uiBut *ui_but_find_rect_over(const struct ARegion *region, const rcti *rect_px)
@@ -375,13 +373,13 @@ uiBut *ui_but_find_rect_over(const struct ARegion *region, const rcti *rect_px)
return butover;
}
-uiBut *ui_list_find_mouse_over_ex(const ARegion *region, int x, int y)
+uiBut *ui_list_find_mouse_over_ex(const ARegion *region, const int xy[2])
{
- if (!ui_region_contains_point_px(region, x, y)) {
+ if (!ui_region_contains_point_px(region, xy)) {
return NULL;
}
LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
- float mx = x, my = y;
+ float mx = xy[0], my = xy[1];
ui_window_to_block_fl(region, block, &mx, &my);
LISTBASE_FOREACH_BACKWARD (uiBut *, but, &block->buttons) {
if (but->type == UI_BTYPE_LISTBOX && ui_but_contains_pt(but, mx, my)) {
@@ -399,7 +397,7 @@ uiBut *ui_list_find_mouse_over(const ARegion *region, const wmEvent *event)
/* If there is no info about the mouse, just act as if there is nothing underneath it. */
return NULL;
}
- return ui_list_find_mouse_over_ex(region, event->xy[0], event->xy[1]);
+ return ui_list_find_mouse_over_ex(region, event->xy);
}
uiList *UI_list_find_mouse_over(const ARegion *region, const wmEvent *event)
@@ -436,9 +434,9 @@ static bool ui_but_is_listrow(const uiBut *but, const void *UNUSED(customdata))
return but->type == UI_BTYPE_LISTROW;
}
-uiBut *ui_list_row_find_mouse_over(const ARegion *region, const int x, const int y)
+uiBut *ui_list_row_find_mouse_over(const ARegion *region, const int xy[2])
{
- return ui_but_find_mouse_over_ex(region, x, y, false, ui_but_is_listrow, NULL);
+ return ui_but_find_mouse_over_ex(region, xy, false, ui_but_is_listrow, NULL);
}
struct ListRowFindIndexData {
@@ -469,9 +467,9 @@ static bool ui_but_is_treerow(const uiBut *but, const void *UNUSED(customdata))
return but->type == UI_BTYPE_TREEROW;
}
-uiBut *ui_tree_row_find_mouse_over(const ARegion *region, const int x, const int y)
+uiBut *ui_tree_row_find_mouse_over(const ARegion *region, const int xy[2])
{
- return ui_but_find_mouse_over_ex(region, x, y, false, ui_but_is_treerow, NULL);
+ return ui_but_find_mouse_over_ex(region, xy, false, ui_but_is_treerow, NULL);
}
static bool ui_but_is_active_treerow(const uiBut *but, const void *customdata)
@@ -683,12 +681,9 @@ bool UI_block_can_add_separator(const uiBlock *block)
/** \name Block (#uiBlock) Spatial
* \{ */
-uiBlock *ui_block_find_mouse_over_ex(const ARegion *region,
- const int x,
- const int y,
- bool only_clip)
+uiBlock *ui_block_find_mouse_over_ex(const ARegion *region, const int xy[2], bool only_clip)
{
- if (!ui_region_contains_point_px(region, x, y)) {
+ if (!ui_region_contains_point_px(region, xy)) {
return NULL;
}
LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
@@ -697,7 +692,7 @@ uiBlock *ui_block_find_mouse_over_ex(const ARegion *region,
continue;
}
}
- float mx = x, my = y;
+ float mx = xy[0], my = xy[1];
ui_window_to_block_fl(region, block, &mx, &my);
if (BLI_rctf_isect_pt(&block->rect, mx, my)) {
return block;
@@ -708,7 +703,7 @@ uiBlock *ui_block_find_mouse_over_ex(const ARegion *region,
uiBlock *ui_block_find_mouse_over(const ARegion *region, const wmEvent *event, bool only_clip)
{
- return ui_block_find_mouse_over_ex(region, event->xy[0], event->xy[1], only_clip);
+ return ui_block_find_mouse_over_ex(region, event->xy, only_clip);
}
/** \} */
@@ -748,11 +743,11 @@ uiBut *ui_region_find_first_but_test_flag(ARegion *region, int flag_include, int
/** \name Region (#ARegion) Spatial
* \{ */
-bool ui_region_contains_point_px(const ARegion *region, int x, int y)
+bool ui_region_contains_point_px(const ARegion *region, const int xy[2])
{
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 false;
}
@@ -763,11 +758,11 @@ bool ui_region_contains_point_px(const ARegion *region, int x, int y)
*/
if (region->v2d.mask.xmin != region->v2d.mask.xmax) {
const View2D *v2d = &region->v2d;
- int mx = x, my = y;
+ int mx = xy[0], my = xy[1];
ui_window_to_region(region, &mx, &my);
if (!BLI_rcti_isect_pt(&v2d->mask, mx, my) ||
- UI_view2d_mouse_in_scrollers(region, &region->v2d, x, y)) {
+ UI_view2d_mouse_in_scrollers(region, &region->v2d, xy)) {
return false;
}
}
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index a78c208e4ca..1cd3ef89ed3 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -290,11 +290,11 @@ int ui_searchbox_find_index(ARegion *region, const char *name)
}
/* x and y in screen-coords. */
-bool ui_searchbox_inside(ARegion *region, int x, int y)
+bool ui_searchbox_inside(ARegion *region, const int xy[2])
{
uiSearchboxData *data = region->regiondata;
- return BLI_rcti_isect_pt(&data->bbox, x - region->winrct.xmin, y - region->winrct.ymin);
+ return BLI_rcti_isect_pt(&data->bbox, xy[0] - region->winrct.xmin, xy[1] - region->winrct.ymin);
}
/* string validated to be of correct length (but->hardmax) */
diff --git a/source/blender/editors/interface/interface_view.cc b/source/blender/editors/interface/interface_view.cc
index fdd8eb0cc71..4e38f245155 100644
--- a/source/blender/editors/interface/interface_view.cc
+++ b/source/blender/editors/interface/interface_view.cc
@@ -82,11 +82,9 @@ void ui_block_free_views(uiBlock *block)
/**
* \param x, y: Coordinate to find a tree-row item at, in window space.
*/
-uiTreeViewItemHandle *UI_block_tree_view_find_item_at(const ARegion *region,
- const int x,
- const int y)
+uiTreeViewItemHandle *UI_block_tree_view_find_item_at(const ARegion *region, const int xy[2])
{
- uiButTreeRow *tree_row_but = (uiButTreeRow *)ui_tree_row_find_mouse_over(region, x, y);
+ uiButTreeRow *tree_row_but = (uiButTreeRow *)ui_tree_row_find_mouse_over(region, xy);
if (!tree_row_but) {
return nullptr;
}
diff --git a/source/blender/editors/interface/tree_view.cc b/source/blender/editors/interface/tree_view.cc
index 6e4440947be..88aa362deb5 100644
--- a/source/blender/editors/interface/tree_view.cc
+++ b/source/blender/editors/interface/tree_view.cc
@@ -220,8 +220,8 @@ void AbstractTreeViewItem::collapse_chevron_click_fn(struct bContext *C,
const wmWindow *win = CTX_wm_window(C);
const ARegion *region = CTX_wm_region(C);
- uiTreeViewItemHandle *hovered_item_handle = UI_block_tree_view_find_item_at(
- region, win->eventstate->xy[0], win->eventstate->xy[1]);
+ uiTreeViewItemHandle *hovered_item_handle = UI_block_tree_view_find_item_at(region,
+ win->eventstate->xy);
AbstractTreeViewItem *hovered_item = reinterpret_cast<AbstractTreeViewItem *>(
hovered_item_handle);
BLI_assert(hovered_item != nullptr);
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 0036a812a87..ca96fde9810 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1924,8 +1924,10 @@ void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac)
* - 'v' = in vertical scroller.
* - 0 = not in scroller.
*/
-char UI_view2d_mouse_in_scrollers_ex(
- const ARegion *region, const View2D *v2d, int x, int y, int *r_scroll)
+char UI_view2d_mouse_in_scrollers_ex(const ARegion *region,
+ const View2D *v2d,
+ const int xy[2],
+ int *r_scroll)
{
const int scroll = view2d_scroll_mapped(v2d->scroll);
*r_scroll = scroll;
@@ -1933,8 +1935,8 @@ char UI_view2d_mouse_in_scrollers_ex(
if (scroll) {
/* Move to region-coordinates. */
const int co[2] = {
- x - region->winrct.xmin,
- y - region->winrct.ymin,
+ xy[0] - region->winrct.xmin,
+ xy[1] - region->winrct.ymin,
};
if (scroll & V2D_SCROLL_HORIZONTAL) {
if (IN_2D_HORIZ_SCROLL(v2d, co)) {
@@ -1978,10 +1980,10 @@ char UI_view2d_rect_in_scrollers_ex(const ARegion *region,
return 0;
}
-char UI_view2d_mouse_in_scrollers(const ARegion *region, const View2D *v2d, int x, int y)
+char UI_view2d_mouse_in_scrollers(const ARegion *region, const View2D *v2d, const int xy[2])
{
int scroll_dummy = 0;
- return UI_view2d_mouse_in_scrollers_ex(region, v2d, x, y, &scroll_dummy);
+ return UI_view2d_mouse_in_scrollers_ex(region, v2d, xy, &scroll_dummy);
}
char UI_view2d_rect_in_scrollers(const ARegion *region, const View2D *v2d, const rcti *rect)
diff --git a/source/blender/editors/interface/view2d_edge_pan.c b/source/blender/editors/interface/view2d_edge_pan.c
index 0ad6883b078..a49666ebbd3 100644
--- a/source/blender/editors/interface/view2d_edge_pan.c
+++ b/source/blender/editors/interface/view2d_edge_pan.c
@@ -217,7 +217,7 @@ static void edge_pan_apply_delta(bContext *C, View2DEdgePanData *vpd, float dx,
UI_view2d_sync(vpd->screen, vpd->area, v2d, V2D_LOCK_COPY);
}
-void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, int x, int y)
+void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, const int xy[2])
{
ARegion *region = vpd->region;
@@ -229,18 +229,18 @@ void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, int x, int y)
int pan_dir_x = 0;
int pan_dir_y = 0;
- if ((vpd->outside_pad == 0) || BLI_rcti_isect_pt(&outside_rect, x, y)) {
+ if ((vpd->outside_pad == 0) || BLI_rcti_isect_pt_v(&outside_rect, xy)) {
/* Find whether the mouse is beyond X and Y edges. */
- if (x > inside_rect.xmax) {
+ if (xy[0] > inside_rect.xmax) {
pan_dir_x = 1;
}
- else if (x < inside_rect.xmin) {
+ else if (xy[0] < inside_rect.xmin) {
pan_dir_x = -1;
}
- if (y > inside_rect.ymax) {
+ if (xy[1] > inside_rect.ymax) {
pan_dir_y = 1;
}
- else if (y < inside_rect.ymin) {
+ else if (xy[1] < inside_rect.ymin) {
pan_dir_y = -1;
}
}
@@ -252,11 +252,11 @@ void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, int x, int y)
const float dtime = (float)(current_time - vpd->edge_pan_last_time);
float dx = 0.0f, dy = 0.0f;
if (pan_dir_x != 0) {
- const float speed = edge_pan_speed(vpd, x, true, current_time);
+ const float speed = edge_pan_speed(vpd, xy[0], true, current_time);
dx = dtime * speed * (float)pan_dir_x;
}
if (pan_dir_y != 0) {
- const float speed = edge_pan_speed(vpd, y, false, current_time);
+ const float speed = edge_pan_speed(vpd, xy[1], false, current_time);
dy = dtime * speed * (float)pan_dir_y;
}
vpd->edge_pan_last_time = current_time;
@@ -272,7 +272,7 @@ void UI_view2d_edge_pan_apply_event(bContext *C, View2DEdgePanData *vpd, const w
return;
}
- UI_view2d_edge_pan_apply(C, vpd, event->xy[0], event->xy[1]);
+ UI_view2d_edge_pan_apply(C, vpd, event->xy);
}
void UI_view2d_edge_pan_cancel(bContext *C, View2DEdgePanData *vpd)
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index a73449f659d..0bca4e327cc 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1846,7 +1846,7 @@ static bool scroller_activate_poll(bContext *C)
wmEvent *event = win->eventstate;
/* check if mouse in scrollbars, if they're enabled */
- return (UI_view2d_mouse_in_scrollers(region, v2d, event->xy[0], event->xy[1]) != 0);
+ return (UI_view2d_mouse_in_scrollers(region, v2d, event->xy) != 0);
}
/* initialize customdata for scroller manipulation operator */
@@ -2090,7 +2090,7 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *
View2D *v2d = &region->v2d;
/* check if mouse in scrollbars, if they're enabled */
- const char in_scroller = UI_view2d_mouse_in_scrollers(region, v2d, event->xy[0], event->xy[1]);
+ const char in_scroller = UI_view2d_mouse_in_scrollers(region, v2d, event->xy);
/* if in a scroller, init customdata then set modal handler which will
* catch mouse-down to start doing useful stuff */