diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index 0427b66b5..3c2a190b5 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -670,7 +670,10 @@ void Manager::handleWindowZOrder() win_manager->insertChild(0, window); else { int pos = (int)win_manager->children().size(); - UI_FOREACH_WIDGET_BACKWARD(win_manager->children(), it) { + + for (auto it=win_manager->children().rbegin(), + end=win_manager->children().rend(); + it != end; ++it) { if (static_cast(*it)->isOnTop()) break; diff --git a/src/ui/menu.cpp b/src/ui/menu.cpp index 2f48ed6b5..0e060055c 100644 --- a/src/ui/menu.cpp +++ b/src/ui/menu.cpp @@ -345,18 +345,25 @@ void Menu::onSizeHint(SizeHintEvent& ev) Size size(0, 0); Size reqSize; - UI_FOREACH_WIDGET_WITH_END(children(), it, end) { + for (auto it=children().begin(), + end=children().end(); + it!=end; ) { + auto next = it; + ++next; + reqSize = (*it)->sizeHint(); if (parent() && parent()->type() == kMenuBarWidget) { - size.w += reqSize.w + ((it+1 != end) ? childSpacing(): 0); + size.w += reqSize.w + ((next != end) ? childSpacing(): 0); size.h = std::max(size.h, reqSize.h); } else { size.w = std::max(size.w, reqSize.w); - size.h += reqSize.h + ((it+1 != end) ? childSpacing(): 0); + size.h += reqSize.h + ((next != end) ? childSpacing(): 0); } + + it = next; } size.w += border().width(); diff --git a/src/ui/splitter.cpp b/src/ui/splitter.cpp index 73fa7a46c..9176ad2c7 100644 --- a/src/ui/splitter.cpp +++ b/src/ui/splitter.cpp @@ -61,10 +61,15 @@ bool Splitter::onProcessMessage(Message* msg) bar = click_bar = 0; - UI_FOREACH_WIDGET_WITH_END(children(), it, end) { - if (it+1 != end) { + for (auto it=children().begin(), + end=children().end(); + it != end; ) { + auto next = it; + ++next; + + if (next != end) { c1 = *it; - c2 = *(it+1); + c2 = *next; ++bar; @@ -85,6 +90,8 @@ bool Splitter::onProcessMessage(Message* msg) (mousePos.y >= y1) && (mousePos.y < y2)) click_bar = bar; } + + it = next; } if (!click_bar) @@ -142,8 +149,13 @@ bool Splitter::onProcessMessage(Message* msg) int x1, y1, x2, y2; bool change_cursor = false; - UI_FOREACH_WIDGET_WITH_END(children(), it, end) { - if (it+1 != end) { + for (auto it=children().begin(), + end=children().end(); + it != end; ) { + auto next = it; + ++next; + + if (next != end) { c1 = *it; c2 = *(it+1); @@ -166,6 +178,8 @@ bool Splitter::onProcessMessage(Message* msg) break; } } + + it = next; } if (change_cursor) { diff --git a/src/ui/widgets_list.h b/src/ui/widgets_list.h index b8235d4f3..c004e3681 100644 --- a/src/ui/widgets_list.h +++ b/src/ui/widgets_list.h @@ -1,5 +1,6 @@ // Aseprite UI Library -// Copyright (C) 2001-2013, 2015 David Capello +// Copyright (C) 2019 Igara Studio S.A. +// Copyright (C) 2001-2015 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -10,20 +11,6 @@ #include -#define UI_FOREACH_WIDGET_BACKWARD(list_name, iterator_name) \ - for (WidgetsList::const_reverse_iterator \ - iterator_name = (list_name).rbegin(), \ - __end=(list_name).rend(); \ - iterator_name != __end; \ - ++iterator_name) - -#define UI_FOREACH_WIDGET_WITH_END(list_name, iterator_name, end_name) \ - for (WidgetsList::const_iterator \ - iterator_name = (list_name).begin(), \ - end_name = (list_name).end(); \ - iterator_name != end_name; \ - ++iterator_name) - #define UI_FIRST_WIDGET(list_name) \ ((list_name).empty() ? NULL: (list_name).front())