mirror of https://github.com/axmolengine/axmol.git
commit
b5f9a45ee4
|
@ -1137,7 +1137,7 @@ float Layout::calculateNearestDistance(Widget* baseWidget)
|
|||
return distance;
|
||||
}
|
||||
|
||||
float Layout::calculateFarestDistance(cocos2d::ui::Widget *baseWidget)
|
||||
float Layout::calculateFarthestDistance(cocos2d::ui::Widget *baseWidget)
|
||||
{
|
||||
float distance = -FLT_MAX;
|
||||
|
||||
|
@ -1147,7 +1147,7 @@ float Layout::calculateFarestDistance(cocos2d::ui::Widget *baseWidget)
|
|||
Layout *layout = dynamic_cast<Layout*>(node);
|
||||
int length;
|
||||
if (layout) {
|
||||
length = layout->calculateFarestDistance(baseWidget);
|
||||
length = layout->calculateFarthestDistance(baseWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1231,7 +1231,7 @@ int Layout::findNearestChildWidgetIndex(FocusDirection direction, Widget* baseWi
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Layout::findFarestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Widget *baseWidget)
|
||||
int Layout::findFarthestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Widget *baseWidget)
|
||||
{
|
||||
if (baseWidget == nullptr || baseWidget == this)
|
||||
{
|
||||
|
@ -1256,7 +1256,7 @@ int Layout::findFarestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Wi
|
|||
Layout *layout = dynamic_cast<Layout*>(w);
|
||||
if (layout)
|
||||
{
|
||||
length = layout->calculateFarestDistance(baseWidget);
|
||||
length = layout->calculateFarthestDistance(baseWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1337,11 +1337,11 @@ void Layout::findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget)
|
|||
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
|
||||
}
|
||||
else{
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
|
||||
}
|
||||
}else if(dir == FocusDirection::RIGHT){
|
||||
if (previousWidgetPosition.x > widgetPosition.x) {
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
|
||||
}
|
||||
else{
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
|
||||
|
@ -1350,13 +1350,13 @@ void Layout::findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget)
|
|||
if (previousWidgetPosition.y > widgetPosition.y) {
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
|
||||
}else{
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
|
||||
}
|
||||
}else if(dir == FocusDirection::UP){
|
||||
if (previousWidgetPosition.y < widgetPosition.y) {
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
|
||||
}else{
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
|
||||
}
|
||||
}else{
|
||||
CCASSERT(0, "invalid direction!");
|
||||
|
|
|
@ -365,11 +365,11 @@ protected:
|
|||
|
||||
/**
|
||||
* When the layout get focused, it the layout pass the focus to its child, it will use this method to determine which child
|
||||
* will get the focus. The current algorithm to determine which child will get focus is farest-distance-priority algorithm
|
||||
* will get the focus. The current algorithm to determine which child will get focus is farthest-distance-priority algorithm
|
||||
*@param dir next focused widget direction
|
||||
*@return The index of child widget in the container
|
||||
*/
|
||||
int findFarestChildWidgetIndex(FocusDirection direction, Widget* baseWidget);
|
||||
int findFarthestChildWidgetIndex(FocusDirection direction, Widget* baseWidget);
|
||||
|
||||
/**
|
||||
* caculate the nearest distance between the baseWidget and the children of the layout
|
||||
|
@ -379,15 +379,15 @@ protected:
|
|||
float calculateNearestDistance(Widget* baseWidget);
|
||||
|
||||
/**
|
||||
* caculate the farest distance between the baseWidget and the children of the layout
|
||||
* caculate the farthest distance between the baseWidget and the children of the layout
|
||||
*@param the base widget which will be used to caculate the distance between the layout's children and itself
|
||||
*@return return the farest distance between the baseWidget and the layout's children
|
||||
*@return return the farthest distance between the baseWidget and the layout's children
|
||||
*/
|
||||
|
||||
float calculateFarestDistance(Widget* baseWidget);
|
||||
float calculateFarthestDistance(Widget* baseWidget);
|
||||
|
||||
/**
|
||||
* when a layout pass the focus to it's child, use this method to determine which algorithm to use, nearest or farest distance algorithm or not
|
||||
* when a layout pass the focus to it's child, use this method to determine which algorithm to use, nearest or farthest distance algorithm or not
|
||||
*/
|
||||
void findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget);
|
||||
|
||||
|
|
Loading…
Reference in New Issue