Cleanup: early exit ui_but_extra_operator_icon_mouse_over_get

Early exit when the button has no extra icons, avoiding a redundant
transformation from mouse to button coordinates.
This commit is contained in:
Campbell Barton 2022-08-12 10:41:39 +10:00
parent a2247c271c
commit 8649ac0ca8
1 changed files with 6 additions and 3 deletions

View File

@ -4344,15 +4344,18 @@ static uiButExtraOpIcon *ui_but_extra_operator_icon_mouse_over_get(uiBut *but,
ARegion *region,
const wmEvent *event)
{
float xmax = but->rect.xmax;
const float icon_size = 0.8f * BLI_rctf_size_y(&but->rect); /* ICON_SIZE_FROM_BUTRECT */
int x = event->xy[0], y = event->xy[1];
if (BLI_listbase_is_empty(&but->extra_op_icons)) {
return NULL;
}
int x = event->xy[0], y = event->xy[1];
ui_window_to_block(region, but->block, &x, &y);
if (!BLI_rctf_isect_pt(&but->rect, x, y)) {
return NULL;
}
const float icon_size = 0.8f * BLI_rctf_size_y(&but->rect); /* ICON_SIZE_FROM_BUTRECT */
float xmax = but->rect.xmax;
/* Same as in 'widget_draw_extra_icons', icon padding from the right edge. */
xmax -= 0.2 * icon_size;