MCPcopy Create free account
hub / github.com/axmolengine/axmol / calculateNearestDistance

Method calculateNearestDistance

core/ui/UILayout.cpp:1072–1106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1070}
1071
1072float Layout::calculateNearestDistance(Widget* baseWidget)
1073{
1074 float distance = FLT_MAX;
1075
1076 Vec2 widgetPosition = this->getWorldCenterPoint(baseWidget);
1077
1078 for (Node* node : _children)
1079 {
1080 Layout* layout = dynamic_cast<Layout*>(node);
1081 int length;
1082 if (layout)
1083 {
1084 length = layout->calculateNearestDistance(baseWidget);
1085 }
1086 else
1087 {
1088 Widget* w = dynamic_cast<Widget*>(node);
1089 if (w && w->isFocusEnabled())
1090 {
1091 Vec2 wPosition = this->getWorldCenterPoint(w);
1092 length = (wPosition - widgetPosition).length();
1093 }
1094 else
1095 {
1096 continue;
1097 }
1098 }
1099
1100 if (length < distance)
1101 {
1102 distance = length;
1103 }
1104 }
1105 return distance;
1106}
1107
1108float Layout::calculateFarthestDistance(ax::ui::Widget* baseWidget)
1109{

Callers 1

Calls 3

getWorldCenterPointMethod · 0.95
isFocusEnabledMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected