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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-23 10:12:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-23 10:16:18 +0300
commit532f4366a5713f4796745873aad7921a344ae923 (patch)
treeea93223219e1c89a79110fff9e0744bc6727ef40 /source
parentbe3adb51de21652d64a6839cd5614c5096064c6a (diff)
Cleanup: minor changes to scrollbar checks
Remove some redundant comments & declare vars in for loops.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_query.c40
-rw-r--r--source/blender/editors/interface/view2d.c54
2 files changed, 36 insertions, 58 deletions
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index db60e967d6d..e1f91be1631 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -209,14 +209,11 @@ bool ui_but_contains_rect(const uiBut *but, const rctf *rect)
bool ui_but_contains_point_px(const uiBut *but, const ARegion *ar, int x, int y)
{
uiBlock *block = but->block;
- float mx, my;
if (!ui_region_contains_point_px(ar, x, y)) {
return false;
}
- mx = x;
- my = y;
-
+ float mx = x, my = y;
ui_window_to_block_fl(ar, block, &mx, &my);
if (but->pie_dir != UI_RADIAL_NONE) {
@@ -258,23 +255,16 @@ bool ui_but_contains_point_px_icon(const uiBut *but, ARegion *ar, const wmEvent
/* x and y are only used in case event is NULL... */
uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, const bool labeledit)
{
- uiBlock *block;
- uiBut *but, *butover = NULL;
- float mx, my;
+ uiBut *butover = NULL;
- // if (!win->active) {
- // return NULL;
- // }
if (!ui_region_contains_point_px(ar, x, y)) {
return NULL;
}
-
- for (block = ar->uiblocks.first; block; block = block->next) {
- mx = x;
- my = y;
+ for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
+ float mx = x, my = y;
ui_window_to_block_fl(ar, block, &mx, &my);
- for (but = block->buttons.last; but; but = but->prev) {
+ for (uiBut *but = block->buttons.last; but; but = but->prev) {
if (ui_but_is_interactive(but, labeledit)) {
if (but->pie_dir != UI_RADIAL_NONE) {
if (ui_but_isect_pie_seg(block, but)) {
@@ -346,20 +336,13 @@ uiBut *ui_but_find_rect_over(const struct ARegion *ar, const rcti *rect_px)
uiBut *ui_list_find_mouse_over_ex(ARegion *ar, int x, int y)
{
- uiBlock *block;
- uiBut *but;
- float mx, my;
-
if (!ui_region_contains_point_px(ar, x, y)) {
return NULL;
}
-
- for (block = ar->uiblocks.first; block; block = block->next) {
- mx = x;
- my = y;
+ for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
+ float mx = x, my = y;
ui_window_to_block_fl(ar, block, &mx, &my);
-
- for (but = block->buttons.last; but; but = but->prev) {
+ for (uiBut *but = block->buttons.last; but; but = but->prev) {
if (but->type == UI_BTYPE_LISTBOX && ui_but_contains_pt(but, mx, my)) {
return but;
}
@@ -498,11 +481,8 @@ bool UI_block_is_empty(const uiBlock *block)
uiBut *ui_region_find_active_but(ARegion *ar)
{
- uiBlock *block;
- uiBut *but;
-
- for (block = ar->uiblocks.first; block; block = block->next) {
- for (but = block->buttons.first; but; but = but->next) {
+ for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
+ for (uiBut *but = block->buttons.first; but; but = but->next) {
if (but->active) {
return but;
}
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;
}