diff options
author | Nicholas Rishel <nicholas_rishel> | 2020-02-14 17:35:34 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-02-14 19:57:34 +0300 |
commit | e7cf132e573da5c47718be79a2d3278fb842d49b (patch) | |
tree | 094651b57145c7a5dff64560bd16990ec58411ef /source/blender/editors/interface | |
parent | 9b243b9a53ca48f5dba1142170944174716bbd72 (diff) |
Cleanup: simplify redundant tests in scrollbar code
Differential Revision: https://developer.blender.org/D6783
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 5cf7cb4e7c4..527c23e4588 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1738,46 +1738,32 @@ enum { */ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_min, int sh_max) { - bool in_min, in_max, in_bar, out_min, out_max, in_view = 1; - /* firstly, check if * - 'bubble' fills entire scroller * - 'bubble' completely out of view on either side */ - if ((sh_min <= sc_min) && (sh_max >= sc_max)) { - in_view = 0; - } - if (sh_min == sh_max) { - if (sh_min <= sc_min) { - in_view = 0; - } - if (sh_max >= sc_max) { - in_view = 0; - } + bool in_view = true; + if (sh_min <= sc_min && sc_max <= sh_max) { + in_view = false; } - else { - if (sh_max <= sc_min) { - in_view = 0; - } - if (sh_min >= sc_max) { - in_view = 0; - } + else if (sh_max <= sc_min || sc_max <= sh_min) { + in_view = false; } - if (in_view == 0) { + if (!in_view) { return SCROLLHANDLE_BAR; } /* check if mouse is in or past either handle */ /* TODO: check if these extents are still valid or not */ - in_max = ((mouse >= (sh_max - V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) && - (mouse <= (sh_max + V2D_SCROLL_HANDLE_SIZE_HOTSPOT))); - in_min = ((mouse <= (sh_min + V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) && - (mouse >= (sh_min - V2D_SCROLL_HANDLE_SIZE_HOTSPOT))); - in_bar = ((mouse < (sh_max - V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) && - (mouse > (sh_min + V2D_SCROLL_HANDLE_SIZE_HOTSPOT))); - out_min = mouse < (sh_min - V2D_SCROLL_HANDLE_SIZE_HOTSPOT); - out_max = mouse > (sh_max + V2D_SCROLL_HANDLE_SIZE_HOTSPOT); + bool in_max = ((mouse >= (sh_max - V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) && + (mouse <= (sh_max + V2D_SCROLL_HANDLE_SIZE_HOTSPOT))); + bool in_min = ((mouse <= (sh_min + V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) && + (mouse >= (sh_min - V2D_SCROLL_HANDLE_SIZE_HOTSPOT))); + bool in_bar = ((mouse < (sh_max - V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) && + (mouse > (sh_min + V2D_SCROLL_HANDLE_SIZE_HOTSPOT))); + bool out_min = mouse < (sh_min - V2D_SCROLL_HANDLE_SIZE_HOTSPOT); + bool out_max = mouse > (sh_max + V2D_SCROLL_HANDLE_SIZE_HOTSPOT); if (in_bar) { return SCROLLHANDLE_BAR; |