Browse Source

Fix the GetElementAt() layout optimization, which should not check up/left limits for child elements in layout. Closes #1923.

Lasse Öörni 8 năm trước cách đây
mục cha
commit
0fe1f9d6ca
1 tập tin đã thay đổi với 3 bổ sung6 xóa
  1. 3 6
      Source/Urho3D/UI/UI.cpp

+ 3 - 6
Source/Urho3D/UI/UI.cpp

@@ -1007,19 +1007,16 @@ void UI::GetElementAt(UIElement*& result, UIElement* current, const IntVector2&
                                 i += (toSkip - 1);
                         }
                     }
+                    // Note: we cannot check for the up / left limits of positioning, since the element may be off the visible
+                    // screen but some of its layouted children will yet be visible. In down & right directions we can terminate
+                    // the loop, since all further children will be further down or right.
                     else if (parentLayoutMode == LM_HORIZONTAL)
                     {
-                        if (element->GetScreenPosition().x_ < rootElement_->GetPosition().x_)
-                            break;
-
                         if (element->GetScreenPosition().x_ >= rootElement_->GetPosition().x_ + rootElement_->GetSize().x_)
                             break;
                     }
                     else if (parentLayoutMode == LM_VERTICAL)
                     {
-                        if (element->GetScreenPosition().y_ < rootElement_->GetPosition().y_)
-                            break;
-
                         if (element->GetScreenPosition().y_ >= rootElement_->GetPosition().y_ + rootElement_->GetSize().y_)
                             break;
                     }