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:
authorCampbell Barton <campbell@blender.org>2022-08-12 03:41:39 +0300
committerCampbell Barton <campbell@blender.org>2022-08-12 03:41:39 +0300
commit8649ac0ca869a12872865500ce8b99eaedb97f97 (patch)
tree0cd663739ebd0f44199fd85cf982ce3d9fa7ddab
parenta2247c271c822ba82d7ae38030509933233cd3a5 (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.
-rw-r--r--source/blender/editors/interface/interface_handlers.c9
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;