diff options
author | Hans Goudey <h.goudey@me.com> | 2020-08-19 04:46:29 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-08-19 04:47:00 +0300 |
commit | 349eebd7d1459fa2525850751040963899ef7535 (patch) | |
tree | eb1db9c00555f8827fa3bd49afb744a1ada1ea6d /source/blender/editors/interface/interface_query.c | |
parent | ffa8e7579916609b4ddd4dda031cf2a3a7eaefb1 (diff) |
UI Code Quality: Use LISTBASE_FOREACH in interface directory
I only skipped a few loops in the monstrous ui_handle_menu_event
function. Also, I only changed variable names where necessary to
prevent redeclarations.
Differential Revision: https://developer.blender.org/D8586
Diffstat (limited to 'source/blender/editors/interface/interface_query.c')
-rw-r--r-- | source/blender/editors/interface/interface_query.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index edb5d51a392..8648a54f7d5 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -276,7 +276,7 @@ uiBut *ui_but_find_mouse_over_ex(ARegion *region, const int x, const int y, cons float mx = x, my = y; ui_window_to_block_fl(region, block, &mx, &my); - for (uiBut *but = block->buttons.last; but; but = but->prev) { + LISTBASE_FOREACH_BACKWARD (uiBut *, but, &block->buttons) { if (ui_but_is_interactive(but, labeledit)) { if (but->pie_dir != UI_RADIAL_NONE) { if (ui_but_isect_pie_seg(block, but)) { @@ -324,7 +324,7 @@ uiBut *ui_but_find_rect_over(const struct ARegion *region, const rcti *rect_px) rctf rect_block; ui_window_to_block_rctf(region, block, &rect_block, &rect_px_fl); - for (uiBut *but = block->buttons.last; but; but = but->prev) { + LISTBASE_FOREACH_BACKWARD (uiBut *, but, &block->buttons) { if (ui_but_is_interactive(but, labeledit)) { /* No pie menu support. */ BLI_assert(but->pie_dir == UI_RADIAL_NONE); @@ -354,7 +354,7 @@ uiBut *ui_list_find_mouse_over_ex(ARegion *region, int x, int y) LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { float mx = x, my = y; ui_window_to_block_fl(region, block, &mx, &my); - for (uiBut *but = block->buttons.last; but; but = but->prev) { + LISTBASE_FOREACH_BACKWARD (uiBut *, but, &block->buttons) { if (but->type == UI_BTYPE_LISTBOX && ui_but_contains_pt(but, mx, my)) { return but; } @@ -399,14 +399,10 @@ uiBut *ui_but_next(uiBut *but) uiBut *ui_but_first(uiBlock *block) { - uiBut *but; - - but = block->buttons.first; - while (but) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (ui_but_is_editable(but)) { return but; } - but = but->next; } return NULL; } |