| 1298 | } |
| 1299 | |
| 1300 | void Layout::findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget) |
| 1301 | { |
| 1302 | if (baseWidget == nullptr) |
| 1303 | { |
| 1304 | return; |
| 1305 | } |
| 1306 | |
| 1307 | Vec2 previousWidgetPosition = this->getWorldCenterPoint(baseWidget); |
| 1308 | |
| 1309 | Vec2 widgetPosition = this->getWorldCenterPoint(this->findFirstNonLayoutWidget()); |
| 1310 | |
| 1311 | if (dir == FocusDirection::LEFT) |
| 1312 | { |
| 1313 | if (previousWidgetPosition.x > widgetPosition.x) |
| 1314 | { |
| 1315 | onPassFocusToChild = AX_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); |
| 1316 | } |
| 1317 | else |
| 1318 | { |
| 1319 | onPassFocusToChild = AX_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this); |
| 1320 | } |
| 1321 | } |
| 1322 | else if (dir == FocusDirection::RIGHT) |
| 1323 | { |
| 1324 | if (previousWidgetPosition.x > widgetPosition.x) |
| 1325 | { |
| 1326 | onPassFocusToChild = AX_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this); |
| 1327 | } |
| 1328 | else |
| 1329 | { |
| 1330 | onPassFocusToChild = AX_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); |
| 1331 | } |
| 1332 | } |
| 1333 | else if (dir == FocusDirection::DOWN) |
| 1334 | { |
| 1335 | if (previousWidgetPosition.y > widgetPosition.y) |
| 1336 | { |
| 1337 | onPassFocusToChild = AX_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); |
| 1338 | } |
| 1339 | else |
| 1340 | { |
| 1341 | onPassFocusToChild = AX_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this); |
| 1342 | } |
| 1343 | } |
| 1344 | else if (dir == FocusDirection::UP) |
| 1345 | { |
| 1346 | if (previousWidgetPosition.y < widgetPosition.y) |
| 1347 | { |
| 1348 | onPassFocusToChild = AX_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); |
| 1349 | } |
| 1350 | else |
| 1351 | { |
| 1352 | onPassFocusToChild = AX_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this); |
| 1353 | } |
| 1354 | } |
| 1355 | else |
| 1356 | { |
| 1357 | AXASSERT(0, "invalid direction!"); |
no test coverage detected