From 532f4366a5713f4796745873aad7921a344ae923 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Apr 2019 17:12:09 +1000 Subject: Cleanup: minor changes to scrollbar checks Remove some redundant comments & declare vars in for loops. --- source/blender/editors/interface/view2d.c | 54 +++++++++++++++---------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'source/blender/editors/interface/view2d.c') diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 096ea230bbe..952778cfc6d 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -2629,25 +2629,24 @@ char UI_view2d_mouse_in_scrollers_ex( const int scroll = view2d_scroll_mapped(v2d->scroll); *r_scroll = scroll; - /* clamp x,y to region-coordinates first */ - const int co[2] = { - x - ar->winrct.xmin, - y - ar->winrct.ymin, - }; - - /* check if within scrollbars */ - if (scroll & V2D_SCROLL_HORIZONTAL) { - if (IN_2D_HORIZ_SCROLL(v2d, co)) { - return 'h'; + if (scroll) { + /* Move to region-coordinates. */ + const int co[2] = { + x - ar->winrct.xmin, + y - ar->winrct.ymin, + }; + if (scroll & V2D_SCROLL_HORIZONTAL) { + if (IN_2D_HORIZ_SCROLL(v2d, co)) { + return 'h'; + } } - } - if (scroll & V2D_SCROLL_VERTICAL) { - if (IN_2D_VERT_SCROLL(v2d, co)) { - return 'v'; + if (scroll & V2D_SCROLL_VERTICAL) { + if (IN_2D_VERT_SCROLL(v2d, co)) { + return 'v'; + } } } - /* not found */ return 0; } @@ -2659,23 +2658,22 @@ char UI_view2d_rect_in_scrollers_ex(const ARegion *ar, const int scroll = view2d_scroll_mapped(v2d->scroll); *r_scroll = scroll; - /* clamp x,y to region-coordinates first */ - rcti rect_region = *rect; - BLI_rcti_translate(&rect_region, -ar->winrct.xmin, ar->winrct.ymin); - - /* check if within scrollbars */ - if (scroll & V2D_SCROLL_HORIZONTAL) { - if (IN_2D_HORIZ_SCROLL_RECT(v2d, &rect_region)) { - return 'h'; + if (scroll) { + /* Move to region-coordinates. */ + rcti rect_region = *rect; + BLI_rcti_translate(&rect_region, -ar->winrct.xmin, ar->winrct.ymin); + if (scroll & V2D_SCROLL_HORIZONTAL) { + if (IN_2D_HORIZ_SCROLL_RECT(v2d, &rect_region)) { + return 'h'; + } } - } - if (scroll & V2D_SCROLL_VERTICAL) { - if (IN_2D_VERT_SCROLL_RECT(v2d, &rect_region)) { - return 'v'; + if (scroll & V2D_SCROLL_VERTICAL) { + if (IN_2D_VERT_SCROLL_RECT(v2d, &rect_region)) { + return 'v'; + } } } - /* not found */ return 0; } -- cgit v1.2.3