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
This commit is contained in:
parent
2905b493fe
commit
6910278604
Notes:
blender-bot
2023-02-14 05:53:42 +01:00
Referenced by commitd71c423c28
, Cleanup: Use array as a parameter for event x/y functions Referenced by commit5297bf318e
, Cleanup: Use array as a parameter for event x/y functions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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, ®ion->v2d, event->xy[0], event->xy[1])) {
|
||||
if (UI_view2d_mouse_in_scrollers(region, ®ion->v2d, event->xy)) {
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -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, ®ion->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, ®ion->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, ®ion->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 = ®ion->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, ®ion->v2d, x, y)) {
|
||||
UI_view2d_mouse_in_scrollers(region, ®ion->v2d, xy)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 = ®ion->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 */
|
||||
|
|
|
@ -900,8 +900,7 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b
|
|||
ARegion *region = az->region;
|
||||
View2D *v2d = ®ion->v2d;
|
||||
int scroll_flag = 0;
|
||||
const int isect_value = UI_view2d_mouse_in_scrollers_ex(
|
||||
region, v2d, xy[0], xy[1], &scroll_flag);
|
||||
const int isect_value = UI_view2d_mouse_in_scrollers_ex(region, v2d, xy, &scroll_flag);
|
||||
|
||||
/* Check if we even have scroll bars. */
|
||||
if (((az->direction == AZ_SCROLL_HOR) && !(scroll_flag & V2D_SCROLL_HORIZONTAL)) ||
|
||||
|
|
|
@ -149,7 +149,7 @@ static void console_cursor(wmWindow *win, ScrArea *UNUSED(area), ARegion *region
|
|||
{
|
||||
int wmcursor = WM_CURSOR_TEXT_EDIT;
|
||||
const wmEvent *event = win->eventstate;
|
||||
if (UI_view2d_mouse_in_scrollers(region, ®ion->v2d, event->xy[0], event->xy[1])) {
|
||||
if (UI_view2d_mouse_in_scrollers(region, ®ion->v2d, event->xy)) {
|
||||
wmcursor = WM_CURSOR_DEFAULT;
|
||||
}
|
||||
|
||||
|
|
|
@ -173,9 +173,11 @@ void flushTransNodes(TransInfo *t)
|
|||
}
|
||||
else {
|
||||
/* Edge panning functions expect window coordinates, mval is relative to region */
|
||||
const float x = t->region->winrct.xmin + t->mval[0];
|
||||
const float y = t->region->winrct.ymin + t->mval[1];
|
||||
UI_view2d_edge_pan_apply(t->context, customdata, x, y);
|
||||
const int xy[2] = {
|
||||
t->region->winrct.xmin + t->mval[0],
|
||||
t->region->winrct.ymin + t->mval[1],
|
||||
};
|
||||
UI_view2d_edge_pan_apply(t->context, customdata, xy);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue