diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-23 10:12:09 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-23 10:16:18 +0300 |
commit | 532f4366a5713f4796745873aad7921a344ae923 (patch) | |
tree | ea93223219e1c89a79110fff9e0744bc6727ef40 /source/blender/editors/interface/view2d.c | |
parent | be3adb51de21652d64a6839cd5614c5096064c6a (diff) |
Cleanup: minor changes to scrollbar checks
Remove some redundant comments & declare vars in for loops.
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r-- | source/blender/editors/interface/view2d.c | 54 |
1 files changed, 26 insertions, 28 deletions
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; } |