From: Hosang Kim Date: Mon, 11 Dec 2023 10:57:28 +0000 (+0900) Subject: AurumXML: Sort child objects by coordinates. X-Git-Tag: accepted/tizen/unified/20240205.162750~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=63263af1abfa778f9775ce34c33b581ac68dc2d4;p=platform%2Fcore%2Fuifw%2Faurum.git AurumXML: Sort child objects by coordinates. Sometimes the order of child objects is not consistent. Therefore, we sort them to always ensure the same order. Change-Id: Ia49c88bc1fa32d1e73ebeca1c8415789d9d1594e --- diff --git a/libaurum/src/AurumXML.cc b/libaurum/src/AurumXML.cc index 8f90001..6974d59 100644 --- a/libaurum/src/AurumXML.cc +++ b/libaurum/src/AurumXML.cc @@ -67,6 +67,19 @@ void AurumXML::traverse(xml_node& element, const std::shared_ptr mXNodeMap[node->getId()] = node; auto children = node->getChildren(); + + std::sort(children.begin(), children.end(), [](std::shared_ptr a, std::shared_ptr b){ + a->updateExtents(); + b->updateExtents(); + + auto aRect = a->getScreenBoundingBox(); + auto bRect = b->getScreenBoundingBox(); + + if (aRect.mTopLeft.x != bRect.mTopLeft.x) return aRect.mTopLeft.x < bRect.mTopLeft.x; + if (aRect.mTopLeft.y != bRect.mTopLeft.y) return aRect.mTopLeft.y < bRect.mTopLeft.y; + else return aRect.width() * aRect.height() <= bRect.width() * bRect.height(); + }); + for (const auto &child : children) { if (child->getRawHandler() == nullptr) continue;