diff options
author | Campbell Barton <campbell@blender.org> | 2022-08-12 03:41:39 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-12 03:41:39 +0300 |
commit | 8649ac0ca869a12872865500ce8b99eaedb97f97 (patch) | |
tree | 0cd663739ebd0f44199fd85cf982ce3d9fa7ddab /source/blender/editors/interface/interface_handlers.c | |
parent | a2247c271c822ba82d7ae38030509933233cd3a5 (diff) |
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.
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 5d4c8a342e2..6ee421fb4d2 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -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; |